From d17fc40a4761d29aef83605ccf819c3cab441e73 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sat, 18 Dec 2021 15:25:40 +0000 Subject: [PATCH] Added decent spacing to all scripts thanks to Rubocop --- .../001_Debugging/001_PBDebug.rb | 2 +- .../001_Technical/001_Debugging/003_Errors.rb | 2 +- .../001_Technical/002_Files/001_FileTests.rb | 58 +- .../002_Files/003_HTTP_Utilities.rb | 6 +- .../001_Technical/002_RubyUtilities.rb | 2 +- .../001_Technical/003_Intl_Messages.rb | 532 +++---- .../001_Technical/005_PluginManager.rb | 4 +- Data/Scripts/001_Technical/006_RPG_Sprite.rb | 32 +- .../003_Game processing/002_Scene_Map.rb | 10 +- .../004_Interpreter_Commands.rb | 2 +- .../003_Game processing/005_Event_Handlers.rb | 28 +- .../006_Event_OverworldEvents.rb | 4 +- .../004_Game classes/001_Game_Screen.rb | 48 +- .../004_Game_SelfSwitches.rb | 2 +- .../004_Game classes/002_Game_System.rb | 74 +- Data/Scripts/004_Game classes/004_Game_Map.rb | 62 +- .../005_Game_Map_Autoscroll.rb | 32 +- .../004_Game classes/006_Game_MapFactory.rb | 118 +- .../004_Game classes/007_Game_Character.rb | 44 +- .../004_Game classes/008_Game_Event.rb | 36 +- .../004_Game classes/009_Game_Player.rb | 36 +- .../004_Game classes/011_Game_Follower.rb | 2 +- .../Scripts/005_Sprites/001_Sprite_Picture.rb | 6 +- Data/Scripts/005_Sprites/002_Sprite_Timer.rb | 28 +- .../005_Sprites/004_Sprite_Reflection.rb | 30 +- .../005_Sprites/005_Sprite_SurfBase.rb | 22 +- Data/Scripts/005_Sprites/007_Spriteset_Map.rb | 58 +- .../005_Sprites/008_Sprite_AnimationSprite.rb | 16 +- .../005_Sprites/009_Sprite_DynamicShadows.rb | 32 +- .../Scripts/005_Sprites/010_ParticleEngine.rb | 214 +-- Data/Scripts/005_Sprites/011_PictureEx.rb | 176 +-- Data/Scripts/005_Sprites/012_Interpolators.rb | 82 +- .../005_Sprites/013_ScreenPosHelper.rb | 28 +- .../006_Map renderer/001_TilemapRenderer.rb | 2 +- .../006_Map renderer/003_AutotileExpander.rb | 2 +- .../006_Map renderer/004_TileDrawingHelper.rb | 96 +- .../002_MessageConfig.rb | 402 ++--- .../007_Objects and windows/003_Window.rb | 548 +++---- .../004_SpriteWindow.rb | 854 +++++------ .../005_SpriteWindow_text.rb | 694 ++++----- .../006_SpriteWindow_pictures.rb | 76 +- .../007_SpriteWrapper.rb | 260 ++-- .../008_AnimatedBitmap.rb | 6 +- .../007_Objects and windows/010_DrawText.rb | 1230 +++++++-------- .../007_Objects and windows/011_Messages.rb | 552 +++---- .../007_Objects and windows/012_TextEntry.rb | 452 +++--- Data/Scripts/008_Audio/001_Audio.rb | 4 +- Data/Scripts/008_Audio/002_Audio_Play.rb | 72 +- Data/Scripts/009_Scenes/001_Transitions.rb | 4 +- Data/Scripts/009_Scenes/002_EventScene.rb | 28 +- .../001_Hardcoded data/001_GrowthRate.rb | 12 +- .../Scripts/010_Data/002_PBS data/003_Type.rb | 2 +- .../002_PBS data/009_Species_Files.rb | 4 +- .../011_Battle/001_Battle/001_Battle.rb | 206 +-- .../001_Battle/002_Battle_StartAndEnd.rb | 258 ++-- .../003_Battle_ExpAndMoveLearning.rb | 100 +- .../004_Battle_ActionAttacksPriority.rb | 116 +- .../001_Battle/005_Battle_ActionSwitching.rb | 148 +- .../001_Battle/006_Battle_ActionUseItem.rb | 60 +- .../001_Battle/007_Battle_ActionRunning.rb | 22 +- .../001_Battle/008_Battle_ActionOther.rb | 56 +- .../001_Battle/009_Battle_CommandPhase.rb | 82 +- .../001_Battle/010_Battle_AttackPhase.rb | 60 +- .../001_Battle/011_Battle_EndOfRoundPhase.rb | 278 ++-- .../002_Battler/001_Battle_Battler.rb | 100 +- .../002_Battler/002_Battler_Initialize.rb | 34 +- .../002_Battler/003_Battler_ChangeSelf.rb | 136 +- .../002_Battler/004_Battler_Statuses.rb | 104 +- .../002_Battler/005_Battler_StatStages.rb | 160 +- .../002_Battler/006_Battler_AbilityAndItem.rb | 12 +- .../002_Battler/007_Battler_UseMove.rb | 248 +-- .../008_Battler_UseMoveTargeting.rb | 96 +- .../009_Battler_UseMoveSuccessChecks.rb | 172 +-- .../010_Battler_UseMoveTriggerEffects.rb | 52 +- .../011_Battle/003_Move/001_Battle_Move.rb | 12 +- .../011_Battle/003_Move/002_Move_Usage.rb | 136 +- .../003_Move/003_Move_UsageCalculations.rb | 152 +- .../003_Move/004_Move_BaseEffects.rb | 200 +-- .../003_Move/005_MoveEffects_Misc.rb | 142 +- .../003_Move/006_MoveEffects_BattlerStats.rb | 590 +++---- .../003_Move/007_MoveEffects_BattlerOther.rb | 356 ++--- .../008_MoveEffects_MoveAttributes.rb | 470 +++--- .../003_Move/009_MoveEffects_MultiHit.rb | 202 +-- .../003_Move/010_MoveEffects_Healing.rb | 176 +-- .../003_Move/011_MoveEffects_Items.rb | 238 +-- .../012_MoveEffects_ChangeMoveEffect.rb | 360 ++--- .../013_MoveEffects_SwitchingActing.rb | 224 +-- .../011_Battle/004_Scene/001_Battle_Scene.rb | 58 +- .../004_Scene/002_Scene_Initialize.rb | 122 +- .../004_Scene/003_Scene_ChooseCommands.rb | 164 +- .../004_Scene/004_Scene_PlayAnimations.rb | 148 +- .../004_Scene/005_Battle_Scene_Menus.rb | 232 +-- .../004_Scene/006_Battle_Scene_Objects.rb | 228 +-- .../007_Battle_Scene_BaseAnimation.rb | 150 +- .../004_Scene/008_Battle_Scene_Animations.rb | 590 +++---- .../004_Scene/009_Battle_DebugScene.rb | 56 +- .../011_Battle/005_AI/001_Battle_AI.rb | 10 +- Data/Scripts/011_Battle/005_AI/002_AI_Item.rb | 32 +- .../011_Battle/005_AI/003_AI_Switch.rb | 102 +- Data/Scripts/011_Battle/005_AI/004_AI_Move.rb | 156 +- .../005_AI/005_AI_Move_EffectScores.rb | 1352 ++++++++--------- .../005_AI/006_AI_Move_Utilities.rb | 276 ++-- .../006_Other battle code/004_Battle_Peers.rb | 20 +- .../005_Battle_CatchAndStoreMixin.rb | 54 +- .../006_Battle_Clauses.rb | 48 +- .../007_BattleAnimationPlayer.rb | 418 ++--- .../008_Battle_AbilityEffects.rb | 784 +++++----- .../009_Battle_ItemEffects.rb | 630 ++++---- .../001_SafariBattle.rb | 224 +-- .../002_BugContestBattle.rb | 30 +- .../003_BattlePalaceBattle.rb | 70 +- .../004_BattleArenaBattle.rb | 118 +- .../005_RecordedBattle.rb | 54 +- .../002_Overworld_Overlays.rb | 58 +- .../003_Overworld_MapTransitionAnims.rb | 40 +- Data/Scripts/012_Overworld/001_Overworld.rb | 134 +- .../001_Overworld_BattleStarting.rb | 130 +- .../002_Overworld_BattleIntroAnim.rb | 34 +- .../003_Overworld_WildEncounters.rb | 18 +- .../005_Overworld_RoamingPokemon.rb | 30 +- .../012_Overworld/002_Overworld_Metadata.rb | 20 +- .../012_Overworld/003_Overworld_Time.rb | 122 +- .../012_Overworld/004_Overworld_FieldMoves.rb | 358 ++--- .../012_Overworld/005_Overworld_Fishing.rb | 44 +- .../012_Overworld/007_Overworld_DayCare.rb | 2 +- .../008_Overworld_RandomDungeons.rb | 8 +- Data/Scripts/013_Items/001_Item_Utilities.rb | 178 +-- Data/Scripts/013_Items/002_Item_Effects.rb | 408 ++--- .../013_Items/003_Item_BattleEffects.rb | 416 ++--- Data/Scripts/013_Items/004_Item_Phone.rb | 92 +- Data/Scripts/013_Items/005_Item_PokeRadar.rb | 58 +- Data/Scripts/013_Items/006_Item_Mail.rb | 68 +- Data/Scripts/013_Items/007_Item_Sprites.rb | 34 +- .../001_Pokemon-related/001_FormHandlers.rb | 306 ++-- .../002_ShadowPokemon_Other.rb | 70 +- .../003_Pokemon_Sprites.rb | 62 +- .../001_Pokemon-related/004_PokemonStorage.rb | 116 +- Data/Scripts/014_Pokemon/001_Pokemon.rb | 2 +- .../015_Trainers and player/001_Trainer.rb | 4 +- .../002_Trainer_LoadAndNew.rb | 2 +- .../003_Trainer_Sprites.rb | 16 +- .../003_UI_EggHatching.rb | 102 +- .../004_UI_Evolution.rb | 242 +-- .../001_Non-interactive UI/005_UI_Trading.rb | 158 +- .../006_UI_HallOfFame.rb | 344 ++--- Data/Scripts/016_UI/001_UI_PauseMenu.rb | 40 +- Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb | 52 +- Data/Scripts/016_UI/003_UI_Pokedex_Main.rb | 756 ++++----- Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb | 194 +-- Data/Scripts/016_UI/005_UI_Party.rb | 538 +++---- Data/Scripts/016_UI/006_UI_Summary.rb | 620 ++++---- Data/Scripts/016_UI/007_UI_Bag.rb | 314 ++-- Data/Scripts/016_UI/008_UI_Pokegear.rb | 54 +- Data/Scripts/016_UI/009_UI_RegionMap.rb | 4 +- Data/Scripts/016_UI/010_UI_Phone.rb | 96 +- Data/Scripts/016_UI/011_UI_Jukebox.rb | 32 +- Data/Scripts/016_UI/012_UI_TrainerCard.rb | 54 +- Data/Scripts/016_UI/013_UI_Load.rb | 98 +- Data/Scripts/016_UI/014_UI_Save.rb | 42 +- Data/Scripts/016_UI/015_UI_Options.rb | 194 +-- Data/Scripts/016_UI/016_UI_ReadyMenu.rb | 104 +- Data/Scripts/016_UI/017_UI_PokemonStorage.rb | 808 +++++----- Data/Scripts/016_UI/018_UI_ItemStorage.rb | 122 +- Data/Scripts/016_UI/019_UI_PC.rb | 44 +- Data/Scripts/016_UI/020_UI_PokeMart.rb | 104 +- Data/Scripts/016_UI/021_UI_MoveRelearner.rb | 130 +- Data/Scripts/016_UI/022_UI_PurifyChamber.rb | 959 ++++++------ Data/Scripts/016_UI/023_UI_MysteryGift.rb | 290 ++-- Data/Scripts/016_UI/024_UI_TextEntry.rb | 278 ++-- .../017_Minigames/001_Minigame_Duel.rb | 2 +- .../017_Minigames/002_Minigame_TripleTriad.rb | 404 ++--- .../017_Minigames/003_Minigame_SlotMachine.rb | 312 ++-- .../017_Minigames/004_Minigame_VoltorbFlip.rb | 572 +++---- .../017_Minigames/005_Minigame_Lottery.rb | 52 +- .../017_Minigames/006_Minigame_Mining.rb | 602 ++++---- .../017_Minigames/007_Minigame_TilePuzzles.rb | 542 +++---- .../001_Challenge_BattleChallenge.rb | 2 +- .../004_Challenge_Battles.rb | 2 +- .../001_Battle Frontier/005_UI_BattleSwap.rb | 2 +- .../001_SafariZone.rb | 32 +- .../001_Challenge_ChallengeRules.rb | 6 +- .../003_Challenge_EntryRestrictions.rb | 2 +- .../004_Challenge_LevelAdjustment.rb | 6 +- .../002_BugContest.rb | 212 +-- .../001_ChallengeGenerator_Data.rb | 4 +- .../004_ChallengeGenerator_BattleSim.rb | 4 +- Data/Scripts/019_Utilities/001_Utilities.rb | 142 +- .../003_Utilities_BattleAudio.rb | 22 +- .../001_Editor screens/001_EditorScreens.rb | 48 +- .../003_EditorScreens_MapConnections.rb | 448 +++--- .../Scripts/020_Debug/001_Editor_Utilities.rb | 102 +- .../001_AnimEditor_SceneElements.rb | 904 +++++------ .../002_AnimEditor_ControlsButtons.rb | 700 ++++----- .../003_AnimEditor_Interpolation.rb | 358 ++--- .../004_AnimEditor_ExportImport.rb | 92 +- .../005_AnimEditor_Functions.rb | 1064 ++++++------- .../Scripts/020_Debug/002_Editor_DataTypes.rb | 288 ++-- .../003_Debug menus/002_Debug_MenuCommands.rb | 2 +- .../003_Debug_MenuExtraCode.rb | 294 ++-- .../005_Debug_PokemonCommands.rb | 2 +- .../007_Debug_BattleCommands.rb | 20 +- .../008_Debug_BattlerCommands.rb | 27 +- Data/Scripts/020_Debug/003_Editor_Listers.rb | 82 +- Data/Scripts/021_Compiler/001_Compiler.rb | 256 ++-- .../021_Compiler/002_Compiler_CompilePBS.rb | 128 +- .../021_Compiler/003_Compiler_WritePBS.rb | 38 +- .../004_Compiler_MapsAndEvents.rb | 774 +++++----- 207 files changed, 18577 insertions(+), 18587 deletions(-) diff --git a/Data/Scripts/001_Technical/001_Debugging/001_PBDebug.rb b/Data/Scripts/001_Technical/001_Debugging/001_PBDebug.rb index 5b8c230cb..36a6de9f6 100644 --- a/Data/Scripts/001_Technical/001_Debugging/001_PBDebug.rb +++ b/Data/Scripts/001_Technical/001_Debugging/001_PBDebug.rb @@ -15,7 +15,7 @@ module PBDebug end def self.flush - if $DEBUG && $INTERNAL && @@log.length>0 + if $DEBUG && $INTERNAL && @@log.length > 0 File.open("Data/debuglog.txt", "a+b") { |f| f.write(@@log.to_s) } end @@log.clear diff --git a/Data/Scripts/001_Technical/001_Debugging/003_Errors.rb b/Data/Scripts/001_Technical/001_Debugging/003_Errors.rb index 0eba02855..9043ad576 100644 --- a/Data/Scripts/001_Technical/001_Debugging/003_Errors.rb +++ b/Data/Scripts/001_Technical/001_Debugging/003_Errors.rb @@ -13,7 +13,7 @@ class EventScriptError < Exception end end -def pbGetExceptionMessage(e,_script = "") +def pbGetExceptionMessage(e, _script = "") return e.event_message.dup if e.is_a?(EventScriptError) # Message with map/event ID generated elsewhere emessage = e.message.dup emessage.force_encoding(Encoding::UTF_8) diff --git a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb index ecbfa0ba1..259087b71 100644 --- a/Data/Scripts/001_Technical/002_Files/001_FileTests.rb +++ b/Data/Scripts/001_Technical/002_Files/001_FileTests.rb @@ -79,7 +79,7 @@ def safeExists?(f) return FileTest.exist?(f) if f[/\A[\x20-\x7E]*\z/] ret = false begin - File.open(f,"rb") { ret = true } + File.open(f, "rb") { ret = true } rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES ret = false end @@ -89,13 +89,13 @@ end # Similar to "Dir.glob", but designed to work around a problem with accessing # files if a path contains accent marks. # "dir" is the directory path, "wildcard" is the filename pattern to match. -def safeGlob(dir,wildcard) +def safeGlob(dir, wildcard) ret = [] afterChdir = false begin Dir.chdir(dir) { afterChdir = true - Dir.glob(wildcard) { |f| ret.push(dir+"/"+f) } + Dir.glob(wildcard) { |f| ret.push(dir + "/" + f) } } rescue Errno::ENOENT raise if afterChdir @@ -118,18 +118,18 @@ end # archives. Returns nil if the path can't be found. def pbResolveBitmap(x) return nil if !x - noext = x.gsub(/\.(bmp|png|gif|jpg|jpeg)$/,"") + noext = x.gsub(/\.(bmp|png|gif|jpg|jpeg)$/, "") filename = nil # RTP.eachPathFor(x) { |path| # filename = pbTryString(path) if !filename -# filename = pbTryString(path+".gif") if !filename +# filename = pbTryString(path + ".gif") if !filename # } RTP.eachPathFor(noext) { |path| - filename = pbTryString(path+".png") if !filename - filename = pbTryString(path+".gif") if !filename -# filename = pbTryString(path+".jpg") if !filename -# filename = pbTryString(path+".jpeg") if !filename -# filename = pbTryString(path+".bmp") if !filename + filename = pbTryString(path + ".png") if !filename + filename = pbTryString(path + ".gif") if !filename +# filename = pbTryString(path + ".jpg") if !filename +# filename = pbTryString(path + ".jpeg") if !filename +# filename = pbTryString(path + ".bmp") if !filename } return filename end @@ -180,31 +180,31 @@ end module RTP @rtpPaths = nil - def self.exists?(filename,extensions = []) + def self.exists?(filename, extensions = []) return false if nil_or_empty?(filename) eachPathFor(filename) { |path| return true if safeExists?(path) for ext in extensions - return true if safeExists?(path+ext) + return true if safeExists?(path + ext) end } return false end def self.getImagePath(filename) - return self.getPath(filename,["",".png",".gif"]) # ".jpg", ".jpeg", ".bmp" + return self.getPath(filename, ["", ".png", ".gif"]) # ".jpg", ".jpeg", ".bmp" end def self.getAudioPath(filename) - return self.getPath(filename,["",".wav",".wma",".mid",".ogg",".midi"]) # ".mp3" + return self.getPath(filename, ["", ".wav", ".wma", ".mid", ".ogg", ".midi"]) # ".mp3" end - def self.getPath(filename,extensions = []) + def self.getPath(filename, extensions = []) return filename if nil_or_empty?(filename) eachPathFor(filename) { |path| return path if safeExists?(path) for ext in extensions - file = path+ext + file = path + ext return file if safeExists?(file) end } @@ -220,10 +220,10 @@ module RTP else # relative path RTP.eachPath { |path| - if path=="./" + if path == "./" yield filename else - yield path+filename + yield path + filename end } end @@ -237,7 +237,7 @@ module RTP def self.eachPath # XXX: Use "." instead of Dir.pwd because of problems retrieving files if # the current directory contains an accent mark - yield ".".gsub(/[\/\\]/,"/").gsub(/[\/\\]$/,"")+"/" + yield ".".gsub(/[\/\\]/, "/").gsub(/[\/\\]$/, "") + "/" end private @@ -264,11 +264,11 @@ module FileTest Audio_ext = ['.mid', '.midi', '.ogg', '.wav', '.wma'] # '.mp3' def self.audio_exist?(filename) - return RTP.exists?(filename,Audio_ext) + return RTP.exists?(filename, Audio_ext) end def self.image_exist?(filename) - return RTP.exists?(filename,Image_ext) + return RTP.exists?(filename, Image_ext) end end @@ -281,7 +281,7 @@ end # and matching mount points added through System.mount def pbRgssExists?(filename) if safeExists?("./Game.rgssad") - return pbGetFileChar(filename)!=nil + return pbGetFileChar(filename) != nil else filename = canonicalize(filename) return safeExists?(filename) @@ -293,14 +293,14 @@ end # NOTE: load_data checks anything added in MKXP's RTP setting, # and matching mount points added through System.mount -def pbRgssOpen(file,mode = nil) +def pbRgssOpen(file, mode = nil) # File.open("debug.txt","ab") { |fw| fw.write([file,mode,Time.now.to_f].inspect+"\r\n") } if !safeExists?("./Game.rgssad") if block_given? - File.open(file,mode) { |f| yield f } + File.open(file, mode) { |f| yield f } return nil else - return File.open(file,mode) + return File.open(file, mode) end end file = canonicalize(file) @@ -338,7 +338,7 @@ end def pbTryString(x) ret = pbGetFileChar(x) - return (ret!=nil && ret!="") ? x : nil + return (ret != nil && ret != "") ? x : nil end # Gets the contents of a file. Doesn't check RTP, but does check @@ -351,7 +351,7 @@ def pbGetFileString(file) if !safeExists?("./Game.rgssad") return nil if !safeExists?(file) begin - File.open(file,"rb") { |f| return f.read } # read all data + File.open(file, "rb") { |f| return f.read } # read all data rescue Errno::ENOENT, Errno::EINVAL, Errno::EACCES return nil end @@ -396,10 +396,10 @@ class StringInput @lineno = 0 end - attr_reader :lineno,:string + attr_reader :lineno, :string def inspect - return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0,30].inspect}>" + return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0, 30].inspect}>" end def close diff --git a/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb b/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb index a53599bfe..3eb23c8b0 100644 --- a/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb +++ b/Data/Scripts/001_Technical/002_Files/003_HTTP_Utilities.rb @@ -7,7 +7,7 @@ def pbPostData(url, postdata, filename = nil, depth = 0) if url[/^http:\/\/([^\/]+)(.*)$/] host = $1 path = $2 - path = "/" if path.length==0 + path = "/" if path.length == 0 userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14" body = postdata.map { |key, value| keyString = key.to_s @@ -63,7 +63,7 @@ end def pbDownloadToFile(url, file) begin - pbDownloadData(url,file) + pbDownloadData(url, file) rescue end end @@ -79,7 +79,7 @@ end def pbPostToFile(url, postdata, file) begin - pbPostData(url, postdata,file) + pbPostData(url, postdata, file) rescue end end diff --git a/Data/Scripts/001_Technical/002_RubyUtilities.rb b/Data/Scripts/001_Technical/002_RubyUtilities.rb index 311f9cb94..c8ae85240 100644 --- a/Data/Scripts/001_Technical/002_RubyUtilities.rb +++ b/Data/Scripts/001_Technical/002_RubyUtilities.rb @@ -89,7 +89,7 @@ end #=============================================================================== class Array def ^(other) # xor of two arrays - return (self|other) - (self&other) + return (self | other) - (self & other) end def swap(val1, val2) diff --git a/Data/Scripts/001_Technical/003_Intl_Messages.rb b/Data/Scripts/001_Technical/003_Intl_Messages.rb index 143fc20a3..9927c66eb 100644 --- a/Data/Scripts/001_Technical/003_Intl_Messages.rb +++ b/Data/Scripts/001_Technical/003_Intl_Messages.rb @@ -1,20 +1,20 @@ -def pbAddScriptTexts(items,script) +def pbAddScriptTexts(items, script) script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s| - string=s[0] - string.gsub!(/\\\"/,"\"") - string.gsub!(/\\\\/,"\\") + string = s[0] + string.gsub!(/\\\"/, "\"") + string.gsub!(/\\\\/, "\\") items.push(string) } end -def pbAddRgssScriptTexts(items,script) +def pbAddRgssScriptTexts(items, script) script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s| - string=s[0] - string.gsub!(/\\r/,"\r") - string.gsub!(/\\n/,"\n") - string.gsub!(/\\1/,"\1") - string.gsub!(/\\\"/,"\"") - string.gsub!(/\\\\/,"\\") + string = s[0] + string.gsub!(/\\r/, "\r") + string.gsub!(/\\n/, "\n") + string.gsub!(/\\1/, "\1") + string.gsub!(/\\\"/, "\"") + string.gsub!(/\\\\/, "\\") items.push(string) } end @@ -23,14 +23,14 @@ def pbSetTextMessages Graphics.update begin t = Time.now.to_i - texts=[] + texts = [] for script in $RGSS_SCRIPTS if Time.now.to_i - t >= 5 t = Time.now.to_i Graphics.update end - scr=Zlib::Inflate.inflate(script[2]) - pbAddRgssScriptTexts(texts,scr) + scr = Zlib::Inflate.inflate(script[2]) + pbAddRgssScriptTexts(texts, scr) end if safeExists?("Data/PluginScripts.rxdata") plugin_scripts = load_data("Data/PluginScripts.rxdata") @@ -41,62 +41,62 @@ def pbSetTextMessages Graphics.update end scr = Zlib::Inflate.inflate(script[1]).force_encoding(Encoding::UTF_8) - pbAddRgssScriptTexts(texts,scr) + pbAddRgssScriptTexts(texts, scr) end end end # Must add messages because this code is used by both game system and Editor - MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts,texts) + MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts, texts) commonevents = load_data("Data/CommonEvents.rxdata") - items=[] - choices=[] + items = [] + choices = [] for event in commonevents.compact if Time.now.to_i - t >= 5 t = Time.now.to_i Graphics.update end begin - neednewline=false - lastitem="" + neednewline = false + lastitem = "" for j in 0...event.list.size list = event.list[j] - if neednewline && list.code!=401 - if lastitem!="" - lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1+" " } + if neednewline && list.code != 401 + if lastitem != "" + lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1 + " " } items.push(lastitem) - lastitem="" + lastitem = "" end - neednewline=false + neednewline = false end if list.code == 101 - lastitem+="#{list.parameters[0]}" - neednewline=true + lastitem += "#{list.parameters[0]}" + neednewline = true elsif list.code == 102 for k in 0...list.parameters[0].length choices.push(list.parameters[0][k]) end - neednewline=false + neednewline = false elsif list.code == 401 - lastitem+=" " if lastitem!="" - lastitem+="#{list.parameters[0]}" - neednewline=true + lastitem += " " if lastitem != "" + lastitem += "#{list.parameters[0]}" + neednewline = true elsif list.code == 355 || list.code == 655 - pbAddScriptTexts(items,list.parameters[0]) - elsif list.code == 111 && list.parameters[0]==12 - pbAddScriptTexts(items,list.parameters[1]) + pbAddScriptTexts(items, list.parameters[0]) + elsif list.code == 111 && list.parameters[0] == 12 + pbAddScriptTexts(items, list.parameters[1]) elsif list.code == 209 - route=list.parameters[1] + route = list.parameters[1] for k in 0...route.list.size if route.list[k].code == 45 - pbAddScriptTexts(items,route.list[k].parameters[0]) + pbAddScriptTexts(items, route.list[k].parameters[0]) end end end end if neednewline - if lastitem!="" + if lastitem != "" items.push(lastitem) - lastitem="" + lastitem = "" end end end @@ -105,21 +105,21 @@ def pbSetTextMessages t = Time.now.to_i Graphics.update end - items|=[] - choices|=[] + items |= [] + choices |= [] items.concat(choices) - MessageTypes.setMapMessagesAsHash(0,items) + MessageTypes.setMapMessagesAsHash(0, items) mapinfos = pbLoadMapInfos for id in mapinfos.keys if Time.now.to_i - t >= 5 t = Time.now.to_i Graphics.update end - filename=sprintf("Data/Map%03d.rxdata",id) + filename = sprintf("Data/Map%03d.rxdata", id) next if !pbRgssExists?(filename) map = load_data(filename) - items=[] - choices=[] + items = [] + choices = [] for event in map.events.values if Time.now.to_i - t >= 5 t = Time.now.to_i @@ -127,47 +127,47 @@ def pbSetTextMessages end begin for i in 0...event.pages.size - neednewline=false - lastitem="" + neednewline = false + lastitem = "" for j in 0...event.pages[i].list.size list = event.pages[i].list[j] - if neednewline && list.code!=401 - if lastitem!="" - lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1+" " } + if neednewline && list.code != 401 + if lastitem != "" + lastitem.gsub!(/([^\.\!\?])\s\s+/) { |m| $1 + " " } items.push(lastitem) - lastitem="" + lastitem = "" end - neednewline=false + neednewline = false end if list.code == 101 - lastitem+="#{list.parameters[0]}" - neednewline=true + lastitem += "#{list.parameters[0]}" + neednewline = true elsif list.code == 102 for k in 0...list.parameters[0].length choices.push(list.parameters[0][k]) end - neednewline=false + neednewline = false elsif list.code == 401 - lastitem+=" " if lastitem!="" - lastitem+="#{list.parameters[0]}" - neednewline=true - elsif list.code == 355 || list.code==655 - pbAddScriptTexts(items,list.parameters[0]) - elsif list.code == 111 && list.parameters[0]==12 - pbAddScriptTexts(items,list.parameters[1]) - elsif list.code==209 - route=list.parameters[1] + lastitem += " " if lastitem != "" + lastitem += "#{list.parameters[0]}" + neednewline = true + elsif list.code == 355 || list.code == 655 + pbAddScriptTexts(items, list.parameters[0]) + elsif list.code == 111 && list.parameters[0] == 12 + pbAddScriptTexts(items, list.parameters[1]) + elsif list.code == 209 + route = list.parameters[1] for k in 0...route.list.size - if route.list[k].code==45 - pbAddScriptTexts(items,route.list[k].parameters[0]) + if route.list[k].code == 45 + pbAddScriptTexts(items, route.list[k].parameters[0]) end end end end if neednewline - if lastitem!="" + if lastitem != "" items.push(lastitem) - lastitem="" + lastitem = "" end end end @@ -177,10 +177,10 @@ def pbSetTextMessages t = Time.now.to_i Graphics.update end - items|=[] - choices|=[] + items |= [] + choices |= [] items.concat(choices) - MessageTypes.setMapMessagesAsHash(id,items) + MessageTypes.setMapMessagesAsHash(id, items) if Time.now.to_i - t >= 5 t = Time.now.to_i Graphics.update @@ -192,92 +192,92 @@ def pbSetTextMessages end def pbEachIntlSection(file) - lineno=1 - re=/^\s*\[\s*([^\]]+)\s*\]\s*$/ - havesection=false - sectionname=nil - lastsection=[] + lineno = 1 + re = /^\s*\[\s*([^\]]+)\s*\]\s*$/ + havesection = false + sectionname = nil + lastsection = [] file.each_line { |line| - if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF - line=line[3,line.length-3] + if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF + line = line[3, line.length - 3] end if !line[/^\#/] && !line[/^\s*$/] if line[re] if havesection - yield lastsection,sectionname + yield lastsection, sectionname end lastsection.clear - sectionname=$~[1] - havesection=true + sectionname = $~[1] + havesection = true else - if sectionname==nil - raise _INTL("Expected a section at the beginning of the file (line {1})",lineno) + if sectionname == nil + raise _INTL("Expected a section at the beginning of the file (line {1})", lineno) end - lastsection.push(line.gsub(/\s+$/,"")) + lastsection.push(line.gsub(/\s+$/, "")) end end - lineno+=1 - if lineno%500==0 + lineno += 1 + if lineno % 500 == 0 Graphics.update end } if havesection - yield lastsection,sectionname + yield lastsection, sectionname end end def pbGetText(infile) begin - file=File.open(infile,"rb") + file = File.open(infile, "rb") rescue - raise _INTL("Can't find {1}",infile) + raise _INTL("Can't find {1}", infile) end - intldat=[] + intldat = [] begin - pbEachIntlSection(file) { |section,name| - next if section.length==0 + pbEachIntlSection(file) { |section, name| + next if section.length == 0 if !name[/^([Mm][Aa][Pp])?(\d+)$/] - raise _INTL("Invalid section name {1}",name) + raise _INTL("Invalid section name {1}", name) end - ismap=$~[1] && $~[1]!="" - id=$~[2].to_i - itemlength=0 + ismap = $~[1] && $~[1] != "" + id = $~[2].to_i + itemlength = 0 if section[0][/^\d+$/] - intlhash=[] - itemlength=3 + intlhash = [] + itemlength = 3 if ismap - raise _INTL("Section {1} can't be an ordered list (section was recognized as an ordered list because its first line is a number)",name) + raise _INTL("Section {1} can't be an ordered list (section was recognized as an ordered list because its first line is a number)", name) end - if section.length%3!=0 - raise _INTL("Section {1}'s line count is not divisible by 3 (section was recognized as an ordered list because its first line is a number)",name) + if section.length % 3 != 0 + raise _INTL("Section {1}'s line count is not divisible by 3 (section was recognized as an ordered list because its first line is a number)", name) end else - intlhash=OrderedHash.new - itemlength=2 - if section.length%2!=0 - raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)",name) + intlhash = OrderedHash.new + itemlength = 2 + if section.length % 2 != 0 + raise _INTL("Section {1} has an odd number of entries (section was recognized as a hash because its first line is not a number)", name) end end - i=0 + i = 0 loop do break unless i < section.length - if itemlength==3 + if itemlength == 3 if !section[i][/^\d+$/] - raise _INTL("Expected a number in section {1}, got {2} instead",name,section[i]) + raise _INTL("Expected a number in section {1}, got {2} instead", name, section[i]) end - key=section[i].to_i - i+=1 + key = section[i].to_i + i += 1 else - key=MessageTypes.denormalizeValue(section[i]) + key = MessageTypes.denormalizeValue(section[i]) end - intlhash[key]=MessageTypes.denormalizeValue(section[i+1]) - i+=2 + intlhash[key] = MessageTypes.denormalizeValue(section[i + 1]) + i += 2 end if ismap - intldat[0]=[] if !intldat[0] - intldat[0][id]=intlhash + intldat[0] = [] if !intldat[0] + intldat[0][id] = intlhash else - intldat[id]=intlhash + intldat[id] = intlhash end } ensure @@ -287,10 +287,10 @@ def pbGetText(infile) end def pbCompileText - outfile=File.open("intl.dat","wb") + outfile = File.open("intl.dat", "wb") begin - intldat=pbGetText("intl.txt") - Marshal.dump(intldat,outfile) + intldat = pbGetText("intl.txt") + Marshal.dump(intldat, outfile) rescue raise ensure @@ -302,7 +302,7 @@ end class OrderedHash < Hash def initialize - @keys=[] + @keys = [] super end @@ -311,54 +311,54 @@ class OrderedHash < Hash end def inspect - str="{" + str = "{" for i in 0...@keys.length - str+=", " if i>0 - str+=@keys[i].inspect+"=>"+self[@keys[i]].inspect + str += ", " if i > 0 + str += @keys[i].inspect + "=>" + self[@keys[i]].inspect end - str+="}" + str += "}" return str end alias :to_s :inspect - def []=(key,value) - oldvalue=self[key] + def []=(key, value) + oldvalue = self[key] if !oldvalue && value @keys.push(key) elsif !value - @keys|=[] - @keys-=[key] + @keys |= [] + @keys -= [key] end - return super(key,value) + return super(key, value) end def self._load(string) - ret=self.new - keysvalues=Marshal.load(string) - keys=keysvalues[0] - values=keysvalues[1] + ret = self.new + keysvalues = Marshal.load(string) + keys = keysvalues[0] + values = keysvalues[1] for i in 0...keys.length - ret[keys[i]]=values[i] + ret[keys[i]] = values[i] end return ret end def _dump(_depth = 100) - values=[] + values = [] for key in @keys values.push(self[key]) end - return Marshal.dump([@keys,values]) + return Marshal.dump([@keys, values]) end end class Messages - def initialize(filename = nil,delayLoad = false) - @messages=nil - @filename=filename + def initialize(filename = nil, delayLoad = false) + @messages = nil + @filename = filename if @filename && !delayLoad loadMessageFile(@filename) end @@ -367,7 +367,7 @@ class Messages def delayedLoad if @filename && !@messages loadMessageFile(@filename) - @filename=nil + @filename = nil end end @@ -384,13 +384,13 @@ class Messages def self.normalizeValue(value) if value[/[\r\n\t\x01]|^[\[\]]/] - ret=value.clone - ret.gsub!(/\r/,"<>") - ret.gsub!(/\n/,"<>") - ret.gsub!(/\t/,"<>") - ret.gsub!(/\[/,"<<[>>") - ret.gsub!(/\]/,"<<]>>") - ret.gsub!(/\x01/,"<<1>>") + ret = value.clone + ret.gsub!(/\r/, "<>") + ret.gsub!(/\n/, "<>") + ret.gsub!(/\t/, "<>") + ret.gsub!(/\[/, "<<[>>") + ret.gsub!(/\]/, "<<]>>") + ret.gsub!(/\x01/, "<<1>>") return ret end return value @@ -398,45 +398,45 @@ class Messages def self.denormalizeValue(value) if value[/<<[rnt1\[\]]>>/] - ret=value.clone - ret.gsub!(/<<1>>/,"\1") - ret.gsub!(/<>/,"\r") - ret.gsub!(/<>/,"\n") - ret.gsub!(/<<\[>>/,"[") - ret.gsub!(/<<\]>>/,"]") - ret.gsub!(/<>/,"\t") + ret = value.clone + ret.gsub!(/<<1>>/, "\1") + ret.gsub!(/<>/, "\r") + ret.gsub!(/<>/, "\n") + ret.gsub!(/<<\[>>/, "[") + ret.gsub!(/<<\]>>/, "]") + ret.gsub!(/<>/, "\t") return ret end return value end - def self.writeObject(f,msgs,secname,origMessages = nil) + def self.writeObject(f, msgs, secname, origMessages = nil) return if !msgs if msgs.is_a?(Array) f.write("[#{secname}]\r\n") for j in 0...msgs.length next if nil_or_empty?(msgs[j]) - value=Messages.normalizeValue(msgs[j]) - origValue="" + value = Messages.normalizeValue(msgs[j]) + origValue = "" if origMessages - origValue=Messages.normalizeValue(origMessages.get(secname,j)) + origValue = Messages.normalizeValue(origMessages.get(secname, j)) else - origValue=Messages.normalizeValue(MessageTypes.get(secname,j)) + origValue = Messages.normalizeValue(MessageTypes.get(secname, j)) end f.write("#{j}\r\n") - f.write(origValue+"\r\n") - f.write(value+"\r\n") + f.write(origValue + "\r\n") + f.write(value + "\r\n") end elsif msgs.is_a?(OrderedHash) f.write("[#{secname}]\r\n") - keys=msgs.keys + keys = msgs.keys for key in keys next if nil_or_empty?(msgs[key]) - value=Messages.normalizeValue(msgs[key]) - valkey=Messages.normalizeValue(key) + value = Messages.normalizeValue(msgs[key]) + valkey = Messages.normalizeValue(key) # key is already serialized - f.write(valkey+"\r\n") - f.write(value+"\r\n") + f.write(valkey + "\r\n") + f.write(value + "\r\n") end end end @@ -447,8 +447,8 @@ class Messages def extract(outfile) # return if !@messages - origMessages=Messages.new("Data/messages.dat") - File.open(outfile,"wb") { |f| + origMessages = Messages.new("Data/messages.dat") + File.open(outfile, "wb") { |f| f.write(0xef.chr) f.write(0xbb.chr) f.write(0xbf.chr) @@ -456,103 +456,103 @@ class Messages f.write("# translate every second line of this file.\r\n") if origMessages.messages[0] for i in 0...origMessages.messages[0].length - msgs=origMessages.messages[0][i] - Messages.writeObject(f,msgs,"Map#{i}",origMessages) + msgs = origMessages.messages[0][i] + Messages.writeObject(f, msgs, "Map#{i}", origMessages) end end for i in 1...origMessages.messages.length - msgs=origMessages.messages[i] - Messages.writeObject(f,msgs,i,origMessages) + msgs = origMessages.messages[i] + Messages.writeObject(f, msgs, i, origMessages) end } end - def setMessages(type,array) - @messages=[] if !@messages - arr=[] + def setMessages(type, array) + @messages = [] if !@messages + arr = [] for i in 0...array.length - arr[i]=(array[i]) ? array[i] : "" + arr[i] = (array[i]) ? array[i] : "" end - @messages[type]=arr + @messages[type] = arr end - def addMessages(type,array) - @messages=[] if !@messages - arr=(@messages[type]) ? @messages[type] : [] + def addMessages(type, array) + @messages = [] if !@messages + arr = (@messages[type]) ? @messages[type] : [] for i in 0...array.length - arr[i]=(array[i]) ? array[i] : (arr[i]) ? arr[i] : "" + arr[i] = (array[i]) ? array[i] : (arr[i]) ? arr[i] : "" end - @messages[type]=arr + @messages[type] = arr end - def self.createHash(_type,array) - arr=OrderedHash.new + def self.createHash(_type, array) + arr = OrderedHash.new for i in 0...array.length if array[i] - key=Messages.stringToKey(array[i]) - arr[key]=array[i] + key = Messages.stringToKey(array[i]) + arr[key] = array[i] end end return arr end - def self.addToHash(_type,array,hash) - hash=OrderedHash.new if !hash + 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]) - hash[key]=array[i] + key = Messages.stringToKey(array[i]) + hash[key] = array[i] end end return hash end - def setMapMessagesAsHash(type,array) - @messages=[] if !@messages - @messages[0]=[] if !@messages[0] - @messages[0][type]=Messages.createHash(type,array) + def setMapMessagesAsHash(type, array) + @messages = [] if !@messages + @messages[0] = [] if !@messages[0] + @messages[0][type] = Messages.createHash(type, array) end - def addMapMessagesAsHash(type,array) - @messages=[] if !@messages - @messages[0]=[] if !@messages[0] - @messages[0][type]=Messages.addToHash(type,array,@messages[0][type]) + def addMapMessagesAsHash(type, array) + @messages = [] if !@messages + @messages[0] = [] if !@messages[0] + @messages[0][type] = Messages.addToHash(type, array, @messages[0][type]) end - def setMessagesAsHash(type,array) - @messages=[] if !@messages - @messages[type]=Messages.createHash(type,array) + def setMessagesAsHash(type, array) + @messages = [] if !@messages + @messages[type] = Messages.createHash(type, array) end - def addMessagesAsHash(type,array) - @messages=[] if !@messages - @messages[type]=Messages.addToHash(type,array,@messages[type]) + def addMessagesAsHash(type, array) + @messages = [] if !@messages + @messages[type] = Messages.addToHash(type, array, @messages[type]) end def saveMessages(filename = nil) - filename="Data/messages.dat" if !filename - File.open(filename,"wb") { |f| Marshal.dump(@messages,f) } + filename = "Data/messages.dat" if !filename + File.open(filename, "wb") { |f| Marshal.dump(@messages, f) } end def loadMessageFile(filename) begin - pbRgssOpen(filename,"rb") { |f| @messages=Marshal.load(f) } + pbRgssOpen(filename, "rb") { |f| @messages = Marshal.load(f) } if !@messages.is_a?(Array) - @messages=nil + @messages = nil raise "Corrupted data" end return @messages rescue - @messages=nil + @messages = nil return nil end end - def set(type,id,value) + def set(type, id, value) delayedLoad return if !@messages return if !@messages[type] - @messages[type][id]=value + @messages[type][id] = value end def getCount(type) @@ -562,7 +562,7 @@ class Messages return @messages[type].length end - def get(type,id) + def get(type, id) delayedLoad return "" if !@messages return "" if !@messages[type] @@ -570,21 +570,21 @@ class Messages return @messages[type][id] end - def getFromHash(type,key) + def getFromHash(type, key) delayedLoad return key if !@messages || !@messages[type] || !key - id=Messages.stringToKey(key) + id = Messages.stringToKey(key) return key if !@messages[type][id] return @messages[type][id] end - def getFromMapHash(type,key) + def getFromMapHash(type, key) delayedLoad return key if !@messages return key if !@messages[0] return key if !@messages[0][type] && !@messages[0][0] - id=Messages.stringToKey(key) - if @messages[0][type] && @messages[0][type][id] + id = Messages.stringToKey(key) + if @messages[0][type] && @messages[0][type][id] return @messages[0][type][id] elsif @messages[0][0] && @messages[0][0][id] return @messages[0][0][id] @@ -625,7 +625,7 @@ module MessageTypes RibbonDescriptions = 26 StorageCreator = 27 @@messages = Messages.new - @@messagesFallback = Messages.new("Data/messages.dat",true) + @@messagesFallback = Messages.new("Data/messages.dat", true) def self.stringToKey(str) return Messages.stringToKey(str) @@ -639,7 +639,7 @@ module MessageTypes Messages.denormalizeValue(value) end - def self.writeObject(f,msgs,secname) + def self.writeObject(f, msgs, secname) Messages.denormalizeValue(str) end @@ -647,32 +647,32 @@ module MessageTypes @@messages.extract(outfile) end - def self.setMessages(type,array) - @@messages.setMessages(type,array) + def self.setMessages(type, array) + @@messages.setMessages(type, array) end - def self.addMessages(type,array) - @@messages.addMessages(type,array) + def self.addMessages(type, array) + @@messages.addMessages(type, array) end - def self.createHash(type,array) - Messages.createHash(type,array) + def self.createHash(type, array) + Messages.createHash(type, array) end - def self.addMapMessagesAsHash(type,array) - @@messages.addMapMessagesAsHash(type,array) + def self.addMapMessagesAsHash(type, array) + @@messages.addMapMessagesAsHash(type, array) end - def self.setMapMessagesAsHash(type,array) - @@messages.setMapMessagesAsHash(type,array) + def self.setMapMessagesAsHash(type, array) + @@messages.setMapMessagesAsHash(type, array) end - def self.addMessagesAsHash(type,array) - @@messages.addMessagesAsHash(type,array) + def self.addMessagesAsHash(type, array) + @@messages.addMessagesAsHash(type, array) end - def self.setMessagesAsHash(type,array) - @@messages.setMessagesAsHash(type,array) + def self.setMessagesAsHash(type, array) + @@messages.setMessagesAsHash(type, array) end def self.saveMessages(filename = nil) @@ -683,30 +683,30 @@ module MessageTypes @@messages.loadMessageFile(filename) end - def self.get(type,id) - ret=@@messages.get(type,id) - if ret=="" - ret=@@messagesFallback.get(type,id) + def self.get(type, id) + ret = @@messages.get(type, id) + if ret == "" + ret = @@messagesFallback.get(type, id) end return ret end def self.getCount(type) - c1=@@messages.getCount(type) - c2=@@messagesFallback.getCount(type) - return c1>c2 ? c1 : c2 + c1 = @@messages.getCount(type) + c2 = @@messagesFallback.getCount(type) + return c1 > c2 ? c1 : c2 end - def self.getOriginal(type,id) - return @@messagesFallback.get(type,id) + def self.getOriginal(type, id) + return @@messagesFallback.get(type, id) end - def self.getFromHash(type,key) - @@messages.getFromHash(type,key) + def self.getFromHash(type, key) + @@messages.getFromHash(type, key) end - def self.getFromMapHash(type,key) - @@messages.getFromMapHash(type,key) + def self.getFromMapHash(type, key) + @@messages.getFromMapHash(type, key) end end @@ -720,25 +720,25 @@ def pbGetMessageCount(type) return MessageTypes.getCount(type) end -def pbGetMessage(type,id) - return MessageTypes.get(type,id) +def pbGetMessage(type, id) + return MessageTypes.get(type, id) end -def pbGetMessageFromHash(type,id) - return MessageTypes.getFromHash(type,id) +def pbGetMessageFromHash(type, id) + return MessageTypes.getFromHash(type, id) end # Replaces first argument with a localized version and formats the other # parameters by replacing {1}, {2}, etc. with those placeholders. def _INTL(*arg) begin - string=MessageTypes.getFromHash(MessageTypes::ScriptTexts,arg[0]) + string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0]) rescue - string=arg[0] + string = arg[0] end - string=string.clone + string = string.clone for i in 1...arg.length - string.gsub!(/\{#{i}\}/,"#{arg[i]}") + string.gsub!(/\{#{i}\}/, "#{arg[i]}") end return string end @@ -748,38 +748,38 @@ end # This version acts more like sprintf, supports e.g. {1:d} or {2:s} def _ISPRINTF(*arg) begin - string=MessageTypes.getFromHash(MessageTypes::ScriptTexts,arg[0]) + string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0]) rescue - string=arg[0] + string = arg[0] end - string=string.clone + string = string.clone for i in 1...arg.length string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| - next sprintf("%"+$1,arg[i]) + next sprintf("%" + $1, arg[i]) } end return string end def _I(str) - return _MAPINTL($game_map.map_id,str) + return _MAPINTL($game_map.map_id, str) end -def _MAPINTL(mapid,*arg) - string=MessageTypes.getFromMapHash(mapid,arg[0]) - string=string.clone +def _MAPINTL(mapid, *arg) + string = MessageTypes.getFromMapHash(mapid, arg[0]) + string = string.clone for i in 1...arg.length - string.gsub!(/\{#{i}\}/,"#{arg[i]}") + string.gsub!(/\{#{i}\}/, "#{arg[i]}") end return string end -def _MAPISPRINTF(mapid,*arg) - string=MessageTypes.getFromMapHash(mapid,arg[0]) - string=string.clone +def _MAPISPRINTF(mapid, *arg) + string = MessageTypes.getFromMapHash(mapid, arg[0]) + string = string.clone for i in 1...arg.length string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| - next sprintf("%"+$1,arg[i]) + next sprintf("%" + $1, arg[i]) } end return string diff --git a/Data/Scripts/001_Technical/005_PluginManager.rb b/Data/Scripts/001_Technical/005_PluginManager.rb index c1d6a379e..19baf8e5f 100644 --- a/Data/Scripts/001_Technical/005_PluginManager.rb +++ b/Data/Scripts/001_Technical/005_PluginManager.rb @@ -588,7 +588,7 @@ module PluginManager optional = false # clean the name to a simple string if dname.is_a?(Array) - optional = [:optional,:optional_exact].include?(dname[0]) + optional = [:optional, :optional_exact].include?(dname[0]) dname = dname[dname.length - 2] end # catch missing dependency @@ -710,7 +710,7 @@ module PluginManager # get rid of tabs code.gsub!("\t", " ") # construct filename - sname = scr[0].gsub("\\","/").split("/")[-1] + sname = scr[0].gsub("\\", "/").split("/")[-1] fname = "[#{name}] #{sname}" # try to run the code begin diff --git a/Data/Scripts/001_Technical/006_RPG_Sprite.rb b/Data/Scripts/001_Technical/006_RPG_Sprite.rb index 261631064..f6fedfc4d 100644 --- a/Data/Scripts/001_Technical/006_RPG_Sprite.rb +++ b/Data/Scripts/001_Technical/006_RPG_Sprite.rb @@ -199,16 +199,16 @@ class SpriteAnimation sprite.visible = false if sprite != nil next end - sprite.x = sprite_x + cell_data[i, 1] - sprite.y = sprite_y + cell_data[i, 2] + sprite.x = sprite_x + cell_data[i, 1] + sprite.y = sprite_y + cell_data[i, 2] next if quick_update - sprite.visible = true + sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192) case @_animation_height - when 0 then sprite.z = 1 - when 1 then sprite.z = sprite.y+32+15 - when 2 then sprite.z = sprite.y+32+32+17 - else sprite.z = 2000 + when 0 then sprite.z = 1 + when 1 then sprite.z = sprite.y + 32 + 15 + when 2 then sprite.z = sprite.y + 32 + 32 + 17 + else sprite.z = 2000 end sprite.ox = 96 sprite.oy = 96 @@ -299,9 +299,9 @@ module RPG end def whiten - self.blend_type = 0 + self.blend_type = 0 self.color.set(255, 255, 255, 128) - self.opacity = 255 + self.opacity = 255 @_whiten_duration = 16 @_appear_duration = 0 @_escape_duration = 0 @@ -345,10 +345,10 @@ module RPG bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) - bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) - bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) - bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) - bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) + bitmap.draw_text(-1, 12 - 1, 160, 36, damage_string, 1) + bitmap.draw_text(+1, 12 - 1, 160, 36, damage_string, 1) + bitmap.draw_text(-1, 12 + 1, 160, 36, damage_string, 1) + bitmap.draw_text(+1, 12 + 1, 160, 36, damage_string, 1) if value.is_a?(Numeric) && value < 0 bitmap.font.color.set(176, 255, 144) else @@ -386,14 +386,14 @@ module RPG def animation(animation, hit, height = 3) anim = SpriteAnimation.new(self) - anim.animation(animation,hit,height) - pushAnimation(@animations,anim) + anim.animation(animation, hit, height) + pushAnimation(@animations, anim) end def loop_animation(animation) anim = SpriteAnimation.new(self) anim.loop_animation(animation) - pushAnimation(@loopAnimations,anim) + pushAnimation(@loopAnimations, anim) end def dispose_damage diff --git a/Data/Scripts/003_Game processing/002_Scene_Map.rb b/Data/Scripts/003_Game processing/002_Scene_Map.rb index 24efa6060..5030f76ba 100644 --- a/Data/Scripts/003_Game processing/002_Scene_Map.rb +++ b/Data/Scripts/003_Game processing/002_Scene_Map.rb @@ -10,7 +10,7 @@ class Scene_Map def spriteset(map_id = -1) return @spritesets[map_id] if map_id > 0 && @spritesets[map_id] for i in @spritesets.values - return i if i.map==$game_map + return i if i.map == $game_map end return @spritesets.values[0] end @@ -56,13 +56,13 @@ class Scene_Map map = load_data(sprintf("Data/Map%03d.rxdata", mapid)) if playingBGM && map.autoplay_bgm if (PBDayNight.isNight? rescue false) - pbBGMFade(0.8) if playingBGM.name!=map.bgm.name && playingBGM.name!=map.bgm.name+"_n" + pbBGMFade(0.8) if playingBGM.name != map.bgm.name && playingBGM.name != map.bgm.name + "_n" else - pbBGMFade(0.8) if playingBGM.name!=map.bgm.name + pbBGMFade(0.8) if playingBGM.name != map.bgm.name end end if playingBGS && map.autoplay_bgs - pbBGMFade(0.8) if playingBGS.name!=map.bgs.name + pbBGMFade(0.8) if playingBGS.name != map.bgs.name end Graphics.frame_reset end @@ -73,7 +73,7 @@ class Scene_Map autofade($game_temp.player_new_map_id) pbBridgeOff @spritesetGlobal.playersprite.clearShadows - if $game_map.map_id!=$game_temp.player_new_map_id + if $game_map.map_id != $game_temp.player_new_map_id $map_factory.setup($game_temp.player_new_map_id) end $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y) diff --git a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb index 83eadc3aa..9b9ecbf34 100644 --- a/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb +++ b/Data/Scripts/003_Game processing/004_Interpreter_Commands.rb @@ -1034,7 +1034,7 @@ class Interpreter # Look for more script commands or a continuation of one, and add them to script loop do break if ![355, 655].include?(@list[@index + 1].code) - script += @list[@index+1].parameters[0] + "\n" + script += @list[@index + 1].parameters[0] + "\n" @index += 1 end # Run the script diff --git a/Data/Scripts/003_Game processing/005_Event_Handlers.rb b/Data/Scripts/003_Game processing/005_Event_Handlers.rb index 309375749..80c537e81 100644 --- a/Data/Scripts/003_Game processing/005_Event_Handlers.rb +++ b/Data/Scripts/003_Game processing/005_Event_Handlers.rb @@ -38,13 +38,13 @@ class Event # proc { |sender,params| } where params is an array of the other parameters, and # proc { |sender,arg0,arg1,...| } def trigger(*arg) - arglist = arg[1,arg.length] + arglist = arg[1, arg.length] for callback in @callbacks - if callback.arity>2 && arg.length==callback.arity + if callback.arity > 2 && arg.length == callback.arity # Retrofitted for callbacks that take three or more arguments callback.call(*arg) else - callback.call(arg[0],arglist) + callback.call(arg[0], arglist) end end end @@ -84,7 +84,7 @@ class HandlerHash mod = Object.const_get(@mod) rescue nil return nil if !mod for key in mod.constants - next if mod.const_get(key)!=sym + next if mod.const_get(key) != sym ret = key.to_sym @symbolCache[sym] = ret break @@ -92,15 +92,15 @@ class HandlerHash return ret end - def addIf(conditionProc,handler = nil,&handlerBlock) - if ![Proc,Hash].include?(handler.class) && !block_given? + def addIf(conditionProc, handler = nil, &handlerBlock) + if ![Proc, Hash].include?(handler.class) && !block_given? raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)" end - @addIfs.push([conditionProc,handler || handlerBlock]) + @addIfs.push([conditionProc, handler || handlerBlock]) end - def add(sym,handler = nil,&handlerBlock) # 'sym' can be an ID or symbol - if ![Proc,Hash].include?(handler.class) && !block_given? + def add(sym, handler = nil, &handlerBlock) # 'sym' can be an ID or symbol + if ![Proc, Hash].include?(handler.class) && !block_given? raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)" end id = fromSymbol(sym) @@ -109,11 +109,11 @@ class HandlerHash @hash[symbol] = handler || handlerBlock if symbol end - def copy(src,*dests) + def copy(src, *dests) handler = self[src] if handler for dest in dests - self.add(dest,handler) + self.add(dest, handler) end end end @@ -132,9 +132,9 @@ class HandlerHash return ret end - def trigger(sym,*args) + def trigger(sym, *args) handler = self[sym] - return (handler) ? handler.call(fromSymbol(sym),*args) : nil + return (handler) ? handler.call(fromSymbol(sym), *args) : nil end def clear @@ -221,7 +221,7 @@ class HandlerHashBasic end def add(entry, handler = nil, &handlerBlock) - if ![Proc,Hash].include?(handler.class) && !block_given? + if ![Proc, Hash].include?(handler.class) && !block_given? raise ArgumentError, "#{self.class.name} for #{entry.inspect} has no valid handler (#{handler.inspect} was given)" end return if !entry || entry.empty? diff --git a/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb b/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb index 4960dc550..d7f733597 100644 --- a/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb +++ b/Data/Scripts/003_Game processing/006_Event_OverworldEvents.rb @@ -136,8 +136,8 @@ end #=============================================================================== # #=============================================================================== -def pbOnSpritesetCreate(spriteset,viewport) - Events.onSpritesetCreate.trigger(nil,spriteset,viewport) +def pbOnSpritesetCreate(spriteset, viewport) + Events.onSpritesetCreate.trigger(nil, spriteset, viewport) end #=============================================================================== diff --git a/Data/Scripts/004_Game classes/001_Game_Screen.rb b/Data/Scripts/004_Game classes/001_Game_Screen.rb index 500ce3afa..d41d1a68a 100644 --- a/Data/Scripts/004_Game classes/001_Game_Screen.rb +++ b/Data/Scripts/004_Game classes/001_Game_Screen.rb @@ -90,39 +90,39 @@ class Game_Screen # * Frame Update #----------------------------------------------------------------------------- def update - if @fadeout_duration && @fadeout_duration>=1 + if @fadeout_duration && @fadeout_duration >= 1 d = @fadeout_duration - @brightness = (@brightness*(d-1))/d + @brightness = (@brightness * (d - 1)) / d @fadeout_duration -= 1 end - if @fadein_duration && @fadein_duration>=1 + if @fadein_duration && @fadein_duration >= 1 d = @fadein_duration - @brightness = (@brightness*(d-1)+255)/d + @brightness = (@brightness * (d - 1) + 255) / d @fadein_duration -= 1 end - if @tone_duration>=1 + if @tone_duration >= 1 d = @tone_duration - @tone.red = (@tone.red*(d-1)+@tone_target.red)/d - @tone.green = (@tone.green*(d-1)+@tone_target.green)/d - @tone.blue = (@tone.blue*(d-1)+@tone_target.blue)/d - @tone.gray = (@tone.gray*(d-1)+@tone_target.gray)/d + @tone.red = (@tone.red * (d - 1) + @tone_target.red) / d + @tone.green = (@tone.green * (d - 1) + @tone_target.green) / d + @tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d + @tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d @tone_duration -= 1 end - if @flash_duration>=1 + if @flash_duration >= 1 d = @flash_duration - @flash_color.alpha = @flash_color.alpha*(d-1)/d + @flash_color.alpha = @flash_color.alpha * (d - 1) / d @flash_duration -= 1 end - if @shake_duration>=1 || @shake!=0 - delta = (@shake_power*@shake_speed*@shake_direction)/10.0 - if @shake_duration<=1 && @shake*(@shake+delta)<0 + if @shake_duration >= 1 || @shake != 0 + delta = (@shake_power * @shake_speed * @shake_direction) / 10.0 + if @shake_duration <= 1 && @shake * (@shake + delta) < 0 @shake = 0 else @shake += delta end - @shake_direction = -1 if @shake>@shake_power*2 - @shake_direction = 1 if @shake<-@shake_power*2 - @shake_duration -= 1 if @shake_duration>=1 + @shake_direction = -1 if @shake > @shake_power * 2 + @shake_direction = 1 if @shake < -@shake_power * 2 + @shake_duration -= 1 if @shake_duration >= 1 end if $game_temp.in_battle for i in 51..100 @@ -139,17 +139,17 @@ end #=============================================================================== # #=============================================================================== -def pbToneChangeAll(tone,duration) - $game_screen.start_tone_change(tone,duration*Graphics.frame_rate/20) +def pbToneChangeAll(tone, duration) + $game_screen.start_tone_change(tone, duration * Graphics.frame_rate / 20) for picture in $game_screen.pictures - picture.start_tone_change(tone,duration*Graphics.frame_rate/20) if picture + picture.start_tone_change(tone, duration * Graphics.frame_rate / 20) if picture end end -def pbShake(power,speed,frames) - $game_screen.start_shake(power,speed,frames*Graphics.frame_rate/20) +def pbShake(power, speed, frames) + $game_screen.start_shake(power, speed, frames * Graphics.frame_rate / 20) end -def pbFlash(color,frames) - $game_screen.start_flash(color,frames*Graphics.frame_rate/20) +def pbFlash(color, frames) + $game_screen.start_flash(color, frames * Graphics.frame_rate / 20) end diff --git a/Data/Scripts/004_Game classes/001_Switches and Variables/004_Game_SelfSwitches.rb b/Data/Scripts/004_Game classes/001_Switches and Variables/004_Game_SelfSwitches.rb index 528e4b1c0..c67b55d93 100644 --- a/Data/Scripts/004_Game classes/001_Switches and Variables/004_Game_SelfSwitches.rb +++ b/Data/Scripts/004_Game classes/001_Switches and Variables/004_Game_SelfSwitches.rb @@ -16,7 +16,7 @@ class Game_SelfSwitches # key : key #----------------------------------------------------------------------------- def [](key) - return (@data[key]==true) ? true : false + return (@data[key] == true) ? true : false end #----------------------------------------------------------------------------- # * Set Self Switch diff --git a/Data/Scripts/004_Game classes/002_Game_System.rb b/Data/Scripts/004_Game classes/002_Game_System.rb index 2312c4659..4284d30cb 100644 --- a/Data/Scripts/004_Game classes/002_Game_System.rb +++ b/Data/Scripts/004_Game classes/002_Game_System.rb @@ -44,28 +44,28 @@ class Game_System def bgm_play(bgm) old_pos = @bgm_position @bgm_position = 0 - bgm_play_internal(bgm,0) + bgm_play_internal(bgm, 0) @bgm_position = old_pos end - def bgm_play_internal2(name,volume,pitch,position) # :nodoc: + def bgm_play_internal2(name, volume, pitch, position) # :nodoc: vol = volume - vol *= $PokemonSystem.bgmvolume/100.0 + vol *= $PokemonSystem.bgmvolume / 100.0 vol = vol.to_i begin - Audio.bgm_play(name,vol,pitch,position) + Audio.bgm_play(name, vol, pitch, position) rescue ArgumentError - Audio.bgm_play(name,vol,pitch) + Audio.bgm_play(name, vol, pitch) end end - def bgm_play_internal(bgm,position) # :nodoc: + def bgm_play_internal(bgm, position) # :nodoc: @bgm_position = position if !@bgm_paused - @playing_bgm = (bgm==nil) ? nil : bgm.clone - if bgm!=nil && bgm.name!="" - if FileTest.audio_exist?("Audio/BGM/"+bgm.name) - bgm_play_internal2("Audio/BGM/"+bgm.name, - bgm.volume,bgm.pitch,@bgm_position) if !@defaultBGM + @playing_bgm = (bgm == nil) ? nil : bgm.clone + if bgm != nil && bgm.name != "" + if FileTest.audio_exist?("Audio/BGM/" + bgm.name) + bgm_play_internal2("Audio/BGM/" + bgm.name, + bgm.volume, bgm.pitch, @bgm_position) if !@defaultBGM end else @bgm_position = position if !@bgm_paused @@ -73,15 +73,15 @@ class Game_System Audio.bgm_stop if !@defaultBGM end if @defaultBGM - bgm_play_internal2("Audio/BGM/"+@defaultBGM.name, - @defaultBGM.volume,@defaultBGM.pitch,@bgm_position) + bgm_play_internal2("Audio/BGM/" + @defaultBGM.name, + @defaultBGM.volume, @defaultBGM.pitch, @bgm_position) end Graphics.frame_reset end def bgm_pause(fadetime = 0.0) # :nodoc: pos = Audio.bgm_pos rescue 0 - self.bgm_fade(fadetime) if fadetime>0.0 + self.bgm_fade(fadetime) if fadetime > 0.0 @bgm_position = pos @bgm_paused = true end @@ -93,7 +93,7 @@ class Game_System def bgm_resume(bgm) # :nodoc: if @bgm_paused - self.bgm_play_internal(bgm,@bgm_position) + self.bgm_play_internal(bgm, @bgm_position) @bgm_position = 0 @bgm_paused = false end @@ -108,7 +108,7 @@ class Game_System def bgm_fade(time) # :nodoc: @bgm_position = 0 if !@bgm_paused @playing_bgm = nil - Audio.bgm_fade((time*1000).floor) if !@defaultBGM + Audio.bgm_fade((time * 1000).floor) if !@defaultBGM end def playing_bgm @@ -130,9 +130,9 @@ class Game_System return (@playing_bgm) ? @playing_bgm.clone : nil end - def setDefaultBGM(bgm,volume = 80,pitch = 100) - bgm = RPG::AudioFile.new(bgm,volume,pitch) if bgm.is_a?(String) - if bgm!=nil && bgm.name!="" + def setDefaultBGM(bgm, volume = 80, pitch = 100) + bgm = RPG::AudioFile.new(bgm, volume, pitch) if bgm.is_a?(String) + if bgm != nil && bgm.name != "" @defaultBGM = nil self.bgm_play(bgm) @defaultBGM = bgm.clone @@ -146,12 +146,12 @@ class Game_System def me_play(me) me = RPG::AudioFile.new(me) if me.is_a?(String) - if me!=nil && me.name!="" - if FileTest.audio_exist?("Audio/ME/"+me.name) + if me != nil && me.name != "" + if FileTest.audio_exist?("Audio/ME/" + me.name) vol = me.volume - vol *= $PokemonSystem.bgmvolume/100.0 + vol *= $PokemonSystem.bgmvolume / 100.0 vol = vol.to_i - Audio.me_play("Audio/ME/"+me.name,vol,me.pitch) + Audio.me_play("Audio/ME/" + me.name, vol, me.pitch) end else Audio.me_stop @@ -162,13 +162,13 @@ class Game_System ################################################################################ def bgs_play(bgs) - @playing_bgs = (bgs==nil) ? nil : bgs.clone - if bgs!=nil && bgs.name!="" - if FileTest.audio_exist?("Audio/BGS/"+bgs.name) + @playing_bgs = (bgs == nil) ? nil : bgs.clone + if bgs != nil && bgs.name != "" + if FileTest.audio_exist?("Audio/BGS/" + bgs.name) vol = bgs.volume - vol *= $PokemonSystem.sevolume/100.0 + vol *= $PokemonSystem.sevolume / 100.0 vol = vol.to_i - Audio.bgs_play("Audio/BGS/"+bgs.name,vol,bgs.pitch) + Audio.bgs_play("Audio/BGS/" + bgs.name, vol, bgs.pitch) end else @bgs_position = 0 @@ -179,7 +179,7 @@ class Game_System end def bgs_pause(fadetime = 0.0) # :nodoc: - if fadetime>0.0 + if fadetime > 0.0 self.bgs_fade(fadetime) else self.bgs_stop @@ -207,7 +207,7 @@ class Game_System def bgs_fade(time) @bgs_position = 0 @playing_bgs = nil - Audio.bgs_fade((time*1000).floor) + Audio.bgs_fade((time * 1000).floor) end def playing_bgs @@ -230,11 +230,11 @@ class Game_System def se_play(se) se = RPG::AudioFile.new(se) if se.is_a?(String) - if se!=nil && se.name!="" && FileTest.audio_exist?("Audio/SE/"+se.name) + if se != nil && se.name != "" && FileTest.audio_exist?("Audio/SE/" + se.name) vol = se.volume - vol *= $PokemonSystem.sevolume/100.0 + vol *= $PokemonSystem.sevolume / 100.0 vol = vol.to_i - Audio.se_play("Audio/SE/"+se.name,vol,se.pitch) + Audio.se_play("Audio/SE/" + se.name, vol, se.pitch) end end @@ -259,7 +259,7 @@ class Game_System ################################################################################ def windowskin_name - if @windowskin_name==nil + if @windowskin_name == nil return $data_system.windowskin_name else return @windowskin_name @@ -269,10 +269,10 @@ class Game_System attr_writer :windowskin_name def update - @timer -= 1 if @timer_working && @timer>0 - if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1,"Cut Scene") + @timer -= 1 if @timer_working && @timer > 0 + if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1, "Cut Scene") event = @map_interpreter.get_self - @map_interpreter.pbSetSelfSwitch(event.id,"A",true) + @map_interpreter.pbSetSelfSwitch(event.id, "A", true) @map_interpreter.command_end event.start end diff --git a/Data/Scripts/004_Game classes/004_Game_Map.rb b/Data/Scripts/004_Game classes/004_Game_Map.rb index bdf87a956..a3baa1080 100644 --- a/Data/Scripts/004_Game classes/004_Game_Map.rb +++ b/Data/Scripts/004_Game classes/004_Game_Map.rb @@ -43,8 +43,8 @@ class Game_Map end def setup(map_id) - @map_id = map_id - @map = load_data(sprintf("Data/Map%03d.rxdata",map_id)) + @map_id = map_id + @map = load_data(sprintf("Data/Map%03d.rxdata", map_id)) tileset = $data_tilesets[@map.tileset_id] updateTileset @fog_ox = 0 @@ -57,10 +57,10 @@ class Game_Map self.display_x = 0 self.display_y = 0 @need_refresh = false - Events.onMapCreate.trigger(self,map_id,@map,tileset) + Events.onMapCreate.trigger(self, map_id, @map, tileset) @events = {} for i in @map.events.keys - @events[i] = Game_Event.new(@map_id, @map.events[i],self) + @events[i] = Game_Event.new(@map_id, @map.events[i], self) end @common_events = {} for i in 1...$data_common_events.size @@ -110,10 +110,10 @@ class Game_Map #----------------------------------------------------------------------------- def autoplayAsCue if @map.autoplay_bgm - if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "_n") - pbCueBGM(@map.bgm.name+"_n",1.0,@map.bgm.volume,@map.bgm.pitch) + if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n") + pbCueBGM(@map.bgm.name + "_n", 1.0, @map.bgm.volume, @map.bgm.pitch) else - pbCueBGM(@map.bgm,1.0) + pbCueBGM(@map.bgm, 1.0) end end if @map.autoplay_bgs @@ -126,8 +126,8 @@ class Game_Map #----------------------------------------------------------------------------- def autoplay if @map.autoplay_bgm - if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/"+ @map.bgm.name+ "_n") - pbBGMPlay(@map.bgm.name+"_n",@map.bgm.volume,@map.bgm.pitch) + if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n") + pbBGMPlay(@map.bgm.name + "_n", @map.bgm.volume, @map.bgm.pitch) else pbBGMPlay(@map.bgm) end @@ -159,7 +159,7 @@ class Game_Map return false if passage & 0x0f == 0x0f return true if @priorities[event.tile_id] == 0 end - return playerPassable?(x, y, d, self_event) if self_event==$game_player + return playerPassable?(x, y, d, self_event) if self_event == $game_player # All other events newx = x newy = y @@ -270,7 +270,7 @@ class Game_Map return true end - def bush?(x,y) + def bush?(x, y) for i in [2, 1, 0] tile_id = data[x, y, i] return false if GameData::TerrainTag.try_get(@terrain_tags[tile_id]).bridge && @@ -280,7 +280,7 @@ class Game_Map return false end - def deepBush?(x,y) + def deepBush?(x, y) for i in [2, 1, 0] tile_id = data[x, y, i] terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id]) @@ -290,7 +290,7 @@ class Game_Map return false end - def counter?(x,y) + def counter?(x, y) for i in [2, 1, 0] tile_id = data[x, y, i] passage = @passages[tile_id] @@ -299,7 +299,7 @@ class Game_Map return false end - def terrain_tag(x,y,countBridge = false) + def terrain_tag(x, y, countBridge = false) if valid?(x, y) for i in [2, 1, 0] tile_id = data[x, y, i] @@ -313,7 +313,7 @@ class Game_Map end # Unused. - def check_event(x,y) + def check_event(x, y) for event in self.events.values return event.id if event.at_coordinate?(x, y) end @@ -323,7 +323,7 @@ class Game_Map return if @display_x == value @display_x = value if metadata&.snap_edges - max_x = (self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X + max_x = (self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X @display_x = [0, [@display_x, max_x].min].max end $map_factory.setMapsInRange if $map_factory @@ -333,7 +333,7 @@ class Game_Map return if @display_y == value @display_y = value if metadata&.snap_edges - max_y = (self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y + max_y = (self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y @display_y = [0, [@display_y, max_y].min].max end $map_factory.setMapsInRange if $map_factory @@ -357,7 +357,7 @@ class Game_Map def start_scroll(direction, distance, speed) @scroll_direction = direction - if direction==2 || direction==8 # down or up + if direction == 2 || direction == 8 # down or up @scroll_rest = distance * REAL_RES_Y else @scroll_rest = distance * REAL_RES_X @@ -369,7 +369,7 @@ class Game_Map return @scroll_rest > 0 end - def start_fog_tone_change(tone,duration) + def start_fog_tone_change(tone, duration) @fog_tone_target = tone.clone @fog_tone_duration = duration if @fog_tone_duration == 0 @@ -377,10 +377,10 @@ class Game_Map end end - def start_fog_opacity_change(opacity,duration) - @fog_opacity_target = opacity*1.0 + def start_fog_opacity_change(opacity, duration) + @fog_opacity_target = opacity * 1.0 @fog_opacity_duration = duration - if @fog_opacity_duration==0 + if @fog_opacity_duration == 0 @fog_opacity = @fog_opacity_target end end @@ -412,9 +412,9 @@ class Game_Map $map_factory.setCurrentMap end # If scrolling - if @scroll_rest>0 - distance = (1<<@scroll_speed)*40.0/Graphics.frame_rate - distance = @scroll_rest if distance>@scroll_rest + if @scroll_rest > 0 + distance = (1 << @scroll_speed) * 40.0 / Graphics.frame_rate + distance = @scroll_rest if distance > @scroll_rest case @scroll_direction when 2 then scroll_down(distance) when 4 then scroll_left(distance) @@ -432,9 +432,9 @@ class Game_Map common_event.update end # Update fog - @fog_ox -= @fog_sx/8.0 - @fog_oy -= @fog_sy/8.0 - if @fog_tone_duration>=1 + @fog_ox -= @fog_sx / 8.0 + @fog_oy -= @fog_sy / 8.0 + if @fog_tone_duration >= 1 d = @fog_tone_duration target = @fog_tone_target @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d @@ -454,8 +454,8 @@ end #=============================================================================== # #=============================================================================== -def pbScrollMap(direction,distance,speed) - if speed==0 +def pbScrollMap(direction, distance, speed) + if speed == 0 case direction when 2 then $game_map.scroll_down(distance * Game_Map::REAL_RES_Y) when 4 then $game_map.scroll_left(distance * Game_Map::REAL_RES_X) @@ -471,7 +471,7 @@ def pbScrollMap(direction,distance,speed) Input.update break if !$game_map.scrolling? pbUpdateSceneMap - break if $game_map.display_x==oldx && $game_map.display_y==oldy + break if $game_map.display_x == oldx && $game_map.display_y == oldy oldx = $game_map.display_x oldy = $game_map.display_y end diff --git a/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb b/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb index 35478091f..4e386dbea 100644 --- a/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb +++ b/Data/Scripts/004_Game classes/005_Game_Map_Autoscroll.rb @@ -77,22 +77,22 @@ class Interpreter # y : y coordinate to scroll to and center on # speed : (optional) scroll speed (from 1-6, default being 4) #----------------------------------------------------------------------------- - def autoscroll(x,y,speed = SCROLL_SPEED_DEFAULT) + def autoscroll(x, y, speed = SCROLL_SPEED_DEFAULT) if $game_map.scrolling? return false - elsif !$game_map.valid?(x,y) + elsif !$game_map.valid?(x, y) print 'Map Autoscroll: given x,y is invalid' return command_skip elsif !(1..6).include?(speed) print 'Map Autoscroll: invalid speed (1-6 only)' return command_skip end - center_x = (Graphics.width/2 - Game_Map::TILE_WIDTH/2) * 4 # X coordinate in the center of the screen - center_y = (Graphics.height/2 - Game_Map::TILE_HEIGHT/2) * 4 # Y coordinate in the center of the screen - max_x = ($game_map.width - Graphics.width*1.0/Game_Map::TILE_WIDTH) * 4 * Game_Map::TILE_WIDTH - max_y = ($game_map.height - Graphics.height*1.0/Game_Map::TILE_HEIGHT) * 4 * Game_Map::TILE_HEIGHT - count_x = ($game_map.display_x - [0,[x*Game_Map::REAL_RES_X-center_x,max_x].min].max)/Game_Map::REAL_RES_X - count_y = ($game_map.display_y - [0,[y*Game_Map::REAL_RES_Y-center_y,max_y].min].max)/Game_Map::REAL_RES_Y + center_x = (Graphics.width / 2 - Game_Map::TILE_WIDTH / 2) * 4 # X coordinate in the center of the screen + center_y = (Graphics.height / 2 - Game_Map::TILE_HEIGHT / 2) * 4 # Y coordinate in the center of the screen + max_x = ($game_map.width - Graphics.width * 1.0 / Game_Map::TILE_WIDTH) * 4 * Game_Map::TILE_WIDTH + max_y = ($game_map.height - Graphics.height * 1.0 / Game_Map::TILE_HEIGHT) * 4 * Game_Map::TILE_HEIGHT + count_x = ($game_map.display_x - [0, [x * Game_Map::REAL_RES_X - center_x, max_x].min].max) / Game_Map::REAL_RES_X + count_y = ($game_map.display_y - [0, [y * Game_Map::REAL_RES_Y - center_y, max_y].min].max) / Game_Map::REAL_RES_Y if !@diag @diag = true dir = nil @@ -109,7 +109,7 @@ class Interpreter dir = 3 end end - count = [count_x.abs,count_y.abs].min + count = [count_x.abs, count_y.abs].min else @diag = false dir = nil @@ -139,7 +139,7 @@ class Interpreter # speed : (optional) scroll speed (from 1-6, default being 4) #----------------------------------------------------------------------------- def autoscroll_player(speed = SCROLL_SPEED_DEFAULT) - autoscroll($game_player.x,$game_player.y,speed) + autoscroll($game_player.x, $game_player.y, speed) end end @@ -148,20 +148,20 @@ end class Game_Map def scroll_downright(distance) @display_x = [@display_x + distance, - (self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X].min + (self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min @display_y = [@display_y + distance, - (self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y].min + (self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min end def scroll_downleft(distance) @display_x = [@display_x - distance, 0].max @display_y = [@display_y + distance, - (self.height - Graphics.height*1.0/TILE_HEIGHT) * REAL_RES_Y].min + (self.height - Graphics.height * 1.0 / TILE_HEIGHT) * REAL_RES_Y].min end def scroll_upright(distance) @display_x = [@display_x + distance, - (self.width - Graphics.width*1.0/TILE_WIDTH) * REAL_RES_X].min + (self.width - Graphics.width * 1.0 / TILE_WIDTH) * REAL_RES_X].min @display_y = [@display_y - distance, 0].max end @@ -174,8 +174,8 @@ class Game_Map # If scrolling if @scroll_rest > 0 # Change from scroll speed to distance in map coordinates - distance = (1<<@scroll_speed)*40/Graphics.frame_rate - distance = @scroll_rest if distance>@scroll_rest + distance = (1 << @scroll_speed) * 40 / Graphics.frame_rate + distance = @scroll_rest if distance > @scroll_rest # Execute scrolling case @scroll_direction when 1 then scroll_downleft(distance) diff --git a/Data/Scripts/004_Game classes/006_Game_MapFactory.rb b/Data/Scripts/004_Game classes/006_Game_MapFactory.rb index 20ffa4368..7f5f35d3b 100644 --- a/Data/Scripts/004_Game classes/006_Game_MapFactory.rb +++ b/Data/Scripts/004_Game classes/006_Game_MapFactory.rb @@ -19,7 +19,7 @@ class PokemonMapFactory @maps[0] = Game_Map.new @mapIndex = 0 oldID = ($game_map) ? $game_map.map_id : 0 - setMapChanging(id,@maps[0]) if oldID!=0 && oldID!=@maps[0].map_id + setMapChanging(id, @maps[0]) if oldID != 0 && oldID != @maps[0].map_id $game_map = @maps[0] @maps[0].setup(id) setMapsInRange @@ -27,9 +27,9 @@ class PokemonMapFactory end def map - @mapIndex = 0 if !@mapIndex || @mapIndex<0 + @mapIndex = 0 if !@mapIndex || @mapIndex < 0 return @maps[@mapIndex] if @maps[@mapIndex] - raise "No maps in save file... (mapIndex=#{@mapIndex})" if @maps.length==0 + raise "No maps in save file... (mapIndex=#{@mapIndex})" if @maps.length == 0 if @maps[0] echoln "Using next map, may be incorrect (mapIndex=#{@mapIndex}, length=#{@maps.length})" return @maps[0] @@ -39,21 +39,21 @@ class PokemonMapFactory def hasMap?(id) for map in @maps - return true if map.map_id==id + return true if map.map_id == id end return false end def getMapIndex(id) for i in 0...@maps.length - return i if @maps[i].map_id==id + return i if @maps[i].map_id == id end return -1 end - def getMap(id,add = true) + def getMap(id, add = true) for map in @maps - return map if map.map_id==id + return map if map.map_id == id end map = Game_Map.new map.setup(id) @@ -62,10 +62,10 @@ class PokemonMapFactory end def getMapNoAdd(id) - return getMap(id,false) + return getMap(id, false) end - def getNewMap(playerX,playerY) + def getNewMap(playerX, playerY) id = $game_map.map_id conns = MapFactoryHelper.getMapConnections if conns[id] @@ -96,16 +96,16 @@ class PokemonMapFactory # their transfer to that map. def setCurrentMap return if $game_player.moving? - return if $game_map.valid?($game_player.x,$game_player.y) - newmap = getNewMap($game_player.x,$game_player.y) + return if $game_map.valid?($game_player.x, $game_player.y) + newmap = getNewMap($game_player.x, $game_player.y) return if !newmap - oldmap=$game_map.map_id - if oldmap!=0 && oldmap!=newmap[0].map_id - setMapChanging(newmap[0].map_id,newmap[0]) + oldmap = $game_map.map_id + if oldmap != 0 && oldmap != newmap[0].map_id + setMapChanging(newmap[0].map_id, newmap[0]) end $game_map = newmap[0] @mapIndex = getMapIndex($game_map.map_id) - $game_player.moveto(newmap[1],newmap[2]) + $game_player.moveto(newmap[1], newmap[2]) $game_map.update pbAutoplayOnTransition $game_map.refresh @@ -144,17 +144,17 @@ class PokemonMapFactory @fixup = false end - def setMapChanging(newID,newMap) - Events.onMapChanging.trigger(self,newID,newMap) + def setMapChanging(newID, newMap) + Events.onMapChanging.trigger(self, newID, newMap) end def setMapChanged(prevMap) - Events.onMapChange.trigger(self,prevMap) + Events.onMapChange.trigger(self, prevMap) @mapChanged = true end def setSceneStarted(scene) - Events.onMapSceneChange.trigger(self,scene,@mapChanged) + Events.onMapSceneChange.trigger(self, scene, @mapChanged) @mapChanged = false end @@ -194,42 +194,42 @@ class PokemonMapFactory end # Only used by dependent events - def isPassableStrict?(mapID,x,y,thisEvent = nil) + def isPassableStrict?(mapID, x, y, thisEvent = nil) thisEvent = $game_player if !thisEvent map = getMapNoAdd(mapID) return false if !map - return false if !map.valid?(x,y) + return false if !map.valid?(x, y) return true if thisEvent.through - if thisEvent==$game_player + if thisEvent == $game_player if !($DEBUG && Input.press?(Input::CTRL)) - return false if !map.passableStrict?(x,y,0,thisEvent) + return false if !map.passableStrict?(x, y, 0, thisEvent) end else - return false if !map.passableStrict?(x,y,0,thisEvent) + return false if !map.passableStrict?(x, y, 0, thisEvent) end for event in map.events.values next if event == thisEvent || !event.at_coordinate?(x, y) - return false if !event.through && event.character_name!="" + return false if !event.through && event.character_name != "" end return true end - def getTerrainTag(mapid,x,y,countBridge = false) + def getTerrainTag(mapid, x, y, countBridge = false) map = getMapNoAdd(mapid) - return map.terrain_tag(x,y,countBridge) + return map.terrain_tag(x, y, countBridge) end # NOTE: Assumes the event is 1x1 tile in size. Only returns one terrain tag. - def getFacingTerrainTag(dir = nil,event = nil) - tile = getFacingTile(dir,event) + def getFacingTerrainTag(dir = nil, event = nil) + tile = getFacingTile(dir, event) return GameData::TerrainTag.get(:None) if !tile - return getTerrainTag(tile[0],tile[1],tile[2]) + return getTerrainTag(tile[0], tile[1], tile[2]) end - def getTerrainTagFromCoords(mapid,x,y,countBridge = false) - tile = getRealTilePos(mapid,x,y) + def getTerrainTagFromCoords(mapid, x, y, countBridge = false) + tile = getRealTilePos(mapid, x, y) return GameData::TerrainTag.get(:None) if !tile - return getTerrainTag(tile[0],tile[1],tile[2]) + return getTerrainTag(tile[0], tile[1], tile[2]) end def areConnected?(mapID1, mapID2) @@ -268,38 +268,38 @@ class PokemonMapFactory # Gets the distance from this event to another event. Example: If this event's # coordinates are (2,5) and the other event's coordinates are (5,1), returns # the array (3,-4), because (5-2=3) and (1-5=-4). - def getThisAndOtherEventRelativePos(thisEvent,otherEvent) - return [0,0] if !thisEvent || !otherEvent + def getThisAndOtherEventRelativePos(thisEvent, otherEvent) + return [0, 0] if !thisEvent || !otherEvent return getRelativePos( - thisEvent.map.map_id,thisEvent.x,thisEvent.y, - otherEvent.map.map_id,otherEvent.x,otherEvent.y) + thisEvent.map.map_id, thisEvent.x, thisEvent.y, + otherEvent.map.map_id, otherEvent.x, otherEvent.y) end - def getThisAndOtherPosRelativePos(thisEvent,otherMapID,otherX,otherY) - return [0,0] if !thisEvent + def getThisAndOtherPosRelativePos(thisEvent, otherMapID, otherX, otherY) + return [0, 0] if !thisEvent return getRelativePos( - thisEvent.map.map_id,thisEvent.x,thisEvent.y,otherMapID,otherX,otherY) + thisEvent.map.map_id, thisEvent.x, thisEvent.y, otherMapID, otherX, otherY) end # Unused - def getOffsetEventPos(event,xOffset,yOffset) + def getOffsetEventPos(event, xOffset, yOffset) event = $game_player if !event return nil if !event - return getRealTilePos(event.map.map_id,event.x+xOffset,event.y+yOffset) + return getRealTilePos(event.map.map_id, event.x + xOffset, event.y + yOffset) end # NOTE: Assumes the event is 1x1 tile in size. Only returns one tile. - def getFacingTile(direction = nil,event = nil,steps = 1) - event = $game_player if event==nil - return [0,0,0] if !event + def getFacingTile(direction = nil, event = nil, steps = 1) + event = $game_player if event == nil + return [0, 0, 0] if !event x = event.x y = event.y id = event.map.map_id - direction = event.direction if direction==nil - return getFacingTileFromPos(id,x,y,direction,steps) + direction = event.direction if direction == nil + return getFacingTileFromPos(id, x, y, direction, steps) end - def getFacingTileFromPos(mapID,x,y,direction = 0,steps = 1) + def getFacingTileFromPos(mapID, x, y, direction = 0, steps = 1) id = mapID case direction when 1 @@ -323,9 +323,9 @@ class PokemonMapFactory x += steps y -= steps else - return [id,x,y] + return [id, x, y] end - return getRealTilePos(mapID,x,y) + return getRealTilePos(mapID, x, y) end def getRealTilePos(mapID, x, y) @@ -354,7 +354,7 @@ class PokemonMapFactory return nil end - def getFacingCoords(x,y,direction = 0,steps = 1) + def getFacingCoords(x, y, direction = 0, steps = 1) case direction when 1 x -= steps @@ -377,7 +377,7 @@ class PokemonMapFactory x += steps y -= steps end - return [x,y] + return [x, y] end def updateMaps(scene) @@ -464,9 +464,9 @@ module MapFactoryHelper if !@@MapDims[id] begin map = load_data(sprintf("Data/Map%03d.rxdata", id)) - @@MapDims[id] = [map.width,map.height] + @@MapDims[id] = [map.width, map.height] rescue - @@MapDims[id] = [0,0] + @@MapDims[id] = [0, 0] end end # Return map in cache @@ -475,11 +475,11 @@ module MapFactoryHelper # Returns the X or Y coordinate of an edge on the map with id. # Considers the special strings "N","W","E","S" - def self.getMapEdge(id,edge) - return 0 if edge=="N" || edge=="W" + def self.getMapEdge(id, edge) + return 0 if edge == "N" || edge == "W" dims = getMapDims(id) # Get dimensions - return dims[0] if edge=="E" - return dims[1] if edge=="S" + return dims[0] if edge == "E" + return dims[1] if edge == "S" return dims[0] # real dimension (use width) end @@ -494,7 +494,7 @@ module MapFactoryHelper return true end - def self.mapInRangeById?(id,dispx,dispy) + def self.mapInRangeById?(id, dispx, dispy) range = 6 # Number of tiles dims = MapFactoryHelper.getMapDims(id) return false if dispx >= (dims[0] + range) * Game_Map::REAL_RES_X diff --git a/Data/Scripts/004_Game classes/007_Game_Character.rb b/Data/Scripts/004_Game classes/007_Game_Character.rb index 4dc20b4de..936c87673 100644 --- a/Data/Scripts/004_Game classes/007_Game_Character.rb +++ b/Data/Scripts/004_Game classes/007_Game_Character.rb @@ -96,7 +96,7 @@ class Game_Character end def move_speed=(val) - return if val==@move_speed + return if val == @move_speed @move_speed = val # @move_speed_real is the number of quarter-pixels to move each frame. There # are 128 quarter-pixels per tile. By default, it is calculated from @@ -107,7 +107,7 @@ class Game_Character # 4 => 25.6 # 5 frames per tile - running speed (2x walking speed) # 5 => 32 # 4 frames per tile - cycling speed (1.25x running speed) # 6 => 64 # 2 frames per tile - self.move_speed_real = (val == 6) ? 64 : (val == 5) ? 32 : (2 ** (val + 1)) * 0.8 + self.move_speed_real = (val == 6) ? 64 : (val == 5) ? 32 : (2**(val + 1)) * 0.8 end def move_speed_real @@ -120,7 +120,7 @@ class Game_Character end def jump_speed_real - self.jump_speed_real = (2 ** (3 + 1)) * 0.8 if !@jump_speed_real # 3 is walking speed + self.jump_speed_real = (2**(3 + 1)) * 0.8 if !@jump_speed_real # 3 is walking speed return @jump_speed_real end @@ -129,7 +129,7 @@ class Game_Character end def move_frequency=(val) - return if val==@move_frequency + return if val == @move_frequency @move_frequency = val # @move_frequency_real is the number of frames to wait between each action # in a move route (not forced). Specifically, this is the number of frames @@ -381,8 +381,8 @@ class Game_Character def triggerLeaveTile if @oldX && @oldY && @oldMap && - (@oldX!=self.x || @oldY!=self.y || @oldMap!=self.map.map_id) - Events.onLeaveTile.trigger(self,self,@oldMap,@oldX,@oldY) + (@oldX != self.x || @oldY != self.y || @oldMap != self.map.map_id) + Events.onLeaveTile.trigger(self, self, @oldMap, @oldX, @oldY) end @oldX = self.x @oldY = self.y @@ -629,23 +629,23 @@ class Game_Character end end - def move_random_range(xrange = -1,yrange = -1) + def move_random_range(xrange = -1, yrange = -1) dirs = [] # 0=down, 1=left, 2=right, 3=up - if xrange<0 + if xrange < 0 dirs.push(1) dirs.push(2) - elsif xrange>0 + elsif xrange > 0 dirs.push(1) if @x > @original_x - xrange dirs.push(2) if @x < @original_x + xrange end - if yrange<0 + if yrange < 0 dirs.push(0) dirs.push(3) - elsif yrange>0 + elsif yrange > 0 dirs.push(0) if @y < @original_y + yrange dirs.push(3) if @y > @original_y - yrange end - return if dirs.length==0 + return if dirs.length == 0 case dirs[rand(dirs.length)] when 0 then move_down(false) when 1 then move_left(false) @@ -655,11 +655,11 @@ class Game_Character end def move_random_UD(range = -1) - move_random_range(0,range) + move_random_range(0, range) end def move_random_LR(range = -1) - move_random_range(range,0) + move_random_range(range, 0) end def move_toward_player @@ -755,19 +755,19 @@ class Game_Character def jumpForward case self.direction - when 2 then jump(0,1) # down - when 4 then jump(-1,0) # left - when 6 then jump(1,0) # right - when 8 then jump(0,-1) # up + when 2 then jump(0, 1) # down + when 4 then jump(-1, 0) # left + when 6 then jump(1, 0) # right + when 8 then jump(0, -1) # up end end def jumpBackward case self.direction - when 2 then jump(0,-1) # down - when 4 then jump(1,0) # left - when 6 then jump(-1,0) # right - when 8 then jump(0,1) # up + when 2 then jump(0, -1) # down + when 4 then jump(1, 0) # left + when 6 then jump(-1, 0) # right + when 8 then jump(0, 1) # up end end diff --git a/Data/Scripts/004_Game classes/008_Game_Event.rb b/Data/Scripts/004_Game classes/008_Game_Event.rb index e4b64dafe..2803bc849 100644 --- a/Data/Scripts/004_Game classes/008_Game_Event.rb +++ b/Data/Scripts/004_Game classes/008_Game_Event.rb @@ -54,7 +54,7 @@ class Game_Event < Game_Character end def tsOn?(c) - return @tempSwitches && @tempSwitches[c]==true + return @tempSwitches && @tempSwitches[c] == true end def tsOff?(c) @@ -62,17 +62,17 @@ class Game_Event < Game_Character end def setTempSwitchOn(c) - @tempSwitches[c]=true + @tempSwitches[c] = true refresh end def setTempSwitchOff(c) - @tempSwitches[c]=false + @tempSwitches[c] = false refresh end def isOff?(c) - return !$game_self_switches[[@map_id,@event.id,c]] + return !$game_self_switches[[@map_id, @event.id, c]] end def switchIsOn?(id) @@ -87,31 +87,31 @@ class Game_Event < Game_Character def variable return nil if !$PokemonGlobal.eventvars - return $PokemonGlobal.eventvars[[@map_id,@event.id]] + return $PokemonGlobal.eventvars[[@map_id, @event.id]] end def setVariable(variable) - $PokemonGlobal.eventvars[[@map_id,@event.id]]=variable + $PokemonGlobal.eventvars[[@map_id, @event.id]] = variable end def varAsInt return 0 if !$PokemonGlobal.eventvars - return $PokemonGlobal.eventvars[[@map_id,@event.id]].to_i + return $PokemonGlobal.eventvars[[@map_id, @event.id]].to_i end def expired?(secs = 86400) - ontime=self.variable - time=pbGetTimeNow - return ontime && (time.to_i>ontime+secs) + ontime = self.variable + time = pbGetTimeNow + return ontime && (time.to_i > ontime + secs) end def expiredDays?(days = 1) - ontime=self.variable.to_i + ontime = self.variable.to_i return false if !ontime - now=pbGetTimeNow - elapsed=(now.to_i-ontime)/86400 - elapsed+=1 if (now.to_i-ontime)%86400>(now.hour*3600+now.min*60+now.sec) - return elapsed>=days + now = pbGetTimeNow + elapsed = (now.to_i - ontime) / 86400 + elapsed += 1 if (now.to_i - ontime) % 86400 > (now.hour * 3600 + now.min * 60 + now.sec) + return elapsed >= days end def cooledDown?(seconds) @@ -143,7 +143,7 @@ class Game_Event < Game_Character return if $game_system.map_interpreter.running? || @starting if @event.name[/trainer\((\d+)\)/i] distance = $~[1].to_i - if @trigger==2 && pbEventCanReachPlayer?(self,$game_player,distance) + if @trigger == 2 && pbEventCanReachPlayer?(self, $game_player, distance) start if !jumping? && !over_trigger? end end @@ -248,8 +248,8 @@ class Game_Event < Game_Character return true if @move_route_forcing return true if @event.name[/update/i] range = 2 # Number of tiles - return false if self.screen_x - @sprite_size[0]/2 > Graphics.width + range * Game_Map::TILE_WIDTH - return false if self.screen_x + @sprite_size[0]/2 < -range * Game_Map::TILE_WIDTH + return false if self.screen_x - @sprite_size[0] / 2 > Graphics.width + range * Game_Map::TILE_WIDTH + return false if self.screen_x + @sprite_size[0] / 2 < -range * Game_Map::TILE_WIDTH return false if self.screen_y_ground - @sprite_size[1] > Graphics.height + range * Game_Map::TILE_HEIGHT return false if self.screen_y_ground < -range * Game_Map::TILE_HEIGHT return true diff --git a/Data/Scripts/004_Game classes/009_Game_Player.rb b/Data/Scripts/004_Game classes/009_Game_Player.rb index f8f96897c..ddb6bbdff 100644 --- a/Data/Scripts/004_Game classes/009_Game_Player.rb +++ b/Data/Scripts/004_Game classes/009_Game_Player.rb @@ -17,9 +17,9 @@ class Game_Player < Game_Character def initialize(*arg) super(*arg) - @lastdir=0 - @lastdirframe=0 - @bump_se=0 + @lastdir = 0 + @lastdirframe = 0 + @bump_se = 0 end def map @@ -103,9 +103,9 @@ class Game_Player < Game_Character end def bump_into_object - return if @bump_se && @bump_se>0 + return if @bump_se && @bump_se > 0 pbSEPlay("Player bump") - @bump_se = Graphics.frame_rate/4 + @bump_se = Graphics.frame_rate / 4 end def move_generic(dir, turn_enabled = true) @@ -179,7 +179,7 @@ class Game_Player < Game_Character triggerLeaveTile end - def pbTriggeredTrainerEvents(triggers,checkIfRunning = true) + def pbTriggeredTrainerEvents(triggers, checkIfRunning = true) result = [] # If event is running return result if checkIfRunning && $game_system.map_interpreter.running? @@ -188,7 +188,7 @@ class Game_Player < Game_Character next if !event.name[/trainer\((\d+)\)/i] distance = $~[1].to_i # If event coordinates and triggers are consistent - if pbEventCanReachPlayer?(event,self,distance) && triggers.include?(event.trigger) + if pbEventCanReachPlayer?(event, self, distance) && triggers.include?(event.trigger) # If starting determinant is front event (other than jumping) result.push(event) if !event.jumping? && !event.over_trigger? end @@ -196,7 +196,7 @@ class Game_Player < Game_Character return result end - def pbTriggeredCounterEvents(triggers,checkIfRunning = true) + def pbTriggeredCounterEvents(triggers, checkIfRunning = true) result = [] # If event is running return result if checkIfRunning && $game_system.map_interpreter.running? @@ -205,7 +205,7 @@ class Game_Player < Game_Character next if !event.name[/counter\((\d+)\)/i] distance = $~[1].to_i # If event coordinates and triggers are consistent - if pbEventFacesPlayer?(event,self,distance) && triggers.include?(event.trigger) + if pbEventFacesPlayer?(event, self, distance) && triggers.include?(event.trigger) # If starting determinant is front event (other than jumping) result.push(event) if !event.jumping? && !event.over_trigger? end @@ -218,7 +218,7 @@ class Game_Player < Game_Character def pbCheckEventTriggerFromDistance(triggers) ret = pbTriggeredTrainerEvents(triggers) ret.concat(pbTriggeredCounterEvents(triggers)) - return false if ret.length==0 + return false if ret.length == 0 for event in ret event.start end @@ -401,10 +401,10 @@ class Game_Player < Game_Character next if !event.at_coordinate?(@x + x_offset, @y + y_offset) if event.name[/trainer\((\d+)\)/i] distance = $~[1].to_i - next if !pbEventCanReachPlayer?(event,self,distance) + next if !pbEventCanReachPlayer?(event, self, distance) elsif event.name[/counter\((\d+)\)/i] distance = $~[1].to_i - next if !pbEventFacesPlayer?(event,self,distance) + next if !pbEventFacesPlayer?(event, self, distance) end # If starting determinant is front event (other than jumping) next if event.jumping? || event.over_trigger? @@ -429,12 +429,12 @@ class Game_Player < Game_Character end $game_temp.followers.update # Count down the time between allowed bump sounds - @bump_se -= 1 if @bump_se && @bump_se>0 + @bump_se -= 1 if @bump_se && @bump_se > 0 # Finish up dismounting from surfing if $game_temp.ending_surf && !moving? pbCancelVehicles $game_temp.surf_base_coords = nil - $game_temp.ending_surf = false + $game_temp.ending_surf = false end update_event_triggering end @@ -538,7 +538,7 @@ class Game_Player < Game_Character $game_temp.followers.turn_followers result = pbCheckEventTriggerFromDistance([2]) # Event determinant is via touch of same position event - result |= check_event_trigger_here([1,2]) + result |= check_event_trigger_here([1, 2]) # No events triggered, try other event triggers upon finishing a step pbOnStepTaken(result) end @@ -546,7 +546,7 @@ class Game_Player < Game_Character if Input.trigger?(Input::USE) && !$game_temp.in_mini_update # Same position and front event determinant check_event_trigger_here([0]) - check_event_trigger_there([0,2]) + check_event_trigger_there([0, 2]) end end end @@ -566,8 +566,8 @@ def pbGetPlayerCharset(charset, trainer = nil, force = false) end $game_player.charsetData = [trainer.character_ID, charset, outfit] if $game_player ret = charset - if pbResolveBitmap("Graphics/Characters/"+ret+"_"+outfit.to_s) - ret = ret+"_"+outfit.to_s + if pbResolveBitmap("Graphics/Characters/" + ret + "_" + outfit.to_s) + ret = ret + "_" + outfit.to_s end return ret end diff --git a/Data/Scripts/004_Game classes/011_Game_Follower.rb b/Data/Scripts/004_Game classes/011_Game_Follower.rb index 4b0a51876..95131e1e9 100644 --- a/Data/Scripts/004_Game classes/011_Game_Follower.rb +++ b/Data/Scripts/004_Game classes/011_Game_Follower.rb @@ -161,7 +161,7 @@ class Game_Follower < Game_Event def location_passable?(x, y, direction) this_map = self.map - return false if !this_map || !this_map.valid?(x,y) + return false if !this_map || !this_map.valid?(x, y) return true if @through passed_tile_checks = false bit = (1 << (direction / 2 - 1)) & 0x0f diff --git a/Data/Scripts/005_Sprites/001_Sprite_Picture.rb b/Data/Scripts/005_Sprites/001_Sprite_Picture.rb index 47ed370eb..75614d84c 100644 --- a/Data/Scripts/005_Sprites/001_Sprite_Picture.rb +++ b/Data/Scripts/005_Sprites/001_Sprite_Picture.rb @@ -19,8 +19,8 @@ class Sprite_Picture # If file name is not empty if @picture_name != "" # Get picture graphic - @sprite=IconSprite.new(0,0,@viewport) if !@sprite - @sprite.setBitmap("Graphics/Pictures/"+@picture_name) + @sprite = IconSprite.new(0, 0, @viewport) if !@sprite + @sprite.setBitmap("Graphics/Pictures/" + @picture_name) end end # If file name is empty @@ -28,7 +28,7 @@ class Sprite_Picture # Set sprite to invisible if @sprite @sprite.dispose if @sprite - @sprite=nil + @sprite = nil end return end diff --git a/Data/Scripts/005_Sprites/002_Sprite_Timer.rb b/Data/Scripts/005_Sprites/002_Sprite_Timer.rb index c5d82742c..901dec4d0 100644 --- a/Data/Scripts/005_Sprites/002_Sprite_Timer.rb +++ b/Data/Scripts/005_Sprites/002_Sprite_Timer.rb @@ -1,15 +1,15 @@ class Sprite_Timer def initialize(viewport = nil) - @viewport=viewport - @timer=nil - @total_sec=nil - @disposed=false + @viewport = viewport + @timer = nil + @total_sec = nil + @disposed = false end def dispose @timer.dispose if @timer - @timer=nil - @disposed=true + @timer = nil + @disposed = true end def disposed? @@ -21,14 +21,14 @@ class Sprite_Timer if $game_system.timer_working @timer.visible = true if @timer if !@timer - @timer=Window_AdvancedTextPokemon.newWithSize("",Graphics.width-120,0,120,64) - @timer.width=@timer.borderX+96 - @timer.x=Graphics.width-@timer.width - @timer.viewport=@viewport - @timer.z=99998 + @timer = Window_AdvancedTextPokemon.newWithSize("", Graphics.width - 120, 0, 120, 64) + @timer.width = @timer.borderX + 96 + @timer.x = Graphics.width - @timer.width + @timer.viewport = @viewport + @timer.z = 99998 end - curtime=$game_system.timer / Graphics.frame_rate - curtime=0 if curtime<0 + curtime = $game_system.timer / Graphics.frame_rate + curtime = 0 if curtime < 0 if curtime != @total_sec # Calculate total number of seconds @total_sec = curtime @@ -39,7 +39,7 @@ class Sprite_Timer end @timer.update else - @timer.visible=false if @timer + @timer.visible = false if @timer end end end diff --git a/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb b/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb index d30f0803e..015fc16e4 100644 --- a/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb +++ b/Data/Scripts/005_Sprites/004_Sprite_Reflection.rb @@ -2,13 +2,13 @@ class Sprite_Reflection attr_reader :visible attr_accessor :event - def initialize(sprite,event,viewport = nil) + def initialize(sprite, event, viewport = nil) @rsprite = sprite @sprite = nil @event = event @height = 0 @fixedheight = false - if @event && @event!=$game_player + if @event && @event != $game_player if @event.name[/reflection\((\d+)\)/i] @height = $~[1].to_i || 0 @fixedheight = true @@ -50,35 +50,35 @@ class Sprite_Reflection # Just-in-time creation of sprite @sprite = Sprite.new(@viewport) if !@sprite if @sprite - x = @rsprite.x-@rsprite.ox - y = @rsprite.y-@rsprite.oy + x = @rsprite.x - @rsprite.ox + y = @rsprite.y - @rsprite.oy y -= 32 if @rsprite.character.character_name[/offset/i] @height = $PokemonGlobal.bridge if !@fixedheight - y += @height*16 + y += @height * 16 width = @rsprite.src_rect.width height = @rsprite.src_rect.height - @sprite.x = x+width/2 - @sprite.y = y+height+height/2 - @sprite.ox = width/2 - @sprite.oy = height/2-2 # Hard-coded 2 pixel shift up - @sprite.oy -= @rsprite.character.bob_height*2 + @sprite.x = x + width / 2 + @sprite.y = y + height + height / 2 + @sprite.ox = width / 2 + @sprite.oy = height / 2 - 2 # Hard-coded 2 pixel shift up + @sprite.oy -= @rsprite.character.bob_height * 2 @sprite.z = -50 # Still water is -100, map is 0 and above @sprite.z += 1 if @event == $game_player @sprite.zoom_x = @rsprite.zoom_x @sprite.zoom_y = @rsprite.zoom_y - frame = (Graphics.frame_count%40)/10 + frame = (Graphics.frame_count % 40) / 10 @sprite.zoom_x *= [1.0, 0.95, 1.0, 1.05][frame] @sprite.angle = 180.0 @sprite.mirror = true @sprite.bitmap = @rsprite.bitmap @sprite.tone = @rsprite.tone - if @height>0 - @sprite.color = Color.new(48,96,160,255) # Dark still water + if @height > 0 + @sprite.color = Color.new(48, 96, 160, 255) # Dark still water @sprite.opacity = @rsprite.opacity @sprite.visible = !Settings::TIME_SHADING # Can't time-tone a colored sprite else - @sprite.color = Color.new(224,224,224,96) - @sprite.opacity = @rsprite.opacity*3/4 + @sprite.color = Color.new(224, 224, 224, 96) + @sprite.opacity = @rsprite.opacity * 3 / 4 @sprite.visible = true end @sprite.src_rect = @rsprite.src_rect diff --git a/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb b/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb index ffe8727fa..caa6f16dd 100644 --- a/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb +++ b/Data/Scripts/005_Sprites/005_Sprite_SurfBase.rb @@ -2,7 +2,7 @@ class Sprite_SurfBase attr_reader :visible attr_accessor :event - def initialize(sprite,event,viewport = nil) + def initialize(sprite, event, viewport = nil) @rsprite = sprite @sprite = nil @event = event @@ -12,10 +12,10 @@ class Sprite_SurfBase @divebitmap = AnimatedBitmap.new("Graphics/Characters/base_dive") RPG::Cache.retain("Graphics/Characters/base_surf") RPG::Cache.retain("Graphics/Characters/base_dive") - @cws = @surfbitmap.width/4 - @chs = @surfbitmap.height/4 - @cwd = @divebitmap.width/4 - @chd = @divebitmap.height/4 + @cws = @surfbitmap.width / 4 + @chs = @surfbitmap.height / 4 + @cwd = @divebitmap.width / 4 + @chd = @divebitmap.height / 4 update end @@ -59,9 +59,9 @@ class Sprite_SurfBase cw = @cwd ch = @chd end - sx = @event.pattern_surf*cw - sy = ((@event.direction-2)/2)*ch - @sprite.src_rect.set(sx,sy,cw,ch) + sx = @event.pattern_surf * cw + sy = ((@event.direction - 2) / 2) * ch + @sprite.src_rect.set(sx, sy, cw, ch) if $game_temp.surf_base_coords @sprite.x = ($game_temp.surf_base_coords[0] * Game_Map::REAL_RES_X - @event.map.display_x + 3) / 4 + (Game_Map::TILE_WIDTH / 2) @sprite.y = ($game_temp.surf_base_coords[1] * Game_Map::REAL_RES_Y - @event.map.display_y + 3) / 4 + (Game_Map::TILE_HEIGHT / 2) + 16 @@ -69,10 +69,10 @@ class Sprite_SurfBase @sprite.x = @rsprite.x @sprite.y = @rsprite.y end - @sprite.ox = cw/2 - @sprite.oy = ch-16 # Assume base needs offsetting + @sprite.ox = cw / 2 + @sprite.oy = ch - 16 # Assume base needs offsetting @sprite.oy -= @event.bob_height - @sprite.z = @event.screen_z(ch)-1 + @sprite.z = @event.screen_z(ch) - 1 @sprite.zoom_x = @rsprite.zoom_x @sprite.zoom_y = @rsprite.zoom_y @sprite.tone = @rsprite.tone diff --git a/Data/Scripts/005_Sprites/007_Spriteset_Map.rb b/Data/Scripts/005_Sprites/007_Spriteset_Map.rb index 75673ac65..fc2a5c9a7 100644 --- a/Data/Scripts/005_Sprites/007_Spriteset_Map.rb +++ b/Data/Scripts/005_Sprites/007_Spriteset_Map.rb @@ -1,30 +1,30 @@ # Unused class ClippableSprite < Sprite_Character - def initialize(viewport,event,tilemap) + def initialize(viewport, event, tilemap) @tilemap = tilemap - @_src_rect = Rect.new(0,0,0,0) - super(viewport,event) + @_src_rect = Rect.new(0, 0, 0, 0) + super(viewport, event) end def update super @_src_rect = self.src_rect - tmright = @tilemap.map_data.xsize*Game_Map::TILE_WIDTH-@tilemap.ox + tmright = @tilemap.map_data.xsize * Game_Map::TILE_WIDTH - @tilemap.ox echoln "x=#{self.x},ox=#{self.ox},tmright=#{tmright},tmox=#{@tilemap.ox}" - if @tilemap.ox-self.ox<-self.x + if @tilemap.ox - self.ox < -self.x # clipped on left - diff = -self.x-@tilemap.ox+self.ox - self.src_rect = Rect.new(@_src_rect.x+diff,@_src_rect.y, - @_src_rect.width-diff,@_src_rect.height) - echoln "clipped out left: #{diff} #{@tilemap.ox-self.ox} #{self.x}" - elsif tmright-self.ox1) ? params[1] : 0 - @anglemax = (params.size>2) ? params[2] : 0 - @self_opacity = (params.size>4) ? params[4] : 100 - @distancemax = (params.size>3) ? params[3] : 350 + @anglemin = (params.size > 1) ? params[1] : 0 + @anglemax = (params.size > 2) ? params[2] : 0 + @self_opacity = (params.size > 4) ? params[4] : 100 + @distancemax = (params.size > 3) ? params[3] : 350 @character = character update end @@ -47,7 +47,7 @@ class Sprite_Shadow < RPG::Sprite else @chbitmap.dispose if @chbitmap @chbitmap = AnimatedBitmap.new( - 'Graphics/Characters/'+@character.character_name,@character.character_hue) + 'Graphics/Characters/' + @character.character_name, @character.character_hue) @cw = @chbitmap.width / 4 @ch = @chbitmap.height / 4 self.ox = @cw / 2 @@ -75,8 +75,8 @@ class Sprite_Shadow < RPG::Sprite self.src_rect.set(sx, sy, @cw, @ch) end self.x = ScreenPosHelper.pbScreenX(@character) - self.y = ScreenPosHelper.pbScreenY(@character)-5 - self.z = ScreenPosHelper.pbScreenZ(@character,@ch)-1 + self.y = ScreenPosHelper.pbScreenY(@character) - 5 + self.z = ScreenPosHelper.pbScreenZ(@character, @ch) - 1 self.zoom_x = ScreenPosHelper.pbScreenZoomX(@character) self.zoom_y = ScreenPosHelper.pbScreenZoomY(@character) self.blend_type = @character.blend_type @@ -89,10 +89,10 @@ class Sprite_Shadow < RPG::Sprite @deltax = ScreenPosHelper.pbScreenX(@source) - self.x @deltay = ScreenPosHelper.pbScreenY(@source) - self.y self.color = Color.new(0, 0, 0) - @distance = ((@deltax ** 2) + (@deltay ** 2)) + @distance = ((@deltax**2) + (@deltay**2)) self.opacity = @self_opacity * 13000 / ((@distance * 370 / @distancemax) + 6000) self.angle = 57.3 * Math.atan2(@deltax, @deltay) - @angle_trigo = self.angle+90 + @angle_trigo = self.angle + 90 @angle_trigo += 360 if @angle_trigo < 0 if @anglemin != 0 || @anglemax != 0 if (@angle_trigo < @anglemin || @angle_trigo > @anglemax) && @anglemin < @anglemax @@ -132,9 +132,9 @@ class Sprite_Character < RPG::Sprite shadow_initialize(viewport, @character) end - def setShadows(map,shadows) + def setShadows(map, shadows) if character.is_a?(Game_Event) && shadows.length > 0 - params = XPML_read(map,"Shadow",@character,4) + params = XPML_read(map, "Shadow", @character, 4) if params != nil for i in 0...shadows.size @ombrelist.push(Sprite_Shadow.new(viewport, @character, shadows[i])) @@ -158,7 +158,7 @@ class Sprite_Character < RPG::Sprite def update shadow_update - if @ombrelist.length>0 + if @ombrelist.length > 0 for i in 0...@ombrelist.size @ombrelist[i].update end @@ -193,7 +193,7 @@ class Spriteset_Map warn = true if (ev.list != nil && ev.list.length > 0 && ev.list[0].code == 108 && (ev.list[0].parameters == ["s"] || ev.list[0].parameters == ["o"])) - params = XPML_read(map,"Shadow Source", ev, 4) + params = XPML_read(map, "Shadow Source", ev, 4) @shadows.push([ev] + params) if params != nil end if warn == true @@ -228,14 +228,14 @@ end # p XPML_read("third", event_id) -> [3] # p XPML_read("forth", event_id) -> nil #=================================================== -def XPML_read(map,markup,event,max_param_number = 0) +def XPML_read(map, markup, event, max_param_number = 0) parameter_list = nil return nil if !event || event.list == nil for i in 0...event.list.size if event.list[i].code == 108 && event.list[i].parameters[0].downcase == "begin " + markup.downcase parameter_list = [] if parameter_list == nil - for j in i+1...event.list.size + for j in (i + 1)...event.list.size if event.list[j].code == 108 parts = event.list[j].parameters[0].split if parts.size != 1 && parts[0].downcase != "begin" diff --git a/Data/Scripts/005_Sprites/010_ParticleEngine.rb b/Data/Scripts/005_Sprites/010_ParticleEngine.rb index b6e212a34..4e00ddb08 100644 --- a/Data/Scripts/005_Sprites/010_ParticleEngine.rb +++ b/Data/Scripts/005_Sprites/010_ParticleEngine.rb @@ -2,7 +2,7 @@ # Based on version 2 by Near Fantastica, 04.01.06 # In turn based on the Particle Engine designed by PinkMan class Particle_Engine - def initialize(viewport = nil,map = nil) + def initialize(viewport = nil, map = nil) @map = (map) ? map : $game_map @viewport = viewport @effect = [] @@ -54,7 +54,7 @@ class Particle_Engine @effect.delete_at(event.id) end - def realloc_effect(event,particle) + def realloc_effect(event, particle) type = pbEventCommentInput(event, 1, "Particle Engine Type") if type.nil? particle.dispose if particle @@ -68,13 +68,13 @@ class Particle_Engine end if !particle || !particle.is_a?(cls) particle.dispose if particle - particle = cls.new(event,@viewport) + particle = cls.new(event, @viewport) end return particle end def pbParticleEffect(event) - return realloc_effect(event,nil) + return realloc_effect(event, nil) end def update @@ -91,7 +91,7 @@ class Particle_Engine if particle.event.pe_refresh event = particle.event event.pe_refresh = false - particle = realloc_effect(event,particle) + particle = realloc_effect(event, particle) @effect[i] = particle end particle.update if particle @@ -153,21 +153,21 @@ class ParticleSprite def update w = Graphics.width h = Graphics.height - if !@sprite && @x>=@minleft && @y>=@mintop && @x= @minleft && @y >= @mintop && @x < w && @y < h @sprite = Sprite.new(@viewport) - elsif @sprite && (@x<@minleft || @y<@mintop || @x>=w || @y>=h) + elsif @sprite && (@x < @minleft || @y < @mintop || @x >= w || @y >= h) @sprite.dispose @sprite = nil end if @sprite - @sprite.x = @x if @sprite.x!=@x + @sprite.x = @x if @sprite.x != @x @sprite.x -= @ox - @sprite.y = @y if @sprite.y!=@y + @sprite.y = @y if @sprite.y != @y @sprite.y -= @oy - @sprite.z = @z if @sprite.z!=@z - @sprite.opacity = @opacity if @sprite.opacity!=@opacity - @sprite.blend_type = @blend_type if @sprite.blend_type!=@blend_type - @sprite.bitmap = @bitmap if @sprite.bitmap!=@bitmap + @sprite.z = @z if @sprite.z != @z + @sprite.opacity = @opacity if @sprite.opacity != @opacity + @sprite.blend_type = @blend_type if @sprite.blend_type != @blend_type + @sprite.bitmap = @bitmap if @sprite.bitmap != @bitmap end end end @@ -177,7 +177,7 @@ end class ParticleEffect_Event < ParticleEffect attr_accessor :event - def initialize(event,viewport = nil) + def initialize(event, viewport = nil) @event = event @viewport = viewport @particles = [] @@ -185,24 +185,24 @@ class ParticleEffect_Event < ParticleEffect end def setParameters(params) - @randomhue,@leftright,@fade, - @maxparticless,@hue,@slowdown, - @ytop,@ybottom,@xleft,@xright, - @xgravity,@ygravity,@xoffset,@yoffset, - @opacityvar,@originalopacity = params + @randomhue, @leftright, @fade, + @maxparticless, @hue, @slowdown, + @ytop, @ybottom, @xleft, @xright, + @xgravity, @ygravity, @xoffset, @yoffset, + @opacityvar, @originalopacity = params end - def loadBitmap(filename,hue) - key = [filename,hue] + def loadBitmap(filename, hue) + key = [filename, hue] bitmap = @bitmaps[key] if !bitmap || bitmap.disposed? - bitmap = AnimatedBitmap.new("Graphics/Fogs/"+filename,hue).deanimate + bitmap = AnimatedBitmap.new("Graphics/Fogs/" + filename, hue).deanimate @bitmaps[key] = bitmap end return bitmap end - def initParticles(filename,opacity,zOffset = 0,blendtype = 1) + def initParticles(filename, opacity, zOffset = 0, blendtype = 1) @particles = [] @particlex = [] @particley = [] @@ -222,15 +222,15 @@ class ParticleEffect_Event < ParticleEffect @particley[i] = -@yoffset @particles[i] = ParticleSprite.new(@viewport) @particles[i].bitmap = loadBitmap(filename, @hue) if filename - if i==0 && @particles[i].bitmap + if i == 0 && @particles[i].bitmap @bmwidth = @particles[i].bitmap.width @bmheight = @particles[i].bitmap.height end @particles[i].blend_type = blendtype @particles[i].y = @startingy @particles[i].x = @startingx - @particles[i].z = self.z+zOffset - @opacity[i] = rand(opacity/4) + @particles[i].z = self.z + zOffset + @opacity[i] = rand(opacity / 4) @particles[i].opacity = @opacity[i] @particles[i].update end @@ -253,28 +253,28 @@ class ParticleEffect_Event < ParticleEffect newRealY = @event.real_y @startingx = selfX + @xoffset @startingy = selfY + @yoffset - @__offsetx = (@real_x==newRealX) ? 0 : selfX-@screen_x - @__offsety = (@real_y==newRealY) ? 0 : selfY-@screen_y + @__offsetx = (@real_x == newRealX) ? 0 : selfX - @screen_x + @__offsety = (@real_y == newRealY) ? 0 : selfY - @screen_y @screen_x = selfX @screen_y = selfY @real_x = newRealX @real_y = newRealY - if @opacityvar>0 && @viewport - opac = 255.0/@opacityvar - minX = opac*(-@xgravity*1.0 / @slowdown).floor + @startingx - maxX = opac*(@xgravity*1.0 / @slowdown).floor + @startingx - minY = opac*(-@ygravity*1.0 / @slowdown).floor + @startingy + if @opacityvar > 0 && @viewport + opac = 255.0 / @opacityvar + minX = opac * (-@xgravity * 1.0 / @slowdown).floor + @startingx + maxX = opac * (@xgravity * 1.0 / @slowdown).floor + @startingx + minY = opac * (-@ygravity * 1.0 / @slowdown).floor + @startingy maxY = @startingy minX -= @bmwidth minY -= @bmheight maxX += @bmwidth maxY += @bmheight - if maxX<0 || maxY<0 || minX>=Graphics.width || minY>=Graphics.height + if maxX < 0 || maxY < 0 || minX >= Graphics.width || minY >= Graphics.height # echo "skipped" return end end - particleZ = selfZ+@zoffset + particleZ = selfZ + @zoffset for i in 0...@maxparticless @particles[i].z = particleZ if @particles[i].y <= @ytop @@ -333,19 +333,19 @@ class ParticleEffect_Event < ParticleEffect def calcParticlePos(i) @leftright = rand(2) if @leftright == 1 - xo = -@xgravity*1.0 / @slowdown + xo = -@xgravity * 1.0 / @slowdown else - xo = @xgravity*1.0 / @slowdown + xo = @xgravity * 1.0 / @slowdown end - yo = -@ygravity*1.0 / @slowdown + yo = -@ygravity * 1.0 / @slowdown @particlex[i] += xo @particley[i] += yo @particlex[i] -= @__offsetx @particley[i] -= @__offsety @particlex[i] = @particlex[i].floor @particley[i] = @particley[i].floor - @particles[i].x = @particlex[i]+@startingx+@xoffset - @particles[i].y = @particley[i]+@startingy+@yoffset + @particles[i].x = @particlex[i] + @startingx + @xoffset + @particles[i].y = @particley[i] + @startingy + @yoffset end def dispose @@ -363,33 +363,33 @@ end class Particle_Engine::Fire < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,1,20,40,0.5,-64, - Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0]) - initParticles("particle",250) + setParameters([0, 0, 1, 20, 40, 0.5, -64, + Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0]) + initParticles("particle", 250) end end class Particle_Engine::Smoke < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,0,80,20,0.5,-64, - Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80]) - initParticles("smoke",250) + setParameters([0, 0, 0, 80, 20, 0.5, -64, + Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80]) + initParticles("smoke", 250) end end class Particle_Engine::Teleport < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([1,1,1,10,rand(360),1,-64, - Graphics.height,-64,Graphics.width,0,3,-8,-15,20,0]) - initParticles("wideportal",250) + setParameters([1, 1, 1, 10, rand(360), 1, -64, + Graphics.height, -64, Graphics.width, 0, 3, -8, -15, 20, 0]) + initParticles("wideportal", 250) for i in 0...@maxparticless @particles[i].ox = 16 @particles[i].oy = 16 @@ -400,55 +400,55 @@ end class Particle_Engine::Spirit < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([1,0,1,20,rand(360),0.5,-64, - Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0]) - initParticles("particle",250) + setParameters([1, 0, 1, 20, rand(360), 0.5, -64, + Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0]) + initParticles("particle", 250) end end class Particle_Engine::Explosion < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,1,20,0,0.5,-64, - Graphics.height,-64,Graphics.width,0.5,0.10,-5,-13,30,0]) - initParticles("explosion",250) + setParameters([0, 0, 1, 20, 0, 0.5, -64, + Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0]) + initParticles("explosion", 250) end end class Particle_Engine::Aura < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,1,20,0,1,-64, - Graphics.height,-64,Graphics.width,2,2,-5,-13,30,0]) - initParticles("particle",250) + setParameters([0, 0, 1, 20, 0, 1, -64, + Graphics.height, -64, Graphics.width, 2, 2, -5, -13, 30, 0]) + initParticles("particle", 250) end end class Particle_Engine::Soot < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,0,20,0,0.5,-64, - Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80]) - initParticles("smoke",100,0,2) + setParameters([0, 0, 0, 20, 0, 0.5, -64, + Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80]) + initParticles("smoke", 100, 0, 2) end end class Particle_Engine::SootSmoke < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,0,30,0,0.5,-64, - Graphics.height,-64,Graphics.width,0.5,0.10,-5,-15,5,80]) - initParticles("smoke",100,0) + setParameters([0, 0, 0, 30, 0, 0.5, -64, + Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80]) + initParticles("smoke", 100, 0) for i in 0...@maxparticless @particles[i].blend_type = rand(6) < 3 ? 1 : 2 end @@ -458,22 +458,22 @@ end class Particle_Engine::Rocket < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,0,60,0,0.5,-64, - Graphics.height,-64,Graphics.width,0.5,0,-5,-15,5,80]) - initParticles("smoke",100,-1) + setParameters([0, 0, 0, 60, 0, 0.5, -64, + Graphics.height, -64, Graphics.width, 0.5, 0, -5, -15, 5, 80]) + initParticles("smoke", 100, -1) end end class Particle_Engine::FixedTeleport < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([1,0,1,10,rand(360),1, - -Graphics.height,Graphics.height,0,Graphics.width,0,3,-8,-15,20,0]) - initParticles("wideportal",250) + setParameters([1, 0, 1, 10, rand(360), 1, + -Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 20, 0]) + initParticles("wideportal", 250) for i in 0...@maxparticless @particles[i].ox = 16 @particles[i].oy = 16 @@ -485,11 +485,11 @@ end # By Peter O. class Particle_Engine::StarTeleport < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,1,10,0,1, - -Graphics.height,Graphics.height,0,Graphics.width,0,3,-8,-15,10,0]) - initParticles("star",250) + setParameters([0, 0, 1, 10, 0, 1, + -Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 10, 0]) + initParticles("star", 250) for i in 0...@maxparticless @particles[i].ox = 48 @particles[i].oy = 48 @@ -500,59 +500,59 @@ end class Particle_Engine::Smokescreen < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,0,250,0,0.2,-64, - Graphics.height,-64,Graphics.width,0.8,0.8,-5,-15,5,80]) - initParticles(nil,100) + setParameters([0, 0, 0, 250, 0, 0.2, -64, + Graphics.height, -64, Graphics.width, 0.8, 0.8, -5, -15, 5, 80]) + initParticles(nil, 100) for i in 0...@maxparticless rnd = rand(3) - @opacity[i] = (rnd==0) ? 1 : 100 - filename = (rnd==0) ? "explosionsmoke" : "smoke" + @opacity[i] = (rnd == 0) ? 1 : 100 + filename = (rnd == 0) ? "explosionsmoke" : "smoke" @particles[i].bitmap = loadBitmap(filename, @hue) end end def calcParticlePos(i) - if @randomhue==1 - filename = (rand(3)==0) ? "explosionsmoke" : "smoke" + if @randomhue == 1 + filename = (rand(3) == 0) ? "explosionsmoke" : "smoke" @particles[i].bitmap = loadBitmap(filename, @hue) end multiple = 1.7 - xgrav = @xgravity*multiple/@slowdown - xgrav = -xgrav if (rand(2)==1) - ygrav = @ygravity*multiple/@slowdown - ygrav = -ygrav if (rand(2)==1) + xgrav = @xgravity * multiple / @slowdown + xgrav = -xgrav if (rand(2) == 1) + ygrav = @ygravity * multiple / @slowdown + ygrav = -ygrav if (rand(2) == 1) @particlex[i] += xgrav @particley[i] += ygrav @particlex[i] -= @__offsetx @particley[i] -= @__offsety @particlex[i] = @particlex[i].floor @particley[i] = @particley[i].floor - @particles[i].x = @particlex[i]+@startingx+@xoffset - @particles[i].y = @particley[i]+@startingy+@yoffset + @particles[i].x = @particlex[i] + @startingx + @xoffset + @particles[i].y = @particley[i] + @startingy + @yoffset end end class Particle_Engine::Flare < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,1,30,10,1,-64, - Graphics.height,-64,Graphics.width,2,2,-5,-12,30,0]) - initParticles("particle",255) + setParameters([0, 0, 1, 30, 10, 1, -64, + Graphics.height, -64, Graphics.width, 2, 2, -5, -12, 30, 0]) + initParticles("particle", 255) end end class Particle_Engine::Splash < ParticleEffect_Event - def initialize(event,viewport) + def initialize(event, viewport) super - setParameters([0,0,1,30,255,1,-64, - Graphics.height,-64,Graphics.width,4,2,-5,-12,30,0]) - initParticles("smoke",50) + setParameters([0, 0, 1, 30, 255, 1, -64, + Graphics.height, -64, Graphics.width, 4, 2, -5, -12, 30, 0]) + initParticles("smoke", 50) end def update @@ -570,7 +570,7 @@ class Game_Event < Game_Character attr_accessor :pe_refresh alias nf_particles_game_map_initialize initialize - def initialize(map_id,event,map = nil) + def initialize(map_id, event, map = nil) @pe_refresh = false begin nf_particles_game_map_initialize(map_id, event, map) diff --git a/Data/Scripts/005_Sprites/011_PictureEx.rb b/Data/Scripts/005_Sprites/011_PictureEx.rb index b8a3394f4..27ff47ddc 100644 --- a/Data/Scripts/005_Sprites/011_PictureEx.rb +++ b/Data/Scripts/005_Sprites/011_PictureEx.rb @@ -37,7 +37,7 @@ end -def getCubicPoint2(src,t) +def getCubicPoint2(src, t) x0 = src[0] y0 = src[1] cx0 = src[2] @@ -47,29 +47,29 @@ def getCubicPoint2(src,t) x1 = src[6] y1 = src[7] - x1 = cx1+(x1-cx1)*t - x0 = x0+(cx0-x0)*t - cx0 = cx0+(cx1-cx0)*t - cx1 = cx0+(x1-cx0)*t - cx0 = x0+(cx0-x0)*t - cx = cx0+(cx1-cx0)*t + x1 = cx1 + (x1 - cx1) * t + x0 = x0 + (cx0 - x0) * t + cx0 = cx0 + (cx1 - cx0) * t + cx1 = cx0 + (x1 - cx0) * t + cx0 = x0 + (cx0 - x0) * t + cx = cx0 + (cx1 - cx0) * t # a = x1 - 3 * cx1 + 3 * cx0 - x0 # b = 3 * (cx1 - 2 * cx0 + x0) # c = 3 * (cx0 - x0) # d = x0 # cx = a*t*t*t + b*t*t + c*t + d - y1 = cy1+(y1-cy1)*t - y0 = y0+(cy0-y0)*t - cy0 = cy0+(cy1-cy0)*t - cy1 = cy0+(y1-cy0)*t - cy0 = y0+(cy0-y0)*t - cy = cy0+(cy1-cy0)*t + y1 = cy1 + (y1 - cy1) * t + y0 = y0 + (cy0 - y0) * t + cy0 = cy0 + (cy1 - cy0) * t + cy1 = cy0 + (y1 - cy0) * t + cy0 = y0 + (cy0 - y0) * t + cy = cy0 + (cy1 - cy0) * t # a = y1 - 3 * cy1 + 3 * cy0 - y0 # b = 3 * (cy1 - 2 * cy0 + y0) # c = 3 * (cy0 - y0) # d = y0 # cy = a*t*t*t + b*t*t + c*t + d - return [cx,cy] + return [cx, cy] end @@ -115,7 +115,7 @@ class PictureEx @blend_type = 0 @name = "" @origin = PictureOrigin::TopLeft - @src_rect = Rect.new(0,0,-1,-1) + @src_rect = Rect.new(0, 0, -1, -1) @cropBottom = -1 @frameUpdates = [] end @@ -132,28 +132,28 @@ class PictureEx def setCallback(delay, cb = nil) delay = ensureDelayAndDuration(delay) - @processes.push([nil,delay,0,0,cb]) + @processes.push([nil, delay, 0, 0, cb]) end def running? - return @processes.length>0 + return @processes.length > 0 end def totalDuration ret = 0 for process in @processes - dur = process[1]+process[2] - ret = dur if dur>ret + dur = process[1] + process[2] + ret = dur if dur > ret end - ret *= 20.0/Graphics.frame_rate + ret *= 20.0 / Graphics.frame_rate return ret.to_i end def ensureDelayAndDuration(delay, duration = nil) - delay = self.totalDuration if delay<0 - delay *= Graphics.frame_rate/20.0 + delay = self.totalDuration if delay < 0 + delay *= Graphics.frame_rate / 20.0 if !duration.nil? - duration *= Graphics.frame_rate/20.0 + duration *= Graphics.frame_rate / 20.0 return delay.to_i, duration.to_i end return delay.to_i @@ -169,8 +169,8 @@ class PictureEx # point. If you make a sprite auto-rotate, you should not try to alter # the angle another way too. def rotate(speed) - @rotate_speed = speed*20.0/Graphics.frame_rate - while @rotate_speed<0 + @rotate_speed = speed * 20.0 / Graphics.frame_rate + while @rotate_speed < 0 @rotate_speed += 360 end @rotate_speed %= 360 @@ -186,7 +186,7 @@ class PictureEx def adjustPosition(xOffset, yOffset) for process in @processes - next if process[0]!=Processes::XY + next if process[0] != Processes::XY process[5] += xOffset process[6] += yOffset process[7] += xOffset @@ -195,150 +195,150 @@ class PictureEx end def move(delay, duration, origin, x, y, zoom_x = 100.0, zoom_y = 100.0, opacity = 255) - setOrigin(delay,duration,origin) - moveXY(delay,duration,x,y) - moveZoomXY(delay,duration,zoom_x,zoom_y) - moveOpacity(delay,duration,opacity) + setOrigin(delay, duration, origin) + moveXY(delay, duration, x, y) + moveZoomXY(delay, duration, zoom_x, zoom_y) + moveOpacity(delay, duration, opacity) end def moveXY(delay, duration, x, y, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::XY,delay,duration,0,cb,@x,@y,x,y]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::XY, delay, duration, 0, cb, @x, @y, x, y]) end def setXY(delay, x, y, cb = nil) - moveXY(delay,0,x,y,cb) + moveXY(delay, 0, x, y, cb) end def moveCurve(delay, duration, x1, y1, x2, y2, x3, y3, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::Curve,delay,duration,0,cb,[@x,@y,x1,y1,x2,y2,x3,y3]]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::Curve, delay, duration, 0, cb, [@x, @y, x1, y1, x2, y2, x3, y3]]) end def moveDelta(delay, duration, x, y, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::DeltaXY,delay,duration,0,cb,@x,@y,x,y]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::DeltaXY, delay, duration, 0, cb, @x, @y, x, y]) end def setDelta(delay, x, y, cb = nil) - moveDelta(delay,0,x,y,cb) + moveDelta(delay, 0, x, y, cb) end def moveZ(delay, duration, z, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::Z,delay,duration,0,cb,@z,z]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::Z, delay, duration, 0, cb, @z, z]) end def setZ(delay, z, cb = nil) - moveZ(delay,0,z,cb) + moveZ(delay, 0, z, cb) end def moveZoomXY(delay, duration, zoom_x, zoom_y, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::Zoom,delay,duration,0,cb,@zoom_x,@zoom_y,zoom_x,zoom_y]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::Zoom, delay, duration, 0, cb, @zoom_x, @zoom_y, zoom_x, zoom_y]) end def setZoomXY(delay, zoom_x, zoom_y, cb = nil) - moveZoomXY(delay,0,zoom_x,zoom_y,cb) + moveZoomXY(delay, 0, zoom_x, zoom_y, cb) end def moveZoom(delay, duration, zoom, cb = nil) - moveZoomXY(delay,duration,zoom,zoom,cb) + moveZoomXY(delay, duration, zoom, zoom, cb) end def setZoom(delay, zoom, cb = nil) - moveZoomXY(delay,0,zoom,zoom,cb) + moveZoomXY(delay, 0, zoom, zoom, cb) end def moveAngle(delay, duration, angle, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::Angle,delay,duration,0,cb,@angle,angle]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::Angle, delay, duration, 0, cb, @angle, angle]) end def setAngle(delay, angle, cb = nil) - moveAngle(delay,0,angle,cb) + moveAngle(delay, 0, angle, cb) end def moveTone(delay, duration, tone, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - target = (tone) ? tone.clone : Tone.new(0,0,0,0) - @processes.push([Processes::Tone,delay,duration,0,cb,@tone.clone,target]) + delay, duration = ensureDelayAndDuration(delay, duration) + target = (tone) ? tone.clone : Tone.new(0, 0, 0, 0) + @processes.push([Processes::Tone, delay, duration, 0, cb, @tone.clone, target]) end def setTone(delay, tone, cb = nil) - moveTone(delay,0,tone,cb) + moveTone(delay, 0, tone, cb) end def moveColor(delay, duration, color, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - target = (color) ? color.clone : Color.new(0,0,0,0) - @processes.push([Processes::Color,delay,duration,0,cb,@color.clone,target]) + delay, duration = ensureDelayAndDuration(delay, duration) + target = (color) ? color.clone : Color.new(0, 0, 0, 0) + @processes.push([Processes::Color, delay, duration, 0, cb, @color.clone, target]) end def setColor(delay, color, cb = nil) - moveColor(delay,0,color,cb) + moveColor(delay, 0, color, cb) end # Hue changes don't actually work. def moveHue(delay, duration, hue, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::Hue,delay,duration,0,cb,@hue,hue]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::Hue, delay, duration, 0, cb, @hue, hue]) end # Hue changes don't actually work. def setHue(delay, hue, cb = nil) - moveHue(delay,0,hue,cb) + moveHue(delay, 0, hue, cb) end def moveOpacity(delay, duration, opacity, cb = nil) - delay, duration = ensureDelayAndDuration(delay,duration) - @processes.push([Processes::Opacity,delay,duration,0,cb,@opacity,opacity]) + delay, duration = ensureDelayAndDuration(delay, duration) + @processes.push([Processes::Opacity, delay, duration, 0, cb, @opacity, opacity]) end def setOpacity(delay, opacity, cb = nil) - moveOpacity(delay,0,opacity,cb) + moveOpacity(delay, 0, opacity, cb) end def setVisible(delay, visible, cb = nil) delay = ensureDelay(delay) - @processes.push([Processes::Visible,delay,0,0,cb,visible]) + @processes.push([Processes::Visible, delay, 0, 0, cb, visible]) end # Only values of 0 (normal), 1 (additive) and 2 (subtractive) are allowed. def setBlendType(delay, blend, cb = nil) delay = ensureDelayAndDuration(delay) - @processes.push([Processes::BlendType,delay,0,0,cb,blend]) + @processes.push([Processes::BlendType, delay, 0, 0, cb, blend]) end def setSE(delay, seFile, volume = nil, pitch = nil, cb = nil) delay = ensureDelay(delay) - @processes.push([Processes::SE,delay,0,0,cb,seFile,volume,pitch]) + @processes.push([Processes::SE, delay, 0, 0, cb, seFile, volume, pitch]) end def setName(delay, name, cb = nil) delay = ensureDelay(delay) - @processes.push([Processes::Name,delay,0,0,cb,name]) + @processes.push([Processes::Name, delay, 0, 0, cb, name]) end def setOrigin(delay, origin, cb = nil) delay = ensureDelay(delay) - @processes.push([Processes::Origin,delay,0,0,cb,origin]) + @processes.push([Processes::Origin, delay, 0, 0, cb, origin]) end def setSrc(delay, srcX, srcY, cb = nil) delay = ensureDelay(delay) - @processes.push([Processes::Src,delay,0,0,cb,srcX,srcY]) + @processes.push([Processes::Src, delay, 0, 0, cb, srcX, srcY]) end def setSrcSize(delay, srcWidth, srcHeight, cb = nil) delay = ensureDelay(delay) - @processes.push([Processes::SrcSize,delay,0,0,cb,srcWidth,srcHeight]) + @processes.push([Processes::SrcSize, delay, 0, 0, cb, srcWidth, srcHeight]) end # Used to cut Pokémon sprites off when they faint and sink into the ground. def setCropBottom(delay, y, cb = nil) delay = ensureDelay(delay) - @processes.push([Processes::CropBottom,delay,0,0,cb,y]) + @processes.push([Processes::CropBottom, delay, 0, 0, cb, y]) end def update @@ -347,9 +347,9 @@ class PictureEx for i in 0...@processes.length process = @processes[i] # Decrease delay of processes that are scheduled to start later - if process[1]>=0 + if process[1] >= 0 # Set initial values if the process will start this frame - if process[1]==0 + if process[1] == 0 case process[0] when Processes::XY process[5] = @x @@ -382,18 +382,18 @@ class PictureEx # Decrease delay counter process[1] -= 1 # Process hasn't started yet, skip to the next one - next if process[1]>=0 + next if process[1] >= 0 end # Update process @frameUpdates.push(process[0]) if !@frameUpdates.include?(process[0]) - fra = (process[2]==0) ? 1 : process[3] # Frame counter - dur = (process[2]==0) ? 1 : process[2] # Total duration of process + fra = (process[2] == 0) ? 1 : process[3] # Frame counter + dur = (process[2] == 0) ? 1 : process[2] # Total duration of process case process[0] when Processes::XY, Processes::DeltaXY @x = process[5] + fra * (process[7] - process[5]) / dur @y = process[6] + fra * (process[8] - process[6]) / dur when Processes::Curve - @x, @y = getCubicPoint2(process[5],fra.to_f/dur) + @x, @y = getCubicPoint2(process[5], fra.to_f / dur) when Processes::Z @z = process[5] + fra * (process[6] - process[5]) / dur when Processes::Zoom @@ -420,7 +420,7 @@ class PictureEx when Processes::BlendType @blend_type = process[5] when Processes::SE - pbSEPlay(process[5],process[6],process[7]) + pbSEPlay(process[5], process[6], process[7]) when Processes::Name @name = process[5] when Processes::Origin @@ -436,7 +436,7 @@ class PictureEx end # Increase frame counter process[3] += 1 - if process[3]>process[2] + if process[3] > process[2] # Process has ended, erase it callback(process[4]) if process[4] @processes[i] = nil @@ -449,7 +449,7 @@ class PictureEx if @rotate_speed != 0 @frameUpdates.push(Processes::Angle) if !@frameUpdates.include?(Processes::Angle) @angle += @rotate_speed - while @angle<0 + while @angle < 0 @angle += 360 end @angle %= 360 @@ -463,7 +463,7 @@ end # #=============================================================================== def setPictureSprite(sprite, picture, iconSprite = false) - return if picture.frameUpdates.length==0 + return if picture.frameUpdates.length == 0 for i in 0...picture.frameUpdates.length case picture.frameUpdates[i] when Processes::XY, Processes::DeltaXY @@ -495,7 +495,7 @@ def setPictureSprite(sprite, picture, iconSprite = false) when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft sprite.ox = 0 when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom - sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width/2 : 0 + sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width / 2 : 0 when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight sprite.ox = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.width : 0 end @@ -503,7 +503,7 @@ def setPictureSprite(sprite, picture, iconSprite = false) when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight sprite.oy = 0 when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right - sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height/2 : 0 + sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height / 2 : 0 when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight sprite.oy = (sprite.bitmap && !sprite.bitmap.disposed?) ? sprite.src_rect.height : 0 end @@ -517,14 +517,14 @@ def setPictureSprite(sprite, picture, iconSprite = false) sprite.src_rect.height = picture.src_rect.height end end - if iconSprite && sprite.src_rect && picture.cropBottom>=0 - spriteBottom = sprite.y-sprite.oy+sprite.src_rect.height - if spriteBottom>picture.cropBottom - sprite.src_rect.height = [picture.cropBottom-sprite.y+sprite.oy,0].max + if iconSprite && sprite.src_rect && picture.cropBottom >= 0 + spriteBottom = sprite.y - sprite.oy + sprite.src_rect.height + if spriteBottom > picture.cropBottom + sprite.src_rect.height = [picture.cropBottom - sprite.y + sprite.oy, 0].max end end end def setPictureIconSprite(sprite, picture) - setPictureSprite(sprite,picture,true) + setPictureSprite(sprite, picture, true) end diff --git a/Data/Scripts/005_Sprites/012_Interpolators.rb b/Data/Scripts/005_Sprites/012_Interpolators.rb index 420d9f087..174dd5c0d 100644 --- a/Data/Scripts/005_Sprites/012_Interpolators.rb +++ b/Data/Scripts/005_Sprites/012_Interpolators.rb @@ -19,24 +19,24 @@ class Interpolator return @tweening end - def tween(sprite,items,frames) + def tween(sprite, items, frames) @tweensteps = [] - if sprite && !sprite.disposed? && frames>0 + if sprite && !sprite.disposed? && frames > 0 @frames = frames @step = 0 @sprite = sprite for item in items case item[0] when ZOOM_X - @tweensteps[item[0]] = [sprite.zoom_x,item[1]-sprite.zoom_x] + @tweensteps[item[0]] = [sprite.zoom_x, item[1] - sprite.zoom_x] when ZOOM_Y - @tweensteps[item[0]] = [sprite.zoom_y,item[1]-sprite.zoom_y] + @tweensteps[item[0]] = [sprite.zoom_y, item[1] - sprite.zoom_y] when X - @tweensteps[item[0]] = [sprite.x,item[1]-sprite.x] + @tweensteps[item[0]] = [sprite.x, item[1] - sprite.x] when Y - @tweensteps[item[0]] = [sprite.y,item[1]-sprite.y] + @tweensteps[item[0]] = [sprite.y, item[1] - sprite.y] when OPACITY - @tweensteps[item[0]] = [sprite.opacity,item[1]-sprite.opacity] + @tweensteps[item[0]] = [sprite.opacity, item[1] - sprite.opacity] when COLOR @tweensteps[item[0]] = [sprite.color.clone, Color.new(item[1].red - sprite.color.red, @@ -51,21 +51,21 @@ class Interpolator def update if @tweening - t = (@step*1.0)/@frames + t = (@step * 1.0) / @frames for i in 0...@tweensteps.length item = @tweensteps[i] next if !item case i when ZOOM_X - @sprite.zoom_x = item[0]+item[1]*t + @sprite.zoom_x = item[0] + item[1] * t when ZOOM_Y - @sprite.zoom_y = item[0]+item[1]*t + @sprite.zoom_y = item[0] + item[1] * t when X - @sprite.x = item[0]+item[1]*t + @sprite.x = item[0] + item[1] * t when Y - @sprite.y = item[0]+item[1]*t + @sprite.y = item[0] + item[1] * t when OPACITY - @sprite.opacity = item[0]+item[1]*t + @sprite.opacity = item[0] + item[1] * t when COLOR @sprite.color = Color.new(item[0].red + item[1].red * t, item[0].green + item[1].green * t, @@ -74,7 +74,7 @@ class Interpolator end end @step += 1 - if @step==@frames + if @step == @frames @step = 0 @frames = 0 @tweening = false @@ -86,46 +86,46 @@ end class RectInterpolator - def initialize(oldrect,newrect,frames) - restart(oldrect,newrect,frames) + def initialize(oldrect, newrect, frames) + restart(oldrect, newrect, frames) end - def restart(oldrect,newrect,frames) + def restart(oldrect, newrect, frames) @oldrect = oldrect @newrect = newrect - @frames = [frames,1].max + @frames = [frames, 1].max @curframe = 0 @rect = oldrect.clone end def set(rect) - rect.set(@rect.x,@rect.y,@rect.width,@rect.height) + rect.set(@rect.x, @rect.y, @rect.width, @rect.height) end def done? - @curframe>@frames + @curframe > @frames end def update return if done? - t = (@curframe*1.0/@frames) + t = (@curframe * 1.0 / @frames) x1 = @oldrect.x x2 = @newrect.x - x = x1+t*(x2-x1) + x = x1 + t * (x2 - x1) y1 = @oldrect.y y2 = @newrect.y - y = y1+t*(y2-y1) - rx1 = @oldrect.x+@oldrect.width - rx2 = @newrect.x+@newrect.width - rx = rx1+t*(rx2-rx1) - ry1 = @oldrect.y+@oldrect.height - ry2 = @newrect.y+@newrect.height - ry = ry1+t*(ry2-ry1) - minx = xrx ? x : rx - miny = yry ? y : ry - @rect.set(minx,miny,maxx-minx,maxy-miny) + y = y1 + t * (y2 - y1) + rx1 = @oldrect.x + @oldrect.width + rx2 = @newrect.x + @newrect.width + rx = rx1 + t * (rx2 - rx1) + ry1 = @oldrect.y + @oldrect.height + ry2 = @newrect.y + @newrect.height + ry = ry1 + t * (ry2 - ry1) + minx = x < rx ? x : rx + maxx = x > rx ? x : rx + miny = y < ry ? y : ry + maxy = y > ry ? y : ry + @rect.set(minx, miny, maxx - minx, maxy - miny) @curframe += 1 end end @@ -136,11 +136,11 @@ class PointInterpolator attr_reader :x attr_reader :y - def initialize(oldx,oldy,newx,newy,frames) - restart(oldx,oldy,newx,newy,frames) + def initialize(oldx, oldy, newx, newy, frames) + restart(oldx, oldy, newx, newy, frames) end - def restart(oldx,oldy,newx,newy,frames) + def restart(oldx, oldy, newx, newy, frames) @oldx = oldx @oldy = oldy @newx = newx @@ -152,18 +152,18 @@ class PointInterpolator end def done? - @curframe>@frames + @curframe > @frames end def update return if done? - t = (@curframe*1.0/@frames) + t = (@curframe * 1.0 / @frames) rx1 = @oldx rx2 = @newx - @x = rx1+t*(rx2-rx1) + @x = rx1 + t * (rx2 - rx1) ry1 = @oldy ry2 = @newy - @y = ry1+t*(ry2-ry1) + @y = ry1 + t * (ry2 - ry1) @curframe += 1 end end diff --git a/Data/Scripts/005_Sprites/013_ScreenPosHelper.rb b/Data/Scripts/005_Sprites/013_ScreenPosHelper.rb index 5c354ff21..e15424959 100644 --- a/Data/Scripts/005_Sprites/013_ScreenPosHelper.rb +++ b/Data/Scripts/005_Sprites/013_ScreenPosHelper.rb @@ -1,10 +1,10 @@ module ScreenPosHelper def self.pbScreenZoomX(ch) - return Game_Map::TILE_WIDTH/32.0 + return Game_Map::TILE_WIDTH / 32.0 end def self.pbScreenZoomY(ch) - return Game_Map::TILE_HEIGHT/32.0 + return Game_Map::TILE_HEIGHT / 32.0 end def self.pbScreenX(ch) @@ -15,29 +15,29 @@ module ScreenPosHelper return ch.screen_y end - @heightcache={} + @heightcache = {} def self.bmHeight(bm) - h=@heightcache[bm] + h = @heightcache[bm] if !h - bmap=AnimatedBitmap.new("Graphics/Characters/"+bm,0) - h=bmap.height - @heightcache[bm]=h + bmap = AnimatedBitmap.new("Graphics/Characters/" + bm, 0) + h = bmap.height + @heightcache[bm] = h bmap.dispose end return h end - def self.pbScreenZ(ch,height = nil) - if height==nil - height=0 + def self.pbScreenZ(ch, height = nil) + if height == nil + height = 0 if ch.tile_id > 0 - height=32 - elsif ch.character_name!="" - height=bmHeight(ch.character_name)/4 + height = 32 + elsif ch.character_name != "" + height = bmHeight(ch.character_name) / 4 end end - ret=ch.screen_z(height) + ret = ch.screen_z(height) return ret end end diff --git a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb index 62a974668..9ec6a236d 100644 --- a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb +++ b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb @@ -281,7 +281,7 @@ class TilemapRenderer @tiles_horizontal_count.times do |i| @tiles[i] = [] @tiles_vertical_count.times do |j| - @tiles[i][j] = Array.new(3) { TileSprite.new(@viewport) } + @tiles[i][j] = Array.new(3) { TileSprite.new(@viewport) } end end @current_map_id = 0 diff --git a/Data/Scripts/006_Map renderer/003_AutotileExpander.rb b/Data/Scripts/006_Map renderer/003_AutotileExpander.rb index 26ded25af..2ffa487e4 100644 --- a/Data/Scripts/006_Map renderer/003_AutotileExpander.rb +++ b/Data/Scripts/006_Map renderer/003_AutotileExpander.rb @@ -1,6 +1,6 @@ class TilemapRenderer module AutotileExpander - MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024 + MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024 module_function diff --git a/Data/Scripts/006_Map renderer/004_TileDrawingHelper.rb b/Data/Scripts/006_Map renderer/004_TileDrawingHelper.rb index 487e7c9da..af1f7c583 100644 --- a/Data/Scripts/006_Map renderer/004_TileDrawingHelper.rb +++ b/Data/Scripts/006_Map renderer/004_TileDrawingHelper.rb @@ -37,10 +37,10 @@ class TileDrawingHelper 36, 24, 36, 24, 21, 6, 21, 4, 36, 24, 36, 24, 20, 2, 20, 0 ] - def self.tableNeighbors(data,x,y) + def self.tableNeighbors(data, x, y) return 0 if x < 0 || x >= data.xsize return 0 if y < 0 || y >= data.ysize - t = data[x,y] + t = data[x, y] xp1 = [x + 1, data.xsize - 1].min yp1 = [y + 1, data.ysize - 1].min xm1 = [x - 1, 0].max @@ -58,12 +58,12 @@ class TileDrawingHelper end def self.fromTileset(tileset) - bmtileset=pbGetTileset(tileset.tileset_name) - bmautotiles=[] + bmtileset = pbGetTileset(tileset.tileset_name) + bmautotiles = [] for i in 0...7 bmautotiles.push(pbGetAutotile(tileset.autotile_names[i])) end - return self.new(bmtileset,bmautotiles) + return self.new(bmtileset, bmautotiles) end def initialize(tileset, autotiles) @@ -87,7 +87,7 @@ class TileDrawingHelper end end - def bltSmallAutotile(bitmap,x,y,cxTile,cyTile,id,frame) + def bltSmallAutotile(bitmap, x, y, cxTile, cyTile, id, frame) return if id >= 384 || frame < 0 || !@autotiles autotile = @autotiles[id / 48 - 1] return if !autotile || autotile.disposed? @@ -111,14 +111,14 @@ class TileDrawingHelper end end - def bltSmallRegularTile(bitmap,x,y,cxTile,cyTile,id) + def bltSmallRegularTile(bitmap, x, y, cxTile, cyTile, id) return if id < 384 || !@tileset || @tileset.disposed? rect = Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32) rect = TilemapRenderer::TilesetWrapper.getWrappedRect(rect) if @shouldWrap bitmap.stretch_blt(Rect.new(x, y, cxTile, cyTile), @tileset, rect) end - def bltSmallTile(bitmap,x,y,cxTile,cyTile,id,frame = 0) + def bltSmallTile(bitmap, x, y, cxTile, cyTile, id, frame = 0) if id >= 384 bltSmallRegularTile(bitmap, x, y, cxTile, cyTile, id) elsif id > 0 @@ -126,15 +126,15 @@ class TileDrawingHelper end end - def bltAutotile(bitmap,x,y,id,frame) + def bltAutotile(bitmap, x, y, id, frame) bltSmallAutotile(bitmap, x, y, 32, 32, id, frame) end - def bltRegularTile(bitmap,x,y,id) + def bltRegularTile(bitmap, x, y, id) bltSmallRegularTile(bitmap, x, y, 32, 32, id) end - def bltTile(bitmap,x,y,id,frame = 0) + def bltTile(bitmap, x, y, id, frame = 0) if id >= 384 bltRegularTile(bitmap, x, y, id) elsif id > 0 @@ -147,79 +147,79 @@ end # #=============================================================================== def createMinimap(mapid) - map=load_data(sprintf("Data/Map%03d.rxdata",mapid)) rescue nil - return BitmapWrapper.new(32,32) if !map - bitmap=BitmapWrapper.new(map.width*4,map.height*4) - black=Color.new(0,0,0) - tilesets=$data_tilesets - tileset=tilesets[map.tileset_id] + map = load_data(sprintf("Data/Map%03d.rxdata", mapid)) rescue nil + return BitmapWrapper.new(32, 32) if !map + bitmap = BitmapWrapper.new(map.width * 4, map.height * 4) + black = Color.new(0, 0, 0) + tilesets = $data_tilesets + tileset = tilesets[map.tileset_id] return bitmap if !tileset - helper=TileDrawingHelper.fromTileset(tileset) + helper = TileDrawingHelper.fromTileset(tileset) for y in 0...map.height for x in 0...map.width for z in 0..2 - id=map.data[x,y,z] - id=0 if !id - helper.bltSmallTile(bitmap,x*4,y*4,4,4,id) + id = map.data[x, y, z] + id = 0 if !id + helper.bltSmallTile(bitmap, x * 4, y * 4, 4, 4, id) end end end - bitmap.fill_rect(0,0,bitmap.width,1,black) - bitmap.fill_rect(0,bitmap.height-1,bitmap.width,1,black) - bitmap.fill_rect(0,0,1,bitmap.height,black) - bitmap.fill_rect(bitmap.width-1,0,1,bitmap.height,black) + bitmap.fill_rect(0, 0, bitmap.width, 1, black) + bitmap.fill_rect(0, bitmap.height - 1, bitmap.width, 1, black) + bitmap.fill_rect(0, 0, 1, bitmap.height, black) + bitmap.fill_rect(bitmap.width - 1, 0, 1, bitmap.height, black) return bitmap end -def bltMinimapAutotile(dstBitmap,x,y,srcBitmap,id) - return if id>=48 || !srcBitmap || srcBitmap.disposed? - anim=0 - cxTile=3 - cyTile=3 - tiles = TileDrawingHelper::AUTOTILE_PATTERNS[id>>3][id&7] - src=Rect.new(0,0,0,0) +def bltMinimapAutotile(dstBitmap, x, y, srcBitmap, id) + return if id >= 48 || !srcBitmap || srcBitmap.disposed? + anim = 0 + cxTile = 3 + cyTile = 3 + tiles = TileDrawingHelper::AUTOTILE_PATTERNS[id >> 3][id & 7] + src = Rect.new(0, 0, 0, 0) for i in 0...4 tile_position = tiles[i] - 1 src.set( tile_position % 6 * cxTile + anim, tile_position / 6 * cyTile, cxTile, cyTile) - dstBitmap.blt(i%2*cxTile+x,i/2*cyTile+y, srcBitmap, src) + dstBitmap.blt(i % 2 * cxTile + x, i / 2 * cyTile + y, srcBitmap, src) end end -def passable?(passages,tile_id) +def passable?(passages, tile_id) return false if tile_id == nil passage = passages[tile_id] - return (passage && passage<15) + return (passage && passage < 15) end # Unused def getPassabilityMinimap(mapid) - map = load_data(sprintf("Data/Map%03d.rxdata",mapid)) + map = load_data(sprintf("Data/Map%03d.rxdata", mapid)) tileset = $data_tilesets[map.tileset_id] minimap = AnimatedBitmap.new("Graphics/Pictures/minimap_tiles") - ret = Bitmap.new(map.width*6,map.height*6) - passtable = Table.new(map.width,map.height) + ret = Bitmap.new(map.width * 6, map.height * 6) + passtable = Table.new(map.width, map.height) passages = tileset.passages for i in 0...map.width for j in 0...map.height - pass=true - for z in [2,1,0] - if !passable?(passages,map.data[i,j,z]) - pass=false + pass = true + for z in [2, 1, 0] + if !passable?(passages, map.data[i, j, z]) + pass = false break end end - passtable[i,j]=pass ? 1 : 0 + passtable[i, j] = pass ? 1 : 0 end end - neighbors=TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX + neighbors = TileDrawingHelper::NEIGHBORS_TO_AUTOTILE_INDEX for i in 0...map.width for j in 0...map.height - if passtable[i,j]==0 - nb=TileDrawingHelper.tableNeighbors(passtable,i,j) - tile=neighbors[nb] - bltMinimapAutotile(ret,i*6,j*6,minimap.bitmap,tile) + if passtable[i, j] == 0 + nb = TileDrawingHelper.tableNeighbors(passtable, i, j) + tile = neighbors[nb] + bltMinimapAutotile(ret, i * 6, j * 6, minimap.bitmap, tile) end end end diff --git a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb index 1ed0134c9..070457989 100644 --- a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb +++ b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb @@ -40,39 +40,39 @@ module MessageConfig end def self.pbDefaultWindowskin - skin=($data_system) ? $data_system.windowskin_name : nil - if skin && skin!="" - skin=pbResolveBitmap("Graphics/Windowskins/"+skin) || "" + skin = ($data_system) ? $data_system.windowskin_name : nil + if skin && skin != "" + skin = pbResolveBitmap("Graphics/Windowskins/" + skin) || "" end - skin=pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin) - skin=pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin) + skin = pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin) + skin = pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin) return skin || "" end def self.pbGetSystemFrame if !@@systemFrame - skin=MessageConfig.pbDefaultSystemFrame - skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) - @@systemFrame=skin || "" + skin = MessageConfig.pbDefaultSystemFrame + skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) + @@systemFrame = skin || "" end return @@systemFrame end def self.pbGetSpeechFrame if !@@defaultTextSkin - skin=MessageConfig.pbDefaultSpeechFrame - skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) - @@defaultTextSkin=skin || "" + skin = MessageConfig.pbDefaultSpeechFrame + skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) + @@defaultTextSkin = skin || "" end return @@defaultTextSkin end def self.pbSetSystemFrame(value) - @@systemFrame=pbResolveBitmap(value) || "" + @@systemFrame = pbResolveBitmap(value) || "" end def self.pbSetSpeechFrame(value) - @@defaultTextSkin=pbResolveBitmap(value) || "" + @@defaultTextSkin = pbResolveBitmap(value) || "" end #----------------------------------------------------------------------------- @@ -82,12 +82,12 @@ module MessageConfig end def self.pbGetTextSpeed - @@textSpeed=pbDefaultTextSpeed if !@@textSpeed + @@textSpeed = pbDefaultTextSpeed if !@@textSpeed return @@textSpeed end def self.pbSetTextSpeed(value) - @@textSpeed=value + @@textSpeed = value end def self.pbSettingToTextSpeed(speed) @@ -165,106 +165,106 @@ end # Position a window #=============================================================================== def pbBottomRight(window) - window.x=Graphics.width-window.width - window.y=Graphics.height-window.height + window.x = Graphics.width - window.width + window.y = Graphics.height - window.height end def pbBottomLeft(window) - window.x=0 - window.y=Graphics.height-window.height + window.x = 0 + window.y = Graphics.height - window.height end -def pbBottomLeftLines(window,lines,width = nil) - window.x=0 - window.width=width ? width : Graphics.width - window.height=(window.borderY rescue 32)+lines*32 - window.y=Graphics.height-window.height +def pbBottomLeftLines(window, lines, width = nil) + window.x = 0 + window.width = width ? width : Graphics.width + window.height = (window.borderY rescue 32) + lines * 32 + window.y = Graphics.height - window.height end -def pbPositionFaceWindow(facewindow,msgwindow) +def pbPositionFaceWindow(facewindow, msgwindow) return if !facewindow if msgwindow - if facewindow.height<=msgwindow.height - facewindow.y=msgwindow.y + if facewindow.height <= msgwindow.height + facewindow.y = msgwindow.y else - facewindow.y=msgwindow.y+msgwindow.height-facewindow.height + facewindow.y = msgwindow.y + msgwindow.height - facewindow.height end - facewindow.x=Graphics.width-facewindow.width - msgwindow.x=0 - msgwindow.width=Graphics.width-facewindow.width + facewindow.x = Graphics.width - facewindow.width + msgwindow.x = 0 + msgwindow.width = Graphics.width - facewindow.width else - facewindow.height=Graphics.height if facewindow.height>Graphics.height - facewindow.x=0 - facewindow.y=0 + facewindow.height = Graphics.height if facewindow.height > Graphics.height + facewindow.x = 0 + facewindow.y = 0 end end -def pbPositionNearMsgWindow(cmdwindow,msgwindow,side) +def pbPositionNearMsgWindow(cmdwindow, msgwindow, side) return if !cmdwindow if msgwindow - height=[cmdwindow.height,Graphics.height-msgwindow.height].min - if cmdwindow.height!=height - cmdwindow.height=height + height = [cmdwindow.height, Graphics.height - msgwindow.height].min + if cmdwindow.height != height + cmdwindow.height = height end - cmdwindow.y=msgwindow.y-cmdwindow.height - if cmdwindow.y<0 - cmdwindow.y=msgwindow.y+msgwindow.height - if cmdwindow.y+cmdwindow.height>Graphics.height - cmdwindow.y=msgwindow.y-cmdwindow.height + cmdwindow.y = msgwindow.y - cmdwindow.height + if cmdwindow.y < 0 + cmdwindow.y = msgwindow.y + msgwindow.height + if cmdwindow.y + cmdwindow.height > Graphics.height + cmdwindow.y = msgwindow.y - cmdwindow.height end end case side when :left - cmdwindow.x=msgwindow.x + cmdwindow.x = msgwindow.x when :right - cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width + cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width else - cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width + cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width end else - cmdwindow.height=Graphics.height if cmdwindow.height>Graphics.height - cmdwindow.x=0 - cmdwindow.y=0 + cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height + cmdwindow.x = 0 + cmdwindow.y = 0 end end # internal function def pbRepositionMessageWindow(msgwindow, linecount = 2) - msgwindow.height=32*linecount+msgwindow.borderY - msgwindow.y=(Graphics.height)-(msgwindow.height) + msgwindow.height = 32 * linecount + msgwindow.borderY + msgwindow.y = (Graphics.height) - (msgwindow.height) if $game_system case $game_system.message_position when 0 # up - msgwindow.y=0 + msgwindow.y = 0 when 1 # middle - msgwindow.y=(Graphics.height/2)-(msgwindow.height/2) + msgwindow.y = (Graphics.height / 2) - (msgwindow.height / 2) when 2 - msgwindow.y=(Graphics.height)-(msgwindow.height) + msgwindow.y = (Graphics.height) - (msgwindow.height) end msgwindow.opacity = 0 if $game_system.message_frame != 0 end end # internal function -def pbUpdateMsgWindowPos(msgwindow,event,eventChanged = false) +def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false) if event if eventChanged - msgwindow.resizeToFit2(msgwindow.text,Graphics.width*2/3,msgwindow.height) + msgwindow.resizeToFit2(msgwindow.text, Graphics.width * 2 / 3, msgwindow.height) end - msgwindow.y=event.screen_y-48-msgwindow.height - if msgwindow.y<0 - msgwindow.y=event.screen_y+24 + msgwindow.y = event.screen_y - 48 - msgwindow.height + if msgwindow.y < 0 + msgwindow.y = event.screen_y + 24 end - msgwindow.x=event.screen_x-(msgwindow.width/2) - msgwindow.x=0 if msgwindow.x<0 - if msgwindow.x>Graphics.width-msgwindow.width - msgwindow.x=Graphics.width-msgwindow.width + msgwindow.x = event.screen_x - (msgwindow.width / 2) + msgwindow.x = 0 if msgwindow.x < 0 + if msgwindow.x > Graphics.width - msgwindow.width + msgwindow.x = Graphics.width - msgwindow.width end else - curwidth=msgwindow.width - if curwidth!=Graphics.width - msgwindow.width=Graphics.width - msgwindow.width=Graphics.width + curwidth = msgwindow.width + if curwidth != Graphics.width + msgwindow.width = Graphics.width + msgwindow.width = Graphics.width end end end @@ -272,24 +272,24 @@ end #=============================================================================== # Determine the colour of a background #=============================================================================== -def isDarkBackground(background,rect = nil) +def isDarkBackground(background, rect = nil) return true if !background || background.disposed? rect = background.rect if !rect - return true if rect.width<=0 || rect.height<=0 - xSeg = (rect.width/16) - xLoop = (xSeg==0) ? 1 : 16 - xStart = (xSeg==0) ? rect.x+(rect.width/2) : rect.x+xSeg/2 - ySeg = (rect.height/16) - yLoop = (ySeg==0) ? 1 : 16 - yStart = (ySeg==0) ? rect.y+(rect.height/2) : rect.y+ySeg/2 + return true if rect.width <= 0 || rect.height <= 0 + xSeg = (rect.width / 16) + xLoop = (xSeg == 0) ? 1 : 16 + xStart = (xSeg == 0) ? rect.x + (rect.width / 2) : rect.x + xSeg / 2 + ySeg = (rect.height / 16) + yLoop = (ySeg == 0) ? 1 : 16 + yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + ySeg / 2 count = 0 y = yStart r = g = b = 0 yLoop.times do x = xStart xLoop.times do - clr = background.get_pixel(x,y) - if clr.alpha!=0 + clr = background.get_pixel(x, y) + if clr.alpha != 0 r += clr.red g += clr.green b += clr.blue @@ -299,51 +299,51 @@ def isDarkBackground(background,rect = nil) end y += ySeg end - return true if count==0 + return true if count == 0 r /= count g /= count b /= count - return (r*0.299+g*0.587+b*0.114)<160 + return (r * 0.299 + g * 0.587 + b * 0.114) < 160 end def isDarkWindowskin(windowskin) return true if !windowskin || windowskin.disposed? - if windowskin.width==192 && windowskin.height==128 - return isDarkBackground(windowskin,Rect.new(0,0,128,128)) - elsif windowskin.width==128 && windowskin.height==128 - return isDarkBackground(windowskin,Rect.new(0,0,64,64)) - elsif windowskin.width==96 && windowskin.height==48 - return isDarkBackground(windowskin,Rect.new(32,16,16,16)) + if windowskin.width == 192 && windowskin.height == 128 + return isDarkBackground(windowskin, Rect.new(0, 0, 128, 128)) + elsif windowskin.width == 128 && windowskin.height == 128 + return isDarkBackground(windowskin, Rect.new(0, 0, 64, 64)) + elsif windowskin.width == 96 && windowskin.height == 48 + return isDarkBackground(windowskin, Rect.new(32, 16, 16, 16)) else - clr = windowskin.get_pixel(windowskin.width/2, windowskin.height/2) - return (clr.red*0.299+clr.green*0.587+clr.blue*0.114)<160 + clr = windowskin.get_pixel(windowskin.width / 2, windowskin.height / 2) + return (clr.red * 0.299 + clr.green * 0.587 + clr.blue * 0.114) < 160 end end #=============================================================================== # Determine which text colours to use based on the darkness of the background #=============================================================================== -def getSkinColor(windowskin,color,isDarkSkin) +def getSkinColor(windowskin, color, isDarkSkin) if !windowskin || windowskin.disposed? || - windowskin.width!=128 || windowskin.height!=128 + windowskin.width != 128 || windowskin.height != 128 # Base color, shadow color (these are reversed on dark windowskins) textcolors = [ - "0070F8","78B8E8", # 1 Blue - "E82010","F8A8B8", # 2 Red - "60B048","B0D090", # 3 Green - "48D8D8","A8E0E0", # 4 Cyan - "D038B8","E8A0E0", # 5 Magenta - "E8D020","F8E888", # 6 Yellow - "A0A0A8","D0D0D8", # 7 Grey - "F0F0F8","C8C8D0", # 8 White - "9040E8","B8A8E0", # 9 Purple - "F89818","F8C898", # 10 Orange + "0070F8", "78B8E8", # 1 Blue + "E82010", "F8A8B8", # 2 Red + "60B048", "B0D090", # 3 Green + "48D8D8", "A8E0E0", # 4 Cyan + "D038B8", "E8A0E0", # 5 Magenta + "E8D020", "F8E888", # 6 Yellow + "A0A0A8", "D0D0D8", # 7 Grey + "F0F0F8", "C8C8D0", # 8 White + "9040E8", "B8A8E0", # 9 Purple + "F89818", "F8C898", # 10 Orange colorToRgb32(MessageConfig::DARK_TEXT_MAIN_COLOR), colorToRgb32(MessageConfig::DARK_TEXT_SHADOW_COLOR), # 11 Dark default colorToRgb32(MessageConfig::LIGHT_TEXT_MAIN_COLOR), colorToRgb32(MessageConfig::LIGHT_TEXT_SHADOW_COLOR) # 12 Light default ] - if color==0 || color>textcolors.length/2 # No special colour, use default + if color == 0 || color > textcolors.length / 2 # No special colour, use default if isDarkSkin # Dark background, light text return shadowc3tag(MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR) end @@ -351,13 +351,13 @@ def getSkinColor(windowskin,color,isDarkSkin) return shadowc3tag(MessageConfig::DARK_TEXT_MAIN_COLOR, MessageConfig::DARK_TEXT_SHADOW_COLOR) end # Special colour as listed above - if isDarkSkin && color!=12 # Dark background, light text - return sprintf("",textcolors[2*(color-1)+1],textcolors[2*(color-1)]) + if isDarkSkin && color != 12 # Dark background, light text + return sprintf("", textcolors[2 * (color - 1) + 1], textcolors[2 * (color - 1)]) end # Light background, dark text - return sprintf("",textcolors[2*(color-1)],textcolors[2*(color-1)+1]) + return sprintf("", textcolors[2 * (color - 1)], textcolors[2 * (color - 1) + 1]) else # VX windowskin - color = 0 if color>=32 + color = 0 if color >= 32 x = 64 + (color % 8) * 8 y = 96 + (color / 8) * 8 pixel = windowskin.get_pixel(x, y) @@ -367,7 +367,7 @@ end def getDefaultTextColors(windowskin) if !windowskin || windowskin.disposed? || - windowskin.width!=128 || windowskin.height!=128 + windowskin.width != 128 || windowskin.height != 128 if isDarkWindowskin(windowskin) return [MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR] # White else @@ -376,24 +376,24 @@ def getDefaultTextColors(windowskin) else # VX windowskin color = windowskin.get_pixel(64, 96) shadow = nil - isDark = (color.red+color.green+color.blue)/3 < 128 + isDark = (color.red + color.green + color.blue) / 3 < 128 if isDark - shadow = Color.new(color.red+64,color.green+64,color.blue+64) + shadow = Color.new(color.red + 64, color.green + 64, color.blue + 64) else - shadow = Color.new(color.red-64,color.green-64,color.blue-64) + shadow = Color.new(color.red - 64, color.green - 64, color.blue - 64) end - return [color,shadow] + return [color, shadow] end end #=============================================================================== # Makes sure a bitmap exists #=============================================================================== -def pbDoEnsureBitmap(bitmap,dwidth,dheight) - if !bitmap || bitmap.disposed? || bitmap.width0 : false + return ($game_temp) ? $game_temp.fadestate > 0 : false end # pbFadeOutIn(z) { block } # Fades out the screen before a block is run and fades it back in after the # block exits. z indicates the z-coordinate of the viewport used for this effect -def pbFadeOutIn(z = 99999,nofadeout = false) - col=Color.new(0,0,0,0) - viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - viewport.z=z - numFrames = (Graphics.frame_rate*0.4).floor - alphaDiff = (255.0/numFrames).ceil +def pbFadeOutIn(z = 99999, nofadeout = false) + col = Color.new(0, 0, 0, 0) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + viewport.z = z + numFrames = (Graphics.frame_rate * 0.4).floor + alphaDiff = (255.0 / numFrames).ceil for j in 0..numFrames - col.set(0,0,0,j*alphaDiff) - viewport.color=col + col.set(0, 0, 0, j * alphaDiff) + viewport.color = col Graphics.update Input.update end @@ -566,8 +566,8 @@ def pbFadeOutIn(z = 99999,nofadeout = false) pbPopFade if !nofadeout for j in 0..numFrames - col.set(0,0,0,(numFrames-j)*alphaDiff) - viewport.color=col + col.set(0, 0, 0, (numFrames - j) * alphaDiff) + viewport.color = col Graphics.update Input.update end @@ -576,15 +576,15 @@ def pbFadeOutIn(z = 99999,nofadeout = false) end end -def pbFadeOutInWithUpdate(z,sprites,nofadeout = false) - col=Color.new(0,0,0,0) - viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - viewport.z=z - numFrames = (Graphics.frame_rate*0.4).floor - alphaDiff = (255.0/numFrames).ceil +def pbFadeOutInWithUpdate(z, sprites, nofadeout = false) + col = Color.new(0, 0, 0, 0) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + viewport.z = z + numFrames = (Graphics.frame_rate * 0.4).floor + alphaDiff = (255.0 / numFrames).ceil for j in 0..numFrames - col.set(0,0,0,j*alphaDiff) - viewport.color=col + col.set(0, 0, 0, j * alphaDiff) + viewport.color = col pbUpdateSpriteHash(sprites) Graphics.update Input.update @@ -596,8 +596,8 @@ def pbFadeOutInWithUpdate(z,sprites,nofadeout = false) pbPopFade if !nofadeout for j in 0..numFrames - col.set(0,0,0,(numFrames-j)*alphaDiff) - viewport.color=col + col.set(0, 0, 0, (numFrames - j) * alphaDiff) + viewport.color = col pbUpdateSpriteHash(sprites) Graphics.update Input.update @@ -625,11 +625,11 @@ end def pbFadeOutAndHide(sprites) visiblesprites = {} - numFrames = (Graphics.frame_rate*0.4).floor - alphaDiff = (255.0/numFrames).ceil + numFrames = (Graphics.frame_rate * 0.4).floor + alphaDiff = (255.0 / numFrames).ceil pbDeactivateWindows(sprites) { for j in 0..numFrames - pbSetSpritesToColor(sprites,Color.new(0,0,0,j*alphaDiff)) + pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff)) (block_given?) ? yield : pbUpdateSpriteHash(sprites) end } @@ -642,7 +642,7 @@ def pbFadeOutAndHide(sprites) return visiblesprites end -def pbFadeInAndShow(sprites,visiblesprites = nil) +def pbFadeInAndShow(sprites, visiblesprites = nil) if visiblesprites for i in visiblesprites if i[1] && sprites[i[0]] && !pbDisposed?(sprites[i[0]]) @@ -650,11 +650,11 @@ def pbFadeInAndShow(sprites,visiblesprites = nil) end end end - numFrames = (Graphics.frame_rate*0.4).floor - alphaDiff = (255.0/numFrames).ceil + numFrames = (Graphics.frame_rate * 0.4).floor + alphaDiff = (255.0 / numFrames).ceil pbDeactivateWindows(sprites) { for j in 0..numFrames - pbSetSpritesToColor(sprites,Color.new(0,0,0,((numFrames-j)*alphaDiff))) + pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff))) (block_given?) ? yield : pbUpdateSpriteHash(sprites) end } @@ -662,11 +662,11 @@ end # Restores which windows are active for the given sprite hash. # _activeStatuses_ is the result of a previous call to pbActivateWindows -def pbRestoreActivations(sprites,activeStatuses) +def pbRestoreActivations(sprites, activeStatuses) return if !sprites || !activeStatuses for k in activeStatuses.keys if sprites[k] && sprites[k].is_a?(Window) && !pbDisposed?(sprites[k]) - sprites[k].active=activeStatuses[k] ? true : false + sprites[k].active = activeStatuses[k] ? true : false end end end @@ -675,29 +675,29 @@ end # runs the code in the block, and reactivates them. def pbDeactivateWindows(sprites) if block_given? - pbActivateWindow(sprites,nil) { yield } + pbActivateWindow(sprites, nil) { yield } else - pbActivateWindow(sprites,nil) + pbActivateWindow(sprites, nil) end end # Activates a specific window of a sprite hash. _key_ is the key of the window # in the sprite hash. If a code block is given, deactivates all windows except # the specified window, runs the code in the block, and reactivates them. -def pbActivateWindow(sprites,key) +def pbActivateWindow(sprites, key) return if !sprites - activeStatuses={} + activeStatuses = {} for i in sprites if i[1] && i[1].is_a?(Window) && !pbDisposed?(i[1]) - activeStatuses[i[0]]=i[1].active - i[1].active=(i[0]==key) + activeStatuses[i[0]] = i[1].active + i[1].active = (i[0] == key) end end if block_given? begin yield ensure - pbRestoreActivations(sprites,activeStatuses) + pbRestoreActivations(sprites, activeStatuses) end return {} else @@ -713,18 +713,18 @@ end # _background_ is a filename within the Graphics/Pictures/ folder and can be # an animated image. # _viewport_ is a viewport to place the background in. -def addBackgroundPlane(sprites,planename,background,viewport = nil) - sprites[planename]=AnimatedPlane.new(viewport) - bitmapName=pbResolveBitmap("Graphics/Pictures/#{background}") - if bitmapName==nil +def addBackgroundPlane(sprites, planename, background, viewport = nil) + sprites[planename] = AnimatedPlane.new(viewport) + bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}") + if bitmapName == nil # Plane should exist in any case - sprites[planename].bitmap=nil - sprites[planename].visible=false + sprites[planename].bitmap = nil + sprites[planename].visible = false else sprites[planename].setBitmap(bitmapName) for spr in sprites.values if spr.is_a?(Window) - spr.windowskin=nil + spr.windowskin = nil end end end @@ -736,17 +736,17 @@ end # an animated image. # _color_ is the color to use if the background can't be found. # _viewport_ is a viewport to place the background in. -def addBackgroundOrColoredPlane(sprites,planename,background,color,viewport = nil) - bitmapName=pbResolveBitmap("Graphics/Pictures/#{background}") - if bitmapName==nil +def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport = nil) + bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}") + if bitmapName == nil # Plane should exist in any case - sprites[planename]=ColoredPlane.new(color,viewport) + sprites[planename] = ColoredPlane.new(color, viewport) else - sprites[planename]=AnimatedPlane.new(viewport) + sprites[planename] = AnimatedPlane.new(viewport) sprites[planename].setBitmap(bitmapName) for spr in sprites.values if spr.is_a?(Window) - spr.windowskin=nil + spr.windowskin = nil end end end @@ -770,9 +770,9 @@ end if !defined?(_INTL) def _INTL(*args) - string=args[0].clone + string = args[0].clone for i in 1...args.length - string.gsub!(/\{#{i}\}/,"#{args[i]}") + string.gsub!(/\{#{i}\}/, "#{args[i]}") end return string end @@ -780,10 +780,10 @@ end if !defined?(_ISPRINTF) def _ISPRINTF(*args) - string=args[0].clone + string = args[0].clone for i in 1...args.length string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| - next sprintf("%"+$1,args[i]) + next sprintf("%" + $1, args[i]) } end return string @@ -792,9 +792,9 @@ end if !defined?(_MAPINTL) def _MAPINTL(*args) - string=args[1].clone + string = args[1].clone for i in 2...args.length - string.gsub!(/\{#{i}\}/,"#{args[i+1]}") + string.gsub!(/\{#{i}\}/, "#{args[i + 1]}") end return string end diff --git a/Data/Scripts/007_Objects and windows/003_Window.rb b/Data/Scripts/007_Objects and windows/003_Window.rb index 0b385b6da..67177c90d 100644 --- a/Data/Scripts/007_Objects and windows/003_Window.rb +++ b/Data/Scripts/007_Objects and windows/003_Window.rb @@ -76,51 +76,51 @@ class Window end def initialize(viewport = nil) - @sprites={} - @spritekeys=[ + @sprites = {} + @spritekeys = [ "back", - "corner0","side0","scroll0", - "corner1","side1","scroll1", - "corner2","side2","scroll2", - "corner3","side3","scroll3", - "cursor","contents","pause" + "corner0", "side0", "scroll0", + "corner1", "side1", "scroll1", + "corner2", "side2", "scroll2", + "corner3", "side3", "scroll3", + "cursor", "contents", "pause" ] - @sidebitmaps=[nil,nil,nil,nil] - @cursorbitmap=nil - @bgbitmap=nil - @viewport=viewport + @sidebitmaps = [nil, nil, nil, nil] + @cursorbitmap = nil + @bgbitmap = nil + @viewport = viewport for i in @spritekeys - @sprites[i]=Sprite.new(@viewport) + @sprites[i] = Sprite.new(@viewport) end - @disposed=false - @tone=Tone.new(0,0,0) - @color=Color.new(0,0,0,0) - @blankcontents=Bitmap.new(1,1) # RGSS2 requires this - @contents=@blankcontents - @_windowskin=nil - @rpgvx=false # Set to true to emulate RPGVX windows - @x=0 - @y=0 - @width=0 - @openness=255 - @height=0 - @ox=0 - @oy=0 - @z=0 - @stretch=true - @visible=true - @active=true - @blend_type=0 - @contents_blend_type=0 - @opacity=255 - @back_opacity=255 - @contents_opacity=255 - @cursor_rect=WindowCursorRect.new(self) - @cursorblink=0 - @cursoropacity=255 - @pause=false - @pauseopacity=255 - @pauseframe=0 + @disposed = false + @tone = Tone.new(0, 0, 0) + @color = Color.new(0, 0, 0, 0) + @blankcontents = Bitmap.new(1, 1) # RGSS2 requires this + @contents = @blankcontents + @_windowskin = nil + @rpgvx = false # Set to true to emulate RPGVX windows + @x = 0 + @y = 0 + @width = 0 + @openness = 255 + @height = 0 + @ox = 0 + @oy = 0 + @z = 0 + @stretch = true + @visible = true + @active = true + @blend_type = 0 + @contents_blend_type = 0 + @opacity = 255 + @back_opacity = 255 + @contents_opacity = 255 + @cursor_rect = WindowCursorRect.new(self) + @cursorblink = 0 + @cursoropacity = 255 + @pause = false + @pauseopacity = 255 + @pauseframe = 0 privRefresh(true) end @@ -128,55 +128,55 @@ class Window if !self.disposed? for i in @sprites i[1].dispose if i[1] - @sprites[i[0]]=nil + @sprites[i[0]] = nil end for i in 0...@sidebitmaps.length @sidebitmaps[i].dispose if @sidebitmaps[i] - @sidebitmaps[i]=nil + @sidebitmaps[i] = nil end @blankcontents.dispose @cursorbitmap.dispose if @cursorbitmap @backbitmap.dispose if @backbitmap @sprites.clear @sidebitmaps.clear - @_windowskin=nil - @_contents=nil - @disposed=true + @_windowskin = nil + @_contents = nil + @disposed = true end end def openness=(value) - @openness=value - @openness=0 if @openness<0 - @openness=255 if @openness>255 + @openness = value + @openness = 0 if @openness < 0 + @openness = 255 if @openness > 255 privRefresh end def stretch=(value) - @stretch=value + @stretch = value privRefresh(true) end def visible=(value) - @visible=value + @visible = value privRefresh end def viewport=(value) - @viewport=value + @viewport = value for i in @spritekeys @sprites[i].dispose if @sprites[i].is_a?(Sprite) - @sprites[i]=Sprite.new(@viewport) + @sprites[i] = Sprite.new(@viewport) else - @sprites[i]=nil + @sprites[i] = nil end end privRefresh(true) end def z=(value) - @z=value + @z = value privRefresh end @@ -185,27 +185,27 @@ class Window end def contents=(value) - @contents=value + @contents = value privRefresh end def windowskin=(value) - @_windowskin=value - if value && value.is_a?(Bitmap) && !value.disposed? && value.width==128 - @rpgvx=true + @_windowskin = value + if value && value.is_a?(Bitmap) && !value.disposed? && value.width == 128 + @rpgvx = true else - @rpgvx=false + @rpgvx = false end privRefresh(true) end def ox=(value) - @ox=value + @ox = value privRefresh end def active=(value) - @active=value + @active = value privRefresh(true) end @@ -213,104 +213,104 @@ class Window if !value @cursor_rect.empty else - @cursor_rect.set(value.x,value.y,value.width,value.height) + @cursor_rect.set(value.x, value.y, value.width, value.height) end end def oy=(value) - @oy=value + @oy = value privRefresh end def width=(value) - @width=value + @width = value privRefresh(true) end def height=(value) - @height=value + @height = value privRefresh(true) end def pause=(value) - @pause=value - @pauseopacity=0 if !value + @pause = value + @pauseopacity = 0 if !value privRefresh end def x=(value) - @x=value + @x = value privRefresh end def y=(value) - @y=value + @y = value privRefresh end def opacity=(value) - @opacity=value - @opacity=0 if @opacity<0 - @opacity=255 if @opacity>255 + @opacity = value + @opacity = 0 if @opacity < 0 + @opacity = 255 if @opacity > 255 privRefresh end def back_opacity=(value) - @back_opacity=value - @back_opacity=0 if @back_opacity<0 - @back_opacity=255 if @back_opacity>255 + @back_opacity = value + @back_opacity = 0 if @back_opacity < 0 + @back_opacity = 255 if @back_opacity > 255 privRefresh end def contents_opacity=(value) - @contents_opacity=value - @contents_opacity=0 if @contents_opacity<0 - @contents_opacity=255 if @contents_opacity>255 + @contents_opacity = value + @contents_opacity = 0 if @contents_opacity < 0 + @contents_opacity = 255 if @contents_opacity > 255 privRefresh end def tone=(value) - @tone=value + @tone = value privRefresh end def color=(value) - @color=value + @color = value privRefresh end def blend_type=(value) - @blend_type=value + @blend_type = value privRefresh end - def flash(color,duration) + def flash(color, duration) return if disposed? for i in @sprites - i[1].flash(color,duration) + i[1].flash(color, duration) end end def update return if disposed? - mustchange=false + mustchange = false if @active - if @cursorblink==0 - @cursoropacity-=8 - @cursorblink=1 if @cursoropacity<=128 + if @cursorblink == 0 + @cursoropacity -= 8 + @cursorblink = 1 if @cursoropacity <= 128 else - @cursoropacity+=8 - @cursorblink=0 if @cursoropacity>=255 + @cursoropacity += 8 + @cursorblink = 0 if @cursoropacity >= 255 end - mustchange=true if !@cursor_rect.empty? + mustchange = true if !@cursor_rect.empty? else - mustchange=true if @cursoropacity!=128 - @cursoropacity=128 + mustchange = true if @cursoropacity != 128 + @cursoropacity = 128 end if @pause - @pauseframe=(Graphics.frame_count / 8) % 4 - @pauseopacity=[@pauseopacity+64,255].min - mustchange=true + @pauseframe = (Graphics.frame_count / 8) % 4 + @pauseopacity = [@pauseopacity + 64, 255].min + mustchange = true end privRefresh if mustchange for i in @sprites @@ -320,139 +320,139 @@ class Window private - def ensureBitmap(bitmap,dwidth,dheight) - if !bitmap||bitmap.disposed?||bitmap.width 0 @sprites["scroll1"].visible = @visible && hascontents && @ox > 0 @sprites["scroll2"].visible = @visible && hascontents && - (@contents.width - @ox) > @width-32 + (@contents.width - @ox) > @width - 32 @sprites["scroll3"].visible = @visible && hascontents && - (@contents.height - @oy) > @height-32 + (@contents.height - @oy) > @height - 32 else for i in 0...4 - @sprites["corner#{i}"].visible=false - @sprites["side#{i}"].visible=false - @sprites["scroll#{i}"].visible=false + @sprites["corner#{i}"].visible = false + @sprites["side#{i}"].visible = false + @sprites["scroll#{i}"].visible = false end - @sprites["contents"].visible=@visible && @openness==255 - @sprites["contents"].color=@color - @sprites["contents"].tone=@tone - @sprites["contents"].blend_type=@contents_blend_type - @sprites["contents"].opacity=contopac - @sprites["back"].visible=false - @sprites["pause"].visible=false - @sprites["cursor"].visible=false + @sprites["contents"].visible = @visible && @openness == 255 + @sprites["contents"].color = @color + @sprites["contents"].tone = @tone + @sprites["contents"].blend_type = @contents_blend_type + @sprites["contents"].opacity = contopac + @sprites["back"].visible = false + @sprites["pause"].visible = false + @sprites["cursor"].visible = false end for i in @sprites - i[1].z=@z + i[1].z = @z end if @rpgvx - @sprites["cursor"].z=@z # For Compatibility - @sprites["contents"].z=@z # For Compatibility - @sprites["pause"].z=@z # For Compatibility + @sprites["cursor"].z = @z # For Compatibility + @sprites["contents"].z = @z # For Compatibility + @sprites["pause"].z = @z # For Compatibility else - @sprites["cursor"].z=@z+1 # For Compatibility - @sprites["contents"].z=@z+2 # For Compatibility - @sprites["pause"].z=@z+2 # For Compatibility + @sprites["cursor"].z = @z + 1 # For Compatibility + @sprites["contents"].z = @z + 2 # For Compatibility + @sprites["pause"].z = @z + 2 # For Compatibility end if @rpgvx - trimX=64 - trimY=0 - backRect=Rect.new(0,0,64,64) - blindsRect=Rect.new(0,64,64,64) + trimX = 64 + trimY = 0 + backRect = Rect.new(0, 0, 64, 64) + blindsRect = Rect.new(0, 64, 64, 64) else - trimX=128 - trimY=0 - backRect=Rect.new(0,0,128,128) - blindsRect=nil + trimX = 128 + trimY = 0 + backRect = Rect.new(0, 0, 128, 128) + blindsRect = nil end - @sprites["corner0"].src_rect.set(trimX,trimY+0,16,16) - @sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16) - @sprites["corner2"].src_rect.set(trimX,trimY+48,16,16) - @sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16) - @sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up - @sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down - @sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left - @sprites["scroll2"].src_rect.set(trimX+40, trimY+24, 8, 16) # right - cursorX=trimX - cursorY=trimY+64 - sideRects=[ - Rect.new(trimX+16,trimY+0,32,16), - Rect.new(trimX,trimY+16,16,32), - Rect.new(trimX+48,trimY+16,16,32), - Rect.new(trimX+16,trimY+48,32,16) + @sprites["corner0"].src_rect.set(trimX, trimY + 0, 16, 16) + @sprites["corner1"].src_rect.set(trimX + 48, trimY + 0, 16, 16) + @sprites["corner2"].src_rect.set(trimX, trimY + 48, 16, 16) + @sprites["corner3"].src_rect.set(trimX + 48, trimY + 48, 16, 16) + @sprites["scroll0"].src_rect.set(trimX + 24, trimY + 16, 16, 8) # up + @sprites["scroll3"].src_rect.set(trimX + 24, trimY + 40, 16, 8) # down + @sprites["scroll1"].src_rect.set(trimX + 16, trimY + 24, 8, 16) # left + @sprites["scroll2"].src_rect.set(trimX + 40, trimY + 24, 8, 16) # right + cursorX = trimX + cursorY = trimY + 64 + sideRects = [ + Rect.new(trimX + 16, trimY + 0, 32, 16), + Rect.new(trimX, trimY + 16, 16, 32), + Rect.new(trimX + 48, trimY + 16, 16, 32), + Rect.new(trimX + 16, trimY + 48, 32, 16) ] - if @width>32 && @height>32 - @sprites["contents"].src_rect.set(@ox,@oy,@width-32,@height-32) + if @width > 32 && @height > 32 + @sprites["contents"].src_rect.set(@ox, @oy, @width - 32, @height - 32) else - @sprites["contents"].src_rect.set(0,0,0,0) + @sprites["contents"].src_rect.set(0, 0, 0, 0) end pauseRects = [ trimX + 32, trimY + 64, @@ -460,75 +460,75 @@ class Window trimX + 32, trimY + 80, trimX + 48, trimY + 80 ] - pauseWidth=16 - pauseHeight=16 + pauseWidth = 16 + pauseHeight = 16 @sprites["pause"].src_rect.set(pauseRects[@pauseframe * 2], pauseRects[@pauseframe * 2 + 1], pauseWidth, pauseHeight) - @sprites["pause"].x=@x+(@width/2)-(pauseWidth/2) - @sprites["pause"].y=@y+@height-16 # 16 refers to skin margin - @sprites["contents"].x=@x+16 - @sprites["contents"].y=@y+16 - @sprites["corner0"].x=@x - @sprites["corner0"].y=@y - @sprites["corner1"].x=@x+@width-16 - @sprites["corner1"].y=@y - @sprites["corner2"].x=@x - @sprites["corner2"].y=@y+@height-16 - @sprites["corner3"].x=@x+@width-16 - @sprites["corner3"].y=@y+@height-16 - @sprites["side0"].x=@x+16 - @sprites["side0"].y=@y - @sprites["side1"].x=@x - @sprites["side1"].y=@y+16 - @sprites["side2"].x=@x+@width-16 - @sprites["side2"].y=@y+16 - @sprites["side3"].x=@x+16 - @sprites["side3"].y=@y+@height-16 - @sprites["scroll0"].x = @x+@width / 2 - 8 - @sprites["scroll0"].y = @y+8 - @sprites["scroll1"].x = @x+8 - @sprites["scroll1"].y = @y+@height / 2 - 8 - @sprites["scroll2"].x = @x+@width - 16 - @sprites["scroll2"].y = @y+@height / 2 - 8 - @sprites["scroll3"].x = @x+@width / 2 - 8 - @sprites["scroll3"].y = @y+@height - 16 - @sprites["back"].x=@x+2 - @sprites["back"].y=@y+2 - @sprites["cursor"].x=@x+16+@cursor_rect.x - @sprites["cursor"].y=@y+16+@cursor_rect.y + @sprites["pause"].x = @x + (@width / 2) - (pauseWidth / 2) + @sprites["pause"].y = @y + @height - 16 # 16 refers to skin margin + @sprites["contents"].x = @x + 16 + @sprites["contents"].y = @y + 16 + @sprites["corner0"].x = @x + @sprites["corner0"].y = @y + @sprites["corner1"].x = @x + @width - 16 + @sprites["corner1"].y = @y + @sprites["corner2"].x = @x + @sprites["corner2"].y = @y + @height - 16 + @sprites["corner3"].x = @x + @width - 16 + @sprites["corner3"].y = @y + @height - 16 + @sprites["side0"].x = @x + 16 + @sprites["side0"].y = @y + @sprites["side1"].x = @x + @sprites["side1"].y = @y + 16 + @sprites["side2"].x = @x + @width - 16 + @sprites["side2"].y = @y + 16 + @sprites["side3"].x = @x + 16 + @sprites["side3"].y = @y + @height - 16 + @sprites["scroll0"].x = @x + @width / 2 - 8 + @sprites["scroll0"].y = @y + 8 + @sprites["scroll1"].x = @x + 8 + @sprites["scroll1"].y = @y + @height / 2 - 8 + @sprites["scroll2"].x = @x + @width - 16 + @sprites["scroll2"].y = @y + @height / 2 - 8 + @sprites["scroll3"].x = @x + @width / 2 - 8 + @sprites["scroll3"].y = @y + @height - 16 + @sprites["back"].x = @x + 2 + @sprites["back"].y = @y + 2 + @sprites["cursor"].x = @x + 16 + @cursor_rect.x + @sprites["cursor"].y = @y + 16 + @cursor_rect.y if changeBitmap && @_windowskin && !@_windowskin.disposed? - width=@cursor_rect.width - height=@cursor_rect.height + width = @cursor_rect.width + height = @cursor_rect.height if width > 0 && height > 0 - cursorrects=[ + cursorrects = [ # sides - Rect.new(cursorX+2, cursorY+0, 28, 2), - Rect.new(cursorX+0, cursorY+2, 2, 28), - Rect.new(cursorX+30, cursorY+2, 2, 28), - Rect.new(cursorX+2, cursorY+30, 28, 2), + Rect.new(cursorX + 2, cursorY + 0, 28, 2), + Rect.new(cursorX + 0, cursorY + 2, 2, 28), + Rect.new(cursorX + 30, cursorY + 2, 2, 28), + Rect.new(cursorX + 2, cursorY + 30, 28, 2), # corners - Rect.new(cursorX+0, cursorY+0, 2, 2), - Rect.new(cursorX+30, cursorY+0, 2, 2), - Rect.new(cursorX+0, cursorY+30, 2, 2), - Rect.new(cursorX+30, cursorY+30, 2, 2), + Rect.new(cursorX + 0, cursorY + 0, 2, 2), + Rect.new(cursorX + 30, cursorY + 0, 2, 2), + Rect.new(cursorX + 0, cursorY + 30, 2, 2), + Rect.new(cursorX + 30, cursorY + 30, 2, 2), # back - Rect.new(cursorX+2, cursorY+2, 28, 28) + Rect.new(cursorX + 2, cursorY + 2, 28, 28) ] - margin=2 - fullmargin=4 + margin = 2 + fullmargin = 4 @cursorbitmap = ensureBitmap(@cursorbitmap, width, height) @cursorbitmap.clear - @sprites["cursor"].bitmap=@cursorbitmap - @sprites["cursor"].src_rect.set(0,0,width,height) - rect = Rect.new(margin,margin, + @sprites["cursor"].bitmap = @cursorbitmap + @sprites["cursor"].src_rect.set(0, 0, width, height) + rect = Rect.new(margin, margin, width - fullmargin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8]) @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4]) # top left - @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right - @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right - @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left + @cursorbitmap.blt(width - margin, 0, @_windowskin, cursorrects[5]) # top right + @cursorbitmap.blt(0, height - margin, @_windowskin, cursorrects[6]) # bottom right + @cursorbitmap.blt(width - margin, height - margin, @_windowskin, cursorrects[7]) # bottom left rect = Rect.new(margin, 0, width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0]) @@ -538,67 +538,67 @@ class Window rect = Rect.new(width - margin, margin, margin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2]) - rect = Rect.new(margin, height-margin, + rect = Rect.new(margin, height - margin, width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3]) else - @sprites["cursor"].visible=false - @sprites["cursor"].src_rect.set(0,0,0,0) + @sprites["cursor"].visible = false + @sprites["cursor"].src_rect.set(0, 0, 0, 0) end for i in 0...4 dwidth = [0, 3].include?(i) ? @width - 32 : 16 dheight = [0, 3].include?(i) ? 16 : @height - 32 - @sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight) - @sprites["side#{i}"].bitmap=@sidebitmaps[i] - @sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight) + @sidebitmaps[i] = ensureBitmap(@sidebitmaps[i], dwidth, dheight) + @sprites["side#{i}"].bitmap = @sidebitmaps[i] + @sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight) @sidebitmaps[i].clear - if sideRects[i].width>0 && sideRects[i].height>0 + if sideRects[i].width > 0 && sideRects[i].height > 0 @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect, - @_windowskin,sideRects[i]) + @_windowskin, sideRects[i]) end end - backwidth=@width-4 - backheight=@height-4 - if backwidth>0 && backheight>0 - @backbitmap=ensureBitmap(@backbitmap,backwidth,backheight) - @sprites["back"].bitmap=@backbitmap - @sprites["back"].src_rect.set(0,0,backwidth,backheight) + backwidth = @width - 4 + backheight = @height - 4 + if backwidth > 0 && backheight > 0 + @backbitmap = ensureBitmap(@backbitmap, backwidth, backheight) + @sprites["back"].bitmap = @backbitmap + @sprites["back"].src_rect.set(0, 0, backwidth, backheight) @backbitmap.clear if @stretch - @backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect) + @backbitmap.stretch_blt(@sprites["back"].src_rect, @_windowskin, backRect) else - tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect) + tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, backRect) end if blindsRect - tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect) + tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, blindsRect) end else - @sprites["back"].visible=false - @sprites["back"].src_rect.set(0,0,0,0) + @sprites["back"].visible = false + @sprites["back"].src_rect.set(0, 0, 0, 0) end end - if @openness!=255 - opn=@openness/255.0 + if @openness != 255 + opn = @openness / 255.0 for k in @spritekeys - sprite=@sprites[k] - ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height - sprite.zoom_y=opn - sprite.oy=0 - sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor + sprite = @sprites[k] + ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height + sprite.zoom_y = opn + sprite.oy = 0 + sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor end else for k in @spritekeys - sprite=@sprites[k] - sprite.zoom_y=1.0 + sprite = @sprites[k] + sprite.zoom_y = 1.0 end end - i=0 + i = 0 # Ensure Z order for k in @spritekeys - sprite=@sprites[k] - y=sprite.y - sprite.y=i - sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y + sprite = @sprites[k] + y = sprite.y + sprite.y = i + sprite.oy = (sprite.zoom_y <= 0) ? 0 : (i - y) / sprite.zoom_y end end end diff --git a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb index d49967aa2..481bc9406 100644 --- a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb +++ b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb @@ -48,65 +48,65 @@ class SpriteWindow < Window attr_reader :compat def compat=(value) - @compat=value + @compat = value privRefresh(true) end def initialize(viewport = nil) - @sprites={} - @spritekeys=[ + @sprites = {} + @spritekeys = [ "back", - "corner0","side0","scroll0", - "corner1","side1","scroll1", - "corner2","side2","scroll2", - "corner3","side3","scroll3", - "cursor","contents","pause" + "corner0", "side0", "scroll0", + "corner1", "side1", "scroll1", + "corner2", "side2", "scroll2", + "corner3", "side3", "scroll3", + "cursor", "contents", "pause" ] - @viewport=viewport - @sidebitmaps=[nil,nil,nil,nil] - @cursorbitmap=nil - @bgbitmap=nil + @viewport = viewport + @sidebitmaps = [nil, nil, nil, nil] + @cursorbitmap = nil + @bgbitmap = nil for i in @spritekeys - @sprites[i]=Sprite.new(@viewport) + @sprites[i] = Sprite.new(@viewport) end - @disposed=false - @tone=Tone.new(0,0,0) - @color=Color.new(0,0,0,0) - @blankcontents=Bitmap.new(1,1) # RGSS2 requires this - @contents=@blankcontents - @_windowskin=nil - @rpgvx=false - @compat=CompatBits::ExpandBack|CompatBits::StretchSides - @x=0 - @y=0 - @width=0 - @height=0 - @offset_x=0 - @offset_y=0 - @zoom_x=1.0 - @zoom_y=1.0 - @ox=0 - @oy=0 - @z=0 - @stretch=true - @visible=true - @active=true - @openness=255 - @opacity=255 - @back_opacity=255 - @blend_type=0 - @contents_blend_type=0 - @contents_opacity=255 - @cursor_rect=WindowCursorRect.new(self) - @cursorblink=0 - @cursoropacity=255 - @pause=false - @pauseframe=0 - @flash=0 - @pauseopacity=0 - @skinformat=0 - @skinrect=Rect.new(0,0,0,0) - @trim=[16,16,16,16] + @disposed = false + @tone = Tone.new(0, 0, 0) + @color = Color.new(0, 0, 0, 0) + @blankcontents = Bitmap.new(1, 1) # RGSS2 requires this + @contents = @blankcontents + @_windowskin = nil + @rpgvx = false + @compat = CompatBits::ExpandBack | CompatBits::StretchSides + @x = 0 + @y = 0 + @width = 0 + @height = 0 + @offset_x = 0 + @offset_y = 0 + @zoom_x = 1.0 + @zoom_y = 1.0 + @ox = 0 + @oy = 0 + @z = 0 + @stretch = true + @visible = true + @active = true + @openness = 255 + @opacity = 255 + @back_opacity = 255 + @blend_type = 0 + @contents_blend_type = 0 + @contents_opacity = 255 + @cursor_rect = WindowCursorRect.new(self) + @cursorblink = 0 + @cursoropacity = 255 + @pause = false + @pauseframe = 0 + @flash = 0 + @pauseopacity = 0 + @skinformat = 0 + @skinrect = Rect.new(0, 0, 0, 0) + @trim = [16, 16, 16, 16] privRefresh(true) end @@ -114,49 +114,49 @@ class SpriteWindow < Window if !self.disposed? for i in @sprites i[1].dispose if i[1] - @sprites[i[0]]=nil + @sprites[i[0]] = nil end for i in 0...@sidebitmaps.length @sidebitmaps[i].dispose if @sidebitmaps[i] - @sidebitmaps[i]=nil + @sidebitmaps[i] = nil end @blankcontents.dispose @cursorbitmap.dispose if @cursorbitmap @backbitmap.dispose if @backbitmap @sprites.clear @sidebitmaps.clear - @_windowskin=nil - @disposed=true + @_windowskin = nil + @disposed = true end end def stretch=(value) - @stretch=value + @stretch = value privRefresh(true) end def visible=(value) - @visible=value + @visible = value privRefresh end def viewport=(value) - @viewport=value + @viewport = value for i in @spritekeys @sprites[i].dispose if @sprites[i] end for i in @spritekeys if @sprites[i].is_a?(Sprite) - @sprites[i]=Sprite.new(@viewport) + @sprites[i] = Sprite.new(@viewport) else - @sprites[i]=nil + @sprites[i] = nil end end privRefresh(true) end def z=(value) - @z=value + @z = value privRefresh end @@ -165,28 +165,28 @@ class SpriteWindow < Window end def contents=(value) - if @contents!=value - @contents=value + if @contents != value + @contents = value privRefresh if @visible end end def ox=(value) - if @ox!=value - @ox=value + if @ox != value + @ox = value privRefresh if @visible end end def oy=(value) - if @oy!=value - @oy=value + if @oy != value + @oy = value privRefresh if @visible end end def active=(value) - @active=value + @active = value privRefresh(true) end @@ -194,136 +194,136 @@ class SpriteWindow < Window if !value @cursor_rect.empty else - @cursor_rect.set(value.x,value.y,value.width,value.height) + @cursor_rect.set(value.x, value.y, value.width, value.height) end end def openness=(value) - @openness=value - @openness=0 if @openness<0 - @openness=255 if @openness>255 + @openness = value + @openness = 0 if @openness < 0 + @openness = 255 if @openness > 255 privRefresh end def width=(value) - @width=value + @width = value privRefresh(true) end def height=(value) - @height=value + @height = value privRefresh(true) end def pause=(value) - @pause=value - @pauseopacity=0 if !value + @pause = value + @pauseopacity = 0 if !value privRefresh if @visible end def x=(value) - @x=value + @x = value privRefresh if @visible end def y=(value) - @y=value + @y = value privRefresh if @visible end def zoom_x=(value) - @zoom_x=value + @zoom_x = value privRefresh if @visible end def zoom_y=(value) - @zoom_y=value + @zoom_y = value privRefresh if @visible end def offset_x=(value) - @x=value + @x = value privRefresh if @visible end def offset_y=(value) - @y=value + @y = value privRefresh if @visible end def opacity=(value) - @opacity=value - @opacity=0 if @opacity<0 - @opacity=255 if @opacity>255 + @opacity = value + @opacity = 0 if @opacity < 0 + @opacity = 255 if @opacity > 255 privRefresh if @visible end def back_opacity=(value) - @back_opacity=value - @back_opacity=0 if @back_opacity<0 - @back_opacity=255 if @back_opacity>255 + @back_opacity = value + @back_opacity = 0 if @back_opacity < 0 + @back_opacity = 255 if @back_opacity > 255 privRefresh if @visible end def contents_opacity=(value) - @contents_opacity=value - @contents_opacity=0 if @contents_opacity<0 - @contents_opacity=255 if @contents_opacity>255 + @contents_opacity = value + @contents_opacity = 0 if @contents_opacity < 0 + @contents_opacity = 255 if @contents_opacity > 255 privRefresh if @visible end def tone=(value) - @tone=value + @tone = value privRefresh if @visible end def color=(value) - @color=value + @color = value privRefresh if @visible end def blend_type=(value) - @blend_type=value + @blend_type = value privRefresh if @visible end - def flash(color,duration) + def flash(color, duration) return if disposed? - @flash=duration+1 + @flash = duration + 1 for i in @sprites - i[1].flash(color,duration) + i[1].flash(color, duration) end end def update return if disposed? - mustchange=false + mustchange = false if @active - if @cursorblink==0 - @cursoropacity-=8 - @cursorblink=1 if @cursoropacity<=128 + if @cursorblink == 0 + @cursoropacity -= 8 + @cursorblink = 1 if @cursoropacity <= 128 else - @cursoropacity+=8 - @cursorblink=0 if @cursoropacity>=255 + @cursoropacity += 8 + @cursorblink = 0 if @cursoropacity >= 255 end privRefreshCursor else - @cursoropacity=128 + @cursoropacity = 128 privRefreshCursor end if @pause - oldpauseframe=@pauseframe - oldpauseopacity=@pauseopacity - @pauseframe=(Graphics.frame_count / 8) % 4 - @pauseopacity=[@pauseopacity+64,255].min - mustchange=@pauseframe!=oldpauseframe || @pauseopacity!=oldpauseopacity + oldpauseframe = @pauseframe + oldpauseopacity = @pauseopacity + @pauseframe = (Graphics.frame_count / 8) % 4 + @pauseopacity = [@pauseopacity + 64, 255].min + mustchange = @pauseframe != oldpauseframe || @pauseopacity != oldpauseopacity end privRefresh if mustchange - if @flash>0 + if @flash > 0 for i in @sprites.values i.update end - @flash-=1 + @flash -= 1 end end @@ -332,493 +332,493 @@ class SpriteWindow < Window attr_reader :skinrect def loadSkinFile(_file) - if (self.windowskin.width==80 || self.windowskin.width==96) && - self.windowskin.height==48 + if (self.windowskin.width == 80 || self.windowskin.width == 96) && + self.windowskin.height == 48 # Body = X, Y, width, height of body rectangle within windowskin - @skinrect.set(32,16,16,16) + @skinrect.set(32, 16, 16, 16) # Trim = X, Y, width, height of trim rectangle within windowskin - @trim=[32,16,16,16] - elsif self.windowskin.width==80 && self.windowskin.height==80 - @skinrect.set(32,32,16,16) - @trim=[32,16,16,48] + @trim = [32, 16, 16, 16] + elsif self.windowskin.width == 80 && self.windowskin.height == 80 + @skinrect.set(32, 32, 16, 16) + @trim = [32, 16, 16, 48] end end def windowskin=(value) - oldSkinWidth=(@_windowskin && !@_windowskin.disposed?) ? @_windowskin.width : -1 - oldSkinHeight=(@_windowskin && !@_windowskin.disposed?) ? @_windowskin.height : -1 - @_windowskin=value - if @skinformat==1 - @rpgvx=false + oldSkinWidth = (@_windowskin && !@_windowskin.disposed?) ? @_windowskin.width : -1 + oldSkinHeight = (@_windowskin && !@_windowskin.disposed?) ? @_windowskin.height : -1 + @_windowskin = value + if @skinformat == 1 + @rpgvx = false if @_windowskin && !@_windowskin.disposed? - if @_windowskin.width!=oldSkinWidth || @_windowskin.height!=oldSkinHeight + if @_windowskin.width != oldSkinWidth || @_windowskin.height != oldSkinHeight # Update skinrect and trim if windowskin's dimensions have changed - @skinrect.set((@_windowskin.width-16)/2,(@_windowskin.height-16)/2,16,16) - @trim=[@skinrect.x,@skinrect.y,@skinrect.x,@skinrect.y] + @skinrect.set((@_windowskin.width - 16) / 2, (@_windowskin.height - 16) / 2, 16, 16) + @trim = [@skinrect.x, @skinrect.y, @skinrect.x, @skinrect.y] end else - @skinrect.set(16,16,16,16) - @trim=[16,16,16,16] + @skinrect.set(16, 16, 16, 16) + @trim = [16, 16, 16, 16] end else - if value && value.is_a?(Bitmap) && !value.disposed? && value.width==128 - @rpgvx=true + if value && value.is_a?(Bitmap) && !value.disposed? && value.width == 128 + @rpgvx = true else - @rpgvx=false + @rpgvx = false end - @trim=[16,16,16,16] + @trim = [16, 16, 16, 16] end privRefresh(true) end def skinrect=(value) - @skinrect=value + @skinrect = value privRefresh end def skinformat=(value) - if @skinformat!=value - @skinformat=value + if @skinformat != value + @skinformat = value privRefresh(true) end end def borderX - return 32 if !@trim || skinformat==0 + return 32 if !@trim || skinformat == 0 if @_windowskin && !@_windowskin.disposed? - return @trim[0]+(@_windowskin.width-@trim[2]-@trim[0]) + return @trim[0] + (@_windowskin.width - @trim[2] - @trim[0]) end return 32 end def borderY - return 32 if !@trim || skinformat==0 + return 32 if !@trim || skinformat == 0 if @_windowskin && !@_windowskin.disposed? - return @trim[1]+(@_windowskin.height-@trim[3]-@trim[1]) + return @trim[1] + (@_windowskin.height - @trim[3] - @trim[1]) end return 32 end def leftEdge; self.startX; end def topEdge; self.startY; end - def rightEdge; self.borderX-self.leftEdge; end - def bottomEdge; self.borderY-self.topEdge; end + def rightEdge; self.borderX - self.leftEdge; end + def bottomEdge; self.borderY - self.topEdge; end def startX - return !@trim || skinformat==0 ? 16 : @trim[0] + return !@trim || skinformat == 0 ? 16 : @trim[0] end def startY - return !@trim || skinformat==0 ? 16 : @trim[1] + return !@trim || skinformat == 0 ? 16 : @trim[1] end def endX - return !@trim || skinformat==0 ? 16 : @trim[2] + return !@trim || skinformat == 0 ? 16 : @trim[2] end def endY - return !@trim || skinformat==0 ? 16 : @trim[3] + return !@trim || skinformat == 0 ? 16 : @trim[3] end def startX=(value) - @trim[0]=value + @trim[0] = value privRefresh end def startY=(value) - @trim[1]=value + @trim[1] = value privRefresh end def endX=(value) - @trim[2]=value + @trim[2] = value privRefresh end def endY=(value) - @trim[3]=value + @trim[3] = value privRefresh end ############# private - def ensureBitmap(bitmap,dwidth,dheight) - if !bitmap||bitmap.disposed?||bitmap.width0 && @skinformat==0 && !@rpgvx + if (@compat & CompatBits::CorrectZ) > 0 && @skinformat == 0 && !@rpgvx # Compatibility Mode: Cursor, pause, and contents have higher Z - @sprites["cursor"].z=@z+1 - @sprites["contents"].z=@z+2 - @sprites["pause"].z=@z+2 + @sprites["cursor"].z = @z + 1 + @sprites["contents"].z = @z + 2 + @sprites["pause"].z = @z + 2 end - if @skinformat==0 - startX=16 - startY=16 - endX=16 - endY=16 - trimStartX=16 - trimStartY=16 - trimWidth=32 - trimHeight=32 + if @skinformat == 0 + startX = 16 + startY = 16 + endX = 16 + endY = 16 + trimStartX = 16 + trimStartY = 16 + trimWidth = 32 + trimHeight = 32 if @rpgvx - trimX=64 - trimY=0 - backRect=Rect.new(0,0,64,64) - blindsRect=Rect.new(0,64,64,64) + trimX = 64 + trimY = 0 + backRect = Rect.new(0, 0, 64, 64) + blindsRect = Rect.new(0, 64, 64, 64) else - trimX=128 - trimY=0 - backRect=Rect.new(0,0,128,128) - blindsRect=nil + trimX = 128 + trimY = 0 + backRect = Rect.new(0, 0, 128, 128) + blindsRect = nil end if @_windowskin && !@_windowskin.disposed? - @sprites["corner0"].src_rect.set(trimX,trimY+0,16,16) - @sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16) - @sprites["corner2"].src_rect.set(trimX,trimY+48,16,16) - @sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16) - @sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up - @sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down - @sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left - @sprites["scroll2"].src_rect.set(trimX+40, trimY+24, 8, 16) # right - cursorX=trimX - cursorY=trimY+64 - sideRects=[ - Rect.new(trimX+16,trimY+0,32,16), - Rect.new(trimX,trimY+16,16,32), - Rect.new(trimX+48,trimY+16,16,32), - Rect.new(trimX+16,trimY+48,32,16) + @sprites["corner0"].src_rect.set(trimX, trimY + 0, 16, 16) + @sprites["corner1"].src_rect.set(trimX + 48, trimY + 0, 16, 16) + @sprites["corner2"].src_rect.set(trimX, trimY + 48, 16, 16) + @sprites["corner3"].src_rect.set(trimX + 48, trimY + 48, 16, 16) + @sprites["scroll0"].src_rect.set(trimX + 24, trimY + 16, 16, 8) # up + @sprites["scroll3"].src_rect.set(trimX + 24, trimY + 40, 16, 8) # down + @sprites["scroll1"].src_rect.set(trimX + 16, trimY + 24, 8, 16) # left + @sprites["scroll2"].src_rect.set(trimX + 40, trimY + 24, 8, 16) # right + cursorX = trimX + cursorY = trimY + 64 + sideRects = [ + Rect.new(trimX + 16, trimY + 0, 32, 16), + Rect.new(trimX, trimY + 16, 16, 32), + Rect.new(trimX + 48, trimY + 16, 16, 32), + Rect.new(trimX + 16, trimY + 48, 32, 16) ] - pauseRects=[ - trimX+32,trimY+64, - trimX+48,trimY+64, - trimX+32,trimY+80, - trimX+48,trimY+80, + pauseRects = [ + trimX + 32, trimY + 64, + trimX + 48, trimY + 64, + trimX + 32, trimY + 80, + trimX + 48, trimY + 80, ] - pauseWidth=16 - pauseHeight=16 + pauseWidth = 16 + pauseHeight = 16 @sprites["pause"].src_rect.set( - pauseRects[@pauseframe*2], - pauseRects[@pauseframe*2+1], - pauseWidth,pauseHeight + pauseRects[@pauseframe * 2], + pauseRects[@pauseframe * 2 + 1], + pauseWidth, pauseHeight ) end else - trimStartX=@trim[0] - trimStartY=@trim[1] - trimWidth=@trim[0]+(@skinrect.width-@trim[2]+@trim[0]) - trimHeight=@trim[1]+(@skinrect.height-@trim[3]+@trim[1]) + trimStartX = @trim[0] + trimStartY = @trim[1] + trimWidth = @trim[0] + (@skinrect.width - @trim[2] + @trim[0]) + trimHeight = @trim[1] + (@skinrect.height - @trim[3] + @trim[1]) if @_windowskin && !@_windowskin.disposed? # width of left end of window - startX=@skinrect.x + startX = @skinrect.x # width of top end of window - startY=@skinrect.y - cx=@skinrect.x+@skinrect.width # right side of BODY rect - cy=@skinrect.y+@skinrect.height # bottom side of BODY rect + startY = @skinrect.y + 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 - endX=(!@_windowskin || @_windowskin.disposed?) ? @skinrect.x : @_windowskin.width-cx + endX = (!@_windowskin || @_windowskin.disposed?) ? @skinrect.x : @_windowskin.width - cx # height of bottom end of window - endY=(!@_windowskin || @_windowskin.disposed?) ? @skinrect.y : @_windowskin.height-cy - @sprites["corner0"].src_rect.set(0,0,startX,startY) - @sprites["corner1"].src_rect.set(cx,0,endX,startY) - @sprites["corner2"].src_rect.set(0,cy,startX,endY) - @sprites["corner3"].src_rect.set(cx,cy,endX,endY) - backRect=Rect.new(@skinrect.x,@skinrect.y, - @skinrect.width,@skinrect.height) - blindsRect=nil - sideRects=[ - Rect.new(startX,0,@skinrect.width,startY), # side0 (top) - Rect.new(0,startY,startX,@skinrect.height), # side1 (left) - Rect.new(cx,startY,endX,@skinrect.height), # side2 (right) - Rect.new(startX,cy,@skinrect.width,endY) # side3 (bottom) + endY = (!@_windowskin || @_windowskin.disposed?) ? @skinrect.y : @_windowskin.height - cy + @sprites["corner0"].src_rect.set(0, 0, startX, startY) + @sprites["corner1"].src_rect.set(cx, 0, endX, startY) + @sprites["corner2"].src_rect.set(0, cy, startX, endY) + @sprites["corner3"].src_rect.set(cx, cy, endX, endY) + backRect = Rect.new(@skinrect.x, @skinrect.y, + @skinrect.width, @skinrect.height) + blindsRect = nil + sideRects = [ + Rect.new(startX, 0, @skinrect.width, startY), # side0 (top) + Rect.new(0, startY, startX, @skinrect.height), # side1 (left) + Rect.new(cx, startY, endX, @skinrect.height), # side2 (right) + Rect.new(startX, cy, @skinrect.width, endY) # side3 (bottom) ] end end - if @width>trimWidth && @height>trimHeight - @sprites["contents"].src_rect.set(@ox,@oy,@width-trimWidth,@height-trimHeight) + if @width > trimWidth && @height > trimHeight + @sprites["contents"].src_rect.set(@ox, @oy, @width - trimWidth, @height - trimHeight) else - @sprites["contents"].src_rect.set(0,0,0,0) + @sprites["contents"].src_rect.set(0, 0, 0, 0) end - @sprites["contents"].x=@x+trimStartX - @sprites["contents"].y=@y+trimStartY - if (@compat & CompatBits::ShowScrollArrows)>0 && @skinformat==0 + @sprites["contents"].x = @x + trimStartX + @sprites["contents"].y = @y + trimStartY + if (@compat & CompatBits::ShowScrollArrows) > 0 && @skinformat == 0 # Compatibility mode: Make scroll arrows visible - if @skinformat==0 && @_windowskin && !@_windowskin.disposed? && + if @skinformat == 0 && @_windowskin && !@_windowskin.disposed? && @contents && !@contents.disposed? @sprites["scroll0"].visible = @visible && hascontents && @oy > 0 @sprites["scroll1"].visible = @visible && hascontents && @ox > 0 - @sprites["scroll2"].visible = @visible && (@contents.width - @ox) > @width-trimWidth - @sprites["scroll3"].visible = @visible && (@contents.height - @oy) > @height-trimHeight + @sprites["scroll2"].visible = @visible && (@contents.width - @ox) > @width - trimWidth + @sprites["scroll3"].visible = @visible && (@contents.height - @oy) > @height - trimHeight end end if @_windowskin && !@_windowskin.disposed? - borderX=startX+endX - borderY=startY+endY - @sprites["corner0"].x=@x - @sprites["corner0"].y=@y - @sprites["corner1"].x=@x+@width-endX - @sprites["corner1"].y=@y - @sprites["corner2"].x=@x - @sprites["corner2"].y=@y+@height-endY - @sprites["corner3"].x=@x+@width-endX - @sprites["corner3"].y=@y+@height-endY - @sprites["side0"].x=@x+startX - @sprites["side0"].y=@y - @sprites["side1"].x=@x - @sprites["side1"].y=@y+startY - @sprites["side2"].x=@x+@width-endX - @sprites["side2"].y=@y+startY - @sprites["side3"].x=@x+startX - @sprites["side3"].y=@y+@height-endY - @sprites["scroll0"].x = @x+@width / 2 - 8 - @sprites["scroll0"].y = @y+8 - @sprites["scroll1"].x = @x+8 - @sprites["scroll1"].y = @y+@height / 2 - 8 - @sprites["scroll2"].x = @x+@width - 16 - @sprites["scroll2"].y = @y+@height / 2 - 8 - @sprites["scroll3"].x = @x+@width / 2 - 8 - @sprites["scroll3"].y = @y+@height - 16 - @sprites["cursor"].x=@x+startX+@cursor_rect.x - @sprites["cursor"].y=@y+startY+@cursor_rect.y - if (@compat & CompatBits::ExpandBack)>0 && @skinformat==0 + borderX = startX + endX + borderY = startY + endY + @sprites["corner0"].x = @x + @sprites["corner0"].y = @y + @sprites["corner1"].x = @x + @width - endX + @sprites["corner1"].y = @y + @sprites["corner2"].x = @x + @sprites["corner2"].y = @y + @height - endY + @sprites["corner3"].x = @x + @width - endX + @sprites["corner3"].y = @y + @height - endY + @sprites["side0"].x = @x + startX + @sprites["side0"].y = @y + @sprites["side1"].x = @x + @sprites["side1"].y = @y + startY + @sprites["side2"].x = @x + @width - endX + @sprites["side2"].y = @y + startY + @sprites["side3"].x = @x + startX + @sprites["side3"].y = @y + @height - endY + @sprites["scroll0"].x = @x + @width / 2 - 8 + @sprites["scroll0"].y = @y + 8 + @sprites["scroll1"].x = @x + 8 + @sprites["scroll1"].y = @y + @height / 2 - 8 + @sprites["scroll2"].x = @x + @width - 16 + @sprites["scroll2"].y = @y + @height / 2 - 8 + @sprites["scroll3"].x = @x + @width / 2 - 8 + @sprites["scroll3"].y = @y + @height - 16 + @sprites["cursor"].x = @x + startX + @cursor_rect.x + @sprites["cursor"].y = @y + startY + @cursor_rect.y + if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0 # Compatibility mode: Expand background - @sprites["back"].x=@x+2 - @sprites["back"].y=@y+2 + @sprites["back"].x = @x + 2 + @sprites["back"].y = @y + 2 else - @sprites["back"].x=@x+startX - @sprites["back"].y=@y+startY + @sprites["back"].x = @x + startX + @sprites["back"].y = @y + startY end end if changeBitmap && @_windowskin && !@_windowskin.disposed? - if @skinformat==0 - @sprites["cursor"].x=@x+startX+@cursor_rect.x - @sprites["cursor"].y=@y+startY+@cursor_rect.y - width=@cursor_rect.width - height=@cursor_rect.height + if @skinformat == 0 + @sprites["cursor"].x = @x + startX + @cursor_rect.x + @sprites["cursor"].y = @y + startY + @cursor_rect.y + width = @cursor_rect.width + height = @cursor_rect.height if width > 0 && height > 0 - cursorrects=[ + cursorrects = [ # sides - Rect.new(cursorX+2, cursorY+0, 28, 2), - Rect.new(cursorX+0, cursorY+2, 2, 28), - Rect.new(cursorX+30, cursorY+2, 2, 28), - Rect.new(cursorX+2, cursorY+30, 28, 2), + Rect.new(cursorX + 2, cursorY + 0, 28, 2), + Rect.new(cursorX + 0, cursorY + 2, 2, 28), + Rect.new(cursorX + 30, cursorY + 2, 2, 28), + Rect.new(cursorX + 2, cursorY + 30, 28, 2), # corners - Rect.new(cursorX+0, cursorY+0, 2, 2), - Rect.new(cursorX+30, cursorY+0, 2, 2), - Rect.new(cursorX+0, cursorY+30, 2, 2), - Rect.new(cursorX+30, cursorY+30, 2, 2), + Rect.new(cursorX + 0, cursorY + 0, 2, 2), + Rect.new(cursorX + 30, cursorY + 0, 2, 2), + Rect.new(cursorX + 0, cursorY + 30, 2, 2), + Rect.new(cursorX + 30, cursorY + 30, 2, 2), # back - Rect.new(cursorX+2, cursorY+2, 28, 28) + Rect.new(cursorX + 2, cursorY + 2, 28, 28) ] - margin=2 - fullmargin=4 + margin = 2 + fullmargin = 4 @cursorbitmap = ensureBitmap(@cursorbitmap, width, height) @cursorbitmap.clear - @sprites["cursor"].bitmap=@cursorbitmap - @sprites["cursor"].src_rect.set(0,0,width,height) - rect = Rect.new(margin,margin,width - fullmargin, height - fullmargin) + @sprites["cursor"].bitmap = @cursorbitmap + @sprites["cursor"].src_rect.set(0, 0, width, height) + rect = Rect.new(margin, margin, width - fullmargin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8]) @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4]) # top left - @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right - @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right - @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left - rect = Rect.new(margin, 0,width - fullmargin, margin) + @cursorbitmap.blt(width - margin, 0, @_windowskin, cursorrects[5]) # top right + @cursorbitmap.blt(0, height - margin, @_windowskin, cursorrects[6]) # bottom right + @cursorbitmap.blt(width - margin, height - margin, @_windowskin, cursorrects[7]) # bottom left + rect = Rect.new(margin, 0, width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0]) - rect = Rect.new(0, margin,margin, height - fullmargin) + rect = Rect.new(0, margin, margin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[1]) rect = Rect.new(width - margin, margin, margin, height - fullmargin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2]) - rect = Rect.new(margin, height-margin, width - fullmargin, margin) + rect = Rect.new(margin, height - margin, width - fullmargin, margin) @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3]) else - @sprites["cursor"].visible=false - @sprites["cursor"].src_rect.set(0,0,0,0) + @sprites["cursor"].visible = false + @sprites["cursor"].src_rect.set(0, 0, 0, 0) end end for i in 0..3 case i when 0 - dwidth = @width-startX-endX + dwidth = @width - startX - endX dheight = startY when 1 dwidth = startX - dheight = @height-startY-endY + dheight = @height - startY - endY when 2 dwidth = endX - dheight = @height-startY-endY + dheight = @height - startY - endY when 3 - dwidth = @width-startX-endX + dwidth = @width - startX - endX dheight = endY end - @sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight) - @sprites["side#{i}"].bitmap=@sidebitmaps[i] - @sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight) + @sidebitmaps[i] = ensureBitmap(@sidebitmaps[i], dwidth, dheight) + @sprites["side#{i}"].bitmap = @sidebitmaps[i] + @sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight) @sidebitmaps[i].clear - if sideRects[i].width>0 && sideRects[i].height>0 - if (@compat & CompatBits::StretchSides)>0 && @skinformat==0 + if sideRects[i].width > 0 && sideRects[i].height > 0 + if (@compat & CompatBits::StretchSides) > 0 && @skinformat == 0 # Compatibility mode: Stretch sides @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect, - @_windowskin,sideRects[i]) + @_windowskin, sideRects[i]) else - tileBitmap(@sidebitmaps[i],@sprites["side#{i}"].src_rect, - @_windowskin,sideRects[i]) + tileBitmap(@sidebitmaps[i], @sprites["side#{i}"].src_rect, + @_windowskin, sideRects[i]) end end end - if (@compat & CompatBits::ExpandBack)>0 && @skinformat==0 + if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0 # Compatibility mode: Expand background - backwidth=@width-4 - backheight=@height-4 + backwidth = @width - 4 + backheight = @height - 4 else - backwidth=@width-borderX - backheight=@height-borderY + backwidth = @width - borderX + backheight = @height - borderY end - if backwidth>0 && backheight>0 - @backbitmap=ensureBitmap(@backbitmap,backwidth,backheight) - @sprites["back"].bitmap=@backbitmap - @sprites["back"].src_rect.set(0,0,backwidth,backheight) + if backwidth > 0 && backheight > 0 + @backbitmap = ensureBitmap(@backbitmap, backwidth, backheight) + @sprites["back"].bitmap = @backbitmap + @sprites["back"].src_rect.set(0, 0, backwidth, backheight) @backbitmap.clear if @stretch - @backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect) + @backbitmap.stretch_blt(@sprites["back"].src_rect, @_windowskin, backRect) else - tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect) + tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, backRect) end if blindsRect - tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect) + tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, blindsRect) end else - @sprites["back"].visible=false - @sprites["back"].src_rect.set(0,0,0,0) + @sprites["back"].visible = false + @sprites["back"].src_rect.set(0, 0, 0, 0) end end - if @openness!=255 - opn=@openness/255.0 + if @openness != 255 + opn = @openness / 255.0 for k in @spritekeys - sprite=@sprites[k] - ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height - sprite.zoom_y=opn - sprite.zoom_x=1.0 - sprite.oy=0 - sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor + sprite = @sprites[k] + ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height + sprite.zoom_y = opn + sprite.zoom_x = 1.0 + sprite.oy = 0 + sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor end else for k in @spritekeys - sprite=@sprites[k] - sprite.zoom_x=1.0 - sprite.zoom_y=1.0 + sprite = @sprites[k] + sprite.zoom_x = 1.0 + sprite.zoom_y = 1.0 end end - i=0 + i = 0 # Ensure Z order for k in @spritekeys - sprite=@sprites[k] - y=sprite.y - sprite.y=i - sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y - sprite.zoom_x*=@zoom_x - sprite.zoom_y*=@zoom_y - sprite.x*=@zoom_x - sprite.y*=@zoom_y - sprite.x+=(@offset_x/sprite.zoom_x) - sprite.y+=(@offset_y/sprite.zoom_y) + sprite = @sprites[k] + y = sprite.y + sprite.y = i + sprite.oy = (sprite.zoom_y <= 0) ? 0 : (i - y) / sprite.zoom_y + sprite.zoom_x *= @zoom_x + sprite.zoom_y *= @zoom_y + sprite.x *= @zoom_x + sprite.y *= @zoom_y + sprite.x += (@offset_x / sprite.zoom_x) + sprite.y += (@offset_y / sprite.zoom_y) end end end @@ -829,7 +829,7 @@ end # #=============================================================================== class SpriteWindow_Base < SpriteWindow - TEXTPADDING=4 # In pixels + TEXTPADDING = 4 # In pixels def initialize(x, y, width, height) super() @@ -838,53 +838,53 @@ class SpriteWindow_Base < SpriteWindow self.width = width self.height = height self.z = 100 - @curframe=MessageConfig.pbGetSystemFrame() - @curfont=MessageConfig.pbGetSystemFontName() - @sysframe=AnimatedBitmap.new(@curframe) + @curframe = MessageConfig.pbGetSystemFrame() + @curfont = MessageConfig.pbGetSystemFontName() + @sysframe = AnimatedBitmap.new(@curframe) RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty? - @customskin=nil + @customskin = nil __setWindowskin(@sysframe.bitmap) __resolveSystemFrame() pbSetSystemFont(self.contents) if self.contents end def __setWindowskin(skin) - if skin && (skin.width==192 && skin.height==128) || # RPGXP Windowskin - (skin.width==128 && skin.height==128) # RPGVX Windowskin - self.skinformat=0 + if skin && (skin.width == 192 && skin.height == 128) || # RPGXP Windowskin + (skin.width == 128 && skin.height == 128) # RPGVX Windowskin + self.skinformat = 0 else - self.skinformat=1 + self.skinformat = 1 end - self.windowskin=skin + self.windowskin = skin end def __resolveSystemFrame - if self.skinformat==1 + if self.skinformat == 1 if !@resolvedFrame - @resolvedFrame=MessageConfig.pbGetSystemFrame() - @resolvedFrame.sub!(/\.[^\.\/\\]+$/,"") + @resolvedFrame = MessageConfig.pbGetSystemFrame() + @resolvedFrame.sub!(/\.[^\.\/\\]+$/, "") end - self.loadSkinFile("#{@resolvedFrame}.txt") if @resolvedFrame!="" + self.loadSkinFile("#{@resolvedFrame}.txt") if @resolvedFrame != "" end end def setSkin(skin) # Filename of windowskin to apply. Supports XP, VX, and animated skins. @customskin.dispose if @customskin - @customskin=nil - resolvedName=pbResolveBitmap(skin) + @customskin = nil + resolvedName = pbResolveBitmap(skin) return if nil_or_empty?(resolvedName) - @customskin=AnimatedBitmap.new(resolvedName) + @customskin = AnimatedBitmap.new(resolvedName) RPG::Cache.retain(resolvedName) __setWindowskin(@customskin.bitmap) - if self.skinformat==1 - skinbase=resolvedName.sub(/\.[^\.\/\\]+$/,"") + if self.skinformat == 1 + skinbase = resolvedName.sub(/\.[^\.\/\\]+$/, "") self.loadSkinFile("#{skinbase}.txt") end end def setSystemFrame @customskin.dispose if @customskin - @customskin=nil + @customskin = nil __setWindowskin(@sysframe.bitmap) __resolveSystemFrame() end @@ -893,24 +893,24 @@ class SpriteWindow_Base < SpriteWindow super if self.windowskin if @customskin - if @customskin.totalFrames>1 + if @customskin.totalFrames > 1 @customskin.update __setWindowskin(@customskin.bitmap) end elsif @sysframe - if @sysframe.totalFrames>1 + if @sysframe.totalFrames > 1 @sysframe.update __setWindowskin(@sysframe.bitmap) end end end - if @curframe!=MessageConfig.pbGetSystemFrame() - @curframe=MessageConfig.pbGetSystemFrame() + if @curframe != MessageConfig.pbGetSystemFrame() + @curframe = MessageConfig.pbGetSystemFrame() if @sysframe && !@customskin @sysframe.dispose if @sysframe - @sysframe=AnimatedBitmap.new(@curframe) + @sysframe = AnimatedBitmap.new(@curframe) RPG::Cache.retain(@curframe) if @curframe && !@curframe.empty? - @resolvedFrame=nil + @resolvedFrame = nil __setWindowskin(@sysframe.bitmap) __resolveSystemFrame() end @@ -919,8 +919,8 @@ class SpriteWindow_Base < SpriteWindow rescue NoMethodError end end - if @curfont!=MessageConfig.pbGetSystemFontName() - @curfont=MessageConfig.pbGetSystemFontName() + if @curfont != MessageConfig.pbGetSystemFontName() + @curfont = MessageConfig.pbGetSystemFontName() if self.contents && !self.contents.disposed? pbSetSystemFont(self.contents) end diff --git a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb index 6ae8c6c74..d8ce3d931 100644 --- a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb +++ b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb @@ -11,65 +11,65 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base attr_accessor :letterbyletter def text=(value) - @text=value + @text = value refresh end def baseColor=(value) - @baseColor=value + @baseColor = value refresh end def shadowColor=(value) - @shadowColor=value + @shadowColor = value refresh end def initialize(text = "") - super(0,0,33,33) - self.contents=Bitmap.new(1,1) + super(0, 0, 33, 33) + self.contents = Bitmap.new(1, 1) pbSetSystemFont(self.contents) - @text=text - @letterbyletter=false # Not supported in this class - colors=getDefaultTextColors(self.windowskin) - @baseColor=colors[0] - @shadowColor=colors[1] + @text = text + @letterbyletter = false # Not supported in this class + colors = getDefaultTextColors(self.windowskin) + @baseColor = colors[0] + @shadowColor = colors[1] resizeToFit(text) end - def self.newWithSize(text,x,y,width,height,viewport = nil) - ret=self.new(text) - ret.x=x - ret.y=y - ret.width=width - ret.height=height - ret.viewport=viewport + def self.newWithSize(text, x, y, width, height, viewport = nil) + ret = self.new(text) + ret.x = x + ret.y = y + ret.width = width + ret.height = height + ret.viewport = viewport ret.refresh return ret end - def resizeToFitInternal(text,maxwidth) # maxwidth is maximum acceptable window width - dims=[0,0] - cwidth=maxwidth<0 ? Graphics.width : maxwidth - getLineBrokenChunks(self.contents,text, - cwidth-self.borderX-SpriteWindow_Base::TEXTPADDING,dims,true) + def resizeToFitInternal(text, maxwidth) # maxwidth is maximum acceptable window width + dims = [0, 0] + cwidth = maxwidth < 0 ? Graphics.width : maxwidth + getLineBrokenChunks(self.contents, text, + cwidth - self.borderX - SpriteWindow_Base::TEXTPADDING, dims, true) return dims end - def setTextToFit(text,maxwidth = -1) - resizeToFit(text,maxwidth) - self.text=text + def setTextToFit(text, maxwidth = -1) + resizeToFit(text, maxwidth) + self.text = text end def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width - dims = resizeToFitInternal(text,maxwidth) + dims = resizeToFitInternal(text, maxwidth) self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING self.height = dims[1] + self.borderY refresh end def resizeHeightToFit(text, width = -1) # width is current window width - dims = resizeToFitInternal(text,width) + dims = resizeToFitInternal(text, width) self.width = (width < 0) ? Graphics.width : width self.height = dims[1] + self.borderY refresh @@ -89,20 +89,20 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base colors = getDefaultTextColors(self.windowskin) @baseColor = colors[0] @shadowColor = colors[1] - if oldbaser!=@baseColor.red || oldbaseg!=@baseColor.green || - oldbaseb!=@baseColor.blue || oldbasea!=@baseColor.alpha || - oldshadowr!=@shadowColor.red || oldshadowg!=@shadowColor.green || - oldshadowb!=@shadowColor.blue || oldshadowa!=@shadowColor.alpha + if oldbaser != @baseColor.red || oldbaseg != @baseColor.green || + oldbaseb != @baseColor.blue || oldbasea != @baseColor.alpha || + oldshadowr != @shadowColor.red || oldshadowg != @shadowColor.green || + oldshadowb != @shadowColor.blue || oldshadowa != @shadowColor.alpha self.text = self.text end end def refresh - self.contents=pbDoEnsureBitmap(self.contents,self.width-self.borderX, - self.height-self.borderY) + self.contents = pbDoEnsureBitmap(self.contents, self.width - self.borderX, + self.height - self.borderY) self.contents.clear - drawTextEx(self.contents,0,4,self.contents.width,0, - @text.gsub(/\r/,""),@baseColor,@shadowColor) + drawTextEx(self.contents, 0, 4, self.contents.width, 0, + @text.gsub(/\r/, ""), @baseColor, @shadowColor) end end @@ -135,12 +135,12 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base @fmtchars = [] @frameskipChanged = false @frameskip = MessageConfig.pbGetTextSpeed - super(0,0,33,33) + super(0, 0, 33, 33) @pausesprite = nil @text = "" - self.contents = Bitmap.new(1,1) + self.contents = Bitmap.new(1, 1) pbSetSystemFont(self.contents) - self.resizeToFit(text,Graphics.width) + self.resizeToFit(text, Graphics.width) colors = getDefaultTextColors(self.windowskin) @baseColor = colors[0] @shadowColor = colors[1] @@ -148,7 +148,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base @starting = false end - def self.newWithSize(text,x,y,width,height,viewport = nil) + def self.newWithSize(text, x, y, width, height, viewport = nil) ret = self.new(text) ret.x = x ret.y = y @@ -166,7 +166,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base end def waitcount=(value) - @waitcount = (value<=0) ? 0 : value + @waitcount = (value <= 0) ? 0 : value end attr_reader :cursorMode @@ -196,7 +196,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base end def textspeed=(value) - @frameskipChanged = true if @frameskip!=value + @frameskipChanged = true if @frameskip != value @frameskip = value end @@ -210,40 +210,40 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base self.text = self.text if !@starting end - def resizeToFit(text,maxwidth = -1) - dims = resizeToFitInternal(text,maxwidth) + def resizeToFit(text, maxwidth = -1) + dims = resizeToFitInternal(text, maxwidth) oldstarting = @starting @starting = true - self.width = dims[0]+self.borderX+SpriteWindow_Base::TEXTPADDING - self.height = dims[1]+self.borderY + self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING + self.height = dims[1] + self.borderY @starting = oldstarting redrawText end - def resizeToFit2(text,maxwidth,maxheight) - dims = resizeToFitInternal(text,maxwidth) + def resizeToFit2(text, maxwidth, maxheight) + dims = resizeToFitInternal(text, maxwidth) oldstarting = @starting @starting = true - self.width = [dims[0]+self.borderX+SpriteWindow_Base::TEXTPADDING,maxwidth].min - self.height = [dims[1]+self.borderY,maxheight].min + self.width = [dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING, maxwidth].min + self.height = [dims[1] + self.borderY, maxheight].min @starting = oldstarting redrawText end - def resizeToFitInternal(text,maxwidth) - dims = [0,0] - cwidth = (maxwidth<0) ? Graphics.width : maxwidth - chars = getFormattedTextForDims(self.contents,0,0, - cwidth-self.borderX-2-6,-1,text,@lineHeight,true) + def resizeToFitInternal(text, maxwidth) + dims = [0, 0] + cwidth = (maxwidth < 0) ? Graphics.width : maxwidth + chars = getFormattedTextForDims(self.contents, 0, 0, + cwidth - self.borderX - 2 - 6, -1, text, @lineHeight, true) for ch in chars - dims[0] = [dims[0],ch[1]+ch[3]].max - dims[1] = [dims[1],ch[2]+ch[4]].max + dims[0] = [dims[0], ch[1] + ch[3]].max + dims[1] = [dims[1], ch[2] + ch[4]].max end return dims end - def resizeHeightToFit(text,width = -1) - dims = resizeToFitInternal(text,width) + def resizeHeightToFit(text, width = -1) + dims = resizeToFitInternal(text, width) oldstarting = @starting @starting = true self.width = (width < 0) ? Graphics.width : width @@ -252,7 +252,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base redrawText end - def setSkin(skin,redrawText = true) + def setSkin(skin, redrawText = true) super(skin) privRefresh(true) oldbaser = @baseColor.red @@ -267,16 +267,16 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base @baseColor = colors[0] @shadowColor = colors[1] if redrawText && - (oldbaser!=@baseColor.red || oldbaseg!=@baseColor.green || - oldbaseb!=@baseColor.blue || oldbasea!=@baseColor.alpha || - oldshadowr!=@shadowColor.red || oldshadowg!=@shadowColor.green || - oldshadowb!=@shadowColor.blue || oldshadowa!=@shadowColor.alpha) + (oldbaser != @baseColor.red || oldbaseg != @baseColor.green || + oldbaseb != @baseColor.blue || oldbasea != @baseColor.alpha || + oldshadowr != @shadowColor.red || oldshadowg != @shadowColor.green || + oldshadowb != @shadowColor.blue || oldshadowa != @shadowColor.alpha) setText(self.text) end end - def setTextToFit(text,maxwidth = -1) - resizeToFit(text,maxwidth) + def setTextToFit(text, maxwidth = -1) + resizeToFit(text, maxwidth) self.text = text end @@ -299,8 +299,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base width = 1 height = 1 numlines = 0 - visiblelines = (self.height-self.borderY)/32 - if value.length==0 + visiblelines = (self.height - self.borderY) / 32 + if value.length == 0 @fmtchars = [] @bitmapwidth = width @bitmapheight = height @@ -308,19 +308,19 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base else if @letterbyletter @fmtchars = [] - fmt = getFormattedText(self.contents,0,0, - self.width-self.borderX-SpriteWindow_Base::TEXTPADDING,-1, - shadowctag(@baseColor,@shadowColor)+value,32,true) + fmt = getFormattedText(self.contents, 0, 0, + self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1, + shadowctag(@baseColor, @shadowColor) + value, 32, true) @oldfont = self.contents.font.clone for ch in fmt - chx = ch[1]+ch[3] - chy = ch[2]+ch[4] - width = chx if width=visiblelines + if numlines >= visiblelines fclone = ch.clone fclone[0] = "\1" @fmtchars.push(fclone) @@ -329,22 +329,22 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base end # Don't add newline characters, since they # can slow down letter-by-letter display - if ch[5] || (ch[0]!="\r") + if ch[5] || (ch[0] != "\r") @fmtchars.push(ch) @textchars.push(ch[5] ? "" : ch[0]) end end fmt.clear else - @fmtchars = getFormattedText(self.contents,0,0, - self.width-self.borderX-SpriteWindow_Base::TEXTPADDING,-1, - shadowctag(@baseColor,@shadowColor)+value,32,true) + @fmtchars = getFormattedText(self.contents, 0, 0, + self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1, + shadowctag(@baseColor, @shadowColor) + value, 32, true) @oldfont = self.contents.font.clone for ch in @fmtchars - chx = ch[1]+ch[3] - chy = ch[2]+ch[4] - width = chx if width=@fmtchars.length + return 0 if @lastDrawnChar < 0 + return @numtextchars if @lastDrawnChar >= @fmtchars.length # index after the last character's index - return @fmtchars[@lastDrawnChar][14]+1 + return @fmtchars[@lastDrawnChar][14] + 1 end def maxPosition pos = 0 for ch in @fmtchars # index after the last character's index - pos = ch[14]+1 if pos=@fmtchars.length # End of message - if @textchars[@curchar]=="\1" # Pause message - @pausing = true if @curchar<@numtextchars-1 + break if @curchar >= @fmtchars.length # End of message + if @textchars[@curchar] == "\1" # Pause message + @pausing = true if @curchar < @numtextchars - 1 self.startPause refresh break end - break if @textchars[@curchar]!="\n" # Skip past newlines only - break if @linesdrawn>=visiblelines-1 # No more empty lines to continue to + break if @textchars[@curchar] != "\n" # Skip past newlines only + break if @linesdrawn >= visiblelines - 1 # No more empty lines to continue to @linesdrawn += 1 end end def allocPause return if @pausesprite - @pausesprite = AnimatedSprite.create("Graphics/Pictures/pause",4,3) + @pausesprite = AnimatedSprite.create("Graphics/Pictures/pause", 4, 3) @pausesprite.z = 100000 @pausesprite.visible = false end @@ -441,31 +441,31 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base def moveCursor return if !@pausesprite cursor = @cursorMode - cursor = 2 if cursor==0 && !@endOfText + cursor = 2 if cursor == 0 && !@endOfText case cursor when 0 # End of text - @pausesprite.x = self.x+self.startX+@endOfText.x+@endOfText.width-2 - @pausesprite.y = self.y+self.startY+@endOfText.y-@scrollY + @pausesprite.x = self.x + self.startX + @endOfText.x + @endOfText.width - 2 + @pausesprite.y = self.y + self.startY + @endOfText.y - @scrollY when 1 # Lower right pauseWidth = @pausesprite.bitmap ? @pausesprite.framewidth : 16 pauseHeight = @pausesprite.bitmap ? @pausesprite.frameheight : 16 - @pausesprite.x = self.x+self.width-(20*2)+(pauseWidth/2) - @pausesprite.y = self.y+self.height-(30*2)+(pauseHeight/2) + @pausesprite.x = self.x + self.width - (20 * 2) + (pauseWidth / 2) + @pausesprite.y = self.y + self.height - (30 * 2) + (pauseHeight / 2) when 2 # Lower middle pauseWidth = @pausesprite.bitmap ? @pausesprite.framewidth : 16 pauseHeight = @pausesprite.bitmap ? @pausesprite.frameheight : 16 - @pausesprite.x = self.x+(self.width/2)-(pauseWidth/2) - @pausesprite.y = self.y+self.height-(18*2)+(pauseHeight/2) + @pausesprite.x = self.x + (self.width / 2) - (pauseWidth / 2) + @pausesprite.y = self.y + self.height - (18 * 2) + (pauseHeight / 2) end end def refresh oldcontents = self.contents - self.contents = pbDoEnsureBitmap(oldcontents,@bitmapwidth,@bitmapheight) + self.contents = pbDoEnsureBitmap(oldcontents, @bitmapwidth, @bitmapheight) self.oy = @scrollY numchars = @numtextchars - numchars = [@curchar,@numtextchars].min if self.letterbyletter - return if busy? && @drawncurchar==@curchar && @scrollstate==0 + numchars = [@curchar, @numtextchars].min if self.letterbyletter + return if busy? && @drawncurchar == @curchar && @scrollstate == 0 if !self.letterbyletter || !oldcontents.equal?(self.contents) @drawncurchar = -1 @needclear = true @@ -479,31 +479,31 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base @nodraw = false return end - maxX = self.width-self.borderX - maxY = self.height-self.borderY - for i in @drawncurchar+1..numchars - next if i>=@fmtchars.length + maxX = self.width - self.borderX + maxY = self.height - self.borderY + for i in @drawncurchar + 1..numchars + next if i >= @fmtchars.length if !self.letterbyletter - next if @fmtchars[i][1]>=maxX - next if @fmtchars[i][2]>=maxY + next if @fmtchars[i][1] >= maxX + next if @fmtchars[i][2] >= maxY end - drawSingleFormattedChar(self.contents,@fmtchars[i]) + drawSingleFormattedChar(self.contents, @fmtchars[i]) @lastDrawnChar = i end if !self.letterbyletter # all characters were drawn, reset old font self.contents.font = @oldfont if @oldfont end - if numchars>0 && numchars!=@numtextchars - fch = @fmtchars[numchars-1] + if numchars > 0 && numchars != @numtextchars + fch = @fmtchars[numchars - 1] if fch - rcdst = Rect.new(fch[1],fch[2],fch[3],fch[4]) - if @textchars[numchars]=="\1" + rcdst = Rect.new(fch[1], fch[2], fch[3], fch[4]) + if @textchars[numchars] == "\1" @endOfText = rcdst allocPause moveCursor else - @endOfText = Rect.new(rcdst.x+rcdst.width,rcdst.y,8,1) + @endOfText = Rect.new(rcdst.x + rcdst.width, rcdst.y, 8, 1) end end end @@ -514,8 +514,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base if @letterbyletter oldPosition = self.position self.text = self.text - oldPosition = @numtextchars if oldPosition>@numtextchars - while self.position!=oldPosition + oldPosition = @numtextchars if oldPosition > @numtextchars + while self.position != oldPosition refresh updateInternal end @@ -525,47 +525,47 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base end def updateInternal - curcharskip = @frameskip<0 ? @frameskip.abs : 1 - visiblelines = (self.height-self.borderY)/@lineHeight - if @textchars[@curchar]=="\1" + curcharskip = @frameskip < 0 ? @frameskip.abs : 1 + visiblelines = (self.height - self.borderY) / @lineHeight + if @textchars[@curchar] == "\1" if !@pausing @realframes += 1 - if @realframes>=@frameskip || @frameskip<0 + if @realframes >= @frameskip || @frameskip < 0 curcharSkip(curcharskip) @realframes = 0 end end - elsif @textchars[@curchar]=="\n" - if @linesdrawn>=visiblelines-1 - if @scrollstate<@lineHeight - @scrollstate += [(@lineHeight/4),1].max - @scrollY += [(@lineHeight/4),1].max + elsif @textchars[@curchar] == "\n" + if @linesdrawn >= visiblelines - 1 + if @scrollstate < @lineHeight + @scrollstate += [(@lineHeight / 4), 1].max + @scrollY += [(@lineHeight / 4), 1].max end - if @scrollstate>=@lineHeight + if @scrollstate >= @lineHeight @realframes += 1 - if @realframes>=@frameskip || @frameskip<0 + if @realframes >= @frameskip || @frameskip < 0 curcharSkip(curcharskip) - @linesdrawn += 1 + @linesdrawn += 1 @realframes = 0 @scrollstate = 0 end end else @realframes += 1 - if @realframes>=@frameskip || @frameskip<0 + if @realframes >= @frameskip || @frameskip < 0 curcharSkip(curcharskip) @linesdrawn += 1 @realframes = 0 end end - elsif @curchar<=@numtextchars + elsif @curchar <= @numtextchars @realframes += 1 - if @realframes>=@frameskip || @frameskip<0 + if @realframes >= @frameskip || @frameskip < 0 curcharSkip(curcharskip) @realframes = 0 end - if @textchars[@curchar]=="\1" - @pausing = true if @curchar<@numtextchars-1 + if @textchars[@curchar] == "\1" + @pausing = true if @curchar < @numtextchars - 1 self.startPause refresh end @@ -580,7 +580,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base def update super @pausesprite.update if @pausesprite && @pausesprite.visible - if @waitcount>0 + if @waitcount > 0 @waitcount -= 1 return end @@ -598,10 +598,10 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base def curcharSkip(skip) skip.times do @curchar += 1 - break if @textchars[@curchar]=="\n" || # newline - @textchars[@curchar]=="\1" || # pause - @textchars[@curchar]=="\2" || # letter-by-letter break - @textchars[@curchar]==nil + break if @textchars[@curchar] == "\n" || # newline + @textchars[@curchar] == "\1" || # pause + @textchars[@curchar] == "\2" || # letter-by-letter break + @textchars[@curchar] == nil end end end @@ -615,19 +615,19 @@ class Window_InputNumberPokemon < SpriteWindow_Base attr_reader :sign def initialize(digits_max) - @digits_max=digits_max - @number=0 - @frame=0 - @sign=false - @negative=false - super(0,0,32,32) - self.width=digits_max*24+8+self.borderX - self.height=32+self.borderY - colors=getDefaultTextColors(self.windowskin) - @baseColor=colors[0] - @shadowColor=colors[1] - @index=digits_max-1 - self.active=true + @digits_max = digits_max + @number = 0 + @frame = 0 + @sign = false + @negative = false + super(0, 0, 32, 32) + self.width = digits_max * 24 + 8 + self.borderX + self.height = 32 + self.borderY + colors = getDefaultTextColors(self.windowskin) + @baseColor = colors[0] + @shadowColor = colors[1] + @index = digits_max - 1 + self.active = true refresh end @@ -637,89 +637,89 @@ class Window_InputNumberPokemon < SpriteWindow_Base end def number - @number*(@sign && @negative ? -1 : 1) + @number * (@sign && @negative ? -1 : 1) end def number=(value) - value=0 if !value.is_a?(Numeric) + value = 0 if !value.is_a?(Numeric) if @sign - @negative=(value<0) - @number = [value.abs, 10 ** @digits_max - 1].min + @negative = (value < 0) + @number = [value.abs, 10**@digits_max - 1].min else - @number = [[value, 0].max, 10 ** @digits_max - 1].min + @number = [[value, 0].max, 10**@digits_max - 1].min end 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) + @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) + 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) + s = sprintf("%0*d", @digits_max, @number.abs) if @sign - textHelper(0,0,@negative ? "-" : "+",0) + textHelper(0, 0, @negative ? "-" : "+", 0) end for i in 0...@digits_max - index=i+(@sign ? 1 : 0) - textHelper(index*24,0,s[i,1],index) + index = i + (@sign ? 1 : 0) + textHelper(index * 24, 0, s[i, 1], index) end end def update super - digits=@digits_max+(@sign ? 1 : 0) - refresh if @frame%15==0 + digits = @digits_max + (@sign ? 1 : 0) + refresh if @frame % 15 == 0 if self.active if Input.repeat?(Input::UP) || Input.repeat?(Input::DOWN) pbPlayCursorSE - if @index==0 && @sign - @negative=!@negative + if @index == 0 && @sign + @negative = !@negative else - place = 10 ** (digits - 1 - @index) + place = 10**(digits - 1 - @index) n = @number / place % 10 - @number -= n*place + @number -= n * place if Input.repeat?(Input::UP) n = (n + 1) % 10 elsif Input.repeat?(Input::DOWN) n = (n + 9) % 10 end - @number += n*place + @number += n * place end refresh elsif Input.repeat?(Input::RIGHT) if digits >= 2 pbPlayCursorSE @index = (@index + 1) % digits - @frame=0 + @frame = 0 refresh end elsif Input.repeat?(Input::LEFT) if digits >= 2 pbPlayCursorSE @index = (@index + digits - 1) % digits - @frame=0 + @frame = 0 refresh end end end - @frame=(@frame+1)%30 + @frame = (@frame + 1) % 30 end private - def textHelper(x,y,text,i) - textwidth=self.contents.text_size(text).width - pbDrawShadowText(self.contents, x+(12-textwidth/2), y, textwidth+4, 32, text, @baseColor, @shadowColor) - if @index==i && @active && @frame/15==0 - self.contents.fill_rect(x+(12-textwidth/2), y+30, textwidth, 2, @baseColor) + def textHelper(x, y, text, i) + textwidth = self.contents.text_size(text).width + pbDrawShadowText(self.contents, x + (12 - textwidth / 2), y, textwidth + 4, 32, text, @baseColor, @shadowColor) + if @index == i && @active && @frame / 15 == 0 + self.contents.fill_rect(x + (12 - textwidth / 2), y + 30, textwidth, 2, @baseColor) end end end @@ -737,7 +737,7 @@ class SpriteWindow_Selectable < SpriteWindow_Base super(x, y, width, height) @item_max = 1 @column_max = 1 - @virtualOy=0 + @virtualOy = 0 @index = -1 @row_height = 32 @column_spacing = 32 @@ -749,7 +749,7 @@ class SpriteWindow_Selectable < SpriteWindow_Base end def index=(index) - if @index!=index + if @index != index @index = index priv_update_cursor_rect(true) end @@ -760,10 +760,10 @@ class SpriteWindow_Selectable < SpriteWindow_Base end def rowHeight=(value) - if @row_height!=value - oldTopRow=self.top_row - @row_height=[1,value].max - self.top_row=oldTopRow + if @row_height != value + oldTopRow = self.top_row + @row_height = [1, value].max + self.top_row = oldTopRow update_cursor_rect end end @@ -773,8 +773,8 @@ class SpriteWindow_Selectable < SpriteWindow_Base end def columns=(value) - if @column_max!=value - @column_max=[1,value].max + if @column_max != value + @column_max = [1, value].max update_cursor_rect end end @@ -784,8 +784,8 @@ class SpriteWindow_Selectable < SpriteWindow_Base end def columnSpacing=(value) - if @column_spacing!=value - @column_spacing=[0,value].max + if @column_spacing != value + @column_spacing = [0, value].max update_cursor_rect end end @@ -803,9 +803,9 @@ class SpriteWindow_Selectable < SpriteWindow_Base end def top_row=(row) - row = row_max-1 if row>row_max-1 - row = 0 if row<0 - @virtualOy = row*@row_height + row = row_max - 1 if row > row_max - 1 + row = 0 if row < 0 + @virtualOy = row * @row_height end def top_item @@ -821,11 +821,11 @@ class SpriteWindow_Selectable < SpriteWindow_Base end def itemRect(item) - if item<0 || item>=@item_max || itemself.top_item+self.page_item_max - return Rect.new(0,0,0,0) + if item < 0 || item >= @item_max || item < self.top_item || + item > self.top_item + self.page_item_max + return Rect.new(0, 0, 0, 0) else - cursor_width = (self.width-self.borderX-(@column_max-1)*@column_spacing) / @column_max + cursor_width = (self.width - self.borderX - (@column_max - 1) * @column_spacing) / @column_max x = item % @column_max * (cursor_width + @column_spacing) y = item / @column_max * @row_height - @virtualOy return Rect.new(x, y, cursor_width, @row_height) @@ -843,20 +843,20 @@ class SpriteWindow_Selectable < SpriteWindow_Base if self.active && @item_max > 0 && @index >= 0 && !@ignore_input if Input.repeat?(Input::UP) if @index >= @column_max || - (Input.trigger?(Input::UP) && (@item_max % @column_max)==0) + (Input.trigger?(Input::UP) && (@item_max % @column_max) == 0) oldindex = @index @index = (@index - @column_max + @item_max) % @item_max - if @index!=oldindex + if @index != oldindex pbPlayCursorSE update_cursor_rect end end elsif Input.repeat?(Input::DOWN) if @index < @item_max - @column_max || - (Input.trigger?(Input::DOWN) && (@item_max % @column_max)==0) + (Input.trigger?(Input::DOWN) && (@item_max % @column_max) == 0) oldindex = @index @index = (@index + @column_max) % @item_max - if @index!=oldindex + if @index != oldindex pbPlayCursorSE update_cursor_rect end @@ -865,7 +865,7 @@ class SpriteWindow_Selectable < SpriteWindow_Base if @column_max >= 2 && @index > 0 oldindex = @index @index -= 1 - if @index!=oldindex + if @index != oldindex pbPlayCursorSE update_cursor_rect end @@ -874,7 +874,7 @@ class SpriteWindow_Selectable < SpriteWindow_Base if @column_max >= 2 && @index < @item_max - 1 oldindex = @index @index += 1 - if @index!=oldindex + if @index != oldindex pbPlayCursorSE update_cursor_rect end @@ -882,18 +882,18 @@ class SpriteWindow_Selectable < SpriteWindow_Base elsif Input.repeat?(Input::JUMPUP) if @index > 0 oldindex = @index - @index = [self.index-self.page_item_max, 0].max - if @index!=oldindex + @index = [self.index - self.page_item_max, 0].max + if @index != oldindex pbPlayCursorSE self.top_row -= self.page_row_max update_cursor_rect end end elsif Input.repeat?(Input::JUMPDOWN) - if @index < @item_max-1 + if @index < @item_max - 1 oldindex = @index - @index = [self.index+self.page_item_max, @item_max-1].min - if @index!=oldindex + @index = [self.index + self.page_item_max, @item_max - 1].min + if @index != oldindex pbPlayCursorSE self.top_row += self.page_row_max update_cursor_rect @@ -937,14 +937,14 @@ class SpriteWindow_Selectable < SpriteWindow_Base # self.top_row = [self.top_row, self.row_max - self.page_row_max].min # This code makes the cursor stay in the middle of the visible list as much # as possible. - new_top_row = row - ((self.page_row_max - 1)/2).floor + new_top_row = row - ((self.page_row_max - 1) / 2).floor new_top_row = [[new_top_row, self.row_max - self.page_row_max].min, 0].max if self.top_row != new_top_row self.top_row = new_top_row # dorefresh = true end # End of code - cursor_width = (self.width-self.borderX) / @column_max + cursor_width = (self.width - self.borderX) / @column_max x = self.index % @column_max * (cursor_width + @column_spacing) y = self.index / @column_max * @row_height - @virtualOy self.cursor_rect.set(x, y, cursor_width, @row_height) @@ -959,8 +959,8 @@ end #=============================================================================== module UpDownArrowMixin def initUpDownArrow - @uparrow = AnimatedSprite.create("Graphics/Pictures/uparrow",8,2,self.viewport) - @downarrow = AnimatedSprite.create("Graphics/Pictures/downarrow",8,2,self.viewport) + @uparrow = AnimatedSprite.create("Graphics/Pictures/uparrow", 8, 2, self.viewport) + @downarrow = AnimatedSprite.create("Graphics/Pictures/downarrow", 8, 2, self.viewport) RPG::Cache.retain("Graphics/Pictures/uparrow") RPG::Cache.retain("Graphics/Pictures/downarrow") @uparrow.z = 99998 @@ -992,22 +992,22 @@ module UpDownArrowMixin def adjustForZoom(sprite) sprite.zoom_x = self.zoom_x sprite.zoom_y = self.zoom_y - sprite.x = sprite.x*self.zoom_x + self.offset_x/self.zoom_x - sprite.y = sprite.y*self.zoom_y + self.offset_y/self.zoom_y + sprite.x = sprite.x * self.zoom_x + self.offset_x / self.zoom_x + sprite.y = sprite.y * self.zoom_y + self.offset_y / self.zoom_y end def update super - @uparrow.x = self.x+(self.width/2)-(@uparrow.framewidth/2) - @downarrow.x = self.x+(self.width/2)-(@downarrow.framewidth/2) + @uparrow.x = self.x + (self.width / 2) - (@uparrow.framewidth / 2) + @downarrow.x = self.x + (self.width / 2) - (@downarrow.framewidth / 2) @uparrow.y = self.y - @downarrow.y = self.y+self.height-@downarrow.frameheight - @uparrow.visible = self.visible && self.active && (self.top_item!=0 && + @downarrow.y = self.y + self.height - @downarrow.frameheight + @uparrow.visible = self.visible && self.active && (self.top_item != 0 && @item_max > self.page_item_max) @downarrow.visible = self.visible && self.active && - (self.top_item+self.page_item_max<@item_max && @item_max > self.page_item_max) - @uparrow.z = self.z+1 - @downarrow.z = self.z+1 + (self.top_item + self.page_item_max < @item_max && @item_max > self.page_item_max) + @uparrow.z = self.z + 1 + @downarrow.z = self.z + 1 adjustForZoom(@uparrow) adjustForZoom(@downarrow) @uparrow.viewport = self.viewport @@ -1040,8 +1040,8 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx attr_reader :baseColor attr_reader :shadowColor - def initialize(x,y,width,height,viewport = nil) - super(x,y,width,height) + def initialize(x, y, width, height, viewport = nil) + super(x, y, width, height) self.viewport = viewport if viewport if isDarkWindowskin(self.windowskin) @selarrow = AnimatedBitmap.new("Graphics/Pictures/selarrow_white") @@ -1072,30 +1072,30 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx refresh end - def textWidth(bitmap,text) + def textWidth(bitmap, text) return bitmap.text_size(text).width end - def getAutoDims(commands,dims,width = nil) + def getAutoDims(commands, dims, width = nil) rowMax = ((commands.length + self.columns - 1) / self.columns).to_i - windowheight = (rowMax*self.rowHeight) + windowheight = (rowMax * self.rowHeight) windowheight += self.borderY - if !width || width<0 - width=0 - tmpbitmap = BitmapWrapper.new(1,1) + if !width || width < 0 + width = 0 + tmpbitmap = BitmapWrapper.new(1, 1) pbSetSystemFont(tmpbitmap) for i in commands - width = [width,tmpbitmap.text_size(i).width].max + width = [width, tmpbitmap.text_size(i).width].max end # one 16 to allow cursor - width += 16+16+SpriteWindow_Base::TEXTPADDING + width += 16 + 16 + SpriteWindow_Base::TEXTPADDING tmpbitmap.dispose end # Store suggested width and height of window dims[0] = [self.borderX + 1, (width * self.columns) + self.borderX + (self.columns - 1) * self.columnSpacing].max - dims[1] = [self.borderY+1,windowheight].max - dims[1] = [dims[1],Graphics.height].min + dims[1] = [self.borderY + 1, windowheight].max + dims[1] = [dims[1], Graphics.height].min end def setSkin(skin) @@ -1106,11 +1106,11 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx @shadowColor = colors[1] end - def drawCursor(index,rect) - if self.index==index - pbCopyBitmap(self.contents,@selarrow.bitmap,rect.x,rect.y) + def drawCursor(index, rect) + if self.index == index + pbCopyBitmap(self.contents, @selarrow.bitmap, rect.x, rect.y) end - return Rect.new(rect.x+16,rect.y,rect.width-16,rect.height) + return Rect.new(rect.x + 16, rect.y, rect.width - 16, rect.height) end def itemCount # to be implemented by derived classes @@ -1121,20 +1121,20 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx def refresh @item_max = itemCount - dwidth = self.width-self.borderX - dheight = self.height-self.borderY - self.contents = pbDoEnsureBitmap(self.contents,dwidth,dheight) + dwidth = self.width - self.borderX + dheight = self.height - self.borderY + self.contents = pbDoEnsureBitmap(self.contents, dwidth, dheight) self.contents.clear for i in 0...@item_max - next if iself.top_item+self.page_item_max - drawItem(i,@item_max,itemRect(i)) + next if i < self.top_item || i > self.top_item + self.page_item_max + drawItem(i, @item_max, itemRect(i)) end end def update oldindex = self.index super - refresh if self.index!=oldindex + refresh if self.index != oldindex end end @@ -1146,40 +1146,40 @@ end class Window_CommandPokemon < Window_DrawableCommand attr_reader :commands - def initialize(commands,width = nil) - @starting=true - @commands=[] - dims=[] - super(0,0,32,32) - getAutoDims(commands,dims,width) - self.width=dims[0] - self.height=dims[1] - @commands=commands - self.active=true - colors=getDefaultTextColors(self.windowskin) - self.baseColor=colors[0] - self.shadowColor=colors[1] + def initialize(commands, width = nil) + @starting = true + @commands = [] + dims = [] + super(0, 0, 32, 32) + getAutoDims(commands, dims, width) + self.width = dims[0] + self.height = dims[1] + @commands = commands + self.active = true + colors = getDefaultTextColors(self.windowskin) + self.baseColor = colors[0] + self.shadowColor = colors[1] refresh - @starting=false + @starting = false end - def self.newWithSize(commands,x,y,width,height,viewport = nil) - ret=self.new(commands,width) - ret.x=x - ret.y=y - ret.width=width - ret.height=height - ret.viewport=viewport + def self.newWithSize(commands, x, y, width, height, viewport = nil) + ret = self.new(commands, width) + ret.x = x + ret.y = y + ret.width = width + ret.height = height + ret.viewport = viewport return ret end - def self.newEmpty(x,y,width,height,viewport = nil) - ret=self.new([],width) - ret.x=x - ret.y=y - ret.width=width - ret.height=height - ret.viewport=viewport + def self.newEmpty(x, y, width, height, viewport = nil) + ret = self.new([], width) + ret.x = x + ret.y = y + ret.width = width + ret.height = height + ret.viewport = viewport return ret end @@ -1189,8 +1189,8 @@ class Window_CommandPokemon < Window_DrawableCommand end def commands=(value) - @commands=value - @item_max=commands.length + @commands = value + @item_max = commands.length self.update_cursor_rect self.refresh end @@ -1198,7 +1198,7 @@ class Window_CommandPokemon < Window_DrawableCommand def width=(value) super if !@starting - self.index=self.index + self.index = self.index self.update_cursor_rect end end @@ -1206,27 +1206,27 @@ class Window_CommandPokemon < Window_DrawableCommand def height=(value) super if !@starting - self.index=self.index + self.index = self.index self.update_cursor_rect end end - def resizeToFit(commands,width = nil) - dims=[] - getAutoDims(commands,dims,width) - self.width=dims[0] - self.height=dims[1] + def resizeToFit(commands, width = nil) + dims = [] + getAutoDims(commands, dims, width) + self.width = dims[0] + self.height = dims[1] end def itemCount 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, - @commands[index],self.baseColor,self.shadowColor) + rect = drawCursor(index, rect) + pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height, + @commands[index], self.baseColor, self.shadowColor) end end @@ -1245,53 +1245,53 @@ end class Window_AdvancedCommandPokemon < Window_DrawableCommand attr_reader :commands - def textWidth(bitmap,text) - dims=[nil,0] - chars=getFormattedText(bitmap,0,0, - Graphics.width-self.borderX-SpriteWindow_Base::TEXTPADDING-16, - -1,text,self.rowHeight,true,true) + def textWidth(bitmap, text) + dims = [nil, 0] + chars = getFormattedText(bitmap, 0, 0, + Graphics.width - self.borderX - SpriteWindow_Base::TEXTPADDING - 16, + -1, text, self.rowHeight, true, true) for ch in chars - dims[0]=dims[0] ? [dims[0],ch[1]].min : ch[1] - dims[1]=[dims[1],ch[1]+ch[3]].max + dims[0] = dims[0] ? [dims[0], ch[1]].min : ch[1] + dims[1] = [dims[1], ch[1] + ch[3]].max end - dims[0]=0 if !dims[0] - return dims[1]-dims[0] + dims[0] = 0 if !dims[0] + return dims[1] - dims[0] end - def initialize(commands,width = nil) - @starting=true - @commands=[] - dims=[] - super(0,0,32,32) - getAutoDims(commands,dims,width) - self.width=dims[0] - self.height=dims[1] - @commands=commands - self.active=true - colors=getDefaultTextColors(self.windowskin) - self.baseColor=colors[0] - self.shadowColor=colors[1] + def initialize(commands, width = nil) + @starting = true + @commands = [] + dims = [] + super(0, 0, 32, 32) + getAutoDims(commands, dims, width) + self.width = dims[0] + self.height = dims[1] + @commands = commands + self.active = true + colors = getDefaultTextColors(self.windowskin) + self.baseColor = colors[0] + self.shadowColor = colors[1] refresh - @starting=false + @starting = false end - def self.newWithSize(commands,x,y,width,height,viewport = nil) - ret=self.new(commands,width) - ret.x=x - ret.y=y - ret.width=width - ret.height=height - ret.viewport=viewport + def self.newWithSize(commands, x, y, width, height, viewport = nil) + ret = self.new(commands, width) + ret.x = x + ret.y = y + ret.width = width + ret.height = height + ret.viewport = viewport return ret end - def self.newEmpty(x,y,width,height,viewport = nil) - ret=self.new([],width) - ret.x=x - ret.y=y - ret.width=width - ret.height=height - ret.viewport=viewport + def self.newEmpty(x, y, width, height, viewport = nil) + ret = self.new([], width) + ret.x = x + ret.y = y + ret.width = width + ret.height = height + ret.viewport = viewport return ret end @@ -1301,53 +1301,53 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand end def commands=(value) - @commands=value - @item_max=commands.length + @commands = value + @item_max = commands.length self.update_cursor_rect self.refresh end def width=(value) - oldvalue=self.width + oldvalue = self.width super - if !@starting && oldvalue!=value - self.index=self.index + if !@starting && oldvalue != value + self.index = self.index self.update_cursor_rect end end def height=(value) - oldvalue=self.height + oldvalue = self.height super - if !@starting && oldvalue!=value - self.index=self.index + if !@starting && oldvalue != value + self.index = self.index self.update_cursor_rect end end - def resizeToFit(commands,width = nil) - dims=[] - getAutoDims(commands,dims,width) - self.width=dims[0] - self.height=dims[1] - 6 + def resizeToFit(commands, width = nil) + dims = [] + getAutoDims(commands, dims, width) + self.width = dims[0] + self.height = dims[1] - 6 end def itemCount 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] + rect = drawCursor(index, rect) + if toUnformattedText(@commands[index]).gsub(/\n/, "") == @commands[index] # Use faster alternative for unformatted text without line breaks - pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height, - @commands[index],self.baseColor,self.shadowColor) + pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height, + @commands[index], self.baseColor, self.shadowColor) else - chars=getFormattedText( - self.contents,rect.x,rect.y+4,rect.width,rect.height, - @commands[index],rect.height,true,true) - drawFormattedChars(self.contents,chars) + chars = getFormattedText( + self.contents, rect.x, rect.y + 4, rect.width, rect.height, + @commands[index], rect.height, true, true) + drawFormattedChars(self.contents, chars) end end end diff --git a/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb b/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb index eb59e3211..4bd176102 100644 --- a/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb +++ b/Data/Scripts/007_Objects and windows/006_SpriteWindow_pictures.rb @@ -4,12 +4,12 @@ class IconWindow < SpriteWindow_Base attr_reader :name - def initialize(x,y,width,height,viewport = nil) - super(x,y,width,height) - self.viewport=viewport - self.contents=nil - @name="" - @_iconbitmap=nil + def initialize(x, y, width, height, viewport = nil) + super(x, y, width, height) + self.viewport = viewport + self.contents = nil + @name = "" + @_iconbitmap = nil end def dispose @@ -21,14 +21,14 @@ class IconWindow < SpriteWindow_Base super if @_iconbitmap @_iconbitmap.update - self.contents=@_iconbitmap.bitmap + self.contents = @_iconbitmap.bitmap end end def clearBitmaps @_iconbitmap.dispose if @_iconbitmap - @_iconbitmap=nil - self.contents=nil if !self.disposed? + @_iconbitmap = nil + self.contents = nil if !self.disposed? end # Sets the icon's filename. Alias for setBitmap. @@ -37,16 +37,16 @@ class IconWindow < SpriteWindow_Base end # Sets the icon's filename. - def setBitmap(file,hue = 0) + def setBitmap(file, hue = 0) clearBitmaps() - @name=file - return if file==nil - if file!="" - @_iconbitmap=AnimatedBitmap.new(file,hue) + @name = file + return if file == nil + if file != "" + @_iconbitmap = AnimatedBitmap.new(file, hue) # for compatibility - self.contents=@_iconbitmap ? @_iconbitmap.bitmap : nil + self.contents = @_iconbitmap ? @_iconbitmap.bitmap : nil else - @_iconbitmap=nil + @_iconbitmap = nil end end end @@ -59,10 +59,10 @@ end #=============================================================================== class PictureWindow < SpriteWindow_Base def initialize(pathOrBitmap) - super(0,0,32,32) - self.viewport=viewport - self.contents=nil - @_iconbitmap=nil + super(0, 0, 32, 32) + self.viewport = viewport + self.contents = nil + @_iconbitmap = nil setBitmap(pathOrBitmap) end @@ -75,45 +75,45 @@ class PictureWindow < SpriteWindow_Base super if @_iconbitmap if @_iconbitmap.is_a?(Bitmap) - self.contents=@_iconbitmap + self.contents = @_iconbitmap else @_iconbitmap.update - self.contents=@_iconbitmap.bitmap + self.contents = @_iconbitmap.bitmap end end end def clearBitmaps @_iconbitmap.dispose if @_iconbitmap - @_iconbitmap=nil - self.contents=nil if !self.disposed? + @_iconbitmap = nil + self.contents = nil if !self.disposed? end # Sets the icon's bitmap or filename. (hue parameter # is ignored unless pathOrBitmap is a filename) - def setBitmap(pathOrBitmap,hue = 0) + def setBitmap(pathOrBitmap, hue = 0) clearBitmaps() - if pathOrBitmap!=nil && pathOrBitmap!="" + if pathOrBitmap != nil && pathOrBitmap != "" if pathOrBitmap.is_a?(Bitmap) - @_iconbitmap=pathOrBitmap - self.contents=@_iconbitmap - self.width=@_iconbitmap.width+self.borderX - self.height=@_iconbitmap.height+self.borderY + @_iconbitmap = pathOrBitmap + self.contents = @_iconbitmap + self.width = @_iconbitmap.width + self.borderX + self.height = @_iconbitmap.height + self.borderY elsif pathOrBitmap.is_a?(AnimatedBitmap) - @_iconbitmap=pathOrBitmap - self.contents=@_iconbitmap.bitmap - self.width=@_iconbitmap.bitmap.width+self.borderX - self.height=@_iconbitmap.bitmap.height+self.borderY + @_iconbitmap = pathOrBitmap + self.contents = @_iconbitmap.bitmap + self.width = @_iconbitmap.bitmap.width + self.borderX + self.height = @_iconbitmap.bitmap.height + self.borderY else - @_iconbitmap=AnimatedBitmap.new(pathOrBitmap,hue) + @_iconbitmap = AnimatedBitmap.new(pathOrBitmap, hue) self.contents = @_iconbitmap&.bitmap self.width = self.borderX + (@_iconbitmap&.bitmap&.width || 32) self.height = self.borderY + (@_iconbitmap&.bitmap&.height || 32) end else - @_iconbitmap=nil - self.width=32+self.borderX - self.height=32+self.borderY + @_iconbitmap = nil + self.width = 32 + self.borderX + self.height = 32 + self.borderY end end end diff --git a/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb b/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb index 00c08e0ba..1733956e6 100644 --- a/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb +++ b/Data/Scripts/007_Objects and windows/007_SpriteWrapper.rb @@ -6,48 +6,48 @@ class SpriteWrapper @sprite = Sprite.new(viewport) end - def dispose; @sprite.dispose; end - def disposed?; return @sprite.disposed?; end - def viewport; return @sprite.viewport; end - def flash(color,duration); return @sprite.flash(color,duration); end - def update; return @sprite.update; end - def x; @sprite.x; end - def x=(value); @sprite.x = value; end - def y; @sprite.y; end - def y=(value); @sprite.y = value; end - def bitmap; @sprite.bitmap; end - def bitmap=(value); @sprite.bitmap = value; end - def src_rect; @sprite.src_rect; end - def src_rect=(value); @sprite.src_rect = value; end - def visible; @sprite.visible; end - def visible=(value); @sprite.visible = value; end - def z; @sprite.z; end - def z=(value); @sprite.z = value; end - def ox; @sprite.ox; end - def ox=(value); @sprite.ox = value; end - def oy; @sprite.oy; end - def oy=(value); @sprite.oy = value; end - def zoom_x; @sprite.zoom_x; end - def zoom_x=(value); @sprite.zoom_x = value; end - def zoom_y; @sprite.zoom_y; end - def zoom_y=(value); @sprite.zoom_y = value; end - def angle; @sprite.angle; end - def angle=(value); @sprite.angle = value; end - def mirror; @sprite.mirror; end - def mirror=(value); @sprite.mirror = value; end - def bush_depth; @sprite.bush_depth; end - def bush_depth=(value); @sprite.bush_depth = value; end - def opacity; @sprite.opacity; end - def opacity=(value); @sprite.opacity = value; end - def blend_type; @sprite.blend_type; end - def blend_type=(value); @sprite.blend_type = value; end - def color; @sprite.color; end - def color=(value); @sprite.color = value; end - def tone; @sprite.tone; end - def tone=(value); @sprite.tone = value; end + def dispose; @sprite.dispose; end + def disposed?; return @sprite.disposed?; end + def viewport; return @sprite.viewport; end + def flash(color, duration); return @sprite.flash(color, duration); end + def update; return @sprite.update; end + def x; @sprite.x; end + def x=(value); @sprite.x = value; end + def y; @sprite.y; end + def y=(value); @sprite.y = value; end + def bitmap; @sprite.bitmap; end + def bitmap=(value); @sprite.bitmap = value; end + def src_rect; @sprite.src_rect; end + def src_rect=(value); @sprite.src_rect = value; end + def visible; @sprite.visible; end + def visible=(value); @sprite.visible = value; end + def z; @sprite.z; end + def z=(value); @sprite.z = value; end + def ox; @sprite.ox; end + def ox=(value); @sprite.ox = value; end + def oy; @sprite.oy; end + def oy=(value); @sprite.oy = value; end + def zoom_x; @sprite.zoom_x; end + def zoom_x=(value); @sprite.zoom_x = value; end + def zoom_y; @sprite.zoom_y; end + def zoom_y=(value); @sprite.zoom_y = value; end + def angle; @sprite.angle; end + def angle=(value); @sprite.angle = value; end + def mirror; @sprite.mirror; end + def mirror=(value); @sprite.mirror = value; end + def bush_depth; @sprite.bush_depth; end + def bush_depth=(value); @sprite.bush_depth = value; end + def opacity; @sprite.opacity; end + def opacity=(value); @sprite.opacity = value; end + def blend_type; @sprite.blend_type; end + def blend_type=(value); @sprite.blend_type = value; end + def color; @sprite.color; end + def color=(value); @sprite.color = value; end + def tone; @sprite.tone; end + def tone=(value); @sprite.tone = value; end def viewport=(value) - return if self.viewport==value + return if self.viewport == value bitmap = @sprite.bitmap src_rect = @sprite.src_rect visible = @sprite.visible @@ -94,10 +94,10 @@ end # This bitmap can't be changed to a different one. #=============================================================================== class BitmapSprite < SpriteWrapper - def initialize(width,height,viewport = nil) + def initialize(width, height, viewport = nil) super(viewport) - self.bitmap=Bitmap.new(width,height) - @initialized=true + self.bitmap = Bitmap.new(width, height) + @initialized = true end def bitmap=(value) @@ -122,82 +122,82 @@ class AnimatedSprite < SpriteWrapper attr_reader :framecount attr_reader :animname - def initializeLong(animname,framecount,framewidth,frameheight,frameskip) - @animname=pbBitmapName(animname) - @realframes=0 - @frameskip=[1,frameskip].max - @frameskip *= Graphics.frame_rate/20 - raise _INTL("Frame width is 0") if framewidth==0 - raise _INTL("Frame height is 0") if frameheight==0 + def initializeLong(animname, framecount, framewidth, frameheight, frameskip) + @animname = pbBitmapName(animname) + @realframes = 0 + @frameskip = [1, frameskip].max + @frameskip *= Graphics.frame_rate / 20 + raise _INTL("Frame width is 0") if framewidth == 0 + raise _INTL("Frame height is 0") if frameheight == 0 begin - @animbitmap=AnimatedBitmap.new(animname).deanimate + @animbitmap = AnimatedBitmap.new(animname).deanimate rescue - @animbitmap=Bitmap.new(framewidth,frameheight) + @animbitmap = Bitmap.new(framewidth, frameheight) end - if @animbitmap.width%framewidth!=0 + if @animbitmap.width % framewidth != 0 raise _INTL("Bitmap's width ({1}) is not a multiple of frame width ({2}) [Bitmap={3}]", - @animbitmap.width,framewidth,animname) + @animbitmap.width, framewidth, animname) end - if @animbitmap.height%frameheight!=0 + if @animbitmap.height % frameheight != 0 raise _INTL("Bitmap's height ({1}) is not a multiple of frame height ({2}) [Bitmap={3}]", - @animbitmap.height,frameheight,animname) + @animbitmap.height, frameheight, animname) end - @framecount=framecount - @framewidth=framewidth - @frameheight=frameheight - @framesperrow=@animbitmap.width/@framewidth - @playing=false - self.bitmap=@animbitmap - self.src_rect.width=@framewidth - self.src_rect.height=@frameheight - self.frame=0 + @framecount = framecount + @framewidth = framewidth + @frameheight = frameheight + @framesperrow = @animbitmap.width / @framewidth + @playing = false + self.bitmap = @animbitmap + self.src_rect.width = @framewidth + self.src_rect.height = @frameheight + self.frame = 0 end # Shorter version of AnimationSprite. All frames are placed on a single row # of the bitmap, so that the width and height need not be defined beforehand - def initializeShort(animname,framecount,frameskip) - @animname=pbBitmapName(animname) - @realframes=0 - @frameskip=[1,frameskip].max - @frameskip *= Graphics.frame_rate/20 + def initializeShort(animname, framecount, frameskip) + @animname = pbBitmapName(animname) + @realframes = 0 + @frameskip = [1, frameskip].max + @frameskip *= Graphics.frame_rate / 20 begin - @animbitmap=AnimatedBitmap.new(animname).deanimate + @animbitmap = AnimatedBitmap.new(animname).deanimate rescue - @animbitmap=Bitmap.new(framecount*4,32) + @animbitmap = Bitmap.new(framecount * 4, 32) end - if @animbitmap.width%framecount!=0 + if @animbitmap.width % framecount != 0 raise _INTL("Bitmap's width ({1}) is not a multiple of frame count ({2}) [Bitmap={3}]", - @animbitmap.width,framewidth,animname) + @animbitmap.width, framewidth, animname) end - @framecount=framecount - @framewidth=@animbitmap.width/@framecount - @frameheight=@animbitmap.height - @framesperrow=framecount - @playing=false - self.bitmap=@animbitmap - self.src_rect.width=@framewidth - self.src_rect.height=@frameheight - self.frame=0 + @framecount = framecount + @framewidth = @animbitmap.width / @framecount + @frameheight = @animbitmap.height + @framesperrow = framecount + @playing = false + self.bitmap = @animbitmap + self.src_rect.width = @framewidth + self.src_rect.height = @frameheight + self.frame = 0 end def initialize(*args) - if args.length==1 + if args.length == 1 super(args[0][3]) - initializeShort(args[0][0],args[0][1],args[0][2]) + initializeShort(args[0][0], args[0][1], args[0][2]) else super(args[5]) - initializeLong(args[0],args[1],args[2],args[3],args[4]) + initializeLong(args[0], args[1], args[2], args[3], args[4]) end end - def self.create(animname,framecount,frameskip,viewport = nil) - return self.new([animname,framecount,frameskip,viewport]) + def self.create(animname, framecount, frameskip, viewport = nil) + return self.new([animname, framecount, frameskip, viewport]) end def dispose return if disposed? @animbitmap.dispose - @animbitmap=nil + @animbitmap = nil super end @@ -206,31 +206,31 @@ class AnimatedSprite < SpriteWrapper end def frame=(value) - @frame=value - @realframes=0 - self.src_rect.x=@frame%@framesperrow*@framewidth - self.src_rect.y=@frame/@framesperrow*@frameheight + @frame = value + @realframes = 0 + self.src_rect.x = @frame % @framesperrow * @framewidth + self.src_rect.y = @frame / @framesperrow * @frameheight end def start - @playing=true - @realframes=0 + @playing = true + @realframes = 0 end alias play start def stop - @playing=false + @playing = false end def update super if @playing - @realframes+=1 - if @realframes==@frameskip - @realframes=0 - self.frame+=1 - self.frame%=self.framecount + @realframes += 1 + if @realframes == @frameskip + @realframes = 0 + self.frame += 1 + self.frame %= self.framecount end end end @@ -245,23 +245,23 @@ class IconSprite < SpriteWrapper attr_reader :name def initialize(*args) - if args.length==0 + if args.length == 0 super(nil) - self.bitmap=nil - elsif args.length==1 + self.bitmap = nil + elsif args.length == 1 super(args[0]) - self.bitmap=nil - elsif args.length==2 + self.bitmap = nil + elsif args.length == 2 super(nil) - self.x=args[0] - self.y=args[1] + self.x = args[0] + self.y = args[1] else super(args[2]) - self.x=args[0] - self.y=args[1] + self.x = args[0] + self.y = args[1] end - @name="" - @_iconbitmap=nil + @name = "" + @_iconbitmap = nil end def dispose @@ -275,35 +275,35 @@ class IconSprite < SpriteWrapper end # Sets the icon's filename. - def setBitmap(file,hue = 0) - oldrc=self.src_rect + def setBitmap(file, hue = 0) + oldrc = self.src_rect clearBitmaps() - @name=file - return if file==nil - if file!="" - @_iconbitmap=AnimatedBitmap.new(file,hue) + @name = file + return if file == nil + if file != "" + @_iconbitmap = AnimatedBitmap.new(file, hue) # for compatibility - self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil - self.src_rect=oldrc + self.bitmap = @_iconbitmap ? @_iconbitmap.bitmap : nil + self.src_rect = oldrc else - @_iconbitmap=nil + @_iconbitmap = nil end end def clearBitmaps @_iconbitmap.dispose if @_iconbitmap - @_iconbitmap=nil - self.bitmap=nil if !self.disposed? + @_iconbitmap = nil + self.bitmap = nil if !self.disposed? end def update super return if !@_iconbitmap @_iconbitmap.update - if self.bitmap!=@_iconbitmap.bitmap - oldrc=self.src_rect - self.bitmap=@_iconbitmap.bitmap - self.src_rect=oldrc + if self.bitmap != @_iconbitmap.bitmap + oldrc = self.src_rect + self.bitmap = @_iconbitmap.bitmap + self.src_rect = oldrc end end end @@ -315,7 +315,7 @@ end #=============================================================================== class GifSprite < IconSprite def initialize(path) - super(0,0) + super(0, 0) setBitmap(path) end end @@ -326,7 +326,7 @@ end # SpriteWrapper that stores multiple bitmaps, and displays only one at once. #=============================================================================== class ChangelingSprite < SpriteWrapper - def initialize(x = 0,y = 0,viewport = nil) + def initialize(x = 0, y = 0, viewport = nil) super(viewport) self.x = x self.y = y @@ -334,7 +334,7 @@ class ChangelingSprite < SpriteWrapper @currentBitmap = nil end - def addBitmap(key,path) + def addBitmap(key, path) @bitmaps[key].dispose if @bitmaps[key] @bitmaps[key] = AnimatedBitmap.new(path) end diff --git a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb index e6e1a90c4..688cc3314 100644 --- a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb +++ b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb @@ -225,14 +225,14 @@ def pbGetTileBitmap(filename, tile_id, hue, width = 1, height = 1) } end -def pbGetTileset(name,hue = 0) +def pbGetTileset(name, hue = 0) return AnimatedBitmap.new("Graphics/Tilesets/" + name, hue).deanimate end -def pbGetAutotile(name,hue = 0) +def pbGetAutotile(name, hue = 0) return AnimatedBitmap.new("Graphics/Autotiles/" + name, hue).deanimate end -def pbGetAnimation(name,hue = 0) +def pbGetAnimation(name, hue = 0) return AnimatedBitmap.new("Graphics/Animations/" + name, hue).deanimate end diff --git a/Data/Scripts/007_Objects and windows/010_DrawText.rb b/Data/Scripts/007_Objects and windows/010_DrawText.rb index 17ffdb44c..c8846af20 100644 --- a/Data/Scripts/007_Objects and windows/010_DrawText.rb +++ b/Data/Scripts/007_Objects and windows/010_DrawText.rb @@ -2,23 +2,23 @@ # Text colours #=============================================================================== def ctag(color) - ret=(color.red.to_i << 24) - ret|=((color.green.to_i) << 16) - ret|=((color.blue.to_i) << 8) - ret|=((color.alpha.to_i)) - return sprintf("",ret) + ret = (color.red.to_i << 24) + ret |= ((color.green.to_i) << 16) + ret |= ((color.blue.to_i) << 8) + ret |= ((color.alpha.to_i)) + return sprintf("", ret) end -def shadowctag(base,shadow) - return sprintf("",colorToRgb16(base),colorToRgb16(shadow)) +def shadowctag(base, shadow) + return sprintf("", colorToRgb16(base), colorToRgb16(shadow)) end -def shadowc3tag(base,shadow) - return sprintf("",colorToRgb32(base),colorToRgb32(shadow)) +def shadowc3tag(base, shadow) + return sprintf("", colorToRgb32(base), colorToRgb32(shadow)) end def shadowctagFromColor(color) - return shadowc3tag(color,getContrastColor(color)) + return shadowc3tag(color, getContrastColor(color)) end def shadowctagFromRgb(param) @@ -27,46 +27,46 @@ end def colorToRgb32(color) return "" if !color - if color.alpha.to_i==255 - return sprintf("%02X%02X%02X",color.red.to_i,color.green.to_i,color.blue.to_i) + if color.alpha.to_i == 255 + return sprintf("%02X%02X%02X", color.red.to_i, color.green.to_i, color.blue.to_i) else return sprintf("%02X%02X%02X%02X", - color.red.to_i,color.green.to_i,color.blue.to_i,color.alpha.to_i) + color.red.to_i, color.green.to_i, color.blue.to_i, color.alpha.to_i) end end def colorToRgb16(color) - ret=(color.red.to_i>>3) - ret|=((color.green.to_i>>3)<<5) - ret|=((color.blue.to_i>>3)<<10) - return sprintf("%04X",ret) + ret = (color.red.to_i >> 3) + ret |= ((color.green.to_i >> 3) << 5) + ret |= ((color.blue.to_i >> 3) << 10) + return sprintf("%04X", ret) end def rgbToColor(param) return Font.default_color if !param - baseint=param.to_i(16) - if param.length==8 # 32-bit hex + baseint = param.to_i(16) + if param.length == 8 # 32-bit hex return Color.new( - (baseint>>24)&0xFF, - (baseint>>16)&0xFF, - (baseint>>8)&0xFF, - (baseint)&0xFF + (baseint >> 24) & 0xFF, + (baseint >> 16) & 0xFF, + (baseint >> 8) & 0xFF, + (baseint) & 0xFF ) - elsif param.length==6 # 24-bit hex + elsif param.length == 6 # 24-bit hex return Color.new( - (baseint>>16)&0xFF, - (baseint>>8)&0xFF, - (baseint)&0xFF + (baseint >> 16) & 0xFF, + (baseint >> 8) & 0xFF, + (baseint) & 0xFF ) - elsif param.length==4 # 16-bit hex + elsif param.length == 4 # 16-bit hex return Color.new( - ((baseint)&0x1F)<<3, - ((baseint>>5)&0x1F)<<3, - ((baseint>>10)&0x1F)<<3 + ((baseint) & 0x1F) << 3, + ((baseint >> 5) & 0x1F) << 3, + ((baseint >> 10) & 0x1F) << 3 ) - elsif param.length==1 # Color number - i=param.to_i - return Font.default_color if i>=8 + elsif param.length == 1 # Color number + i = param.to_i + return Font.default_color if i >= 8 return [ Color.new(255, 255, 255, 255), Color.new(128, 128, 255, 255), @@ -83,28 +83,28 @@ def rgbToColor(param) end def Rgb16ToColor(param) - baseint=param.to_i(16) + baseint = param.to_i(16) return Color.new( - ((baseint)&0x1F)<<3, - ((baseint>>5)&0x1F)<<3, - ((baseint>>10)&0x1F)<<3 + ((baseint) & 0x1F) << 3, + ((baseint >> 5) & 0x1F) << 3, + ((baseint >> 10) & 0x1F) << 3 ) end def getContrastColor(color) raise "No color given" if !color - r=color.red - g=color.green - b=color.blue - yuv=[ - r * 0.299 + g * 0.587 + b * 0.114, + r = color.red + g = color.green + b = color.blue + yuv = [ + r * 0.299 + g * 0.587 + b * 0.114, r * -0.1687 + g * -0.3313 + b * 0.500 + 0.5, - r * 0.500 + g * -0.4187 + b * -0.0813 + 0.5 + r * 0.500 + g * -0.4187 + b * -0.0813 + 0.5 ] - if yuv[0]<127.5 - yuv[0]+=(255-yuv[0])/2 + if yuv[0] < 127.5 + yuv[0] += (255 - yuv[0]) / 2 else - yuv[0]=yuv[0]/2 + yuv[0] = yuv[0] / 2 end return Color.new( yuv[0] + 1.4075 * (yuv[2] - 0.5), @@ -123,21 +123,21 @@ FORMATREGEXP = /<(\/?)(c|c2|c3|o|fn|br|fs|i|b|r|pg|pog|u|s|icon|img|ac|ar|al|out def fmtescape(text) if text[/[&<>]/] - text2=text.gsub(/&/,"&") - text2.gsub!(//,">") + text2 = text.gsub(/&/, "&") + text2.gsub!(//, ">") return text2 end return text end def toUnformattedText(text) - text2=text.gsub(FORMATREGEXP,"") - text2.gsub!(/</,"<") - text2.gsub!(/>/,">") - text2.gsub!(/'/,"'") - text2.gsub!(/"/,"\"") - text2.gsub!(/&/,"&") + text2 = text.gsub(FORMATREGEXP, "") + text2.gsub!(/</, "<") + text2.gsub!(/>/, ">") + text2.gsub!(/'/, "'") + text2.gsub!(/"/, "\"") + text2.gsub!(/&/, "&") return text2 end @@ -148,141 +148,141 @@ end def itemIconTag(item) return "" if !item if item.respond_to?("icon_name") - return sprintf("",item.icon_name) + return sprintf("", item.icon_name) else - ix=item.icon_index % 16 * 24 - iy=item.icon_index / 16 * 24 - return sprintf("",ix,iy) + ix = item.icon_index % 16 * 24 + iy = item.icon_index / 16 * 24 + return sprintf("", ix, iy) end end -def getFormattedTextForDims(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, - newlineBreaks = true,explicitBreaksOnly = false) - text2=text.gsub(/<(\/?)(c|c2|c3|o|u|s)(\s*\=\s*([^>]*))?>/i,"") +def getFormattedTextForDims(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight, + newlineBreaks = true, explicitBreaksOnly = false) + text2 = text.gsub(/<(\/?)(c|c2|c3|o|u|s)(\s*\=\s*([^>]*))?>/i, "") if newlineBreaks - text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i,"\n") + text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n") end return getFormattedText( - bitmap,xDst,yDst,widthDst,heightDst, - text2,lineheight,newlineBreaks, - explicitBreaksOnly,true) + bitmap, xDst, yDst, widthDst, heightDst, + text2, lineheight, newlineBreaks, + explicitBreaksOnly, true) end -def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, - newlineBreaks = true,explicitBreaksOnly = false) - x=y=0 - characters=[] - textchunks=[] +def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight, + newlineBreaks = true, explicitBreaksOnly = false) + x = y = 0 + characters = [] + textchunks = [] textchunks.push(text) - text=textchunks.join("") - textchars=text.scan(/./m) - lastword=[0,0] # position of last word - hadspace=false - hadnonspace=false - bold=bitmap.font.bold - italic=bitmap.font.italic - colorclone=bitmap.font.color - defaultfontname=bitmap.font.name + text = textchunks.join("") + textchars = text.scan(/./m) + lastword = [0, 0] # position of last word + hadspace = false + hadnonspace = false + bold = bitmap.font.bold + italic = bitmap.font.italic + colorclone = bitmap.font.color + defaultfontname = bitmap.font.name if defaultfontname.is_a?(Array) - defaultfontname=defaultfontname.find { |i| Font.exist?(i) } || "Arial" + defaultfontname = defaultfontname.find { |i| Font.exist?(i) } || "Arial" elsif !Font.exist?(defaultfontname) - defaultfontname="Arial" + defaultfontname = "Arial" end - defaultfontname=defaultfontname.clone - havenl=false - position=0 - while positionwidthDst && lastword[1]!=0 && + x += width + if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 && (!hadnonspace || !hadspace) - havenl=true - characters.insert(lastword[0],["\n",x,y*lineheight+yDst,0,lineheight, - false,false,false,colorclone,nil,false,false,"",8,position]) - lastword[0]+=1 - y+=1 - x=0 + havenl = true + characters.insert(lastword[0], ["\n", x, y * lineheight + yDst, 0, lineheight, + false, false, false, colorclone, nil, false, false, "", 8, position]) + lastword[0] += 1 + y += 1 + x = 0 for i in lastword[0]...characters.length - characters[i][2]+=lineheight - charwidth=characters[i][3]-2 - characters[i][1]=x - x+=charwidth + characters[i][2] += lineheight + charwidth = characters[i][3] - 2 + characters[i][1] = x + x += charwidth end - lastword[1]=0 + lastword[1] = 0 end - position+=1 + position += 1 end # Eliminate spaces before newlines and pause character if havenl - firstspace=-1 + firstspace = -1 for i in 0...characters.length - if characters[i][5]!=false # If not a character - firstspace=-1 - elsif (characters[i][0]=="\n" || isWaitChar(characters[i][0])) && - firstspace>=0 + if characters[i][5] != false # If not a character + firstspace = -1 + elsif (characters[i][0] == "\n" || isWaitChar(characters[i][0])) && + firstspace >= 0 for j in firstspace...i - characters[j]=nil + characters[j] = nil end firstspace = -1 elsif characters[i][0][/[ \r\t]/] firstspace = i if firstspace < 0 else - firstspace=-1 + firstspace = -1 end end - if firstspace>0 + if firstspace > 0 for j in firstspace...characters.length - characters[j]=nil + characters[j] = nil end end characters.compact! end for i in 0...characters.length - characters[i][1]=xDst+characters[i][1] + characters[i][1] = xDst + characters[i][1] end # Remove all characters with Y greater or equal to _yDst_+_heightDst_ - if heightDst>=0 + if heightDst >= 0 for i in 0...characters.length - if characters[i][2]>=yDst+heightDst - characters[i]=nil + if characters[i][2] >= yDst + heightDst + characters[i] = nil end end characters.compact! @@ -291,22 +291,22 @@ def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, end def isWaitChar(x) - return (x=="\001" || x=="\002") + return (x == "\001" || x == "\002") end -def getLastParam(array,default) - i=array.length-1 - while i>=0 +def getLastParam(array, default) + i = array.length - 1 + while i >= 0 return array[i] if array[i] - i-=1 + i -= 1 end return default end -def getLastColors(colorstack,opacitystack,defaultcolors) - colors=getLastParam(colorstack,defaultcolors) - opacity=getLastParam(opacitystack,255) - if opacity!=255 +def getLastColors(colorstack, opacitystack, defaultcolors) + colors = getLastParam(colorstack, defaultcolors) + opacity = getLastParam(opacitystack, 255) + if opacity != 255 colors = [ Color.new(colors[0].red, colors[0].green, colors[0].blue, colors[0].alpha * opacity / 255), colors[1] ? Color.new(colors[1].red, colors[1].green, colors[1].blue, colors[1].alpha * opacity / 255) : nil @@ -385,21 +385,21 @@ To draw the characters, pass the returned array to the _drawFormattedChars_ function. =end -def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight = 32, - newlineBreaks = true,explicitBreaksOnly = false, +def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = 32, + newlineBreaks = true, explicitBreaksOnly = false, collapseAlignments = false) - dummybitmap=nil + dummybitmap = nil if !bitmap || bitmap.disposed? # allows function to be called with nil bitmap - dummybitmap=Bitmap.new(1,1) - bitmap=dummybitmap + dummybitmap = Bitmap.new(1, 1) + bitmap = dummybitmap return end - if !bitmap || bitmap.disposed? || widthDst<=0 || heightDst==0 || text.length==0 + if !bitmap || bitmap.disposed? || widthDst <= 0 || heightDst == 0 || text.length == 0 return [] end - textchunks=[] - controls=[] - oldtext=text + textchunks = [] + controls = [] + oldtext = text while text[FORMATREGEXP] textchunks.push($~.pre_match) if $~[3] @@ -407,311 +407,311 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight = 32, else controls.push([$~[2].downcase, "", -1, $~[1] == "/"]) end - text=$~.post_match + text = $~.post_match end - if controls.length==0 - ret=getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, - newlineBreaks,explicitBreaksOnly) + if controls.length == 0 + ret = getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight, + newlineBreaks, explicitBreaksOnly) dummybitmap.dispose if dummybitmap return ret end - x=y=0 - characters=[] - charactersInternal=[] - realtext=nil - realtextStart="" - if !explicitBreaksOnly && textchunks.join("").length==0 + x = y = 0 + characters = [] + charactersInternal = [] + realtext = nil + realtextStart = "" + if !explicitBreaksOnly && textchunks.join("").length == 0 # All commands occurred at the beginning of the text string - realtext=(newlineBreaks) ? text : text.gsub(/\n/," ") - realtextStart=oldtext[0,oldtext.length-realtext.length] - realtextHalf=text.length/2 + realtext = (newlineBreaks) ? text : text.gsub(/\n/, " ") + realtextStart = oldtext[0, oldtext.length - realtext.length] + realtextHalf = text.length / 2 end textchunks.push(text) for chunk in textchunks - chunk.gsub!(/</,"<") - chunk.gsub!(/>/,">") - chunk.gsub!(/'/,"'") - chunk.gsub!(/"/,"\"") - chunk.gsub!(/&/,"&") + chunk.gsub!(/</, "<") + chunk.gsub!(/>/, ">") + chunk.gsub!(/'/, "'") + chunk.gsub!(/"/, "\"") + chunk.gsub!(/&/, "&") end - textlen=0 + textlen = 0 for i in 0...controls.length - textlen+=textchunks[i].scan(/./m).length - controls[i][2]=textlen + textlen += textchunks[i].scan(/./m).length + controls[i][2] = textlen end - text=textchunks.join("") - textchars=text.scan(/./m) - colorstack=[] - boldcount=0 - italiccount=0 - outlinecount=0 - underlinecount=0 - strikecount=0 - rightalign=0 - outline2count=0 - opacitystack=[] - oldfont=bitmap.font.clone - defaultfontname=bitmap.font.name - defaultfontsize=bitmap.font.size - fontsize=defaultfontsize - fontnamestack=[] - fontsizestack=[] - defaultcolors=[oldfont.color.clone,nil] + text = textchunks.join("") + textchars = text.scan(/./m) + colorstack = [] + boldcount = 0 + italiccount = 0 + outlinecount = 0 + underlinecount = 0 + strikecount = 0 + rightalign = 0 + outline2count = 0 + opacitystack = [] + oldfont = bitmap.font.clone + defaultfontname = bitmap.font.name + defaultfontsize = bitmap.font.size + fontsize = defaultfontsize + fontnamestack = [] + fontsizestack = [] + defaultcolors = [oldfont.color.clone, nil] if defaultfontname.is_a?(Array) - defaultfontname=defaultfontname.find { |i| Font.exist?(i) } || "Arial" + defaultfontname = defaultfontname.find { |i| Font.exist?(i) } || "Arial" elsif !Font.exist?(defaultfontname) - defaultfontname="Arial" + defaultfontname = "Arial" end - defaultfontname=defaultfontname.clone - fontname=defaultfontname - alignstack=[] - lastword=[0,0] # position of last word - hadspace=false - hadnonspace=false - havenl=false - position=0 - while position0 && nextline==0 + nextline = 1 if x > 0 && nextline == 0 else alignstack.pop - nextline=1 if x>0 && nextline==0 + nextline = 1 if x > 0 && nextline == 0 end - elsif control=="al" # Left align + elsif control == "al" # Left align if !endtag alignstack.push(0) - nextline=1 if x>0 && nextline==0 + nextline = 1 if x > 0 && nextline == 0 else alignstack.pop - nextline=1 if x>0 && nextline==0 + nextline = 1 if x > 0 && nextline == 0 end - elsif control=="ac" # Center align + elsif control == "ac" # Center align if !endtag alignstack.push(2) - nextline=1 if x>0 && nextline==0 + nextline = 1 if x > 0 && nextline == 0 else alignstack.pop - nextline=1 if x>0 && nextline==0 + nextline = 1 if x > 0 && nextline == 0 end - elsif control=="icon" # Icon + elsif control == "icon" # Icon if !endtag - param=param.sub(/\s+$/,"") - graphic="Graphics/Icons/#{param}" - controls[i]=nil + param = param.sub(/\s+$/, "") + graphic = "Graphics/Icons/#{param}" + controls[i] = nil break end - elsif control=="img" # Icon + elsif control == "img" # Icon if !endtag - param=param.sub(/\s+$/,"") - param=param.split("|") - graphic=param[0] - if param.length>1 - graphicX=param[1].to_i - graphicY=param[2].to_i - graphicWidth=param[3].to_i - graphicHeight=param[4].to_i + param = param.sub(/\s+$/, "") + param = param.split("|") + graphic = param[0] + if param.length > 1 + graphicX = param[1].to_i + graphicY = param[2].to_i + graphicWidth = param[3].to_i + graphicHeight = param[4].to_i end - controls[i]=nil + controls[i] = nil break end - elsif control=="br" # Line break + elsif control == "br" # Line break if !endtag - nextline+=1 + nextline += 1 end - elsif control=="r" # Right align this line + elsif control == "r" # Right align this line if !endtag - x=0 - rightalign=1 - lastword=[characters.length,x] + x = 0 + rightalign = 1 + lastword = [characters.length, x] end end - controls[i]=nil + controls[i] = nil end end - bitmap.font.bold=(boldcount>0) - bitmap.font.italic=(italiccount>0) + bitmap.font.bold = (boldcount > 0) + bitmap.font.italic = (italiccount > 0) if graphic if !graphicWidth - tempgraphic=Bitmap.new(graphic) - graphicWidth=tempgraphic.width - graphicHeight=tempgraphic.height + tempgraphic = Bitmap.new(graphic) + graphicWidth = tempgraphic.width + graphicHeight = tempgraphic.height tempgraphic.dispose end - width=graphicWidth # +8 # No padding - xStart=0 # 4 - yStart=[(lineheight/2)-(graphicHeight/2),0].max - graphicRect=Rect.new(graphicX,graphicY,graphicWidth,graphicHeight) + width = graphicWidth # +8 # No padding + xStart = 0 # 4 + yStart = [(lineheight / 2) - (graphicHeight / 2), 0].max + graphicRect = Rect.new(graphicX, graphicY, graphicWidth, graphicHeight) else - xStart=0 - yStart=0 - width=isWaitChar(textchars[position]) ? 0 : bitmap.text_size(textchars[position]).width - width+=2 if width>0 && outline2count>0 + xStart = 0 + yStart = 0 + width = isWaitChar(textchars[position]) ? 0 : bitmap.text_size(textchars[position]).width + width += 2 if width > 0 && outline2count > 0 end - if rightalign==1 && nextline==0 - alignment=1 + if rightalign == 1 && nextline == 0 + alignment = 1 else - alignment=getLastParam(alignstack,0) + alignment = getLastParam(alignstack, 0) end nextline.times do - havenl=true - characters.push(["\n",x,y*lineheight+yDst,0,lineheight,false,false,false, - defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil,0]) - charactersInternal.push([alignment,y,0]) - y+=1 - x=0 - rightalign=0 - lastword=[characters.length,x] - hadspace=false - hadnonspace=false + havenl = true + characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false, false, + defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0]) + charactersInternal.push([alignment, y, 0]) + y += 1 + x = 0 + rightalign = 0 + lastword = [characters.length, x] + hadspace = false + hadnonspace = false end - if textchars[position]=="\n" + if textchars[position] == "\n" if newlineBreaks - if nextline==0 - havenl=true - characters.push(["\n",x,y*lineheight+yDst,0,lineheight,false,false,false, - defaultcolors[0],defaultcolors[1],false,false,"",8,position,nil,0]) - charactersInternal.push([alignment,y,0]) - y+=1 - x=0 + if nextline == 0 + havenl = true + characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false, false, + defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0]) + charactersInternal.push([alignment, y, 0]) + y += 1 + x = 0 end - rightalign=0 - hadspace=true - hadnonspace=false - position+=1 + rightalign = 0 + hadspace = true + hadnonspace = false + position += 1 next else - textchars[position]=" " + textchars[position] = " " if !graphic - width=bitmap.text_size(textchars[position]).width - width+=2 if width>0 && outline2count>0 + width = bitmap.text_size(textchars[position]).width + width += 2 if width > 0 && outline2count > 0 end end end - isspace=(textchars[position][/\s/] || isWaitChar(textchars[position])) ? true : false + isspace = (textchars[position][/\s/] || isWaitChar(textchars[position])) ? true : false if hadspace && !isspace # set last word to here - lastword[0]=characters.length - lastword[1]=x - hadspace=false - hadnonspace=true + lastword[0] = characters.length + lastword[1] = x + hadspace = false + hadnonspace = true elsif isspace - hadspace=true + hadspace = true end - texty=(lineheight*y)+yDst+yStart - colors=getLastColors(colorstack,opacitystack,defaultcolors) + texty = (lineheight * y) + yDst + yStart + colors = getLastColors(colorstack, opacitystack, defaultcolors) # Push character - if heightDst<0 || texty0) ? 2+(width/2) : 2 + if heightDst < 0 || texty < yDst + heightDst + havenl = true if !graphic && isWaitChar(textchars[position]) + extraspace = (!graphic && italiccount > 0) ? 2 + (width / 2) : 2 characters.push([ graphic ? graphic : textchars[position], - x+xStart,texty,width+extraspace,lineheight, + x + xStart, texty, width + extraspace, lineheight, graphic ? true : false, - (boldcount>0),(italiccount>0),colors[0],colors[1], - (underlinecount>0),(strikecount>0),fontname,fontsize, - position,graphicRect, - ((outlinecount>0) ? 1 : 0)+((outline2count>0) ? 2 : 0) + (boldcount > 0), (italiccount > 0), colors[0], colors[1], + (underlinecount > 0), (strikecount > 0), fontname, fontsize, + position, graphicRect, + ((outlinecount > 0) ? 1 : 0) + ((outline2count > 0) ? 2 : 0) ]) - charactersInternal.push([alignment,y,xStart,textchars[position],extraspace]) + charactersInternal.push([alignment, y, xStart, textchars[position], extraspace]) end - x+=width - if !explicitBreaksOnly && x+2>widthDst && lastword[1]!=0 && + x += width + if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 && (!hadnonspace || !hadspace) - havenl=true + havenl = true characters.insert(lastword[0], ["\n", x, y * lineheight + yDst, 0, lineheight, false, false, false, defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil]) - charactersInternal.insert(lastword[0],[alignment,y,0]) - lastword[0]+=1 - y+=1 - x=0 + charactersInternal.insert(lastword[0], [alignment, y, 0]) + lastword[0] += 1 + y += 1 + x = 0 for i in lastword[0]...characters.length - characters[i][2]+=lineheight - charactersInternal[i][1]+=1 - extraspace=(charactersInternal[i][4]) ? charactersInternal[i][4] : 0 - charwidth=characters[i][3]-extraspace - characters[i][1]=x+charactersInternal[i][2] - x+=charwidth + characters[i][2] += lineheight + charactersInternal[i][1] += 1 + extraspace = (charactersInternal[i][4]) ? charactersInternal[i][4] : 0 + charwidth = characters[i][3] - extraspace + characters[i][1] = x + charactersInternal[i][2] + x += charwidth end - lastword[1]=0 + lastword[1] = 0 end - position+=1 if !graphic + position += 1 if !graphic end # This code looks at whether the text occupies exactly two lines when # displayed. If it does, it balances the length of each line. @@ -760,29 +760,29 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight = 32, =end if havenl # Eliminate spaces before newlines and pause character - firstspace=-1 + firstspace = -1 for i in 0...characters.length - if characters[i][5]!=false # If not a character - firstspace=-1 - elsif (characters[i][0]=="\n" || isWaitChar(characters[i][0])) && - firstspace>=0 + if characters[i][5] != false # If not a character + firstspace = -1 + elsif (characters[i][0] == "\n" || isWaitChar(characters[i][0])) && + firstspace >= 0 for j in firstspace...i - characters[j]=nil - charactersInternal[j]=nil + characters[j] = nil + charactersInternal[j] = nil end - firstspace=-1 + firstspace = -1 elsif characters[i][0][/[ \r\t]/] - if firstspace<0 - firstspace=i + if firstspace < 0 + firstspace = i end else - firstspace=-1 + firstspace = -1 end end - if firstspace>0 + if firstspace > 0 for j in firstspace...characters.length - characters[j]=nil - charactersInternal[j]=nil + characters[j] = nil + charactersInternal[j] = nil end end characters.compact! @@ -790,46 +790,46 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight = 32, end # Calculate Xs based on alignment # First, find all text runs with the same alignment on the same line - totalwidth=0 - widthblocks=[] - lastalign=0 - lasty=0 - runstart=0 + totalwidth = 0 + widthblocks = [] + lastalign = 0 + lasty = 0 + runstart = 0 for i in 0...characters.length - c=characters[i] - if i>0 && (charactersInternal[i][0]!=lastalign || - charactersInternal[i][1]!=lasty) + c = characters[i] + if i > 0 && (charactersInternal[i][0] != lastalign || + charactersInternal[i][1] != lasty) # Found end of run - widthblocks.push([runstart,i,lastalign,totalwidth,lasty]) - runstart=i - totalwidth=0 + widthblocks.push([runstart, i, lastalign, totalwidth, lasty]) + runstart = i + totalwidth = 0 end - lastalign=charactersInternal[i][0] - lasty=charactersInternal[i][1] - extraspace=(charactersInternal[i][4]) ? charactersInternal[i][4] : 0 - totalwidth+=c[3]-extraspace + lastalign = charactersInternal[i][0] + lasty = charactersInternal[i][1] + extraspace = (charactersInternal[i][4]) ? charactersInternal[i][4] : 0 + totalwidth += c[3] - extraspace end - widthblocks.push([runstart,characters.length,lastalign,totalwidth,lasty]) + widthblocks.push([runstart, characters.length, lastalign, totalwidth, lasty]) if collapseAlignments # Calculate the total width of each line - totalLineWidths=[] + totalLineWidths = [] for block in widthblocks - y=block[4] + y = block[4] if !totalLineWidths[y] - totalLineWidths[y]=0 + totalLineWidths[y] = 0 end - if totalLineWidths[y]!=0 + if totalLineWidths[y] != 0 # padding in case more than one line has different alignments - totalLineWidths[y]+=16 + totalLineWidths[y] += 16 end - totalLineWidths[y]+=block[3] + totalLineWidths[y] += block[3] end # Calculate a new width for the next step - widthDst=[widthDst,(totalLineWidths.compact.max || 0)].min + widthDst = [widthDst, (totalLineWidths.compact.max || 0)].min end # Now, based on the text runs found, recalculate Xs for block in widthblocks - next if block[0]>=block[1] + next if block[0] >= block[1] for i in block[0]...block[1] case block[2] when 1 then characters[i][1] = xDst + (widthDst - block[3] - 4) + characters[i][1] @@ -840,7 +840,7 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight = 32, end # Remove all characters with Y greater or equal to _yDst_+_heightDst_ characters.delete_if { |ch| ch[2] >= yDst + heightDst } if heightDst >= 0 - bitmap.font=oldfont + bitmap.font = oldfont dummybitmap.dispose if dummybitmap return characters end @@ -850,299 +850,299 @@ end #=============================================================================== # Draw text and images on a bitmap #=============================================================================== -def getLineBrokenText(bitmap,value,width,dims) - x=0 - y=0 - textheight=0 - ret=[] +def getLineBrokenText(bitmap, value, width, dims) + x = 0 + y = 0 + textheight = 0 + ret = [] if dims - dims[0]=0 - dims[1]=0 + dims[0] = 0 + dims[1] = 0 end - line=0 - position=0 - column=0 - return ret if !bitmap || bitmap.disposed? || width<=0 - textmsg=value.clone - ret.push(["",0,0,0,bitmap.text_size("X").height,0,0,0,0]) + line = 0 + position = 0 + column = 0 + return ret if !bitmap || bitmap.disposed? || width <= 0 + textmsg = value.clone + 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=="" - length=c.scan(/./m).length - ccheck=c - if ccheck=="\n" - ret.push(["\n",x,y,0,textheight,line,position,column,0]) - x=0 - y+=(textheight==0) ? bitmap.text_size("X").height : textheight - line+=1 - textheight=0 - column=0 - position+=length - ret.push(["",x,y,0,textheight,line,position,column,0]) + break if c == "" + length = c.scan(/./m).length + ccheck = c + if ccheck == "\n" + ret.push(["\n", x, y, 0, textheight, line, position, column, 0]) + x = 0 + y += (textheight == 0) ? bitmap.text_size("X").height : textheight + line += 1 + textheight = 0 + column = 0 + position += length + ret.push(["", x, y, 0, textheight, line, position, column, 0]) next end - words=[ccheck] + words = [ccheck] for i in 0...words.length - word=words[i] - if word && word!="" - textSize=bitmap.text_size(word) - textwidth=textSize.width - if x>0 && x+textwidth>=width-2 + word = words[i] + if word && word != "" + textSize = bitmap.text_size(word) + textwidth = textSize.width + if x > 0 && x + textwidth >= width - 2 # Zero-length word break - ret.push(["",x,y,0,textheight,line,position,column,0]) - x=0 - column=0 - y+=(textheight==0) ? bitmap.text_size("X").height : textheight - line+=1 - textheight=0 + ret.push(["", x, y, 0, textheight, line, position, column, 0]) + x = 0 + column = 0 + y += (textheight == 0) ? bitmap.text_size("X").height : textheight + line += 1 + textheight = 0 end - textheight=[textheight,textSize.height].max - ret.push([word,x,y,textwidth,textheight,line,position,column,length]) - x+=textwidth - dims[0]=x if dims && dims[0]]+)>/ - reNoMatch=/]+>/ - return ret if !bitmap || bitmap.disposed? || width<=0 - textmsg=value.clone - color=Font.default_color + re = /]+)>/ + reNoMatch = /]+>/ + return ret if !bitmap || bitmap.disposed? || width <= 0 + textmsg = value.clone + color = Font.default_color while (c = textmsg.slice!(/\n|[^ \r\t\f\n\-]*\-+|(\S*([ \r\t\f]?))/)) != nil - break if c=="" - ccheck=c - if ccheck=="\n" - x=0 - y+=32 + break if c == "" + ccheck = c + if ccheck == "\n" + x = 0 + y += 32 next end if ccheck[/0 && x+textwidth>width - minTextSize=bitmap.text_size(word.gsub(/\s*/,"")) - if x>0 && x+minTextSize.width>width - x=0 - y+=32 + word = words[i] + if word && word != "" + textSize = bitmap.text_size(word) + textwidth = textSize.width + if x > 0 && x + textwidth > width + minTextSize = bitmap.text_size(word.gsub(/\s*/, "")) + if x > 0 && x + minTextSize.width > width + x = 0 + y += 32 end end - ret.push([word,x,y,textwidth,32,color]) - x+=textwidth - dims[0]=x if dims && dims[0]"+text - chars=getFormattedText(bitmap,x,y,width,-1,text,lineheight) - drawFormattedChars(bitmap,chars) +def drawFormattedTextEx(bitmap, x, y, width, text, baseColor = nil, shadowColor = nil, lineheight = 32) + base = !baseColor ? Color.new(12 * 8, 12 * 8, 12 * 8) : baseColor.clone + shadow = !shadowColor ? Color.new(26 * 8, 26 * 8, 25 * 8) : shadowColor.clone + text = "" + text + chars = getFormattedText(bitmap, x, y, width, -1, text, lineheight) + drawFormattedChars(bitmap, chars) end # Unused -def pbDrawShadow(bitmap,x,y,width,height,string) +def pbDrawShadow(bitmap, x, y, width, height, string) return if !bitmap || !string - pbDrawShadowText(bitmap,x,y,width,height,string,nil,bitmap.font.color) + pbDrawShadowText(bitmap, x, y, width, height, string, nil, bitmap.font.color) end -def pbDrawShadowText(bitmap,x,y,width,height,string,baseColor,shadowColor = nil,align = 0) +def pbDrawShadowText(bitmap, x, y, width, height, string, baseColor, shadowColor = nil, align = 0) return if !bitmap || !string - width=(width<0) ? bitmap.text_size(string).width+1 : width - height=(height<0) ? bitmap.text_size(string).height+1 : height + width = (width < 0) ? bitmap.text_size(string).width + 1 : width + height = (height < 0) ? bitmap.text_size(string).height + 1 : height y += 4 - if shadowColor && shadowColor.alpha>0 - bitmap.font.color=shadowColor - bitmap.draw_text(x+2,y,width,height,string,align) - bitmap.draw_text(x,y+2,width,height,string,align) - bitmap.draw_text(x+2,y+2,width,height,string,align) + if shadowColor && shadowColor.alpha > 0 + bitmap.font.color = shadowColor + bitmap.draw_text(x + 2, y, width, height, string, align) + bitmap.draw_text(x, y + 2, width, height, string, align) + bitmap.draw_text(x + 2, y + 2, width, height, string, align) end - if baseColor && baseColor.alpha>0 - bitmap.font.color=baseColor - bitmap.draw_text(x,y,width,height,string,align) + if baseColor && baseColor.alpha > 0 + bitmap.font.color = baseColor + bitmap.draw_text(x, y, width, height, string, align) end end -def pbDrawOutlineText(bitmap,x,y,width,height,string,baseColor,shadowColor = nil,align = 0) +def pbDrawOutlineText(bitmap, x, y, width, height, string, baseColor, shadowColor = nil, align = 0) return if !bitmap || !string - width=(width<0) ? bitmap.text_size(string).width+4 : width - height=(height<0) ? bitmap.text_size(string).height+4 : height - if shadowColor && shadowColor.alpha>0 - bitmap.font.color=shadowColor - bitmap.draw_text(x-2,y-2,width,height,string,align) - bitmap.draw_text(x,y-2,width,height,string,align) - bitmap.draw_text(x+2,y-2,width,height,string,align) - bitmap.draw_text(x-2,y,width,height,string,align) - bitmap.draw_text(x+2,y,width,height,string,align) - bitmap.draw_text(x-2,y+2,width,height,string,align) - bitmap.draw_text(x,y+2,width,height,string,align) - bitmap.draw_text(x+2,y+2,width,height,string,align) + width = (width < 0) ? bitmap.text_size(string).width + 4 : width + height = (height < 0) ? bitmap.text_size(string).height + 4 : height + if shadowColor && shadowColor.alpha > 0 + bitmap.font.color = shadowColor + bitmap.draw_text(x - 2, y - 2, width, height, string, align) + bitmap.draw_text(x, y - 2, width, height, string, align) + bitmap.draw_text(x + 2, y - 2, width, height, string, align) + bitmap.draw_text(x - 2, y, width, height, string, align) + bitmap.draw_text(x + 2, y, width, height, string, align) + bitmap.draw_text(x - 2, y + 2, width, height, string, align) + bitmap.draw_text(x, y + 2, width, height, string, align) + bitmap.draw_text(x + 2, y + 2, width, height, string, align) end - if baseColor && baseColor.alpha>0 - bitmap.font.color=baseColor - bitmap.draw_text(x,y,width,height,string,align) + if baseColor && baseColor.alpha > 0 + bitmap.font.color = baseColor + bitmap.draw_text(x, y, width, height, string, align) end end @@ -1156,20 +1156,20 @@ end # 4 - Base color # 5 - Shadow color # 6 - If true or 1, the text has an outline. Otherwise, the text has a shadow. -def pbDrawTextPositions(bitmap,textpos) +def pbDrawTextPositions(bitmap, textpos) for i in textpos textsize = bitmap.text_size(i[0]) x = i[1] y = i[2] + 6 - if i[3]==true || i[3]==1 # right align + if i[3] == true || i[3] == 1 # right align x -= textsize.width - elsif i[3]==2 # centered - x -= (textsize.width/2) + elsif i[3] == 2 # centered + x -= (textsize.width / 2) end - if i[6]==true || i[6]==1 # outline text - pbDrawOutlineText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5]) + if i[6] == true || i[6] == 1 # outline text + pbDrawOutlineText(bitmap, x, y, textsize.width, textsize.height, i[0], i[4], i[5]) else - pbDrawShadowText(bitmap,x,y,textsize.width,textsize.height,i[0],i[4],i[5]) + pbDrawShadowText(bitmap, x, y, textsize.width, textsize.height, i[0], i[4], i[5]) end end end @@ -1179,22 +1179,22 @@ end #=============================================================================== # Draw images on a bitmap #=============================================================================== -def pbCopyBitmap(dstbm,srcbm,x,y,opacity = 255) - rc = Rect.new(0,0,srcbm.width,srcbm.height) - dstbm.blt(x,y,srcbm,rc,opacity) +def pbCopyBitmap(dstbm, srcbm, x, y, opacity = 255) + rc = Rect.new(0, 0, srcbm.width, srcbm.height) + dstbm.blt(x, y, srcbm, rc, opacity) end -def pbDrawImagePositions(bitmap,textpos) +def pbDrawImagePositions(bitmap, textpos) for i in textpos - srcbitmap=AnimatedBitmap.new(pbBitmapName(i[0])) - x=i[1] - y=i[2] - srcx=i[3] || 0 - srcy=i[4] || 0 - width=(i[5] && i[5]>=0) ? i[5] : srcbitmap.width - height=(i[6] && i[6]>=0) ? i[6] : srcbitmap.height - srcrect=Rect.new(srcx,srcy,width,height) - bitmap.blt(x,y,srcbitmap.bitmap,srcrect) + srcbitmap = AnimatedBitmap.new(pbBitmapName(i[0])) + x = i[1] + y = i[2] + srcx = i[3] || 0 + srcy = i[4] || 0 + width = (i[5] && i[5] >= 0) ? i[5] : srcbitmap.width + height = (i[6] && i[6] >= 0) ? i[6] : srcbitmap.height + srcrect = Rect.new(srcx, srcy, width, height) + bitmap.blt(x, y, srcbitmap.bitmap, srcrect) srcbitmap.dispose end end diff --git a/Data/Scripts/007_Objects and windows/011_Messages.rb b/Data/Scripts/007_Objects and windows/011_Messages.rb index 777fee6f6..dee19d92f 100644 --- a/Data/Scripts/007_Objects and windows/011_Messages.rb +++ b/Data/Scripts/007_Objects and windows/011_Messages.rb @@ -43,11 +43,11 @@ def pbEventCommentInput(*args) return nil end -def pbCurrentEventCommentInput(elements,trigger) +def pbCurrentEventCommentInput(elements, trigger) return nil if !pbMapInterpreterRunning? event = pbMapInterpreter.get_self return nil if !event - return pbEventCommentInput(event,elements,trigger) + return pbEventCommentInput(event, elements, trigger) end @@ -60,54 +60,54 @@ class ChooseNumberParams attr_reader :skin def initialize - @maxDigits=0 - @minNumber=0 - @maxNumber=0 - @skin=nil - @messageSkin=nil - @negativesAllowed=false - @initialNumber=0 - @cancelNumber=nil + @maxDigits = 0 + @minNumber = 0 + @maxNumber = 0 + @skin = nil + @messageSkin = nil + @negativesAllowed = false + @initialNumber = 0 + @cancelNumber = nil end def setMessageSkin(value) - @messageSkin=value + @messageSkin = value end def setSkin(value) - @skin=value + @skin = value end def setNegativesAllowed(value) - @negativeAllowed=value + @negativeAllowed = value end def negativesAllowed @negativeAllowed ? true : false end - def setRange(minNumber,maxNumber) - maxNumber=minNumber if minNumber>maxNumber - @maxDigits=0 - @minNumber=minNumber - @maxNumber=maxNumber + def setRange(minNumber, maxNumber) + maxNumber = minNumber if minNumber > maxNumber + @maxDigits = 0 + @minNumber = minNumber + @maxNumber = maxNumber end def setDefaultValue(number) - @initialNumber=number - @cancelNumber=nil + @initialNumber = number + @cancelNumber = nil end def setInitialValue(number) - @initialNumber=number + @initialNumber = number end def setCancelValue(number) - @cancelNumber=number + @cancelNumber = number end def initialNumber - return clamp(@initialNumber,self.minNumber,self.maxNumber) + return clamp(@initialNumber, self.minNumber, self.maxNumber) end def cancelNumber @@ -115,51 +115,51 @@ class ChooseNumberParams end def minNumber - ret=0 - if @maxDigits>0 - ret=-((10**@maxDigits)-1) + ret = 0 + if @maxDigits > 0 + ret = -((10**@maxDigits) - 1) else - ret=@minNumber + ret = @minNumber end - ret=0 if !@negativeAllowed && ret<0 + ret = 0 if !@negativeAllowed && ret < 0 return ret end def maxNumber - ret=0 - if @maxDigits>0 - ret=((10**@maxDigits)-1) + ret = 0 + if @maxDigits > 0 + ret = ((10**@maxDigits) - 1) else - ret=@maxNumber + ret = @maxNumber end - ret=0 if !@negativeAllowed && ret<0 + ret = 0 if !@negativeAllowed && ret < 0 return ret end def setMaxDigits(value) - @maxDigits=[1,value].max + @maxDigits = [1, value].max end def maxDigits - if @maxDigits>0 + if @maxDigits > 0 return @maxDigits else - return [numDigits(self.minNumber),numDigits(self.maxNumber)].max + return [numDigits(self.minNumber), numDigits(self.maxNumber)].max end end private - def clamp(v,mn,mx) - return vmx ? mx : v) + def clamp(v, mn, mx) + return v < mn ? mn : (v > mx ? mx : v) end def numDigits(number) ans = 1 - number=number.abs + number = number.abs while number >= 10 - ans+=1 - number/=10 + ans += 1 + number /= 10 end return ans end @@ -167,20 +167,20 @@ end -def pbChooseNumber(msgwindow,params) +def pbChooseNumber(msgwindow, params) return 0 if !params - ret=0 - maximum=params.maxNumber - minimum=params.minNumber - defaultNumber=params.initialNumber - cancelNumber=params.cancelNumber - cmdwindow=Window_InputNumberPokemon.new(params.maxDigits) - cmdwindow.z=99999 - cmdwindow.visible=true + ret = 0 + maximum = params.maxNumber + minimum = params.minNumber + defaultNumber = params.initialNumber + cancelNumber = params.cancelNumber + cmdwindow = Window_InputNumberPokemon.new(params.maxDigits) + cmdwindow.z = 99999 + cmdwindow.visible = true cmdwindow.setSkin(params.skin) if params.skin - cmdwindow.sign=params.negativesAllowed # must be set before number - cmdwindow.number=defaultNumber - pbPositionNearMsgWindow(cmdwindow,msgwindow,:right) + cmdwindow.sign = params.negativesAllowed # must be set before number + cmdwindow.number = defaultNumber + pbPositionNearMsgWindow(cmdwindow, msgwindow, :right) loop do Graphics.update Input.update @@ -189,10 +189,10 @@ def pbChooseNumber(msgwindow,params) msgwindow.update if msgwindow yield if block_given? if Input.trigger?(Input::USE) - ret=cmdwindow.number - if ret>maximum + ret = cmdwindow.number + if ret > maximum pbPlayBuzzerSE() - elsif ret1 + if @facebitmaptmp.totalFrames > 1 @facebitmaptmp.update - @facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new( + @facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new( (@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96 )) @@ -272,44 +272,44 @@ def pbGetMapNameFromId(id) end def pbCsvField!(str) - ret="" - str.sub!(/\A\s*/,"") - if str[0,1]=="\"" - str[0,1]="" - escaped=false - fieldbytes=0 + ret = "" + str.sub!(/\A\s*/, "") + if str[0, 1] == "\"" + str[0, 1] = "" + escaped = false + fieldbytes = 0 str.scan(/./) do |s| - fieldbytes+=s.length - break if s=="\"" && !escaped - if s=="\\" && !escaped - escaped=true + fieldbytes += s.length + break if s == "\"" && !escaped + if s == "\\" && !escaped + escaped = true else - ret+=s - escaped=false + ret += s + escaped = false end end - str[0,fieldbytes]="" + str[0, fieldbytes] = "" if !str[/\A\s*,/] && !str[/\A\s*$/] - raise _INTL("Invalid quoted field (in: {1})",ret) + raise _INTL("Invalid quoted field (in: {1})", ret) end - str[0,str.length]=$~.post_match + str[0, str.length] = $~.post_match else if str[/,/] - str[0,str.length]=$~.post_match - ret=$~.pre_match + str[0, str.length] = $~.post_match + ret = $~.pre_match else - ret=str.clone - str[0,str.length]="" + ret = str.clone + str[0, str.length] = "" end - ret.gsub!(/\s+$/,"") + ret.gsub!(/\s+$/, "") end return ret end def pbCsvPosInt!(str) - ret=pbCsvField!(str) + ret = pbCsvField!(str) if !ret[/\A\d+$/] - raise _INTL("Field {1} is not a positive integer",ret) + raise _INTL("Field {1} is not a positive integer", ret) end return ret.to_i end @@ -324,50 +324,50 @@ def pbGetGoldString end def pbDisplayGoldWindow(msgwindow) - moneyString=pbGetGoldString() - goldwindow=Window_AdvancedTextPokemon.new(_INTL("Money:\n{1}",moneyString)) + moneyString = pbGetGoldString() + goldwindow = Window_AdvancedTextPokemon.new(_INTL("Money:\n{1}", moneyString)) goldwindow.setSkin("Graphics/Windowskins/goldskin") - goldwindow.resizeToFit(goldwindow.text,Graphics.width) - goldwindow.width=160 if goldwindow.width<=160 - if msgwindow.y==0 - goldwindow.y=Graphics.height-goldwindow.height + goldwindow.resizeToFit(goldwindow.text, Graphics.width) + goldwindow.width = 160 if goldwindow.width <= 160 + if msgwindow.y == 0 + goldwindow.y = Graphics.height - goldwindow.height else - goldwindow.y=0 + goldwindow.y = 0 end - goldwindow.viewport=msgwindow.viewport - goldwindow.z=msgwindow.z + goldwindow.viewport = msgwindow.viewport + goldwindow.z = msgwindow.z return goldwindow end -def pbDisplayCoinsWindow(msgwindow,goldwindow) +def pbDisplayCoinsWindow(msgwindow, goldwindow) coinString = ($player) ? $player.coins.to_s_formatted : "0" - coinwindow=Window_AdvancedTextPokemon.new(_INTL("Coins:\n{1}",coinString)) + coinwindow = Window_AdvancedTextPokemon.new(_INTL("Coins:\n{1}", coinString)) coinwindow.setSkin("Graphics/Windowskins/goldskin") - coinwindow.resizeToFit(coinwindow.text,Graphics.width) - coinwindow.width=160 if coinwindow.width<=160 - if msgwindow.y==0 - coinwindow.y=(goldwindow) ? goldwindow.y-coinwindow.height : Graphics.height-coinwindow.height + coinwindow.resizeToFit(coinwindow.text, Graphics.width) + coinwindow.width = 160 if coinwindow.width <= 160 + if msgwindow.y == 0 + coinwindow.y = (goldwindow) ? goldwindow.y - coinwindow.height : Graphics.height - coinwindow.height else - coinwindow.y=(goldwindow) ? goldwindow.height : 0 + coinwindow.y = (goldwindow) ? goldwindow.height : 0 end - coinwindow.viewport=msgwindow.viewport - coinwindow.z=msgwindow.z + coinwindow.viewport = msgwindow.viewport + coinwindow.z = msgwindow.z return coinwindow end def pbDisplayBattlePointsWindow(msgwindow) pointsString = ($player) ? $player.battle_points.to_s_formatted : "0" - pointswindow=Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n{1}", pointsString)) + pointswindow = Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n{1}", pointsString)) pointswindow.setSkin("Graphics/Windowskins/goldskin") - pointswindow.resizeToFit(pointswindow.text,Graphics.width) - pointswindow.width=160 if pointswindow.width<=160 - if msgwindow.y==0 - pointswindow.y=Graphics.height-pointswindow.height + pointswindow.resizeToFit(pointswindow.text, Graphics.width) + pointswindow.width = 160 if pointswindow.width <= 160 + if msgwindow.y == 0 + pointswindow.y = Graphics.height - pointswindow.height else - pointswindow.y=0 + pointswindow.y = 0 end - pointswindow.viewport=msgwindow.viewport - pointswindow.z=msgwindow.z + pointswindow.viewport = msgwindow.viewport + pointswindow.z = msgwindow.z return pointswindow end @@ -377,39 +377,39 @@ end # #=============================================================================== def pbCreateStatusWindow(viewport = nil) - msgwindow=Window_AdvancedTextPokemon.new("") + msgwindow = Window_AdvancedTextPokemon.new("") if !viewport - msgwindow.z=99999 + msgwindow.z = 99999 else - msgwindow.viewport=viewport + msgwindow.viewport = viewport end - msgwindow.visible=false - msgwindow.letterbyletter=false - pbBottomLeftLines(msgwindow,2) - skinfile=MessageConfig.pbGetSpeechFrame() + msgwindow.visible = false + msgwindow.letterbyletter = false + pbBottomLeftLines(msgwindow, 2) + skinfile = MessageConfig.pbGetSpeechFrame() msgwindow.setSkin(skinfile) return msgwindow end -def pbCreateMessageWindow(viewport = nil,skin = nil) - msgwindow=Window_AdvancedTextPokemon.new("") +def pbCreateMessageWindow(viewport = nil, skin = nil) + msgwindow = Window_AdvancedTextPokemon.new("") if !viewport - msgwindow.z=99999 + msgwindow.z = 99999 else - msgwindow.viewport=viewport + msgwindow.viewport = viewport end - msgwindow.visible=true - msgwindow.letterbyletter=true - msgwindow.back_opacity=MessageConfig::WINDOW_OPACITY - pbBottomLeftLines(msgwindow,2) - $game_temp.message_window_showing=true if $game_temp - skin=MessageConfig.pbGetSpeechFrame() if !skin + msgwindow.visible = true + msgwindow.letterbyletter = true + msgwindow.back_opacity = MessageConfig::WINDOW_OPACITY + pbBottomLeftLines(msgwindow, 2) + $game_temp.message_window_showing = true if $game_temp + skin = MessageConfig.pbGetSpeechFrame() if !skin msgwindow.setSkin(skin) return msgwindow end def pbDisposeMessageWindow(msgwindow) - $game_temp.message_window_showing=false if $game_temp + $game_temp.message_window_showing = false if $game_temp msgwindow.dispose end @@ -418,29 +418,29 @@ end #=============================================================================== # Main message-displaying function #=============================================================================== -def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) +def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil) return if !msgwindow - oldletterbyletter=msgwindow.letterbyletter - msgwindow.letterbyletter=(letterbyletter) ? true : false - ret=nil - commands=nil - facewindow=nil - goldwindow=nil - coinwindow=nil - battlepointswindow=nil - cmdvariable=0 - cmdIfCancel=0 - msgwindow.waitcount=0 - autoresume=false - text=message.clone - msgback=nil - linecount=(Graphics.height>400) ? 3 : 2 + oldletterbyletter = msgwindow.letterbyletter + msgwindow.letterbyletter = (letterbyletter) ? true : false + ret = nil + commands = nil + facewindow = nil + goldwindow = nil + coinwindow = nil + battlepointswindow = nil + cmdvariable = 0 + cmdIfCancel = 0 + msgwindow.waitcount = 0 + autoresume = false + text = message.clone + msgback = nil + linecount = (Graphics.height > 400) ? 3 : 2 ### Text replacement text.gsub!(/\\sign\[([^\]]*)\]/i) { # \sign[something] gets turned into - next "\\op\\cl\\ts[]\\w["+$1+"]" # \op\cl\ts[]\w[something] + next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something] } - text.gsub!(/\\\\/,"\5") - text.gsub!(/\\1/,"\1") + text.gsub!(/\\\\/, "\5") + text.gsub!(/\\1/, "\1") if $game_actors text.gsub!(/\\n\[([1-8])\]/i) { m = $1.to_i @@ -461,17 +461,17 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) text.gsub!(/\\r/i, "") text.gsub!(/\\[Ww]\[([^\]]*)\]/) { w = $1.to_s - if w=="" + if w == "" msgwindow.windowskin = nil else - msgwindow.setSkin("Graphics/Windowskins/#{w}",false) + msgwindow.setSkin("Graphics/Windowskins/#{w}", false) end next "" } isDarkSkin = isDarkWindowskin(msgwindow.windowskin) text.gsub!(/\\[Cc]\[([0-9]+)\]/) { m = $1.to_i - next getSkinColor(msgwindow.windowskin,m,isDarkSkin) + next getSkinColor(msgwindow.windowskin, m, isDarkSkin) } loop do last_text = text.clone @@ -481,33 +481,33 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) loop do last_text = text.clone text.gsub!(/\\l\[([0-9]+)\]/i) { - linecount = [1,$1.to_i].max + linecount = [1, $1.to_i].max next "" } break if text == last_text end colortag = "" if $game_system && $game_system.message_frame != 0 - colortag = getSkinColor(msgwindow.windowskin,0,true) + colortag = getSkinColor(msgwindow.windowskin, 0, true) else - colortag = getSkinColor(msgwindow.windowskin,0,isDarkSkin) + colortag = getSkinColor(msgwindow.windowskin, 0, isDarkSkin) end - text = colortag+text + text = colortag + text ### Controls - textchunks=[] - controls=[] + textchunks = [] + controls = [] while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|pt|wd|wm|op|cl|wu|\.|\||\!|\^))/i] textchunks.push($~.pre_match) if $~[1] - controls.push([$~[1].downcase,$~[2],-1]) + controls.push([$~[1].downcase, $~[2], -1]) else - controls.push([$~[3].downcase,"",-1]) + controls.push([$~[3].downcase, "", -1]) end - text=$~.post_match + text = $~.post_match end textchunks.push(text) for chunk in textchunks - chunk.gsub!(/\005/,"\\") + chunk.gsub!(/\005/, "\\") end textlen = 0 for i in 0...controls.length @@ -523,7 +523,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) end text = textchunks.join("") signWaitCount = 0 - signWaitTime = Graphics.frame_rate/2 + signWaitTime = Graphics.frame_rate / 2 haveSpecialClose = false specialCloseSE = "" for i in 0...controls.length @@ -531,9 +531,9 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) param = controls[i][1] case control when "op" - signWaitCount = signWaitTime+1 + signWaitCount = signWaitTime + 1 when "cl" - text = text.sub(/\001\z/,"") # fix: '$' can match end of line as well + text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well haveSpecialClose = true specialCloseSE = param when "f" @@ -547,59 +547,59 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) cmdvariable = pbCsvPosInt!(cmds) cmdIfCancel = pbCsvField!(cmds).to_i commands = [] - while cmds.length>0 + while cmds.length > 0 commands.push(pbCsvField!(cmds)) end when "wtnp", "^" - text = text.sub(/\001\z/,"") # fix: '$' can match end of line as well + text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well when "se" - if controls[i][2]==0 + if controls[i][2] == 0 startSE = param controls[i] = nil end end end - if startSE!=nil + if startSE != nil pbSEPlay(pbStringToAudioFile(startSE)) - elsif signWaitCount==0 && letterbyletter + elsif signWaitCount == 0 && letterbyletter pbPlayDecisionSE() end ########## Position message window ############## - pbRepositionMessageWindow(msgwindow,linecount) + pbRepositionMessageWindow(msgwindow, linecount) if facewindow - pbPositionNearMsgWindow(facewindow,msgwindow,:left) + pbPositionNearMsgWindow(facewindow, msgwindow, :left) facewindow.viewport = msgwindow.viewport facewindow.z = msgwindow.z end - atTop = (msgwindow.y==0) + atTop = (msgwindow.y == 0) ########## Show text ############################# msgwindow.text = text - Graphics.frame_reset if Graphics.frame_rate>40 + Graphics.frame_reset if Graphics.frame_rate > 40 loop do - if signWaitCount>0 + if signWaitCount > 0 signWaitCount -= 1 if atTop - msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime + msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime else - msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime + msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime end end for i in 0...controls.length next if !controls[i] - next if controls[i][2]>msgwindow.position || msgwindow.waitcount!=0 + next if controls[i][2] > msgwindow.position || msgwindow.waitcount != 0 control = controls[i][0] param = controls[i][1] case control when "f" facewindow.dispose if facewindow facewindow = PictureWindow.new("Graphics/Pictures/#{param}") - pbPositionNearMsgWindow(facewindow,msgwindow,:left) + pbPositionNearMsgWindow(facewindow, msgwindow, :left) facewindow.viewport = msgwindow.viewport facewindow.z = msgwindow.z when "ff" facewindow.dispose if facewindow facewindow = FaceWindowVX.new(param) - pbPositionNearMsgWindow(facewindow,msgwindow,:left) + pbPositionNearMsgWindow(facewindow, msgwindow, :left) facewindow.viewport = msgwindow.viewport facewindow.z = msgwindow.z when "g" # Display gold window @@ -607,7 +607,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) goldwindow = pbDisplayGoldWindow(msgwindow) when "cn" # Display coins window coinwindow.dispose if coinwindow - coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow) + coinwindow = pbDisplayCoinsWindow(msgwindow, goldwindow) when "pt" # Display battle points window battlepointswindow.dispose if battlepointswindow battlepointswindow = pbDisplayBattlePointsWindow(msgwindow) @@ -615,31 +615,31 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) msgwindow.y = 0 atTop = true msgback.y = msgwindow.y if msgback - pbPositionNearMsgWindow(facewindow,msgwindow,:left) - msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime + pbPositionNearMsgWindow(facewindow, msgwindow, :left) + msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime when "wm" atTop = false - msgwindow.y = (Graphics.height-msgwindow.height)/2 + msgwindow.y = (Graphics.height - msgwindow.height) / 2 msgback.y = msgwindow.y if msgback - pbPositionNearMsgWindow(facewindow,msgwindow,:left) + pbPositionNearMsgWindow(facewindow, msgwindow, :left) when "wd" atTop = false - msgwindow.y = Graphics.height-msgwindow.height + msgwindow.y = Graphics.height - msgwindow.height msgback.y = msgwindow.y if msgback - pbPositionNearMsgWindow(facewindow,msgwindow,:left) - msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime + pbPositionNearMsgWindow(facewindow, msgwindow, :left) + msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime when "ts" # Change text speed - msgwindow.textspeed = (param=="") ? -999 : param.to_i + msgwindow.textspeed = (param == "") ? -999 : param.to_i when "." # Wait 0.25 seconds - msgwindow.waitcount += Graphics.frame_rate/4 + msgwindow.waitcount += Graphics.frame_rate / 4 when "|" # Wait 1 second msgwindow.waitcount += Graphics.frame_rate when "wt" # Wait X/20 seconds - param = param.sub(/\A\s+/,"").sub(/\s+\z/,"") - msgwindow.waitcount += param.to_i*Graphics.frame_rate/20 + param = param.sub(/\A\s+/, "").sub(/\s+\z/, "") + msgwindow.waitcount += param.to_i * Graphics.frame_rate / 20 when "wtnp" # Wait X/20 seconds, no pause - param = param.sub(/\A\s+/,"").sub(/\s+\z/,"") - msgwindow.waitcount = param.to_i*Graphics.frame_rate/20 + param = param.sub(/\A\s+/, "").sub(/\s+\z/, "") + msgwindow.waitcount = param.to_i * Graphics.frame_rate / 20 autoresume = true when "^" # Wait, no pause autoresume = true @@ -654,7 +654,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) Graphics.update Input.update facewindow.update if facewindow - if autoresume && msgwindow.waitcount==0 + if autoresume && msgwindow.waitcount == 0 msgwindow.resume if msgwindow.busy? break if !msgwindow.busy? end @@ -663,7 +663,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) pbPlayDecisionSE if msgwindow.pausing? msgwindow.resume else - break if signWaitCount==0 + break if signWaitCount == 0 end end pbUpdateSceneMap @@ -672,13 +672,13 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) break if (!letterbyletter || commandProc || commands) && !msgwindow.busy? end Input.update # Must call Input.update again to avoid extra triggers - msgwindow.letterbyletter=oldletterbyletter + msgwindow.letterbyletter = oldletterbyletter if commands - $game_variables[cmdvariable]=pbShowCommands(msgwindow,commands,cmdIfCancel) + $game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel) $game_map.need_refresh = true if $game_map end if commandProc - ret=commandProc.call(msgwindow) + ret = commandProc.call(msgwindow) end msgback.dispose if msgback goldwindow.dispose if goldwindow @@ -687,12 +687,12 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil) facewindow.dispose if facewindow if haveSpecialClose pbSEPlay(pbStringToAudioFile(specialCloseSE)) - atTop = (msgwindow.y==0) + atTop = (msgwindow.y == 0) for i in 0..signWaitTime if atTop - msgwindow.y = -msgwindow.height*i/signWaitTime + msgwindow.y = -msgwindow.height * i / signWaitTime else - msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-i)/signWaitTime + msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - i) / signWaitTime end Graphics.update Input.update @@ -708,49 +708,49 @@ end #=============================================================================== # Message-displaying functions #=============================================================================== -def pbMessage(message,commands = nil,cmdIfCancel = 0,skin = nil,defaultCmd = 0,&block) +def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = 0, &block) ret = 0 - msgwindow = pbCreateMessageWindow(nil,skin) + msgwindow = pbCreateMessageWindow(nil, skin) if commands - ret = pbMessageDisplay(msgwindow,message,true, + ret = pbMessageDisplay(msgwindow, message, true, proc { |msgwindow| - next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block) - },&block) + next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block) + }, &block) else - pbMessageDisplay(msgwindow,message,&block) + pbMessageDisplay(msgwindow, message, &block) end pbDisposeMessageWindow(msgwindow) Input.update return ret end -def pbConfirmMessage(message,&block) - return (pbMessage(message,[_INTL("Yes"),_INTL("No")],2,&block)==0) +def pbConfirmMessage(message, &block) + return (pbMessage(message, [_INTL("Yes"), _INTL("No")], 2, &block) == 0) end -def pbConfirmMessageSerious(message,&block) - return (pbMessage(message,[_INTL("No"),_INTL("Yes")],1,&block)==1) +def pbConfirmMessageSerious(message, &block) + return (pbMessage(message, [_INTL("No"), _INTL("Yes")], 1, &block) == 1) end -def pbMessageChooseNumber(message,params,&block) - msgwindow = pbCreateMessageWindow(nil,params.messageSkin) - ret = pbMessageDisplay(msgwindow,message,true, +def pbMessageChooseNumber(message, params, &block) + msgwindow = pbCreateMessageWindow(nil, params.messageSkin) + ret = pbMessageDisplay(msgwindow, message, true, proc { |msgwindow| - next pbChooseNumber(msgwindow,params,&block) - },&block) + next pbChooseNumber(msgwindow, params, &block) + }, &block) pbDisposeMessageWindow(msgwindow) return ret end -def pbShowCommands(msgwindow,commands = nil,cmdIfCancel = 0,defaultCmd = 0) +def pbShowCommands(msgwindow, commands = nil, cmdIfCancel = 0, defaultCmd = 0) return 0 if !commands - cmdwindow=Window_CommandPokemonEx.new(commands) - cmdwindow.z=99999 - cmdwindow.visible=true + cmdwindow = Window_CommandPokemonEx.new(commands) + cmdwindow.z = 99999 + cmdwindow.visible = true cmdwindow.resizeToFit(cmdwindow.commands) - pbPositionNearMsgWindow(cmdwindow,msgwindow,:right) - cmdwindow.index=defaultCmd - command=0 + pbPositionNearMsgWindow(cmdwindow, msgwindow, :right) + cmdwindow.index = defaultCmd + command = 0 loop do Graphics.update Input.update @@ -758,80 +758,80 @@ def pbShowCommands(msgwindow,commands = nil,cmdIfCancel = 0,defaultCmd = 0) msgwindow.update if msgwindow yield if block_given? if Input.trigger?(Input::BACK) - if cmdIfCancel>0 - command=cmdIfCancel-1 + if cmdIfCancel > 0 + command = cmdIfCancel - 1 break - elsif cmdIfCancel<0 - command=cmdIfCancel + elsif cmdIfCancel < 0 + command = cmdIfCancel break end end if Input.trigger?(Input::USE) - command=cmdwindow.index + command = cmdwindow.index break end pbUpdateSceneMap end - ret=command + ret = command cmdwindow.dispose Input.update return ret end -def pbShowCommandsWithHelp(msgwindow,commands,help,cmdIfCancel = 0,defaultCmd = 0) - msgwin=msgwindow - msgwin=pbCreateMessageWindow(nil) if !msgwindow - oldlbl=msgwin.letterbyletter - msgwin.letterbyletter=false +def pbShowCommandsWithHelp(msgwindow, commands, help, cmdIfCancel = 0, defaultCmd = 0) + msgwin = msgwindow + msgwin = pbCreateMessageWindow(nil) if !msgwindow + oldlbl = msgwin.letterbyletter + msgwin.letterbyletter = false if commands - cmdwindow=Window_CommandPokemonEx.new(commands) - cmdwindow.z=99999 - cmdwindow.visible=true + cmdwindow = Window_CommandPokemonEx.new(commands) + cmdwindow.z = 99999 + cmdwindow.visible = true cmdwindow.resizeToFit(cmdwindow.commands) - cmdwindow.height=msgwin.y if cmdwindow.height>msgwin.y - cmdwindow.index=defaultCmd - command=0 - msgwin.text=help[cmdwindow.index] - msgwin.width=msgwin.width # Necessary evil to make it use the proper margins + cmdwindow.height = msgwin.y if cmdwindow.height > msgwin.y + cmdwindow.index = defaultCmd + command = 0 + msgwin.text = help[cmdwindow.index] + msgwin.width = msgwin.width # Necessary evil to make it use the proper margins loop do Graphics.update Input.update - oldindex=cmdwindow.index + oldindex = cmdwindow.index cmdwindow.update - if oldindex!=cmdwindow.index - msgwin.text=help[cmdwindow.index] + if oldindex != cmdwindow.index + msgwin.text = help[cmdwindow.index] end msgwin.update yield if block_given? if Input.trigger?(Input::BACK) - if cmdIfCancel>0 - command=cmdIfCancel-1 + if cmdIfCancel > 0 + command = cmdIfCancel - 1 break - elsif cmdIfCancel<0 - command=cmdIfCancel + elsif cmdIfCancel < 0 + command = cmdIfCancel break end end if Input.trigger?(Input::USE) - command=cmdwindow.index + command = cmdwindow.index break end pbUpdateSceneMap end - ret=command + ret = command cmdwindow.dispose Input.update end - msgwin.letterbyletter=oldlbl + msgwin.letterbyletter = oldlbl msgwin.dispose if !msgwindow return ret end # frames is the number of 1/20 seconds to wait for -def pbMessageWaitForInput(msgwindow,frames,showPause = false) - return if !frames || frames<=0 +def pbMessageWaitForInput(msgwindow, frames, showPause = false) + return if !frames || frames <= 0 msgwindow.startPause if msgwindow && showPause - frames = frames*Graphics.frame_rate/20 + frames = frames * Graphics.frame_rate / 20 frames.times do Graphics.update Input.update @@ -845,24 +845,24 @@ def pbMessageWaitForInput(msgwindow,frames,showPause = false) msgwindow.stopPause if msgwindow && showPause end -def pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width = 240) - window=Window_TextEntry_Keyboard.new(currenttext,0,0,width,64) - ret="" - window.maxlength=maxlength - window.visible=true - window.z=99999 - pbPositionNearMsgWindow(window,msgwindow,:right) - window.text=currenttext - window.passwordChar="*" if passwordbox +def pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width = 240) + window = Window_TextEntry_Keyboard.new(currenttext, 0, 0, width, 64) + ret = "" + window.maxlength = maxlength + window.visible = true + window.z = 99999 + pbPositionNearMsgWindow(window, msgwindow, :right) + window.text = currenttext + window.passwordChar = "*" if passwordbox Input.text_input = true loop do Graphics.update Input.update if Input.triggerex?(:ESCAPE) - ret=currenttext + ret = currenttext break elsif Input.triggerex?(:RETURN) - ret=window.text + ret = window.text break end window.update @@ -875,12 +875,12 @@ def pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width = 240) return ret end -def pbMessageFreeText(message,currenttext,passwordbox,maxlength,width = 240,&block) - msgwindow=pbCreateMessageWindow - retval=pbMessageDisplay(msgwindow,message,true, +def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block) + msgwindow = pbCreateMessageWindow + retval = pbMessageDisplay(msgwindow, message, true, proc { |msgwindow| - next pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width,&block) - },&block) + next pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width, &block) + }, &block) pbDisposeMessageWindow(msgwindow) return retval end diff --git a/Data/Scripts/007_Objects and windows/012_TextEntry.rb b/Data/Scripts/007_Objects and windows/012_TextEntry.rb index a75363d90..1c82ea3a0 100644 --- a/Data/Scripts/007_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/007_Objects and windows/012_TextEntry.rb @@ -8,22 +8,22 @@ class CharacterEntryHelper attr_accessor :cursor def initialize(text) - @maxlength=-1 - @text=text - @passwordChar="" - @cursor=text.scan(/./m).length + @maxlength = -1 + @text = text + @passwordChar = "" + @cursor = text.scan(/./m).length end def textChars - chars=text.scan(/./m) - if @passwordChar!="" + chars = text.scan(/./m) + if @passwordChar != "" chars.length.times { |i| chars[i] = @passwordChar } end return chars end def passwordChar=(value) - @passwordChar=value ? value : "" + @passwordChar = value ? value : "" end def length @@ -31,52 +31,52 @@ class CharacterEntryHelper end def canInsert? - chars=self.text.scan(/./m) - return false if @maxlength>=0 && chars.length>=@maxlength + chars = self.text.scan(/./m) + return false if @maxlength >= 0 && chars.length >= @maxlength return true end def insert(ch) - chars=self.text.scan(/./m) - return false if @maxlength>=0 && chars.length>=@maxlength - chars.insert(@cursor,ch) - @text="" + chars = self.text.scan(/./m) + return false if @maxlength >= 0 && chars.length >= @maxlength + chars.insert(@cursor, ch) + @text = "" for ch in chars - @text+=ch if ch + @text += ch if ch end - @cursor+=1 + @cursor += 1 return true end def canDelete? - chars=self.text.scan(/./m) - return false if chars.length<=0 || @cursor<=0 + chars = self.text.scan(/./m) + return false if chars.length <= 0 || @cursor <= 0 return true end def delete - chars=self.text.scan(/./m) - return false if chars.length<=0 || @cursor<=0 - chars.delete_at(@cursor-1) - @text="" + chars = self.text.scan(/./m) + return false if chars.length <= 0 || @cursor <= 0 + chars.delete_at(@cursor - 1) + @text = "" for ch in chars - @text+=ch if ch + @text += ch if ch end - @cursor-=1 + @cursor -= 1 return true end private def ensure - return if @maxlength<0 - chars=self.text.scan(/./m) - if chars.length>@maxlength && @maxlength>=0 - chars=chars[0,@maxlength] + return if @maxlength < 0 + chars = self.text.scan(/./m) + if chars.length > @maxlength && @maxlength >= 0 + chars = chars[0, @maxlength] end - @text="" + @text = "" for ch in chars - @text+=ch if ch + @text += ch if ch end end end @@ -87,19 +87,19 @@ end # #=============================================================================== class Window_TextEntry < SpriteWindow_Base - def initialize(text,x,y,width,height,heading = nil,usedarkercolor = false) - super(x,y,width,height) - colors=getDefaultTextColors(self.windowskin) - @baseColor=colors[0] - @shadowColor=colors[1] + def initialize(text, x, y, width, height, heading = nil, usedarkercolor = false) + super(x, y, width, height) + colors = getDefaultTextColors(self.windowskin) + @baseColor = colors[0] + @shadowColor = colors[1] if usedarkercolor - @baseColor=Color.new(16,24,32) - @shadowColor=Color.new(168,184,184) + @baseColor = Color.new(16, 24, 32) + @shadowColor = Color.new(168, 184, 184) end - @helper=CharacterEntryHelper.new(text) - @heading=heading - self.active=true - @frame=0 + @helper = CharacterEntryHelper.new(text) + @heading = heading + self.active = true + @frame = 0 refresh end @@ -116,23 +116,23 @@ class Window_TextEntry < SpriteWindow_Base end def text=(value) - @helper.text=value + @helper.text = value self.refresh end def passwordChar=(value) - @helper.passwordChar=value + @helper.passwordChar = value refresh end def maxlength=(value) - @helper.maxlength=value + @helper.maxlength = value self.refresh end def insert(ch) if @helper.insert(ch) - @frame=0 + @frame = 0 self.refresh return true end @@ -141,7 +141,7 @@ class Window_TextEntry < SpriteWindow_Base def delete if @helper.delete - @frame=0 + @frame = 0 self.refresh return true end @@ -151,7 +151,7 @@ class Window_TextEntry < SpriteWindow_Base def update @frame += 1 @frame %= 20 - self.refresh if (@frame%10)==0 + self.refresh if (@frame % 10) == 0 return if !self.active # Moving cursor if Input.repeat?(Input::LEFT) && Input.press?(Input::ACTION) @@ -172,47 +172,47 @@ class Window_TextEntry < SpriteWindow_Base end def refresh - self.contents=pbDoEnsureBitmap(self.contents,self.width-self.borderX, - self.height-self.borderY) - bitmap=self.contents + self.contents = pbDoEnsureBitmap(self.contents, self.width - self.borderX, + self.height - self.borderY) + bitmap = self.contents bitmap.clear - x=0 - y=0 + x = 0 + y = 0 if @heading - textwidth=bitmap.text_size(@heading).width - pbDrawShadowText(bitmap,x,y, textwidth+4, 32, @heading,@baseColor,@shadowColor) - y+=32 + textwidth = bitmap.text_size(@heading).width + pbDrawShadowText(bitmap, x, y, textwidth + 4, 32, @heading, @baseColor, @shadowColor) + y += 32 end - x+=4 - width=self.width-self.borderX - cursorcolor=Color.new(16,24,32) - textscan=self.text.scan(/./m) - scanlength=textscan.length - @helper.cursor=scanlength if @helper.cursor>scanlength - @helper.cursor=0 if @helper.cursor<0 - startpos=@helper.cursor - fromcursor=0 - while (startpos>0) - c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[startpos-1] - fromcursor+=bitmap.text_size(c).width - break if fromcursor>width-4 - startpos-=1 + x += 4 + width = self.width - self.borderX + cursorcolor = Color.new(16, 24, 32) + textscan = self.text.scan(/./m) + scanlength = textscan.length + @helper.cursor = scanlength if @helper.cursor > scanlength + @helper.cursor = 0 if @helper.cursor < 0 + startpos = @helper.cursor + fromcursor = 0 + while (startpos > 0) + c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[startpos - 1] + fromcursor += bitmap.text_size(c).width + break if fromcursor > width - 4 + startpos -= 1 end for i in startpos...scanlength - c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[i] - textwidth=bitmap.text_size(c).width - next if c=="\n" + c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[i] + textwidth = bitmap.text_size(c).width + next if c == "\n" # Draw text - pbDrawShadowText(bitmap,x,y, textwidth+4, 32, c,@baseColor,@shadowColor) + pbDrawShadowText(bitmap, x, y, textwidth + 4, 32, c, @baseColor, @shadowColor) # Draw cursor if necessary - if ((@frame/10)&1) == 0 && i==@helper.cursor - bitmap.fill_rect(x,y+4,2,24,cursorcolor) + if ((@frame / 10) & 1) == 0 && i == @helper.cursor + bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor) end # Add x to drawn text width x += textwidth end - if ((@frame/10)&1) == 0 && textscan.length==@helper.cursor - bitmap.fill_rect(x,y+4,2,24,cursorcolor) + if ((@frame / 10) & 1) == 0 && textscan.length == @helper.cursor + bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor) end end end @@ -224,27 +224,27 @@ end #=============================================================================== class Window_TextEntry_Keyboard < Window_TextEntry def update - @frame+=1 - @frame%=20 - self.refresh if ((@frame%10)==0) + @frame += 1 + @frame %= 20 + self.refresh if ((@frame % 10) == 0) return if !self.active # Moving cursor if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT) if @helper.cursor > 0 - @helper.cursor-=1 - @frame=0 + @helper.cursor -= 1 + @frame = 0 self.refresh end return elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT) if @helper.cursor < self.text.scan(/./m).length - @helper.cursor+=1 - @frame=0 + @helper.cursor += 1 + @frame = 0 self.refresh end return elsif Input.triggerex?(:BACKSPACE) || Input.repeatex?(:BACKSPACE) - self.delete if @helper.cursor>0 + self.delete if @helper.cursor > 0 return elsif Input.triggerex?(:RETURN) || Input.triggerex?(:ESCAPE) return @@ -259,17 +259,17 @@ end # #=============================================================================== class Window_MultilineTextEntry < SpriteWindow_Base - def initialize(text,x,y,width,height) - super(x,y,width,height) - colors=getDefaultTextColors(self.windowskin) - @baseColor=colors[0] - @shadowColor=colors[1] - @helper=CharacterEntryHelper.new(text) - @firstline=0 - @cursorLine=0 - @cursorColumn=0 - @frame=0 - self.active=true + def initialize(text, x, y, width, height) + super(x, y, width, height) + colors = getDefaultTextColors(self.windowskin) + @baseColor = colors[0] + @shadowColor = colors[1] + @helper = CharacterEntryHelper.new(text) + @firstline = 0 + @cursorLine = 0 + @cursorColumn = 0 + @frame = 0 + self.active = true refresh end @@ -277,12 +277,12 @@ class Window_MultilineTextEntry < SpriteWindow_Base attr_reader :shadowColor def baseColor=(value) - @baseColor=value + @baseColor = value refresh end def shadowColor=(value) - @shadowColor=value + @shadowColor = value refresh end @@ -295,23 +295,23 @@ class Window_MultilineTextEntry < SpriteWindow_Base end def text=(value) - @helper.text=value - @textchars=nil + @helper.text = value + @textchars = nil self.refresh end def maxlength=(value) - @helper.maxlength=value - @textchars=nil + @helper.maxlength = value + @textchars = nil self.refresh end def insert(ch) - @helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn) + @helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn) if @helper.insert(ch) - @frame=0 - @textchars=nil - moveCursor(0,1) + @frame = 0 + @textchars = nil + moveCursor(0, 1) self.refresh return true end @@ -319,11 +319,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base end def delete - @helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn) + @helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn) if @helper.delete - @frame=0 - moveCursor(0,-1) # use old textchars - @textchars=nil + @frame = 0 + moveCursor(0, -1) # use old textchars + @textchars = nil self.refresh return true end @@ -332,67 +332,67 @@ class Window_MultilineTextEntry < SpriteWindow_Base def getTextChars if !@textchars - @textchars=getLineBrokenText(self.contents,@helper.text, - self.contents.width,nil) + @textchars = getLineBrokenText(self.contents, @helper.text, + self.contents.width, nil) end return @textchars end def getTotalLines - textchars=getTextChars - return 1 if textchars.length==0 - tchar=textchars[textchars.length-1] - return tchar[5]+1 + textchars = getTextChars + return 1 if textchars.length == 0 + tchar = textchars[textchars.length - 1] + return tchar[5] + 1 end def getLineY(line) - textchars=getTextChars - return 0 if textchars.length==0 - totallines=getTotalLines() - line=0 if line<0 - line=totallines-1 if line>=totallines - maximumY=0 + textchars = getTextChars + return 0 if textchars.length == 0 + totallines = getTotalLines() + line = 0 if line < 0 + line = totallines - 1 if line >= totallines + maximumY = 0 for i in 0...textchars.length - thisline=textchars[i][5] - y=textchars[i][2] - return y if thisline==line - maximumY=y if maximumY=totallines - endpos=0 + textchars = getTextChars + 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 + thisline = textchars[i][5] + thislength = textchars[i][8] + endpos += thislength if thisline == line end return endpos end - def getPosFromLineAndColumn(line,column) - textchars=getTextChars - return 0 if textchars.length==0 - totallines=getTotalLines() - line=0 if line<0 - line=totallines-1 if line>=totallines - endpos=0 + def getPosFromLineAndColumn(line, column) + textchars = getTextChars + 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 + 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) + if column >= thiscolumn && column <= thiscolumn + thislength && thislength > 0 + return thispos + (column - thiscolumn) end end end @@ -406,89 +406,89 @@ class Window_MultilineTextEntry < SpriteWindow_Base def getLastVisibleLine getTextChars() - textheight=[1,self.contents.text_size("X").height].max - lastVisible=@firstline+((self.height-self.borderY)/textheight)-1 + textheight = [1, self.contents.text_size("X").height].max + lastVisible = @firstline + ((self.height - self.borderY) / textheight) - 1 return lastVisible end def updateCursorPos(doRefresh) # Calculate new cursor position - @helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn) + @helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn) if doRefresh - @frame=0 + @frame = 0 self.refresh end - @firstline=@cursorLine if @cursorLine<@firstline - lastVisible=getLastVisibleLine() - @firstline+=(@cursorLine-lastVisible) if @cursorLine>lastVisible + @firstline = @cursorLine if @cursorLine < @firstline + lastVisible = getLastVisibleLine() + @firstline += (@cursorLine - lastVisible) if @cursorLine > lastVisible end def moveCursor(lineOffset, columnOffset) # Move column offset first, then lines (since column offset # can affect line offset) # echoln ["beforemoving",@cursorLine,@cursorColumn] - totalColumns=getColumnsInLine(@cursorLine) # check current line - totalLines=getTotalLines() - oldCursorLine=@cursorLine - oldCursorColumn=@cursorColumn - @cursorColumn+=columnOffset - if @cursorColumn<0 && @cursorLine>0 + totalColumns = getColumnsInLine(@cursorLine) # check current line + totalLines = getTotalLines() + oldCursorLine = @cursorLine + oldCursorColumn = @cursorColumn + @cursorColumn += columnOffset + if @cursorColumn < 0 && @cursorLine > 0 # Will happen if cursor is moved left from the beginning of a line - @cursorLine-=1 - @cursorColumn=getColumnsInLine(@cursorLine) - elsif @cursorColumn>totalColumns && @cursorLine totalColumns && @cursorLine < totalLines - 1 # Will happen if cursor is moved right from the end of a line - @cursorLine+=1 - @cursorColumn=0 + @cursorLine += 1 + @cursorColumn = 0 end # Ensure column bounds - totalColumns=getColumnsInLine(@cursorLine) - @cursorColumn=totalColumns if @cursorColumn>totalColumns - @cursorColumn=0 if @cursorColumn<0 # totalColumns can be 0 + totalColumns = getColumnsInLine(@cursorLine) + @cursorColumn = totalColumns if @cursorColumn > totalColumns + @cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0 # Move line offset - @cursorLine+=lineOffset - @cursorLine=0 if @cursorLine<0 - @cursorLine=totalLines-1 if @cursorLine>=totalLines + @cursorLine += lineOffset + @cursorLine = 0 if @cursorLine < 0 + @cursorLine = totalLines - 1 if @cursorLine >= totalLines # Ensure column bounds again - totalColumns=getColumnsInLine(@cursorLine) - @cursorColumn=totalColumns if @cursorColumn>totalColumns - @cursorColumn=0 if @cursorColumn<0 # totalColumns can be 0 + totalColumns = getColumnsInLine(@cursorLine) + @cursorColumn = totalColumns if @cursorColumn > totalColumns + @cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0 updateCursorPos( - oldCursorLine!=@cursorLine || - oldCursorColumn!=@cursorColumn + oldCursorLine != @cursorLine || + oldCursorColumn != @cursorColumn ) # echoln ["aftermoving",@cursorLine,@cursorColumn] end def update - @frame+=1 - @frame%=20 - self.refresh if ((@frame%10)==0) + @frame += 1 + @frame %= 20 + self.refresh if ((@frame % 10) == 0) return if !self.active # Moving cursor if Input.triggerex?(:UP) || Input.repeatex?(:UP) - moveCursor(-1,0) + moveCursor(-1, 0) return elsif Input.triggerex?(:DOWN) || Input.repeatex?(:DOWN) - moveCursor(1,0) + moveCursor(1, 0) return elsif Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT) - moveCursor(0,-1) + moveCursor(0, -1) return elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT) - moveCursor(0,1) + moveCursor(0, 1) return end if Input.press?(Input::CTRL) && Input.triggerex?(:HOME) # Move cursor to beginning - @cursorLine=0 - @cursorColumn=0 + @cursorLine = 0 + @cursorColumn = 0 updateCursorPos(true) return elsif Input.press?(Input::CTRL) && Input.triggerex?(:END) # Move cursor to end - @cursorLine=getTotalLines()-1 - @cursorColumn=getColumnsInLine(@cursorLine) + @cursorLine = getTotalLines() - 1 + @cursorColumn = getColumnsInLine(@cursorLine) updateCursorPos(true) return elsif Input.triggerex?(:RETURN) || Input.repeatex?(:RETURN) @@ -502,59 +502,59 @@ class Window_MultilineTextEntry < SpriteWindow_Base end def refresh - newContents=pbDoEnsureBitmap(self.contents,self.width-self.borderX, - self.height-self.borderY) - @textchars=nil if self.contents!=newContents - self.contents=newContents - bitmap=self.contents + newContents = pbDoEnsureBitmap(self.contents, self.width - self.borderX, + self.height - self.borderY) + @textchars = nil if self.contents != newContents + self.contents = newContents + bitmap = self.contents bitmap.clear getTextChars - height=self.height-self.borderY - cursorcolor=Color.new(0,0,0) - textchars=getTextChars() - startY=getLineY(@firstline) + height = self.height - self.borderY + cursorcolor = Color.new(0, 0, 0) + textchars = getTextChars() + startY = getLineY(@firstline) for i in 0...textchars.length - thisline=textchars[i][5] - thiscolumn=textchars[i][7] - thislength=textchars[i][8] - textY=textchars[i][2]-startY + thisline = textchars[i][5] + thiscolumn = textchars[i][7] + thislength = textchars[i][8] + textY = textchars[i][2] - startY # Don't draw lines before the first or zero-length segments - next if thisline<@firstline || thislength==0 + next if thisline < @firstline || thislength == 0 # Don't draw lines beyond the window's height break if textY >= height - c=textchars[i][0] + 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 - textheight=textchars[i][4] + next if c == " " + textwidth = textchars[i][3] + 4 # add 4 to prevent draw_text from stretching text + textheight = textchars[i][4] # Draw text pbDrawShadowText(bitmap, textchars[i][1], textY, textwidth, textheight, c, @baseColor, @shadowColor) end # Draw cursor - if ((@frame/10)&1) == 0 - textheight=bitmap.text_size("X").height - cursorY=(textheight*@cursorLine)-startY - cursorX=0 + if ((@frame / 10) & 1) == 0 + textheight = bitmap.text_size("X").height + cursorY = (textheight * @cursorLine) - startY + cursorX = 0 for i in 0...textchars.length - thisline=textchars[i][5] - thiscolumn=textchars[i][7] - thislength=textchars[i][8] - if thisline==@cursorLine && @cursorColumn>=thiscolumn && - @cursorColumn<=thiscolumn+thislength - cursorY=textchars[i][2]-startY - cursorX=textchars[i][1] - textheight=textchars[i][4] - posToCursor=@cursorColumn-thiscolumn - if posToCursor>=0 - partialString=textchars[i][0].scan(/./m)[0,posToCursor].join("") - cursorX+=bitmap.text_size(partialString).width + thisline = textchars[i][5] + thiscolumn = textchars[i][7] + thislength = textchars[i][8] + if thisline == @cursorLine && @cursorColumn >= thiscolumn && + @cursorColumn <= thiscolumn + thislength + cursorY = textchars[i][2] - startY + cursorX = textchars[i][1] + textheight = textchars[i][4] + posToCursor = @cursorColumn - thiscolumn + if posToCursor >= 0 + partialString = textchars[i][0].scan(/./m)[0, posToCursor].join("") + cursorX += bitmap.text_size(partialString).width end break end end - cursorY+=4 - cursorHeight=[4,textheight-4,bitmap.text_size("X").height-4].max - bitmap.fill_rect(cursorX,cursorY,2,cursorHeight,cursorcolor) + cursorY += 4 + cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max + bitmap.fill_rect(cursorX, cursorY, 2, cursorHeight, cursorcolor) end end end diff --git a/Data/Scripts/008_Audio/001_Audio.rb b/Data/Scripts/008_Audio/001_Audio.rb index d33631abb..ee8dbefd1 100644 --- a/Data/Scripts/008_Audio/001_Audio.rb +++ b/Data/Scripts/008_Audio/001_Audio.rb @@ -1,7 +1,7 @@ ##################################### # Needed because RGSS doesn't call at_exit procs on exit # Exit is not called when game is reset (using F12) -$AtExitProcs=[] if !$AtExitProcs +$AtExitProcs = [] if !$AtExitProcs def exit(code = 0) for p in $AtExitProcs @@ -127,7 +127,7 @@ def getPlayTime2(filename) data = fgetdw.call(file) return -1 if data != 0x61746164 # "data" datasize = fgetdw.call(file) - time = (datasize*1.0)/bytessec + time = (datasize * 1.0) / bytessec return time elsif fdw == 0x5367674F # "OggS" file.pos = 0 diff --git a/Data/Scripts/008_Audio/002_Audio_Play.rb b/Data/Scripts/008_Audio/002_Audio_Play.rb index 7fdc8624a..ca5db2725 100644 --- a/Data/Scripts/008_Audio/002_Audio_Play.rb +++ b/Data/Scripts/008_Audio/002_Audio_Play.rb @@ -3,13 +3,13 @@ def pbStringToAudioFile(str) file = $1 volume = $2.to_i pitch = $3.to_i - return RPG::AudioFile.new(file,volume,pitch) + return RPG::AudioFile.new(file, volume, pitch) elsif str[/^(.*)\:\s*(\d+)\s*$/] # Of the format "XXX: ###" file = $1 volume = $2.to_i - return RPG::AudioFile.new(file,volume,100) + return RPG::AudioFile.new(file, volume, 100) else - return RPG::AudioFile.new(str,100,100) + return RPG::AudioFile.new(str, 100, 100) end end @@ -21,7 +21,7 @@ end # filename:volume:pitch # volume -- Volume of the file, up to 100 # pitch -- Pitch of the file, normally 100 -def pbResolveAudioFile(str,volume = nil,pitch = nil) +def pbResolveAudioFile(str, volume = nil, pitch = nil) if str.is_a?(String) str = pbStringToAudioFile(str) str.volume = volume || 100 @@ -49,21 +49,21 @@ end # filename:volume:pitch # volume -- Volume of the file, up to 100 # pitch -- Pitch of the file, normally 100 -def pbBGMPlay(param,volume = nil,pitch = nil) +def pbBGMPlay(param, volume = nil, pitch = nil) return if !param - param=pbResolveAudioFile(param,volume,pitch) - if param.name && param.name!="" + param = pbResolveAudioFile(param, volume, pitch) + if param.name && param.name != "" if $game_system $game_system.bgm_play(param) return elsif (RPG.const_defined?(:BGM) rescue false) - b=RPG::BGM.new(param.name,param.volume,param.pitch) + b = RPG::BGM.new(param.name, param.volume, param.pitch) if b && b.respond_to?("play") b.play return end end - Audio.bgm_play(canonicalize("Audio/BGM/"+param.name),param.volume,param.pitch) + Audio.bgm_play(canonicalize("Audio/BGM/" + param.name), param.volume, param.pitch) end end @@ -80,12 +80,12 @@ def pbBGMStop(timeInSeconds = 0.0) return elsif (RPG.const_defined?(:BGM) rescue false) begin - (timeInSeconds>0.0) ? RPG::BGM.fade((timeInSeconds*1000).floor) : RPG::BGM.stop + (timeInSeconds > 0.0) ? RPG::BGM.fade((timeInSeconds * 1000).floor) : RPG::BGM.stop return rescue end end - (timeInSeconds>0.0) ? Audio.bgm_fade((timeInSeconds*1000).floor) : Audio.bgm_stop + (timeInSeconds > 0.0) ? Audio.bgm_fade((timeInSeconds * 1000).floor) : Audio.bgm_stop end ################################################################################ @@ -99,21 +99,21 @@ end # filename:volume:pitch # volume -- Volume of the file, up to 100 # pitch -- Pitch of the file, normally 100 -def pbMEPlay(param,volume = nil,pitch = nil) +def pbMEPlay(param, volume = nil, pitch = nil) return if !param - param=pbResolveAudioFile(param,volume,pitch) - if param.name && param.name!="" + param = pbResolveAudioFile(param, volume, pitch) + if param.name && param.name != "" if $game_system $game_system.me_play(param) return elsif (RPG.const_defined?(:ME) rescue false) - b=RPG::ME.new(param.name,param.volume,param.pitch) + b = RPG::ME.new(param.name, param.volume, param.pitch) if b && b.respond_to?("play") b.play return end end - Audio.me_play(canonicalize("Audio/ME/"+param.name),param.volume,param.pitch) + Audio.me_play(canonicalize("Audio/ME/" + param.name), param.volume, param.pitch) end end @@ -122,7 +122,7 @@ def pbMEFade(x = 0.0); pbMEStop(x); end # Fades out or stops ME playback. 'x' is the time in seconds to fade out. def pbMEStop(timeInSeconds = 0.0) - if $game_system && timeInSeconds>0.0 && $game_system.respond_to?("me_fade") + if $game_system && timeInSeconds > 0.0 && $game_system.respond_to?("me_fade") $game_system.me_fade(timeInSeconds) return elsif $game_system && $game_system.respond_to?("me_stop") @@ -130,12 +130,12 @@ def pbMEStop(timeInSeconds = 0.0) return elsif (RPG.const_defined?(:ME) rescue false) begin - (timeInSeconds>0.0) ? RPG::ME.fade((timeInSeconds*1000).floor) : RPG::ME.stop + (timeInSeconds > 0.0) ? RPG::ME.fade((timeInSeconds * 1000).floor) : RPG::ME.stop return rescue end end - (timeInSeconds>0.0) ? Audio.me_fade((timeInSeconds*1000).floor) : Audio.me_stop + (timeInSeconds > 0.0) ? Audio.me_fade((timeInSeconds * 1000).floor) : Audio.me_stop end ################################################################################ @@ -149,21 +149,21 @@ end # filename:volume:pitch # volume -- Volume of the file, up to 100 # pitch -- Pitch of the file, normally 100 -def pbBGSPlay(param,volume = nil,pitch = nil) +def pbBGSPlay(param, volume = nil, pitch = nil) return if !param - param=pbResolveAudioFile(param,volume,pitch) - if param.name && param.name!="" + param = pbResolveAudioFile(param, volume, pitch) + if param.name && param.name != "" if $game_system $game_system.bgs_play(param) return elsif (RPG.const_defined?(:BGS) rescue false) - b=RPG::BGS.new(param.name,param.volume,param.pitch) + b = RPG::BGS.new(param.name, param.volume, param.pitch) if b && b.respond_to?("play") b.play return end end - Audio.bgs_play(canonicalize("Audio/BGS/"+param.name),param.volume,param.pitch) + Audio.bgs_play(canonicalize("Audio/BGS/" + param.name), param.volume, param.pitch) end end @@ -180,12 +180,12 @@ def pbBGSStop(timeInSeconds = 0.0) return elsif (RPG.const_defined?(:BGS) rescue false) begin - (timeInSeconds>0.0) ? RPG::BGS.fade((timeInSeconds*1000).floor) : RPG::BGS.stop + (timeInSeconds > 0.0) ? RPG::BGS.fade((timeInSeconds * 1000).floor) : RPG::BGS.stop return rescue end end - (timeInSeconds>0.0) ? Audio.bgs_fade((timeInSeconds*1000).floor) : Audio.bgs_stop + (timeInSeconds > 0.0) ? Audio.bgs_fade((timeInSeconds * 1000).floor) : Audio.bgs_stop end ################################################################################ @@ -199,22 +199,22 @@ end # filename:volume:pitch # volume -- Volume of the file, up to 100 # pitch -- Pitch of the file, normally 100 -def pbSEPlay(param,volume = nil,pitch = nil) +def pbSEPlay(param, volume = nil, pitch = nil) return if !param - param = pbResolveAudioFile(param,volume,pitch) - if param.name && param.name!="" + param = pbResolveAudioFile(param, volume, pitch) + if param.name && param.name != "" if $game_system $game_system.se_play(param) return end if (RPG.const_defined?(:SE) rescue false) - b = RPG::SE.new(param.name,param.volume,param.pitch) + b = RPG::SE.new(param.name, param.volume, param.pitch) if b && b.respond_to?("play") b.play return end end - Audio.se_play(canonicalize("Audio/SE/"+param.name),param.volume,param.pitch) + Audio.se_play(canonicalize("Audio/SE/" + param.name), param.volume, param.pitch) end end @@ -239,7 +239,7 @@ def pbPlayCursorSE if !nil_or_empty?($data_system&.cursor_se&.name) pbSEPlay($data_system.cursor_se) elsif FileTest.audio_exist?("Audio/SE/GUI sel cursor") - pbSEPlay("GUI sel cursor",80) + pbSEPlay("GUI sel cursor", 80) end end @@ -248,7 +248,7 @@ def pbPlayDecisionSE if !nil_or_empty?($data_system&.decision_se&.name) pbSEPlay($data_system.decision_se) elsif FileTest.audio_exist?("Audio/SE/GUI sel decision") - pbSEPlay("GUI sel decision",80) + pbSEPlay("GUI sel decision", 80) end end @@ -257,7 +257,7 @@ def pbPlayCancelSE if !nil_or_empty?($data_system&.cancel_se&.name) pbSEPlay($data_system.cancel_se) elsif FileTest.audio_exist?("Audio/SE/GUI sel cancel") - pbSEPlay("GUI sel cancel",80) + pbSEPlay("GUI sel cancel", 80) end end @@ -266,13 +266,13 @@ def pbPlayBuzzerSE if !nil_or_empty?($data_system&.buzzer_se&.name) pbSEPlay($data_system.buzzer_se) elsif FileTest.audio_exist?("Audio/SE/GUI sel buzzer") - pbSEPlay("GUI sel buzzer",80) + pbSEPlay("GUI sel buzzer", 80) end end # Plays a sound effect that plays when the player moves the cursor. def pbPlayCloseMenuSE if FileTest.audio_exist?("Audio/SE/GUI menu close") - pbSEPlay("GUI menu close",80) + pbSEPlay("GUI menu close", 80) end end diff --git a/Data/Scripts/009_Scenes/001_Transitions.rb b/Data/Scripts/009_Scenes/001_Transitions.rb index a15a76e7c..f27a3ff55 100644 --- a/Data/Scripts/009_Scenes/001_Transitions.rb +++ b/Data/Scripts/009_Scenes/001_Transitions.rb @@ -41,7 +41,7 @@ module Graphics @@transition = nil if @@transition && @@transition.disposed? end - def self.judge_special_transition(duration,filename) + def self.judge_special_transition(duration, filename) return false if @_interrupt_transition ret = true if @@transition && !@@transition.disposed? @@ -282,7 +282,7 @@ module Transitions move_x = (dx == 0) ? rand_sign * vague : dx * SPEED * 1.5 move_y = (dy == 0) ? rand_sign * vague : dy * SPEED * 1.5 else - radius = Math.sqrt(dx ** 2 + dy ** 2) + radius = Math.sqrt(dx**2 + dy**2) move_x = dx * vague / radius move_y = dy * vague / radius end diff --git a/Data/Scripts/009_Scenes/002_EventScene.rb b/Data/Scripts/009_Scenes/002_EventScene.rb index 9b633c685..f29c41c1e 100644 --- a/Data/Scripts/009_Scenes/002_EventScene.rb +++ b/Data/Scripts/009_Scenes/002_EventScene.rb @@ -24,9 +24,9 @@ class PictureSprite < SpriteWrapper super @pictureBitmap.update if @pictureBitmap # If picture file name is different from current one - if @customBitmap && @picture.name=="" + if @customBitmap && @picture.name == "" self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap - elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i + elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i # Remember file name to instance variables @picture_name = @picture.name @hue = @picture.hue.to_i @@ -46,16 +46,16 @@ class PictureSprite < SpriteWrapper self.visible = false return end - setPictureSprite(self,@picture) + setPictureSprite(self, @picture) end end def pbTextBitmap(text, maxwidth = Graphics.width) - tmp = Bitmap.new(maxwidth,Graphics.height) + tmp = Bitmap.new(maxwidth, Graphics.height) pbSetSystemFont(tmp) - drawFormattedTextEx(tmp,0,0,maxwidth,text,Color.new(248,248,248),Color.new(168,184,184)) + drawFormattedTextEx(tmp, 0, 0, maxwidth, text, Color.new(248, 248, 248), Color.new(168, 184, 184)) return tmp end @@ -65,7 +65,7 @@ end # EventScene #=============================================================================== class EventScene - attr_accessor :onCTrigger,:onBTrigger,:onUpdate + attr_accessor :onCTrigger, :onBTrigger, :onUpdate def initialize(viewport = nil) @viewport = viewport @@ -105,26 +105,26 @@ class EventScene # EventScene doesn't take ownership of the passed-in bitmap num = @pictures.length picture = PictureEx.new(num) - picture.setXY(0,x,y) - picture.setVisible(0,true) + picture.setXY(0, x, y) + picture.setVisible(0, true) @pictures[num] = picture - @picturesprites[num] = PictureSprite.new(@viewport,picture) + @picturesprites[num] = PictureSprite.new(@viewport, picture) @picturesprites[num].setCustomBitmap(bitmap) return picture end def addLabel(x, y, width, text) - addBitmap(x,y,pbTextBitmap(text,width)) + addBitmap(x, y, pbTextBitmap(text, width)) end def addImage(x, y, name) num = @pictures.length picture = PictureEx.new(num) picture.name = name - picture.setXY(0,x,y) - picture.setVisible(0,true) + picture.setXY(0, x, y) + picture.setVisible(0, true) @pictures[num] = picture - @picturesprites[num] = PictureSprite.new(@viewport,picture) + @picturesprites[num] = PictureSprite.new(@viewport, picture) return picture end @@ -188,7 +188,7 @@ end #=============================================================================== def pbEventScreen(cls) pbFadeOutIn { - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 PBDebug.logonerr { cls.new(viewport).main diff --git a/Data/Scripts/010_Data/001_Hardcoded data/001_GrowthRate.rb b/Data/Scripts/010_Data/001_Hardcoded data/001_GrowthRate.rb index b0ffc28c6..824cc86f4 100644 --- a/Data/Scripts/010_Data/001_Hardcoded data/001_GrowthRate.rb +++ b/Data/Scripts/010_Data/001_Hardcoded data/001_GrowthRate.rb @@ -88,7 +88,7 @@ GameData::GrowthRate.register({ 357911, 373248, 389017, 405224, 421875, 438976, 456533, 474552, 493039, 512000, 531441, 551368, 571787, 592704, 614125, 636056, 658503, 681472, 704969, 729000, 753571, 778688, 804357, 830584, 857375, 884736, 912673, 941192, 970299, 1000000], - :exp_formula => proc { |level| next level ** 3 } + :exp_formula => proc { |level| next level**3 } }) # Erratic (600000): @@ -111,7 +111,7 @@ GameData::GrowthRate.register({ 286328, 296358, 305767, 316074, 326531, 336255, 346965, 357812, 367807, 378880, 390077, 400293, 411686, 423190, 433572, 445239, 457001, 467489, 479378, 491346, 501878, 513934, 526049, 536557, 548720, 560922, 571333, 583539, 591882, 600000], - :exp_formula => proc { |level| next (level ** 4) * 3 / 500 } + :exp_formula => proc { |level| next (level**4) * 3 / 500 } }) # Fluctuating (1640000): @@ -134,7 +134,7 @@ GameData::GrowthRate.register({ 1160499, 1214753, 1254796, 1312322, 1354652, 1415577, 1460276, 1524731, 1571884, 1640000], :exp_formula => proc { |level| rate = [82 - (level - 100) / 2.0, 40].max - next (level ** 4) * rate / 5000 + next (level**4) * rate / 5000 } }) @@ -152,7 +152,7 @@ GameData::GrowthRate.register({ 360838, 377197, 394045, 411388, 429235, 447591, 466464, 485862, 505791, 526260, 547274, 568841, 590969, 613664, 636935, 660787, 685228, 710266, 735907, 762160, 789030, 816525, 844653, 873420, 902835, 932903, 963632, 995030, 1027103, 1059860], - :exp_formula => proc { |level| next ((level ** 3) * 6 / 5) - 15 * (level ** 2) + 100 * level - 140 } + :exp_formula => proc { |level| next ((level**3) * 6 / 5) - 15 * (level**2) + 100 * level - 140 } }) GameData::GrowthRate.register({ @@ -169,7 +169,7 @@ GameData::GrowthRate.register({ 286328, 298598, 311213, 324179, 337500, 351180, 365226, 379641, 394431, 409600, 425152, 441094, 457429, 474163, 491300, 508844, 526802, 545177, 563975, 583200, 602856, 622950, 643485, 664467, 685900, 707788, 730138, 752953, 776239, 800000], - :exp_formula => proc { |level| (level ** 3) * 4 / 5 } + :exp_formula => proc { |level| (level**3) * 4 / 5 } }) GameData::GrowthRate.register({ @@ -186,5 +186,5 @@ GameData::GrowthRate.register({ 447388, 466560, 486271, 506530, 527343, 548720, 570666, 593190, 616298, 640000, 664301, 689210, 714733, 740880, 767656, 795070, 823128, 851840, 881211, 911250, 941963, 973360, 1005446, 1038230, 1071718, 1105920, 1140841, 1176490, 1212873, 1250000], - :exp_formula => proc { |level| (level ** 3) * 5 / 4 } + :exp_formula => proc { |level| (level**3) * 5 / 4 } }) diff --git a/Data/Scripts/010_Data/002_PBS data/003_Type.rb b/Data/Scripts/010_Data/002_PBS data/003_Type.rb index 27d2fd47e..0e5a2b457 100644 --- a/Data/Scripts/010_Data/002_PBS data/003_Type.rb +++ b/Data/Scripts/010_Data/002_PBS data/003_Type.rb @@ -72,7 +72,7 @@ module Effectiveness NOT_VERY_EFFECTIVE_ONE = 1 NORMAL_EFFECTIVE_ONE = 2 SUPER_EFFECTIVE_ONE = 4 - NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE ** 3 + NORMAL_EFFECTIVE = NORMAL_EFFECTIVE_ONE**3 module_function diff --git a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb index 469f6c34f..fd7a3c622 100644 --- a/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb +++ b/Data/Scripts/010_Data/002_PBS data/009_Species_Files.rb @@ -13,10 +13,10 @@ module GameData factors.push([1, try_form, ""]) if form > 0 factors.push([0, try_species, "000"]) # Go through each combination of parameters in turn to find an existing sprite - for i in 0...2 ** factors.length + for i in 0...2**factors.length # Set try_ parameters for this combination factors.each_with_index do |factor, index| - value = ((i / (2 ** index)) % 2 == 0) ? factor[1] : factor[2] + value = ((i / (2**index)) % 2 == 0) ? factor[1] : factor[2] case factor[0] when 0 then try_species = value when 1 then try_form = value diff --git a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb index 83581f037..cda3f7301 100644 --- a/Data/Scripts/011_Battle/001_Battle/001_Battle.rb +++ b/Data/Scripts/011_Battle/001_Battle/001_Battle.rb @@ -92,10 +92,10 @@ class Battle #============================================================================= # Creating the battle class #============================================================================= - def initialize(scene,p1,p2,player,opponent) - if p1.length==0 + def initialize(scene, p1, p2, player, opponent) + if p1.length == 0 raise ArgumentError.new(_INTL("Party 1 has no Pokémon.")) - elsif p2.length==0 + elsif p2.length == 0 raise ArgumentError.new(_INTL("Party 2 has no Pokémon.")) end @scene = scene @@ -106,7 +106,7 @@ class Battle ActiveSide.new] # Foe's side @positions = [] # Battler positions @battlers = [] - @sideSizes = [1,1] # Single battle, 1v1 + @sideSizes = [1, 1] # Single battle, 1v1 @backdrop = "" @backdropBase = nil @time = 0 @@ -194,15 +194,15 @@ class Battle end def singleBattle? - return pbSideSize(0)==1 && pbSideSize(1)==1 + return pbSideSize(0) == 1 && pbSideSize(1) == 1 end def pbSideSize(index) - return @sideSizes[index%2] + return @sideSizes[index % 2] end def maxBattlerIndex - return (pbSideSize(0)>pbSideSize(1)) ? (pbSideSize(0)-1)*2 : pbSideSize(1)*2-1 + return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : pbSideSize(1) * 2 - 1 end #============================================================================= @@ -219,11 +219,11 @@ class Battle return 0 if !trainer case trainer.length when 2 - n = pbSideSize(idxBattler%2) - return [0,0,1][idxBattler/2] if n==3 - return idxBattler/2 # Same as [0,1][idxBattler/2], i.e. 2 battler slots + n = pbSideSize(idxBattler % 2) + return [0, 0, 1][idxBattler / 2] if n == 3 + return idxBattler / 2 # Same as [0,1][idxBattler/2], i.e. 2 battler slots when 3 - return idxBattler/2 + return idxBattler / 2 end return 0 end @@ -234,10 +234,10 @@ class Battle return (trainer.nil?) ? nil : trainer[idxTrainer] end - def pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty) + def pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty) ret = -1 - pbPartyStarts(idxBattler).each_with_index do |start,i| - break if start>idxParty + pbPartyStarts(idxBattler).each_with_index do |start, i| + break if start > idxParty ret = i end return ret @@ -245,8 +245,8 @@ class Battle # Only used for the purpose of an error message when one trainer tries to # switch another trainer's Pokémon. - def pbGetOwnerFromPartyIndex(idxBattler,idxParty) - idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty) + def pbGetOwnerFromPartyIndex(idxBattler, idxParty) + idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty) trainer = (opposes?(idxBattler)) ? @opponent : @player return (trainer.nil?) ? nil : trainer[idxTrainer] end @@ -254,7 +254,7 @@ class Battle def pbGetOwnerName(idxBattler) idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler) return @opponent[idxTrainer].full_name if opposes?(idxBattler) # Opponent - return @player[idxTrainer].full_name if idxTrainer>0 # Ally trainer + return @player[idxTrainer].full_name if idxTrainer > 0 # Ally trainer return @player[idxTrainer].name # Player end @@ -266,24 +266,24 @@ class Battle # Returns whether the battler in position idxBattler is owned by the same # trainer that owns the Pokémon in party slot idxParty. This assumes that # both the battler position and the party slot are from the same side. - def pbIsOwner?(idxBattler,idxParty) + def pbIsOwner?(idxBattler, idxParty) idxTrainer1 = pbGetOwnerIndexFromBattlerIndex(idxBattler) - idxTrainer2 = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty) - return idxTrainer1==idxTrainer2 + idxTrainer2 = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty) + return idxTrainer1 == idxTrainer2 end def pbOwnedByPlayer?(idxBattler) return false if opposes?(idxBattler) - return pbGetOwnerIndexFromBattlerIndex(idxBattler)==0 + return pbGetOwnerIndexFromBattlerIndex(idxBattler) == 0 end # Returns the number of Pokémon positions controlled by the given trainerIndex # on the given side of battle. - def pbNumPositions(side,idxTrainer) + def pbNumPositions(side, idxTrainer) ret = 0 for i in 0...pbSideSize(side) - t = pbGetOwnerIndexFromBattlerIndex(i*2+side) - next if t!=idxTrainer + t = pbGetOwnerIndexFromBattlerIndex(i * 2 + side) + next if t != idxTrainer ret += 1 end return ret @@ -314,7 +314,7 @@ class Battle partyOrders = pbPartyOrder(idxBattler) idxStart, _idxEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler) ret = [] - eachInTeamFromBattlerIndex(idxBattler) { |pkmn,i| ret[partyOrders[i]-idxStart] = pkmn } + eachInTeamFromBattlerIndex(idxBattler) { |pkmn, i| ret[partyOrders[i] - idxStart] = pkmn } return ret end @@ -329,7 +329,7 @@ class Battle party = pbParty(idxBattler) inBattleIndices = allSameSideBattlers(idxBattler).map { |b| b.pokemonIndex } count = 0 - party.each_with_index do |pkmn,idxParty| + party.each_with_index do |pkmn, idxParty| next if !pkmn || !pkmn.able? next if inBattleIndices.include?(idxParty) count += 1 @@ -338,7 +338,7 @@ class Battle end def pbAllFainted?(idxBattler = 0) - return pbAbleCount(idxBattler)==0 + return pbAbleCount(idxBattler) == 0 end def pbTeamAbleNonActiveCount(idxBattler = 0) @@ -360,10 +360,10 @@ class Battle ret = [] idxTeam = -1 nextStart = 0 - party.each_with_index do |pkmn,i| - if i>=nextStart + party.each_with_index do |pkmn, i| + if i >= nextStart idxTeam += 1 - nextStart = (idxTeam=idxPartyStart && i= idxPartyStart && i < idxPartyEnd } end - def eachInTeam(side,idxTrainer) + def eachInTeam(side, idxTrainer) party = pbParty(side) partyStarts = pbPartyStarts(side) idxPartyStart = partyStarts[idxTrainer] - idxPartyEnd = (idxTrainer=idxPartyStart && i= idxPartyStart && i < idxPartyEnd } end # Used for Illusion. @@ -412,8 +412,8 @@ class Battle partyOrders = pbPartyOrder(idxBattler) idxPartyStart, idxPartyEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler) ret = -1 - party.each_with_index do |pkmn,i| - next if i=idxPartyEnd # Check the team only + party.each_with_index do |pkmn, i| + next if i < idxPartyStart || i >= idxPartyEnd # Check the team only next if !pkmn || !pkmn.able? # Can't copy a non-fainted Pokémon or egg ret = i if ret < 0 || partyOrders[i] > partyOrders[ret] end @@ -421,10 +421,10 @@ class Battle end # Used to calculate money gained/lost after winning/losing a battle. - def pbMaxLevelInTeam(side,idxTrainer) + def pbMaxLevelInTeam(side, idxTrainer) ret = 1 - eachInTeam(side,idxTrainer) do |pkmn,_i| - ret = pkmn.level if pkmn.level>ret + eachInTeam(side, idxTrainer) do |pkmn, _i| + ret = pkmn.level if pkmn.level > ret end return ret end @@ -481,7 +481,7 @@ class Battle return nil end - def pbCheckOpposingAbility(abil,idxBattler = 0,nearOnly = false) + def pbCheckOpposingAbility(abil, idxBattler = 0, nearOnly = false) allOtherSideBattlers(idxBattler).each do |b| next if nearOnly && !b.near?(idxBattler) return b if b.hasActiveAbility?(abil) @@ -503,31 +503,31 @@ class Battle return [1] when 2 # 1v2 return [0] if opposes?(idxBattler) - return [3,1] + return [3, 1] when 3 # 1v3 return [0] if opposes?(idxBattler) - return [3,5,1] + return [3, 5, 1] end when 2 case pbSideSize(1) when 1 # 2v1 - return [0,2] if opposes?(idxBattler) + return [0, 2] if opposes?(idxBattler) return [1] when 2 # 2v2 double - return [[3,1],[2,0],[1,3],[0,2]][idxBattler] + return [[3, 1], [2, 0], [1, 3], [0, 2]][idxBattler] when 3 # 2v3 - return [[5,3,1],[2,0],[3,1,5]][idxBattler] if idxBattler<3 - return [0,2] + return [[5, 3, 1], [2, 0], [3, 1, 5]][idxBattler] if idxBattler < 3 + return [0, 2] end when 3 case pbSideSize(1) when 1 # 3v1 - return [2,0,4] if opposes?(idxBattler) + return [2, 0, 4] if opposes?(idxBattler) return [1] when 2 # 3v2 - return [[3,1],[2,4,0],[3,1],[2,0,4],[1,3]][idxBattler] + return [[3, 1], [2, 4, 0], [3, 1], [2, 0, 4], [1, 3]][idxBattler] when 3 # 3v3 triple - return [[5,3,1],[4,2,0],[3,5,1],[2,0,4],[1,3,5],[0,2,4]][idxBattler] + return [[5, 3, 1], [4, 2, 0], [3, 5, 1], [2, 0, 4], [1, 3, 5], [0, 2, 4]][idxBattler] end end return [idxBattler] @@ -536,30 +536,30 @@ class Battle #============================================================================= # Comparing the positions of two battlers #============================================================================= - def opposes?(idxBattler1,idxBattler2 = 0) + def opposes?(idxBattler1, idxBattler2 = 0) idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index") idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index") - return (idxBattler1&1)!=(idxBattler2&1) + return (idxBattler1 & 1) != (idxBattler2 & 1) end - def nearBattlers?(idxBattler1,idxBattler2) - return false if idxBattler1==idxBattler2 - return true if pbSideSize(0)<=2 && pbSideSize(1)<=2 + def nearBattlers?(idxBattler1, idxBattler2) + return false if idxBattler1 == idxBattler2 + return true if pbSideSize(0) <= 2 && pbSideSize(1) <= 2 # Get all pairs of battler positions that are not close to each other - pairsArray = [[0,4],[1,5]] # Covers 3v1 and 1v3 + pairsArray = [[0, 4], [1, 5]] # Covers 3v1 and 1v3 case pbSideSize(0) when 3 case pbSideSize(1) when 3 # 3v3 (triple) - pairsArray.push([0,1]) - pairsArray.push([4,5]) + pairsArray.push([0, 1]) + pairsArray.push([4, 5]) when 2 # 3v2 - pairsArray.push([0,1]) - pairsArray.push([3,4]) + pairsArray.push([0, 1]) + pairsArray.push([3, 4]) end when 2 # 2v3 - pairsArray.push([0,1]) - pairsArray.push([2,5]) + pairsArray.push([0, 1]) + pairsArray.push([2, 5]) end # See if any pair matches the two battlers being assessed pairsArray.each do |pair| @@ -571,7 +571,7 @@ class Battle #============================================================================= # Altering a party or rearranging battlers #============================================================================= - def pbRemoveFromParty(idxBattler,idxParty) + def pbRemoveFromParty(idxBattler, idxParty) party = pbParty(idxBattler) # Erase the Pokémon from the party party[idxParty] = nil @@ -579,27 +579,27 @@ class Battle # in it (to avoid gaps) partyOrders = pbPartyOrder(idxBattler) partyStarts = pbPartyStarts(idxBattler) - idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler,idxParty) + idxTrainer = pbGetOwnerIndexFromPartyIndex(idxBattler, idxParty) idxPartyStart = partyStarts[idxTrainer] - idxPartyEnd = (idxTrainer=idxPartyEnd # Only check the team - next if partyOrders[i]= idxPartyEnd # Only check the team + next if partyOrders[i] < origPartyPos # Appeared before erased Pokémon partyOrders[i] -= 1 # Appeared after erased Pokémon; bump it up by 1 end end - def pbSwapBattlers(idxA,idxB) + def pbSwapBattlers(idxA, idxB) return false if !@battlers[idxA] || !@battlers[idxB] # Can't swap if battlers aren't owned by the same trainer - return false if opposes?(idxA,idxB) - return false if pbGetOwnerIndexFromBattlerIndex(idxA)!=pbGetOwnerIndexFromBattlerIndex(idxB) + return false if opposes?(idxA, idxB) + return false if pbGetOwnerIndexFromBattlerIndex(idxA) != pbGetOwnerIndexFromBattlerIndex(idxB) @battlers[idxA], @battlers[idxB] = @battlers[idxB], @battlers[idxA] @battlers[idxA].index, @battlers[idxB].index = @battlers[idxB].index, @battlers[idxA].index @choices[idxA], @choices[idxB] = @choices[idxB], @choices[idxA] - @scene.pbSwapBattlerSprites(idxA,idxB) + @scene.pbSwapBattlerSprites(idxA, idxB) # Swap the target of any battlers' effects that point at either of the # swapped battlers, to ensure they still point at the correct target # NOTE: LeechSeed is not swapped, because drained HP goes to whichever @@ -619,8 +619,8 @@ class Battle PBEffects::TrappingUser] allBattlers.each do |b| for i in effectsToSwap - next if b.effects[i]!=idxA && b.effects[i]!=idxB - b.effects[i] = (b.effects[i]==idxA) ? idxB : idxA + next if b.effects[i] != idxA && b.effects[i] != idxB + b.effects[i] = (b.effects[i] == idxA) ? idxB : idxA end end return true @@ -631,19 +631,19 @@ class Battle #============================================================================= # Returns the battler representing the Pokémon at index idxParty in its party, # on the same side as a battler with battler index of idxBattlerOther. - def pbFindBattler(idxParty,idxBattlerOther = 0) - allSameSideBattlers(idxBattlerOther).each { |b| return b if b.pokemonIndex==idxParty } + def pbFindBattler(idxParty, idxBattlerOther = 0) + allSameSideBattlers(idxBattlerOther).each { |b| return b if b.pokemonIndex == idxParty } return nil end # Only used for Wish, as the Wishing Pokémon will no longer be in battle. - def pbThisEx(idxBattler,idxParty) + def pbThisEx(idxBattler, idxParty) party = pbParty(idxBattler) if opposes?(idxBattler) - return _INTL("The opposing {1}",party[idxParty].name) if trainerBattle? - return _INTL("The wild {1}",party[idxParty].name) + return _INTL("The opposing {1}", party[idxParty].name) if trainerBattle? + return _INTL("The wild {1}", party[idxParty].name) end - return _INTL("The ally {1}",party[idxParty].name) if !pbOwnedByPlayer?(idxBattler) + return _INTL("The ally {1}", party[idxParty].name) if !pbOwnedByPlayer?(idxBattler) return party[idxParty].name end @@ -696,13 +696,13 @@ class Battle end # Used for causing weather by a move or by an ability. - def pbStartWeather(user,newWeather,fixedDuration = false,showAnim = true) - return if @field.weather==newWeather + def pbStartWeather(user, newWeather, fixedDuration = false, showAnim = true) + return if @field.weather == newWeather @field.weather = newWeather duration = (fixedDuration) ? 5 : -1 - if duration>0 && user && user.itemActive? + if duration > 0 && user && user.itemActive? duration = Battle::ItemEffects.triggerWeatherExtender(user.item, - @field.weather,duration,user,self) + @field.weather, duration, user, self) end @field.weatherDuration = duration weather_data = GameData::BattleWeather.try_get(@field.weather) @@ -743,11 +743,11 @@ class Battle pbDisplay("The mysterious air current has dissipated!") end end - if @field.weather!=oldWeather + if @field.weather != oldWeather # Check for form changes caused by the weather changing allBattlers.each { |b| b.pbCheckFormOnWeatherChange } # Start up the default weather - pbStartWeather(nil,@field.defaultWeather) if @field.defaultWeather != :None + pbStartWeather(nil, @field.defaultWeather) if @field.defaultWeather != :None end end @@ -774,13 +774,13 @@ class Battle @field.terrainDuration = -1 end - def pbStartTerrain(user,newTerrain,fixedDuration = true) - return if @field.terrain==newTerrain + def pbStartTerrain(user, newTerrain, fixedDuration = true) + return if @field.terrain == newTerrain @field.terrain = newTerrain duration = (fixedDuration) ? 5 : -1 - if duration>0 && user && user.itemActive? + if duration > 0 && user && user.itemActive? duration = Battle::ItemEffects.triggerTerrainExtender(user.item, - newTerrain,duration,user,self) + newTerrain, duration, user, self) end @field.terrainDuration = duration terrain_data = GameData::BattleTerrain.try_get(@field.terrain) @@ -804,35 +804,35 @@ class Battle #============================================================================= # Messages and animations #============================================================================= - def pbDisplay(msg,&block) - @scene.pbDisplayMessage(msg,&block) + def pbDisplay(msg, &block) + @scene.pbDisplayMessage(msg, &block) end def pbDisplayBrief(msg) - @scene.pbDisplayMessage(msg,true) + @scene.pbDisplayMessage(msg, true) end - def pbDisplayPaused(msg,&block) - @scene.pbDisplayPausedMessage(msg,&block) + def pbDisplayPaused(msg, &block) + @scene.pbDisplayPausedMessage(msg, &block) end def pbDisplayConfirm(msg) return @scene.pbDisplayConfirmMessage(msg) end - def pbShowCommands(msg,commands,canCancel = true) - @scene.pbShowCommands(msg,commands,canCancel) + def pbShowCommands(msg, commands, canCancel = true) + @scene.pbShowCommands(msg, commands, canCancel) end - def pbAnimation(move,user,targets,hitNum = 0) - @scene.pbAnimation(move,user,targets,hitNum) if @showAnims + def pbAnimation(move, user, targets, hitNum = 0) + @scene.pbAnimation(move, user, targets, hitNum) if @showAnims end - def pbCommonAnimation(name,user = nil,targets = nil) - @scene.pbCommonAnimation(name,user,targets) if @showAnims + def pbCommonAnimation(name, user = nil, targets = nil) + @scene.pbCommonAnimation(name, user, targets) if @showAnims end - def pbShowAbilitySplash(battler,delay = false,logTrigger = true) + def pbShowAbilitySplash(battler, delay = false, logTrigger = true) PBDebug.log("[Ability triggered] #{battler.pbThis}'s #{battler.abilityName}") if logTrigger return if !Scene::USE_ABILITY_SPLASH @scene.pbShowAbilitySplash(battler) diff --git a/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb b/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb index fc6c0b7c9..3df3c3c5f 100644 --- a/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb +++ b/Data/Scripts/011_Battle/001_Battle/002_Battle_StartAndEnd.rb @@ -22,18 +22,18 @@ class Battle # trainer, it's possible that battlers will be unable to move close # enough to hit each other if there are multiple trainers on each # side. - if trainerBattle? && (@sideSizes[0]>2 || @sideSizes[1]>2) && - @player.length>1 && @opponent.length>1 + if trainerBattle? && (@sideSizes[0] > 2 || @sideSizes[1] > 2) && + @player.length > 1 && @opponent.length > 1 raise _INTL("Can't have battles larger than 2v2 where both sides have multiple trainers") end # Find out how many Pokémon each trainer has side1counts = pbAbleTeamCounts(0) side2counts = pbAbleTeamCounts(1) # Change the size of the battle depending on how many wild Pokémon there are - if wildBattle? && side2counts[0]!=@sideSizes[1] - if @sideSizes[0]==@sideSizes[1] + if wildBattle? && side2counts[0] != @sideSizes[1] + if @sideSizes[0] == @sideSizes[1] # Even number of battlers per side, change both equally - @sideSizes = [side2counts[0],side2counts[0]] + @sideSizes = [side2counts[0], side2counts[0]] else # Uneven number of battlers per side, just change wild side's size @sideSizes[1] = side2counts[0] @@ -44,31 +44,31 @@ class Battle loop do needsChanging = false for side in 0...2 # Each side in turn - next if side==1 && wildBattle? # Wild side's size already checked above - sideCounts = (side==0) ? side1counts : side2counts + next if side == 1 && wildBattle? # Wild side's size already checked above + sideCounts = (side == 0) ? side1counts : side2counts requireds = [] # Find out how many Pokémon each trainer on side needs to have for i in 0...@sideSizes[side] - idxTrainer = pbGetOwnerIndexFromBattlerIndex(i*2+side) + idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side) requireds[idxTrainer] = 0 if requireds[idxTrainer].nil? requireds[idxTrainer] += 1 end # Compare the have values with the need values - if requireds.length>sideCounts.length + if requireds.length > sideCounts.length raise _INTL("Error: def pbGetOwnerIndexFromBattlerIndex gives invalid owner index ({1} for battle type {2}v{3}, trainers {4}v{5})", - requireds.length-1,@sideSizes[0],@sideSizes[1],side1counts.length,side2counts.length) + requireds.length - 1, @sideSizes[0], @sideSizes[1], side1counts.length, side2counts.length) end - sideCounts.each_with_index do |_count,i| - if !requireds[i] || requireds[i]==0 + sideCounts.each_with_index do |_count, i| + if !requireds[i] || requireds[i] == 0 raise _INTL("Player-side trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)", - i+1,@sideSizes[0],@sideSizes[1]) if side==0 + i + 1, @sideSizes[0], @sideSizes[1]) if side == 0 raise _INTL("Opposing trainer {1} has no battler position for their Pokémon to go (trying {2}v{3} battle)", - i+1,@sideSizes[0],@sideSizes[1]) if side==1 + i + 1, @sideSizes[0], @sideSizes[1]) if side == 1 end - next if requireds[i]<=sideCounts[i] # Trainer has enough Pokémon to fill their positions - if requireds[i]==1 - raise _INTL("Player-side trainer {1} has no able Pokémon",i+1) if side==0 - raise _INTL("Opposing trainer {1} has no able Pokémon",i+1) if side==1 + next if requireds[i] <= sideCounts[i] # Trainer has enough Pokémon to fill their positions + if requireds[i] == 1 + raise _INTL("Player-side trainer {1} has no able Pokémon", i + 1) if side == 0 + raise _INTL("Opposing trainer {1} has no able Pokémon", i + 1) if side == 1 end # Not enough Pokémon, try lowering the number of battler positions needsChanging = true @@ -81,18 +81,18 @@ class Battle if wildBattle? PBDebug.log("#{@sideSizes[0]}v#{@sideSizes[1]} battle isn't possible " + "(#{side1counts} player-side teams versus #{side2counts[0]} wild Pokémon)") - newSize = @sideSizes[0]-1 + newSize = @sideSizes[0] - 1 else PBDebug.log("#{@sideSizes[0]}v#{@sideSizes[1]} battle isn't possible " + "(#{side1counts} player-side teams versus #{side2counts} opposing teams)") - newSize = @sideSizes.max-1 + newSize = @sideSizes.max - 1 end - if newSize==0 + if newSize == 0 raise _INTL("Couldn't lower either side's size any further, battle isn't possible") end for side in 0...2 - next if side==1 && wildBattle? # Wild Pokémon's side size is fixed - next if @sideSizes[side]==1 || newSize>@sideSizes[side] + next if side == 1 && wildBattle? # Wild Pokémon's side size is fixed + next if @sideSizes[side] == 1 || newSize > @sideSizes[side] @sideSizes[side] = newSize end PBDebug.log("Trying #{@sideSizes[0]}v#{@sideSizes[1]} battle instead") @@ -102,52 +102,52 @@ class Battle #============================================================================= # Set up all battlers #============================================================================= - def pbCreateBattler(idxBattler,pkmn,idxParty) + def pbCreateBattler(idxBattler, pkmn, idxParty) if !@battlers[idxBattler].nil? - raise _INTL("Battler index {1} already exists",idxBattler) + raise _INTL("Battler index {1} already exists", idxBattler) end - @battlers[idxBattler] = Battler.new(self,idxBattler) + @battlers[idxBattler] = Battler.new(self, idxBattler) @positions[idxBattler] = ActivePosition.new pbClearChoice(idxBattler) @successStates[idxBattler] = SuccessState.new - @battlers[idxBattler].pbInitialize(pkmn,idxParty) + @battlers[idxBattler].pbInitialize(pkmn, idxParty) end def pbSetUpSides - ret = [[],[]] + ret = [[], []] for side in 0...2 # Set up wild Pokémon - if side==1 && wildBattle? - pbParty(1).each_with_index do |pkmn,idxPkmn| - pbCreateBattler(2*idxPkmn+side,pkmn,idxPkmn) + if side == 1 && wildBattle? + pbParty(1).each_with_index do |pkmn, idxPkmn| + pbCreateBattler(2 * idxPkmn + side, pkmn, idxPkmn) # Changes the Pokémon's form upon entering battle (if it should) @peer.pbOnEnteringBattle(self, @battlers[2 * idxPkmn + side], pkmn, true) - pbSetSeen(@battlers[2*idxPkmn+side]) + pbSetSeen(@battlers[2 * idxPkmn + side]) @usedInBattle[side][idxPkmn] = true end next end # Set up player's Pokémon and trainers' Pokémon - trainer = (side==0) ? @player : @opponent + trainer = (side == 0) ? @player : @opponent requireds = [] # Find out how many Pokémon each trainer on side needs to have for i in 0...@sideSizes[side] - idxTrainer = pbGetOwnerIndexFromBattlerIndex(i*2+side) + idxTrainer = pbGetOwnerIndexFromBattlerIndex(i * 2 + side) requireds[idxTrainer] = 0 if requireds[idxTrainer].nil? requireds[idxTrainer] += 1 end # For each trainer in turn, find the needed number of Pokémon for them to # send out, and initialize them battlerNumber = 0 - trainer.each_with_index do |_t,idxTrainer| + trainer.each_with_index do |_t, idxTrainer| ret[side][idxTrainer] = [] - eachInTeam(side,idxTrainer) do |pkmn,idxPkmn| + eachInTeam(side, idxTrainer) do |pkmn, idxPkmn| next if !pkmn.able? - idxBattler = 2*battlerNumber+side - pbCreateBattler(idxBattler,pkmn,idxPkmn) + idxBattler = 2 * battlerNumber + side + pbCreateBattler(idxBattler, pkmn, idxPkmn) ret[side][idxTrainer].push(idxBattler) battlerNumber += 1 - break if ret[side][idxTrainer].length>=requireds[idxTrainer] + break if ret[side][idxTrainer].length >= requireds[idxTrainer] end end end @@ -163,71 +163,71 @@ class Battle foeParty = pbParty(1) case foeParty.length when 1 - pbDisplayPaused(_INTL("Oh! A wild {1} appeared!",foeParty[0].name)) + pbDisplayPaused(_INTL("Oh! A wild {1} appeared!", foeParty[0].name)) when 2 - pbDisplayPaused(_INTL("Oh! A wild {1} and {2} appeared!",foeParty[0].name, + pbDisplayPaused(_INTL("Oh! A wild {1} and {2} appeared!", foeParty[0].name, foeParty[1].name)) when 3 - pbDisplayPaused(_INTL("Oh! A wild {1}, {2} and {3} appeared!",foeParty[0].name, - foeParty[1].name,foeParty[2].name)) + pbDisplayPaused(_INTL("Oh! A wild {1}, {2} and {3} appeared!", foeParty[0].name, + foeParty[1].name, foeParty[2].name)) end else # Trainer battle case @opponent.length when 1 - pbDisplayPaused(_INTL("You are challenged by {1}!",@opponent[0].full_name)) + pbDisplayPaused(_INTL("You are challenged by {1}!", @opponent[0].full_name)) when 2 - pbDisplayPaused(_INTL("You are challenged by {1} and {2}!",@opponent[0].full_name, + pbDisplayPaused(_INTL("You are challenged by {1} and {2}!", @opponent[0].full_name, @opponent[1].full_name)) when 3 pbDisplayPaused(_INTL("You are challenged by {1}, {2} and {3}!", - @opponent[0].full_name,@opponent[1].full_name,@opponent[2].full_name)) + @opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name)) end end # Send out Pokémon (opposing trainers first) - for side in [1,0] - next if side==1 && wildBattle? + for side in [1, 0] + next if side == 1 && wildBattle? msg = "" toSendOut = [] - trainers = (side==0) ? @player : @opponent + trainers = (side == 0) ? @player : @opponent # Opposing trainers and partner trainers's messages about sending out Pokémon - trainers.each_with_index do |t,i| - next if side==0 && i==0 # The player's message is shown last - msg += "\r\n" if msg.length>0 + trainers.each_with_index do |t, i| + next if side == 0 && i == 0 # The player's message is shown last + msg += "\r\n" if msg.length > 0 sent = sendOuts[side][i] case sent.length when 1 - msg += _INTL("{1} sent out {2}!",t.full_name,@battlers[sent[0]].name) + msg += _INTL("{1} sent out {2}!", t.full_name, @battlers[sent[0]].name) when 2 - msg += _INTL("{1} sent out {2} and {3}!",t.full_name, - @battlers[sent[0]].name,@battlers[sent[1]].name) + msg += _INTL("{1} sent out {2} and {3}!", t.full_name, + @battlers[sent[0]].name, @battlers[sent[1]].name) when 3 - msg += _INTL("{1} sent out {2}, {3} and {4}!",t.full_name, - @battlers[sent[0]].name,@battlers[sent[1]].name,@battlers[sent[2]].name) + msg += _INTL("{1} sent out {2}, {3} and {4}!", t.full_name, + @battlers[sent[0]].name, @battlers[sent[1]].name, @battlers[sent[2]].name) end toSendOut.concat(sent) end # The player's message about sending out Pokémon - if side==0 - msg += "\r\n" if msg.length>0 + if side == 0 + msg += "\r\n" if msg.length > 0 sent = sendOuts[side][0] case sent.length when 1 - msg += _INTL("Go! {1}!",@battlers[sent[0]].name) + msg += _INTL("Go! {1}!", @battlers[sent[0]].name) when 2 - msg += _INTL("Go! {1} and {2}!",@battlers[sent[0]].name,@battlers[sent[1]].name) + msg += _INTL("Go! {1} and {2}!", @battlers[sent[0]].name, @battlers[sent[1]].name) when 3 - msg += _INTL("Go! {1}, {2} and {3}!",@battlers[sent[0]].name, - @battlers[sent[1]].name,@battlers[sent[2]].name) + msg += _INTL("Go! {1}, {2} and {3}!", @battlers[sent[0]].name, + @battlers[sent[1]].name, @battlers[sent[2]].name) end toSendOut.concat(sent) end - pbDisplayBrief(msg) if msg.length>0 + pbDisplayBrief(msg) if msg.length > 0 # The actual sending out of Pokémon animSendOuts = [] toSendOut.each do |idxBattler| - animSendOuts.push([idxBattler,@battlers[idxBattler].pokemon]) + animSendOuts.push([idxBattler, @battlers[idxBattler].pokemon]) end - pbSendOut(animSendOuts,true) + pbSendOut(animSendOuts, true) end end @@ -238,11 +238,11 @@ class Battle PBDebug.log("") PBDebug.log("******************************************") logMsg = "[Started battle] " - if @sideSizes[0]==1 && @sideSizes[1]==1 + if @sideSizes[0] == 1 && @sideSizes[1] == 1 logMsg += "Single " - elsif @sideSizes[0]==2 && @sideSizes[1]==2 + elsif @sideSizes[0] == 2 && @sideSizes[1] == 2 logMsg += "Double " - elsif @sideSizes[0]==3 && @sideSizes[1]==3 + elsif @sideSizes[0] == 3 && @sideSizes[1] == 3 logMsg += "Triple " else logMsg += "#{@sideSizes[0]}v#{@sideSizes[1]} " @@ -309,8 +309,8 @@ class Battle @turnCount = 0 loop do # Now begin the battle loop PBDebug.log("") - PBDebug.log("***Round #{@turnCount+1}***") - if @debug && @turnCount>=100 + PBDebug.log("***Round #{@turnCount + 1}***") + if @debug && @turnCount >= 100 @decision = pbDecisionOnTime PBDebug.log("") PBDebug.log("***Undecided after 100 rounds, aborting***") @@ -320,13 +320,13 @@ class Battle PBDebug.log("") # Command phase PBDebug.logonerr { pbCommandPhase } - break if @decision>0 + break if @decision > 0 # Attack phase PBDebug.logonerr { pbAttackPhase } - break if @decision>0 + break if @decision > 0 # End of round phase PBDebug.logonerr { pbEndOfRoundPhase } - break if @decision>0 + break if @decision > 0 @turnCount += 1 end pbEndOfBattle @@ -340,29 +340,29 @@ class Battle # Money rewarded from opposing trainers if trainerBattle? tMoney = 0 - @opponent.each_with_index do |t,i| + @opponent.each_with_index do |t, i| tMoney += pbMaxLevelInTeam(1, i) * t.base_money end tMoney *= 2 if @field.effects[PBEffects::AmuletCoin] tMoney *= 2 if @field.effects[PBEffects::HappyHour] oldMoney = pbPlayer.money pbPlayer.money += tMoney - moneyGained = pbPlayer.money-oldMoney - if moneyGained>0 + moneyGained = pbPlayer.money - oldMoney + if moneyGained > 0 $stats.battle_money_gained += moneyGained - pbDisplayPaused(_INTL("You got ${1} for winning!",moneyGained.to_s_formatted)) + pbDisplayPaused(_INTL("You got ${1} for winning!", moneyGained.to_s_formatted)) end end # Pick up money scattered by Pay Day - if @field.effects[PBEffects::PayDay]>0 + if @field.effects[PBEffects::PayDay] > 0 @field.effects[PBEffects::PayDay] *= 2 if @field.effects[PBEffects::AmuletCoin] @field.effects[PBEffects::PayDay] *= 2 if @field.effects[PBEffects::HappyHour] oldMoney = pbPlayer.money pbPlayer.money += @field.effects[PBEffects::PayDay] - moneyGained = pbPlayer.money-oldMoney - if moneyGained>0 + moneyGained = pbPlayer.money - oldMoney + if moneyGained > 0 $stats.battle_money_gained += moneyGained - pbDisplayPaused(_INTL("You picked up ${1}!",moneyGained.to_s_formatted)) + pbDisplayPaused(_INTL("You picked up ${1}!", moneyGained.to_s_formatted)) end end end @@ -370,27 +370,27 @@ class Battle def pbLoseMoney return if !@internalBattle || !@moneyGain return if $game_switches[Settings::NO_MONEY_LOSS] - maxLevel = pbMaxLevelInTeam(0,0) # Player's Pokémon only, not partner's - multiplier = [8,16,24,36,48,64,80,100,120] + maxLevel = pbMaxLevelInTeam(0, 0) # Player's Pokémon only, not partner's + multiplier = [8, 16, 24, 36, 48, 64, 80, 100, 120] idxMultiplier = [pbPlayer.badge_count, multiplier.length - 1].min - tMoney = maxLevel*multiplier[idxMultiplier] - tMoney = pbPlayer.money if tMoney>pbPlayer.money + tMoney = maxLevel * multiplier[idxMultiplier] + tMoney = pbPlayer.money if tMoney > pbPlayer.money oldMoney = pbPlayer.money pbPlayer.money -= tMoney - moneyLost = oldMoney-pbPlayer.money - if moneyLost>0 + moneyLost = oldMoney - pbPlayer.money + if moneyLost > 0 $stats.battle_money_lost += moneyLost if trainerBattle? - pbDisplayPaused(_INTL("You gave ${1} to the winner...",moneyLost.to_s_formatted)) + pbDisplayPaused(_INTL("You gave ${1} to the winner...", moneyLost.to_s_formatted)) else - pbDisplayPaused(_INTL("You panicked and dropped ${1}...",moneyLost.to_s_formatted)) + pbDisplayPaused(_INTL("You panicked and dropped ${1}...", moneyLost.to_s_formatted)) end end end def pbEndOfBattle oldDecision = @decision - @decision = 4 if @decision==1 && wildBattle? && @caughtPokemon.length>0 + @decision = 4 if @decision == 1 && wildBattle? && @caughtPokemon.length > 0 case oldDecision ##### WIN ##### when 1 @@ -400,52 +400,52 @@ class Battle @scene.pbTrainerBattleSuccess case @opponent.length when 1 - pbDisplayPaused(_INTL("You defeated {1}!",@opponent[0].full_name)) + pbDisplayPaused(_INTL("You defeated {1}!", @opponent[0].full_name)) when 2 - pbDisplayPaused(_INTL("You defeated {1} and {2}!",@opponent[0].full_name, + pbDisplayPaused(_INTL("You defeated {1} and {2}!", @opponent[0].full_name, @opponent[1].full_name)) when 3 - pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!",@opponent[0].full_name, - @opponent[1].full_name,@opponent[2].full_name)) + pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!", @opponent[0].full_name, + @opponent[1].full_name, @opponent[2].full_name)) end - @opponent.each_with_index do |_t,i| + @opponent.each_with_index do |_t, i| @scene.pbShowOpponent(i) - msg = (@endSpeeches[i] && @endSpeeches[i]!="") ? @endSpeeches[i] : "..." - pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name)) + msg = (@endSpeeches[i] && @endSpeeches[i] != "") ? @endSpeeches[i] : "..." + pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name)) end end # Gain money from winning a trainer battle, and from Pay Day - pbGainMoney if @decision!=4 + pbGainMoney if @decision != 4 # Hide remaining trainer - @scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length>0 + @scene.pbShowOpponent(@opponent.length) if trainerBattle? && @caughtPokemon.length > 0 ##### LOSE, DRAW ##### when 2, 5 PBDebug.log("") - PBDebug.log("***Player lost***") if @decision==2 - PBDebug.log("***Player drew with opponent***") if @decision==5 + PBDebug.log("***Player lost***") if @decision == 2 + PBDebug.log("***Player drew with opponent***") if @decision == 5 if @internalBattle pbDisplayPaused(_INTL("You have no more Pokémon that can fight!")) if trainerBattle? case @opponent.length when 1 - pbDisplayPaused(_INTL("You lost against {1}!",@opponent[0].full_name)) + pbDisplayPaused(_INTL("You lost against {1}!", @opponent[0].full_name)) when 2 pbDisplayPaused(_INTL("You lost against {1} and {2}!", - @opponent[0].full_name,@opponent[1].full_name)) + @opponent[0].full_name, @opponent[1].full_name)) when 3 pbDisplayPaused(_INTL("You lost against {1}, {2} and {3}!", - @opponent[0].full_name,@opponent[1].full_name,@opponent[2].full_name)) + @opponent[0].full_name, @opponent[1].full_name, @opponent[2].full_name)) end end # Lose money from losing a battle pbLoseMoney pbDisplayPaused(_INTL("You blacked out!")) if !@canLose - elsif @decision==2 + elsif @decision == 2 if @opponent - @opponent.each_with_index do |_t,i| + @opponent.each_with_index do |_t, i| @scene.pbShowOpponent(i) - msg = (@endSpeechesWin[i] && @endSpeechesWin[i]!="") ? @endSpeechesWin[i] : "..." - pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name)) + msg = (@endSpeechesWin[i] && @endSpeechesWin[i] != "") ? @endSpeechesWin[i] : "..." + pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/, pbPlayer.name)) end end end @@ -456,12 +456,12 @@ class Battle # Register captured Pokémon in the Pokédex, and store them pbRecordAndStoreCaughtPokemon # Collect Pay Day money in a wild battle that ended in a capture - pbGainMoney if @decision==4 + pbGainMoney if @decision == 4 # Pass on Pokérus within the party if @internalBattle infected = [] - $player.party.each_with_index do |pkmn,i| - infected.push(i) if pkmn.pokerusStage==1 + $player.party.each_with_index do |pkmn, i| + infected.push(i) if pkmn.pokerusStage == 1 end infected.each do |idxParty| strain = $player.party[idxParty].pokerusStrain @@ -480,9 +480,9 @@ class Battle pbCancelChoice(b.index) # Restore unused items to Bag Battle::AbilityEffects.triggerOnSwitchOut(b.ability, b, true) if b.abilityActive? end - pbParty(0).each_with_index do |pkmn,i| + pbParty(0).each_with_index do |pkmn, i| next if !pkmn - @peer.pbOnLeavingBattle(self,pkmn,@usedInBattle[0][i],true) # Reset form + @peer.pbOnLeavingBattle(self, pkmn, @usedInBattle[0][i], true) # Reset form pkmn.item = @initialItems[0][i] end return @decision @@ -491,11 +491,11 @@ class Battle #============================================================================= # Judging #============================================================================= - def pbJudgeCheckpoint(user,move = nil); end + def pbJudgeCheckpoint(user, move = nil); end def pbDecisionOnTime - counts = [0,0] - hpTotals = [0,0] + counts = [0, 0] + hpTotals = [0, 0] for side in 0...2 pbParty(side).each do |pkmn| next if !pkmn || !pkmn.able? @@ -503,29 +503,29 @@ class Battle hpTotals[side] += pkmn.hp end end - return 1 if counts[0]>counts[1] # Win (player has more able Pokémon) - return 2 if counts[0]hpTotals[1] # Win (player has more HP in total) - return 2 if hpTotals[0] counts[1] # Win (player has more able Pokémon) + return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon) + return 1 if hpTotals[0] > hpTotals[1] # Win (player has more HP in total) + return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has more HP in total) return 5 # Draw end # Unused def pbDecisionOnTime2 - counts = [0,0] - hpTotals = [0,0] + counts = [0, 0] + hpTotals = [0, 0] for side in 0...2 pbParty(side).each do |pkmn| next if !pkmn || !pkmn.able? counts[side] += 1 - hpTotals[side] += 100*pkmn.hp/pkmn.totalhp + hpTotals[side] += 100 * pkmn.hp / pkmn.totalhp end - hpTotals[side] /= counts[side] if counts[side]>1 + hpTotals[side] /= counts[side] if counts[side] > 1 end - return 1 if counts[0]>counts[1] # Win (player has more able Pokémon) - return 2 if counts[0]hpTotals[1] # Win (player has a bigger average HP %) - return 2 if hpTotals[0] counts[1] # Win (player has more able Pokémon) + return 2 if counts[0] < counts[1] # Loss (foe has more able Pokémon) + return 1 if hpTotals[0] > hpTotals[1] # Win (player has a bigger average HP %) + return 2 if hpTotals[0] < hpTotals[1] # Loss (foe has a bigger average HP %) return 5 # Draw end diff --git a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb index 5b5f9a0e6..5c69d39d1 100644 --- a/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb +++ b/Data/Scripts/011_Battle/001_Battle/003_Battle_ExpAndMoveLearning.rb @@ -12,42 +12,42 @@ class Battle p1 = pbParty(0) @battlers.each do |b| next unless b && b.opposes? # Can only gain Exp from fainted foes - next if b.participants.length==0 + next if b.participants.length == 0 next unless b.fainted? || b.captured # Count the number of participants numPartic = 0 b.participants.each do |partic| - next unless p1[partic] && p1[partic].able? && pbIsOwner?(0,partic) + next unless p1[partic] && p1[partic].able? && pbIsOwner?(0, partic) numPartic += 1 end # Find which Pokémon have an Exp Share expShare = [] if !expAll - eachInTeam(0,0) do |pkmn,i| + eachInTeam(0, 0) do |pkmn, i| next if !pkmn.able? next if !pkmn.hasItem?(:EXPSHARE) && GameData::Item.try_get(@initialItems[0][i]) != :EXPSHARE expShare.push(i) end end # Calculate EV and Exp gains for the participants - if numPartic>0 || expShare.length>0 || expAll + if numPartic > 0 || expShare.length > 0 || expAll # Gain EVs and Exp for participants - eachInTeam(0,0) do |pkmn,i| + eachInTeam(0, 0) do |pkmn, i| next if !pkmn.able? next unless b.participants.include?(i) || expShare.include?(i) - pbGainEVsOne(i,b) - pbGainExpOne(i,b,numPartic,expShare,expAll) + pbGainEVsOne(i, b) + pbGainExpOne(i, b, numPartic, expShare, expAll) end # Gain EVs and Exp for all other Pokémon because of Exp All if expAll showMessage = true - eachInTeam(0,0) do |pkmn,i| + eachInTeam(0, 0) do |pkmn, i| next if !pkmn.able? next if b.participants.include?(i) || expShare.include?(i) pbDisplayPaused(_INTL("Your party Pokémon in waiting also got Exp. Points!")) if showMessage showMessage = false - pbGainEVsOne(i,b) - pbGainExpOne(i,b,numPartic,expShare,expAll,false) + pbGainEVsOne(i, b) + pbGainExpOne(i, b, numPartic, expShare, expAll, false) end end end @@ -56,7 +56,7 @@ class Battle end end - def pbGainEVsOne(idxParty,defeatedBattler) + def pbGainEVsOne(idxParty, defeatedBattler) pkmn = pbParty(0)[idxParty] # The Pokémon gaining EVs from defeatedBattler evYield = defeatedBattler.pokemon.evYield # Num of effort points pkmn already has @@ -67,7 +67,7 @@ class Battle Battle::ItemEffects.triggerEVGainModifier(@initialItems[0][idxParty], pkmn, evYield) end # Double EV gain because of Pokérus - if pkmn.pokerusStage>=1 # Infected or cured + if pkmn.pokerusStage >= 1 # Infected or cured evYield.each_key { |stat| evYield[stat] *= 2 } end # Gain EVs for each stat in turn @@ -89,11 +89,11 @@ class Battle end end - def pbGainExpOne(idxParty,defeatedBattler,numPartic,expShare,expAll,showMessages = true) + def pbGainExpOne(idxParty, defeatedBattler, numPartic, expShare, expAll, showMessages = true) pkmn = pbParty(0)[idxParty] # The Pokémon gaining Exp from defeatedBattler growth_rate = pkmn.growth_rate # Don't bother calculating if gainer is already at max Exp - if pkmn.exp>=growth_rate.maximum_exp + if pkmn.exp >= growth_rate.maximum_exp pkmn.calc_stats # To ensure new EVs still have an effect return end @@ -102,30 +102,30 @@ class Battle level = defeatedBattler.level # Main Exp calculation exp = 0 - a = level*defeatedBattler.pokemon.base_exp - if expShare.length>0 && (isPartic || hasExpShare) - if numPartic==0 # No participants, all Exp goes to Exp Share holders + a = level * defeatedBattler.pokemon.base_exp + if expShare.length > 0 && (isPartic || hasExpShare) + if numPartic == 0 # No participants, all Exp goes to Exp Share holders exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? expShare.length : 1) elsif Settings::SPLIT_EXP_BETWEEN_GAINERS # Gain from participating and/or Exp Share - exp = a/(2*numPartic) if isPartic - exp += a/(2*expShare.length) if hasExpShare + exp = a / (2 * numPartic) if isPartic + exp += a / (2 * expShare.length) if hasExpShare else # Gain from participating and/or Exp Share (Exp not split) - exp = (isPartic) ? a : a/2 + exp = (isPartic) ? a : a / 2 end elsif isPartic # Participated in battle, no Exp Shares held by anyone exp = a / (Settings::SPLIT_EXP_BETWEEN_GAINERS ? numPartic : 1) elsif expAll # Didn't participate in battle, gaining Exp due to Exp All # NOTE: Exp All works like the Exp Share from Gen 6+, not like the Exp All # from Gen 1, i.e. Exp isn't split between all Pokémon gaining it. - exp = a/2 + exp = a / 2 end - return if exp<=0 + return if exp <= 0 # Pokémon gain more Exp from trainer battles - exp = (exp*1.5).floor if trainerBattle? + exp = (exp * 1.5).floor if trainerBattle? # Scale the gained Exp based on the gainer's level (or not) if Settings::SCALED_EXP_FORMULA exp /= 5 - levelAdjust = (2*level+10.0)/(pkmn.level+level+10.0) + levelAdjust = (2 * level + 10.0) / (pkmn.level + level + 10.0) levelAdjust = levelAdjust**5 levelAdjust = Math.sqrt(levelAdjust) exp *= levelAdjust @@ -139,19 +139,19 @@ class Battle (pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language)) if isOutsider if pkmn.owner.language != 0 && pkmn.owner.language != pbPlayer.language - exp = (exp*1.7).floor + exp = (exp * 1.7).floor else - exp = (exp*1.5).floor + exp = (exp * 1.5).floor end end # Exp. Charm increases Exp gained exp = exp * 3 / 2 if $bag.has?(:EXPCHARM) # Modify Exp gain based on pkmn's held item i = Battle::ItemEffects.triggerExpGainModifier(pkmn.item, pkmn, exp) - if i<0 + if i < 0 i = Battle::ItemEffects.triggerExpGainModifier(@initialItems[0][idxParty], pkmn, exp) end - exp = i if i>=0 + exp = i if i >= 0 # Boost Exp gained with high affection if Settings::AFFECTION_EFFECTS && @internalBattle && pkmn.affection_level >= 4 && !pkmn.mega? exp = exp * 6 / 5 @@ -159,22 +159,22 @@ class Battle end # Make sure Exp doesn't exceed the maximum expFinal = growth_rate.add_exp(pkmn.exp, exp) - expGained = expFinal-pkmn.exp - return if expGained<=0 + expGained = expFinal - pkmn.exp + return if expGained <= 0 # "Exp gained" message if showMessages if isOutsider - pbDisplayPaused(_INTL("{1} got a boosted {2} Exp. Points!",pkmn.name,expGained)) + pbDisplayPaused(_INTL("{1} got a boosted {2} Exp. Points!", pkmn.name, expGained)) else - pbDisplayPaused(_INTL("{1} got {2} Exp. Points!",pkmn.name,expGained)) + pbDisplayPaused(_INTL("{1} got {2} Exp. Points!", pkmn.name, expGained)) end end curLevel = pkmn.level newLevel = growth_rate.level_from_exp(expFinal) - if newLevelnewLevel + if curLevel > newLevel # Gained all the Exp now, end the animation pkmn.calc_stats battler.pbUpdate(false) if battler @@ -204,7 +204,7 @@ class Battle break end # Levelled up - pbCommonAnimation("LevelUp",battler) if battler + pbCommonAnimation("LevelUp", battler) if battler oldTotalHP = pkmn.totalhp oldAttack = pkmn.attack oldDefense = pkmn.defense @@ -217,19 +217,19 @@ class Battle pkmn.calc_stats battler.pbUpdate(false) if battler @scene.pbRefreshOne(battler.index) if battler - pbDisplayPaused(_INTL("{1} grew to Lv. {2}!",pkmn.name,curLevel)) - @scene.pbLevelUp(pkmn,battler,oldTotalHP,oldAttack,oldDefense, - oldSpAtk,oldSpDef,oldSpeed) + pbDisplayPaused(_INTL("{1} grew to Lv. {2}!", pkmn.name, curLevel)) + @scene.pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense, + oldSpAtk, oldSpDef, oldSpeed) # Learn all moves learned at this level moveList = pkmn.getMoveList - moveList.each { |m| pbLearnMove(idxParty,m[1]) if m[0]==curLevel } + moveList.each { |m| pbLearnMove(idxParty, m[1]) if m[0] == curLevel } end end #============================================================================= # Learning a move #============================================================================= - def pbLearnMove(idxParty,newMove) + def pbLearnMove(idxParty, newMove) pkmn = pbParty(0)[idxParty] return if !pkmn pkmnName = pkmn.name @@ -240,7 +240,7 @@ class Battle # Pokémon has space for the new move; just learn it if pkmn.numMoves < Pokemon::MAX_MOVES pkmn.learn_move(newMove) - pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") } + pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") } if battler battler.moves.push(Move.from_pokemon_move(self, pkmn.moves.last)) battler.pbCheckFormOnMovesetChange @@ -252,18 +252,18 @@ class Battle pkmnName, moveName, pkmn.numMoves.to_word)) if pbDisplayConfirm(_INTL("Should {1} forget a move to learn {2}?", pkmnName, moveName)) loop do - forgetMove = @scene.pbForgetMove(pkmn,newMove) - if forgetMove>=0 + forgetMove = @scene.pbForgetMove(pkmn, newMove) + if forgetMove >= 0 oldMoveName = pkmn.moves[forgetMove].name pkmn.moves[forgetMove] = Pokemon::Move.new(newMove) # Replaces current/total PP battler.moves[forgetMove] = Move.from_pokemon_move(self, pkmn.moves[forgetMove]) if battler pbDisplayPaused(_INTL("1, 2, and... ... ... Ta-da!")) { pbSEPlay("Battle ball drop") } - pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...",pkmnName,oldMoveName)) - pbDisplay(_INTL("{1} learned {2}!",pkmnName,moveName)) { pbSEPlay("Pkmn move learnt") } + pbDisplayPaused(_INTL("{1} forgot how to use {2}. And...", pkmnName, oldMoveName)) + pbDisplay(_INTL("{1} learned {2}!", pkmnName, moveName)) { pbSEPlay("Pkmn move learnt") } battler.pbCheckFormOnMovesetChange if battler break - elsif pbDisplayConfirm(_INTL("Give up on learning {1}?",moveName)) - pbDisplay(_INTL("{1} did not learn {2}.",pkmnName,moveName)) + elsif pbDisplayConfirm(_INTL("Give up on learning {1}?", moveName)) + pbDisplay(_INTL("{1} did not learn {2}.", pkmnName, moveName)) break end end diff --git a/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb b/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb index b91ab1424..132555638 100644 --- a/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb +++ b/Data/Scripts/011_Battle/001_Battle/004_Battle_ActionAttacksPriority.rb @@ -2,30 +2,30 @@ class Battle #============================================================================= # Choosing a move/target #============================================================================= - def pbCanChooseMove?(idxBattler,idxMove,showMessages,sleepTalk = false) + def pbCanChooseMove?(idxBattler, idxMove, showMessages, sleepTalk = false) battler = @battlers[idxBattler] move = battler.moves[idxMove] return false unless move - if move.pp==0 && move.total_pp>0 && !sleepTalk + if move.pp == 0 && move.total_pp > 0 && !sleepTalk pbDisplayPaused(_INTL("There's no PP left for this move!")) if showMessages return false end - if battler.effects[PBEffects::Encore]>0 + if battler.effects[PBEffects::Encore] > 0 idxEncoredMove = battler.pbEncoredMoveIndex - return false if idxEncoredMove>=0 && idxMove!=idxEncoredMove + return false if idxEncoredMove >= 0 && idxMove != idxEncoredMove end - return battler.pbCanChooseMove?(move,true,showMessages,sleepTalk) + return battler.pbCanChooseMove?(move, true, showMessages, sleepTalk) end - def pbCanChooseAnyMove?(idxBattler,sleepTalk = false) + def pbCanChooseAnyMove?(idxBattler, sleepTalk = false) battler = @battlers[idxBattler] - battler.eachMoveWithIndex do |m,i| - next if m.pp==0 && m.total_pp>0 && !sleepTalk - if battler.effects[PBEffects::Encore]>0 + battler.eachMoveWithIndex do |m, i| + next if m.pp == 0 && m.total_pp > 0 && !sleepTalk + if battler.effects[PBEffects::Encore] > 0 idxEncoredMove = battler.pbEncoredMoveIndex - next if idxEncoredMove>=0 && i!=idxEncoredMove + next if idxEncoredMove >= 0 && i != idxEncoredMove end - next if !battler.pbCanChooseMove?(m,true,false,sleepTalk) + next if !battler.pbCanChooseMove?(m, true, false, sleepTalk) return true end return false @@ -33,7 +33,7 @@ class Battle # Called when the Pokémon is Encored, or if it can't use any of its moves. # Makes the Pokémon use the Encored move (if Encored), or Struggle. - def pbAutoChooseMove(idxBattler,showMessages = true) + def pbAutoChooseMove(idxBattler, showMessages = true) battler = @battlers[idxBattler] if battler.fainted? pbClearChoice(idxBattler) @@ -41,7 +41,7 @@ class Battle end # Encore idxEncoredMove = battler.pbEncoredMoveIndex - if idxEncoredMove>=0 && pbCanChooseMove?(idxBattler,idxEncoredMove,false) + if idxEncoredMove >= 0 && pbCanChooseMove?(idxBattler, idxEncoredMove, false) encoreMove = battler.moves[idxEncoredMove] @choices[idxBattler][0] = :UseMove # "Use move" @choices[idxBattler][1] = idxEncoredMove # Index of move to be used @@ -50,15 +50,15 @@ class Battle return true if singleBattle? if pbOwnedByPlayer?(idxBattler) if showMessages - pbDisplayPaused(_INTL("{1} has to use {2}!",battler.name,encoreMove.name)) + pbDisplayPaused(_INTL("{1} has to use {2}!", battler.name, encoreMove.name)) end - return pbChooseTarget(battler,encoreMove) + return pbChooseTarget(battler, encoreMove) end return true end # Struggle if pbOwnedByPlayer?(idxBattler) && showMessages - pbDisplayPaused(_INTL("{1} has no moves left!",battler.name)) + pbDisplayPaused(_INTL("{1} has no moves left!", battler.name)) end @choices[idxBattler][0] = :UseMove # "Use move" @choices[idxBattler][1] = -1 # Index of move to be used @@ -67,10 +67,10 @@ class Battle return true end - def pbRegisterMove(idxBattler,idxMove,showMessages = true) + def pbRegisterMove(idxBattler, idxMove, showMessages = true) battler = @battlers[idxBattler] move = battler.moves[idxMove] - return false if !pbCanChooseMove?(idxBattler,idxMove,showMessages) + return false if !pbCanChooseMove?(idxBattler, idxMove, showMessages) @choices[idxBattler][0] = :UseMove # "Use move" @choices[idxBattler][1] = idxMove # Index of move to be used @choices[idxBattler][2] = move # Battle::Move object @@ -78,54 +78,54 @@ class Battle return true end - def pbChoseMove?(idxBattler,moveID) + def pbChoseMove?(idxBattler, moveID) return false if !@battlers[idxBattler] || @battlers[idxBattler].fainted? - if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1] + if @choices[idxBattler][0] == :UseMove && @choices[idxBattler][1] return @choices[idxBattler][2].id == moveID end return false end - def pbChoseMoveFunctionCode?(idxBattler,code) + def pbChoseMoveFunctionCode?(idxBattler, code) return false if @battlers[idxBattler].fainted? - if @choices[idxBattler][0]==:UseMove && @choices[idxBattler][1] + if @choices[idxBattler][0] == :UseMove && @choices[idxBattler][1] return @choices[idxBattler][2].function == code end return false end - def pbRegisterTarget(idxBattler,idxTarget) + def pbRegisterTarget(idxBattler, idxTarget) @choices[idxBattler][3] = idxTarget # Set target of move end # Returns whether the idxTarget will be targeted by a move with target_data # used by a battler in idxUser. - def pbMoveCanTarget?(idxUser,idxTarget,target_data) + def pbMoveCanTarget?(idxUser, idxTarget, target_data) return false if target_data.num_targets == 0 case target_data.id when :NearAlly - return false if opposes?(idxUser,idxTarget) - return false if !nearBattlers?(idxUser,idxTarget) + return false if opposes?(idxUser, idxTarget) + return false if !nearBattlers?(idxUser, idxTarget) when :UserOrNearAlly - return true if idxUser==idxTarget - return false if opposes?(idxUser,idxTarget) - return false if !nearBattlers?(idxUser,idxTarget) + return true if idxUser == idxTarget + return false if opposes?(idxUser, idxTarget) + return false if !nearBattlers?(idxUser, idxTarget) when :AllAllies return false if idxUser == idxTarget return false if opposes?(idxUser, idxTarget) when :UserAndAllies - return false if opposes?(idxUser,idxTarget) + return false if opposes?(idxUser, idxTarget) when :NearFoe, :RandomNearFoe, :AllNearFoes - return false if !opposes?(idxUser,idxTarget) - return false if !nearBattlers?(idxUser,idxTarget) + return false if !opposes?(idxUser, idxTarget) + return false if !nearBattlers?(idxUser, idxTarget) when :Foe - return false if !opposes?(idxUser,idxTarget) + return false if !opposes?(idxUser, idxTarget) when :AllFoes - return false if !opposes?(idxUser,idxTarget) + return false if !opposes?(idxUser, idxTarget) when :NearOther, :AllNearOthers - return false if !nearBattlers?(idxUser,idxTarget) + return false if !nearBattlers?(idxUser, idxTarget) when :Other - return false if idxUser==idxTarget + return false if idxUser == idxTarget end return true end @@ -133,14 +133,14 @@ class Battle #============================================================================= # Turn order calculation (priority) #============================================================================= - def pbCalculatePriority(fullCalc = false,indexArray = nil) + def pbCalculatePriority(fullCalc = false, indexArray = nil) needRearranging = false if fullCalc - @priorityTrickRoom = (@field.effects[PBEffects::TrickRoom]>0) + @priorityTrickRoom = (@field.effects[PBEffects::TrickRoom] > 0) # Recalculate everything from scratch - randomOrder = Array.new(maxBattlerIndex+1) { |i| i } - (randomOrder.length-1).times do |i| # Can't use shuffle! here - r = i+pbRandom(randomOrder.length-i) + randomOrder = Array.new(maxBattlerIndex + 1) { |i| i } + (randomOrder.length - 1).times do |i| # Can't use shuffle! here + r = i + pbRandom(randomOrder.length - i) randomOrder[i], randomOrder[r] = randomOrder[r], randomOrder[i] end @priority.clear @@ -148,10 +148,10 @@ class Battle b = @battlers[i] next if !b # [battler, speed, sub-priority, priority, tie-breaker order] - bArray = [b,b.pbSpeed,0,0,randomOrder[i]] - if @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift + bArray = [b, b.pbSpeed, 0, 0, randomOrder[i]] + if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift # Calculate move's priority - if @choices[b.index][0]==:UseMove + if @choices[b.index][0] == :UseMove move = @choices[b.index][2] pri = move.pbPriority(b) if b.abilityActive? @@ -168,7 +168,7 @@ class Battle # Abilities (Stall) if b.abilityActive? newSubPri = Battle::AbilityEffects.triggerPriorityBracketChange(b.ability, b, subPri, self) - if subPri!=newSubPri + if subPri != newSubPri subPri = newSubPri b.effects[PBEffects::PriorityAbility] = true b.effects[PBEffects::PriorityItem] = false @@ -177,7 +177,7 @@ class Battle # Items (Quick Claw, Custap Berry, Lagging Tail, Full Incense) if b.itemActive? newSubPri = Battle::ItemEffects.triggerPriorityBracketChange(b.item, b, subPri, self) - if subPri!=newSubPri + if subPri != newSubPri subPri = newSubPri b.effects[PBEffects::PriorityAbility] = false b.effects[PBEffects::PriorityItem] = true @@ -189,9 +189,9 @@ class Battle end needRearranging = true else - if (@field.effects[PBEffects::TrickRoom]>0)!=@priorityTrickRoom + if (@field.effects[PBEffects::TrickRoom] > 0) != @priorityTrickRoom needRearranging = true - @priorityTrickRoom = (@field.effects[PBEffects::TrickRoom]>0) + @priorityTrickRoom = (@field.effects[PBEffects::TrickRoom] > 0) end # Just recheck all battler speeds @priority.each do |orderArray| @@ -199,24 +199,24 @@ class Battle next if indexArray && !indexArray.include?(orderArray[0].index) oldSpeed = orderArray[1] orderArray[1] = orderArray[0].pbSpeed - needRearranging = true if orderArray[1]!=oldSpeed + needRearranging = true if orderArray[1] != oldSpeed end end # Reorder the priority array if needRearranging - @priority.sort! { |a,b| - if a[3]!=b[3] + @priority.sort! { |a, b| + if a[3] != b[3] # Sort by priority (highest value first) - b[3]<=>a[3] - elsif a[2]!=b[2] + b[3] <=> a[3] + elsif a[2] != b[2] # Sort by sub-priority (highest value first) - b[2]<=>a[2] + b[2] <=> a[2] elsif @priorityTrickRoom # Sort by speed (lowest first), and use tie-breaker if necessary - (a[1]==b[1]) ? b[4]<=>a[4] : a[1]<=>b[1] + (a[1] == b[1]) ? b[4] <=> a[4] : a[1] <=> b[1] else # Sort by speed (highest first), and use tie-breaker if necessary - (a[1]==b[1]) ? b[4]<=>a[4] : b[1]<=>a[1] + (a[1] == b[1]) ? b[4] <=> a[4] : b[1] <=> a[1] end } # Write the priority order to the debug log @@ -236,8 +236,8 @@ class Battle if onlySpeedSort # Sort battlers by their speed stats and tie-breaker order only. tempArray = [] - @priority.each { |pArray| tempArray.push([pArray[0],pArray[1],pArray[4]]) } - tempArray.sort! { |a,b| (a[1]==b[1]) ? b[2]<=>a[2] : b[1]<=>a[1] } + @priority.each { |pArray| tempArray.push([pArray[0], pArray[1], pArray[4]]) } + tempArray.sort! { |a, b| (a[1] == b[1]) ? b[2] <=> a[2] : b[1] <=> a[1] } tempArray.each { |tArray| ret.push(tArray[0]) } else # Sort battlers by priority, sub-priority and their speed. Ties are diff --git a/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb b/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb index 493d5be32..92ed2683e 100644 --- a/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb +++ b/Data/Scripts/011_Battle/001_Battle/005_Battle_ActionSwitching.rb @@ -6,18 +6,18 @@ class Battle # battle. # NOTE: Messages are only shown while in the party screen when choosing a # command for the next round. - def pbCanSwitchLax?(idxBattler,idxParty,partyScene = nil) - return true if idxParty<0 + def pbCanSwitchLax?(idxBattler, idxParty, partyScene = nil) + return true if idxParty < 0 party = pbParty(idxBattler) - return false if idxParty>=party.length + return false if idxParty >= party.length return false if !party[idxParty] if party[idxParty].egg? partyScene.pbDisplay(_INTL("An Egg can't battle!")) if partyScene return false end - if !pbIsOwner?(idxBattler,idxParty) + if !pbIsOwner?(idxBattler, idxParty) if partyScene - owner = pbGetOwnerFromPartyIndex(idxBattler,idxParty) + owner = pbGetOwnerFromPartyIndex(idxBattler, idxParty) partyScene.pbDisplay(_INTL("You can't switch {1}'s Pokémon with one of yours!", owner.name)) end @@ -28,7 +28,7 @@ class Battle party[idxParty].name)) if partyScene return false end - if pbFindBattler(idxParty,idxBattler) + if pbFindBattler(idxParty, idxBattler) partyScene.pbDisplay(_INTL("{1} is already in battle!", party[idxParty].name)) if partyScene return false @@ -40,13 +40,13 @@ class Battle # switch out (and that its replacement at party index idxParty can switch in). # NOTE: Messages are only shown while in the party screen when choosing a # command for the next round. - def pbCanSwitch?(idxBattler,idxParty = -1,partyScene = nil) + def pbCanSwitch?(idxBattler, idxParty = -1, partyScene = nil) # Check whether party Pokémon can switch in - return false if !pbCanSwitchLax?(idxBattler,idxParty,partyScene) + return false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene) # Make sure another battler isn't already choosing to switch to the party # Pokémon allSameSideBattlers(idxBattler).each do |b| - next if choices[b.index][0]!=:SwitchOut || choices[b.index][1]!=idxParty + next if choices[b.index][0] != :SwitchOut || choices[b.index][1] != idxParty partyScene.pbDisplay(_INTL("{1} has already been selected.", pbParty(idxBattler)[idxParty].name)) if partyScene return false @@ -69,7 +69,7 @@ class Battle return true if Settings::MORE_TYPE_EFFECTS && battler.pbHasType?(:GHOST) # Other certain trapping effects if battler.trappedInBattle? - partyScene.pbDisplay(_INTL("{1} can't be switched out!",battler.pbThis)) if partyScene + partyScene.pbDisplay(_INTL("{1} can't be switched out!", battler.pbThis)) if partyScene return false end # Trapping abilities/items @@ -77,15 +77,15 @@ class Battle next if !b.abilityActive? if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self) partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!", - b.pbThis,b.abilityName)) if partyScene + b.pbThis, b.abilityName)) if partyScene return false end end allOtherSideBattlers(idxBattler).each do |b| next if !b.itemActive? - if Battle::ItemEffects.triggerTrappingByTarget(b.item,battler,b,self) + if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self) partyScene.pbDisplay(_INTL("{1}'s {2} prevents switching!", - b.pbThis,b.itemName)) if partyScene + b.pbThis, b.itemName)) if partyScene return false end end @@ -93,14 +93,14 @@ class Battle end def pbCanChooseNonActive?(idxBattler) - pbParty(idxBattler).each_with_index do |_pkmn,i| - return true if pbCanSwitchLax?(idxBattler,i) + pbParty(idxBattler).each_with_index do |_pkmn, i| + return true if pbCanSwitchLax?(idxBattler, i) end return false end - def pbRegisterSwitch(idxBattler,idxParty) - return false if !pbCanSwitch?(idxBattler,idxParty) + def pbRegisterSwitch(idxBattler, idxParty) + return false if !pbCanSwitch?(idxBattler, idxParty) @choices[idxBattler][0] = :SwitchOut @choices[idxBattler][1] = idxParty # Party index of Pokémon to switch in @choices[idxBattler][2] = nil @@ -113,16 +113,16 @@ class Battle #============================================================================= # Open party screen and potentially choose a Pokémon to switch with. Used in # all instances where the party screen is opened. - def pbPartyScreen(idxBattler,checkLaxOnly = false,canCancel = false,shouldRegister = false) + def pbPartyScreen(idxBattler, checkLaxOnly = false, canCancel = false, shouldRegister = false) ret = -1 - @scene.pbPartyScreen(idxBattler,canCancel) { |idxParty,partyScene| + @scene.pbPartyScreen(idxBattler, canCancel) { |idxParty, partyScene| if checkLaxOnly - next false if !pbCanSwitchLax?(idxBattler,idxParty,partyScene) + next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene) else - next false if !pbCanSwitch?(idxBattler,idxParty,partyScene) + next false if !pbCanSwitch?(idxBattler, idxParty, partyScene) end if shouldRegister - next false if idxParty<0 || !pbRegisterSwitch(idxBattler,idxParty) + next false if idxParty < 0 || !pbRegisterSwitch(idxBattler, idxParty) end ret = idxParty next true @@ -132,9 +132,9 @@ class Battle # For choosing a replacement Pokémon when prompted in the middle of other # things happening (U-turn, Baton Pass, in def pbEORSwitch). - def pbSwitchInBetween(idxBattler,checkLaxOnly = false,canCancel = false) - return pbPartyScreen(idxBattler,checkLaxOnly,canCancel) if pbOwnedByPlayer?(idxBattler) - return @battleAI.pbDefaultChooseNewEnemy(idxBattler,pbParty(idxBattler)) + def pbSwitchInBetween(idxBattler, checkLaxOnly = false, canCancel = false) + return pbPartyScreen(idxBattler, checkLaxOnly, canCancel) if pbOwnedByPlayer?(idxBattler) + return @battleAI.pbDefaultChooseNewEnemy(idxBattler, pbParty(idxBattler)) end #============================================================================= @@ -143,10 +143,10 @@ class Battle # General switching method that checks if any Pokémon need to be sent out and, # if so, does. Called at the end of each round. def pbEORSwitch(favorDraws = false) - return if @decision>0 && !favorDraws - return if @decision==5 && favorDraws + return if @decision > 0 && !favorDraws + return if @decision == 5 && favorDraws pbJudge - return if @decision>0 + return if @decision > 0 # Check through each fainted battler to see if that spot can be filled. switched = [] loop do @@ -162,9 +162,9 @@ class Battle # NOTE: The player is only offered the chance to switch their own # Pokémon when an opponent replaces a fainted Pokémon in single # battles. In double battles, etc. there is no such offer. - if @internalBattle && @switchStyle && trainerBattle? && pbSideSize(0)==1 && + if @internalBattle && @switchStyle && trainerBattle? && pbSideSize(0) == 1 && opposes?(idxBattler) && !@battlers[0].fainted? && !switched.include?(0) && - pbCanChooseNonActive?(0) && @battlers[0].effects[PBEffects::Outrage]==0 + pbCanChooseNonActive?(0) && @battlers[0].effects[PBEffects::Outrage] == 0 idxPartyForName = idxPartyNew enemyParty = pbParty(idxBattler) if enemyParty[idxPartyNew].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS) @@ -173,82 +173,82 @@ class Battle end if pbDisplayConfirm(_INTL("{1} is about to send in {2}. Will you switch your Pokémon?", opponent.full_name, enemyParty[idxPartyForName].name)) - idxPlayerPartyNew = pbSwitchInBetween(0,false,true) - if idxPlayerPartyNew>=0 + idxPlayerPartyNew = pbSwitchInBetween(0, false, true) + if idxPlayerPartyNew >= 0 pbMessageOnRecall(@battlers[0]) - pbRecallAndReplace(0,idxPlayerPartyNew) + pbRecallAndReplace(0, idxPlayerPartyNew) switched.push(0) end end end - pbRecallAndReplace(idxBattler,idxPartyNew) + pbRecallAndReplace(idxBattler, idxPartyNew) switched.push(idxBattler) elsif trainerBattle? # Player switches in in a trainer battle idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses - pbRecallAndReplace(idxBattler,idxPlayerPartyNew) + pbRecallAndReplace(idxBattler, idxPlayerPartyNew) switched.push(idxBattler) else # Player's Pokémon has fainted in a wild battle switch = false if !pbDisplayConfirm(_INTL("Use next Pokémon?")) - switch = (pbRun(idxBattler,true)<=0) + switch = (pbRun(idxBattler, true) <= 0) else switch = true end if switch idxPlayerPartyNew = pbGetReplacementPokemonIndex(idxBattler) # Owner chooses - pbRecallAndReplace(idxBattler,idxPlayerPartyNew) + pbRecallAndReplace(idxBattler, idxPlayerPartyNew) switched.push(idxBattler) end end end - break if switched.length==0 + break if switched.length == 0 pbOnBattlerEnteringBattle(switched) end end - def pbGetReplacementPokemonIndex(idxBattler,random = false) + def pbGetReplacementPokemonIndex(idxBattler, random = false) if random choices = [] # Find all Pokémon that can switch in - eachInTeamFromBattlerIndex(idxBattler) do |_pkmn,i| - choices.push(i) if pbCanSwitchLax?(idxBattler,i) + eachInTeamFromBattlerIndex(idxBattler) do |_pkmn, i| + choices.push(i) if pbCanSwitchLax?(idxBattler, i) end - return -1 if choices.length==0 + return -1 if choices.length == 0 return choices[pbRandom(choices.length)] else - return pbSwitchInBetween(idxBattler,true) + return pbSwitchInBetween(idxBattler, true) end end # Actually performs the recalling and sending out in all situations. - def pbRecallAndReplace(idxBattler,idxParty,randomReplacement = false,batonPass = false) + def pbRecallAndReplace(idxBattler, idxParty, randomReplacement = false, batonPass = false) @scene.pbRecall(idxBattler) if !@battlers[idxBattler].fainted? @battlers[idxBattler].pbAbilitiesOnSwitchOut # Inc. primordial weather check - @scene.pbShowPartyLineup(idxBattler&1) if pbSideSize(idxBattler)==1 - pbMessagesOnReplace(idxBattler,idxParty) if !randomReplacement - pbReplace(idxBattler,idxParty,batonPass) + @scene.pbShowPartyLineup(idxBattler & 1) if pbSideSize(idxBattler) == 1 + pbMessagesOnReplace(idxBattler, idxParty) if !randomReplacement + pbReplace(idxBattler, idxParty, batonPass) end def pbMessageOnRecall(battler) if battler.pbOwnedByPlayer? - if battler.hp<=battler.totalhp/4 - pbDisplayBrief(_INTL("Good job, {1}! Come back!",battler.name)) - elsif battler.hp<=battler.totalhp/2 - pbDisplayBrief(_INTL("OK, {1}! Come back!",battler.name)) - elsif battler.turnCount>=5 - pbDisplayBrief(_INTL("{1}, that's enough! Come back!",battler.name)) - elsif battler.turnCount>=2 - pbDisplayBrief(_INTL("{1}, come back!",battler.name)) + if battler.hp <= battler.totalhp / 4 + pbDisplayBrief(_INTL("Good job, {1}! Come back!", battler.name)) + elsif battler.hp <= battler.totalhp / 2 + pbDisplayBrief(_INTL("OK, {1}! Come back!", battler.name)) + elsif battler.turnCount >= 5 + pbDisplayBrief(_INTL("{1}, that's enough! Come back!", battler.name)) + elsif battler.turnCount >= 2 + pbDisplayBrief(_INTL("{1}, come back!", battler.name)) else - pbDisplayBrief(_INTL("{1}, switch out! Come back!",battler.name)) + pbDisplayBrief(_INTL("{1}, switch out! Come back!", battler.name)) end else owner = pbGetOwnerName(battler.index) - pbDisplayBrief(_INTL("{1} withdrew {2}!",owner,battler.name)) + pbDisplayBrief(_INTL("{1} withdrew {2}!", owner, battler.name)) end end # Only called from def pbRecallAndReplace and Battle Arena's def pbSwitch. - def pbMessagesOnReplace(idxBattler,idxParty) + def pbMessagesOnReplace(idxBattler, idxParty) party = pbParty(idxBattler) newPkmnName = party[idxParty].name if party[idxParty].ability == :ILLUSION && !pbCheckGlobalAbility(:NEUTRALIZINGGAS) @@ -257,45 +257,45 @@ class Battle end if pbOwnedByPlayer?(idxBattler) opposing = @battlers[idxBattler].pbDirectOpposing - if opposing.fainted? || opposing.hp==opposing.totalhp - pbDisplayBrief(_INTL("You're in charge, {1}!",newPkmnName)) - elsif opposing.hp>=opposing.totalhp/2 - pbDisplayBrief(_INTL("Go for it, {1}!",newPkmnName)) - elsif opposing.hp>=opposing.totalhp/4 - pbDisplayBrief(_INTL("Just a little more! Hang in there, {1}!",newPkmnName)) + if opposing.fainted? || opposing.hp == opposing.totalhp + pbDisplayBrief(_INTL("You're in charge, {1}!", newPkmnName)) + elsif opposing.hp >= opposing.totalhp / 2 + pbDisplayBrief(_INTL("Go for it, {1}!", newPkmnName)) + elsif opposing.hp >= opposing.totalhp / 4 + pbDisplayBrief(_INTL("Just a little more! Hang in there, {1}!", newPkmnName)) else - pbDisplayBrief(_INTL("Your opponent's weak! Get 'em, {1}!",newPkmnName)) + pbDisplayBrief(_INTL("Your opponent's weak! Get 'em, {1}!", newPkmnName)) end else owner = pbGetOwnerFromBattlerIndex(idxBattler) - pbDisplayBrief(_INTL("{1} sent out {2}!",owner.full_name,newPkmnName)) + pbDisplayBrief(_INTL("{1} sent out {2}!", owner.full_name, newPkmnName)) end end # Only called from def pbRecallAndReplace above and Battle Arena's def # pbSwitch. - def pbReplace(idxBattler,idxParty,batonPass = false) + def pbReplace(idxBattler, idxParty, batonPass = false) party = pbParty(idxBattler) idxPartyOld = @battlers[idxBattler].pokemonIndex # Initialise the new Pokémon - @battlers[idxBattler].pbInitialize(party[idxParty],idxParty,batonPass) + @battlers[idxBattler].pbInitialize(party[idxParty], idxParty, batonPass) # Reorder the party for this battle partyOrder = pbPartyOrder(idxBattler) - partyOrder[idxParty],partyOrder[idxPartyOld] = partyOrder[idxPartyOld],partyOrder[idxParty] + partyOrder[idxParty], partyOrder[idxPartyOld] = partyOrder[idxPartyOld], partyOrder[idxParty] # Send out the new Pokémon - pbSendOut([[idxBattler,party[idxParty]]]) - pbCalculatePriority(false,[idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES + pbSendOut([[idxBattler, party[idxParty]]]) + pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES end # Called from def pbReplace above and at the start of battle. # sendOuts is an array; each element is itself an array: [idxBattler,pkmn] - def pbSendOut(sendOuts,startBattle = false) + def pbSendOut(sendOuts, startBattle = false) sendOuts.each { |b| @peer.pbOnEnteringBattle(self, @battlers[b[0]], b[1]) } - @scene.pbSendOutBattlers(sendOuts,startBattle) + @scene.pbSendOutBattlers(sendOuts, startBattle) sendOuts.each do |b| @scene.pbResetMoveIndex(b[0]) pbSetSeen(@battlers[b[0]]) - @usedInBattle[b[0]&1][b[0]/2] = true + @usedInBattle[b[0] & 1][b[0] / 2] = true end end diff --git a/Data/Scripts/011_Battle/001_Battle/006_Battle_ActionUseItem.rb b/Data/Scripts/011_Battle/001_Battle/006_Battle_ActionUseItem.rb index e71004a9b..958dde11b 100644 --- a/Data/Scripts/011_Battle/001_Battle/006_Battle_ActionUseItem.rb +++ b/Data/Scripts/011_Battle/001_Battle/006_Battle_ActionUseItem.rb @@ -2,13 +2,13 @@ class Battle #============================================================================= # Choosing to use an item #============================================================================= - def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages = true) + def pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages = true) if !pkmn || pkmn.egg? scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages return false end # Embargo - if battler && battler.effects[PBEffects::Embargo]>0 + if battler && battler.effects[PBEffects::Embargo] > 0 scene.pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!", battler.pbThis(true))) if showMessages return false @@ -24,7 +24,7 @@ class Battle return false end - def pbRegisterItem(idxBattler,item,idxTarget = nil,idxMove = nil) + def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil) # Register for use of item on a Pokémon in the party @choices[idxBattler][0] = :UseItem @choices[idxBattler][1] = item # ID of item to be used @@ -32,14 +32,14 @@ class Battle @choices[idxBattler][3] = idxMove # Index of move to recharge (Ethers) # Delete the item from the Bag. If it turns out it will have no effect, it # will be re-added to the Bag later. - pbConsumeItemInBag(item,idxBattler) + pbConsumeItemInBag(item, idxBattler) return true end #============================================================================= # Using an item #============================================================================= - def pbConsumeItemInBag(item,idxBattler) + def pbConsumeItemInBag(item, idxBattler) return if !item return if !GameData::Item.get(item).consumed_after_use? if pbOwnedByPlayer?(idxBattler) @@ -52,7 +52,7 @@ class Battle end end - def pbReturnUnusedItemToBag(item,idxBattler) + def pbReturnUnusedItemToBag(item, idxBattler) return if !item return if !GameData::Item.get(item).consumed_after_use? if pbOwnedByPlayer?(idxBattler) @@ -67,41 +67,41 @@ class Battle end end - def pbUseItemMessage(item,trainerName) + def pbUseItemMessage(item, trainerName) itemName = GameData::Item.get(item).name if itemName.starts_with_vowel? - pbDisplayBrief(_INTL("{1} used an {2}.",trainerName,itemName)) + pbDisplayBrief(_INTL("{1} used an {2}.", trainerName, itemName)) else - pbDisplayBrief(_INTL("{1} used a {2}.",trainerName,itemName)) + pbDisplayBrief(_INTL("{1} used a {2}.", trainerName, itemName)) end end # Uses an item on a Pokémon in the trainer's party. - def pbUseItemOnPokemon(item,idxParty,userBattler) + def pbUseItemOnPokemon(item, idxParty, userBattler) trainerName = pbGetOwnerName(userBattler.index) - pbUseItemMessage(item,trainerName) + pbUseItemMessage(item, trainerName) pkmn = pbParty(userBattler.index)[idxParty] - battler = pbFindBattler(idxParty,userBattler.index) + battler = pbFindBattler(idxParty, userBattler.index) ch = @choices[userBattler.index] - if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false) - ItemHandlers.triggerBattleUseOnPokemon(item,pkmn,battler,ch,@scene) + if ItemHandlers.triggerCanUseInBattle(item, pkmn, battler, ch[3], true, self, @scene, false) + ItemHandlers.triggerBattleUseOnPokemon(item, pkmn, battler, ch, @scene) ch[1] = nil # Delete item from choice return end pbDisplay(_INTL("But it had no effect!")) # Return unused item to Bag - pbReturnUnusedItemToBag(item,userBattler.index) + pbReturnUnusedItemToBag(item, userBattler.index) end # Uses an item on a Pokémon in battle that belongs to the trainer. - def pbUseItemOnBattler(item,idxParty,userBattler) + def pbUseItemOnBattler(item, idxParty, userBattler) trainerName = pbGetOwnerName(userBattler.index) - pbUseItemMessage(item,trainerName) - battler = pbFindBattler(idxParty,userBattler.index) + pbUseItemMessage(item, trainerName) + battler = pbFindBattler(idxParty, userBattler.index) ch = @choices[userBattler.index] if battler - if ItemHandlers.triggerCanUseInBattle(item,battler.pokemon,battler,ch[3],true,self,@scene,false) - ItemHandlers.triggerBattleUseOnBattler(item,battler,@scene) + if ItemHandlers.triggerCanUseInBattle(item, battler.pokemon, battler, ch[3], true, self, @scene, false) + ItemHandlers.triggerBattleUseOnBattler(item, battler, @scene) ch[1] = nil # Delete item from choice battler.pbItemOnStatDropped return @@ -112,31 +112,31 @@ class Battle pbDisplay(_INTL("But it's not where this item can be used!")) end # Return unused item to Bag - pbReturnUnusedItemToBag(item,userBattler.index) + pbReturnUnusedItemToBag(item, userBattler.index) end # Uses a Poké Ball in battle directly. - def pbUsePokeBallInBattle(item,idxBattler,userBattler) - idxBattler = userBattler.index if idxBattler<0 + def pbUsePokeBallInBattle(item, idxBattler, userBattler) + idxBattler = userBattler.index if idxBattler < 0 battler = @battlers[idxBattler] - ItemHandlers.triggerUseInBattle(item,battler,self) + ItemHandlers.triggerUseInBattle(item, battler, self) @choices[userBattler.index][1] = nil # Delete item from choice end # Uses an item in battle directly. - def pbUseItemInBattle(item,idxBattler,userBattler) + def pbUseItemInBattle(item, idxBattler, userBattler) trainerName = pbGetOwnerName(userBattler.index) - pbUseItemMessage(item,trainerName) - battler = (idxBattler<0) ? userBattler : @battlers[idxBattler] + pbUseItemMessage(item, trainerName) + battler = (idxBattler < 0) ? userBattler : @battlers[idxBattler] pkmn = battler.pokemon ch = @choices[userBattler.index] - if ItemHandlers.triggerCanUseInBattle(item,pkmn,battler,ch[3],true,self,@scene,false) - ItemHandlers.triggerUseInBattle(item,battler,self) + if ItemHandlers.triggerCanUseInBattle(item, pkmn, battler, ch[3], true, self, @scene, false) + ItemHandlers.triggerUseInBattle(item, battler, self) ch[1] = nil # Delete item from choice return end pbDisplay(_INTL("But it had no effect!")) # Return unused item to Bag - pbReturnUnusedItemToBag(item,userBattler.index) + pbReturnUnusedItemToBag(item, userBattler.index) end end diff --git a/Data/Scripts/011_Battle/001_Battle/007_Battle_ActionRunning.rb b/Data/Scripts/011_Battle/001_Battle/007_Battle_ActionRunning.rb index b6b444ee2..4be5563df 100644 --- a/Data/Scripts/011_Battle/001_Battle/007_Battle_ActionRunning.rb +++ b/Data/Scripts/011_Battle/001_Battle/007_Battle_ActionRunning.rb @@ -27,7 +27,7 @@ class Battle # 1: Succeeded at fleeing, battle will end # duringBattle is true for replacing a fainted Pokémon during the End Of Round # phase, and false for choosing the Run command. - def pbRun(idxBattler,duringBattle = false) + def pbRun(idxBattler, duringBattle = false) battler = @battlers[idxBattler] if battler.opposes? return 0 if trainerBattle? @@ -50,7 +50,7 @@ class Battle pbDisplayPaused(_INTL("No! There's no running from a Trainer battle!")) elsif pbDisplayConfirm(_INTL("Would you like to forfeit the match and quit now?")) pbSEPlay("Battle flee") - pbDisplay(_INTL("{1} forfeited the match!",self.pbPlayer.name)) + pbDisplay(_INTL("{1} forfeited the match!", self.pbPlayer.name)) @decision = 3 return 1 end @@ -77,7 +77,7 @@ class Battle # Abilities that guarantee escape if battler.abilityActive? if Battle::AbilityEffects.triggerCertainEscapeFromBattle(battler.ability, battler) - pbShowAbilitySplash(battler,true) + pbShowAbilitySplash(battler, true) pbHideAbilitySplash(battler) pbSEPlay("Battle flee") pbDisplayPaused(_INTL("You got away safely!")) @@ -89,7 +89,7 @@ class Battle if battler.itemActive? if Battle::ItemEffects.triggerCertainEscapeFromBattle(battler.item, battler) pbSEPlay("Battle flee") - pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis,battler.itemName)) + pbDisplayPaused(_INTL("{1} fled using its {2}!", battler.pbThis, battler.itemName)) @decision = 3 return 1 end @@ -103,14 +103,14 @@ class Battle allOtherSideBattlers(idxBattler).each do |b| next if !b.abilityActive? if Battle::AbilityEffects.triggerTrappingByTarget(b.ability, battler, b, self) - pbDisplayPaused(_INTL("{1} prevents escape with {2}!",b.pbThis,b.abilityName)) + pbDisplayPaused(_INTL("{1} prevents escape with {2}!", b.pbThis, b.abilityName)) return 0 end end allOtherSideBattlers(idxBattler).each do |b| next if !b.itemActive? if Battle::ItemEffects.triggerTrappingByTarget(b.item, battler, b, self) - pbDisplayPaused(_INTL("{1} prevents escape with {2}!",b.pbThis,b.itemName)) + pbDisplayPaused(_INTL("{1} prevents escape with {2}!", b.pbThis, b.itemName)) return 0 end end @@ -123,16 +123,16 @@ class Battle speedEnemy = 1 allOtherSideBattlers(idxBattler).each do |b| speed = b.speed - speedEnemy = speed if speedEnemyspeedEnemy + if speedPlayer > speedEnemy rate = 256 else - rate = (speedPlayer*128)/speedEnemy - rate += @runCommand*30 + rate = (speedPlayer * 128) / speedEnemy + rate += @runCommand * 30 end - if rate>=256 || @battleAI.pbAIRandom(256)= 256 || @battleAI.pbAIRandom(256) < rate pbSEPlay("Battle flee") pbDisplayPaused(_INTL("You got away safely!")) @decision = 3 diff --git a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb index f548a0084..cf24b7342 100644 --- a/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb +++ b/Data/Scripts/011_Battle/001_Battle/008_Battle_ActionOther.rb @@ -3,18 +3,18 @@ class Battle # Shifting a battler to another position in a battle larger than double #============================================================================= def pbCanShift?(idxBattler) - return false if pbSideSize(0)<=2 && pbSideSize(1)<=2 # Double battle or smaller + return false if pbSideSize(0) <= 2 && pbSideSize(1) <= 2 # Double battle or smaller idxOther = -1 case pbSideSize(idxBattler) when 1 return false # Only one battler on that side when 2 - idxOther = (idxBattler+2)%4 + idxOther = (idxBattler + 2) % 4 when 3 - return false if idxBattler==2 || idxBattler==3 # In middle spot already - idxOther = ((idxBattler%2)==0) ? 2 : 3 + return false if idxBattler == 2 || idxBattler == 3 # In middle spot already + idxOther = ((idxBattler % 2) == 0) ? 2 : 3 end - return false if pbGetOwnerIndexFromBattlerIndex(idxBattler)!=pbGetOwnerIndexFromBattlerIndex(idxOther) + return false if pbGetOwnerIndexFromBattlerIndex(idxBattler) != pbGetOwnerIndexFromBattlerIndex(idxOther) return true end @@ -38,20 +38,20 @@ class Battle def pbCall(idxBattler) battler = @battlers[idxBattler] trainerName = pbGetOwnerName(idxBattler) - pbDisplay(_INTL("{1} called {2}!",trainerName,battler.pbThis(true))) - pbDisplay(_INTL("{1}!",battler.name)) + pbDisplay(_INTL("{1} called {2}!", trainerName, battler.pbThis(true))) + pbDisplay(_INTL("{1}!", battler.name)) if battler.shadowPokemon? if battler.inHyperMode? battler.pokemon.hyper_mode = false battler.pokemon.change_heart_gauge("call") - pbDisplay(_INTL("{1} came to its senses from the Trainer's call!",battler.pbThis)) + pbDisplay(_INTL("{1} came to its senses from the Trainer's call!", battler.pbThis)) else pbDisplay(_INTL("But nothing happened!")) end elsif battler.status == :SLEEP battler.pbCureStatus - elsif battler.pbCanRaiseStatStage?(:ACCURACY,battler) - battler.pbRaiseStatStage(:ACCURACY,1,battler) + elsif battler.pbCanRaiseStatStage?(:ACCURACY, battler) + battler.pbRaiseStatStage(:ACCURACY, 1, battler) battler.pbItemOnStatDropped else pbDisplay(_INTL("But nothing happened!")) @@ -85,11 +85,11 @@ class Battle return false if !@battlers[idxBattler].hasMega? return false if @battlers[idxBattler].wild? return true if $DEBUG && Input.press?(Input::CTRL) - return false if @battlers[idxBattler].effects[PBEffects::SkyDrop]>=0 + return false if @battlers[idxBattler].effects[PBEffects::SkyDrop] >= 0 return false if !pbHasMegaRing?(idxBattler) side = @battlers[idxBattler].idxOwnSide owner = pbGetOwnerIndexFromBattlerIndex(idxBattler) - return @megaEvolution[side][owner]==-1 + return @megaEvolution[side][owner] == -1 end def pbRegisterMegaEvolution(idxBattler) @@ -101,13 +101,13 @@ class Battle def pbUnregisterMegaEvolution(idxBattler) side = @battlers[idxBattler].idxOwnSide owner = pbGetOwnerIndexFromBattlerIndex(idxBattler) - @megaEvolution[side][owner] = -1 if @megaEvolution[side][owner]==idxBattler + @megaEvolution[side][owner] = -1 if @megaEvolution[side][owner] == idxBattler end def pbToggleRegisteredMegaEvolution(idxBattler) side = @battlers[idxBattler].idxOwnSide owner = pbGetOwnerIndexFromBattlerIndex(idxBattler) - if @megaEvolution[side][owner]==idxBattler + if @megaEvolution[side][owner] == idxBattler @megaEvolution[side][owner] = -1 else @megaEvolution[side][owner] = idxBattler @@ -117,7 +117,7 @@ class Battle def pbRegisteredMegaEvolution?(idxBattler) side = @battlers[idxBattler].idxOwnSide owner = pbGetOwnerIndexFromBattlerIndex(idxBattler) - return @megaEvolution[side][owner]==idxBattler + return @megaEvolution[side][owner] == idxBattler end #============================================================================= @@ -137,28 +137,28 @@ class Battle # Mega Evolve case battler.pokemon.megaMessage when 1 # Rayquaza - pbDisplay(_INTL("{1}'s fervent wish has reached {2}!",trainerName,battler.pbThis)) + pbDisplay(_INTL("{1}'s fervent wish has reached {2}!", trainerName, battler.pbThis)) else pbDisplay(_INTL("{1}'s {2} is reacting to {3}'s {4}!", - battler.pbThis,battler.itemName,trainerName,pbGetMegaRingName(idxBattler))) + battler.pbThis, battler.itemName, trainerName, pbGetMegaRingName(idxBattler))) end - pbCommonAnimation("MegaEvolution",battler) + pbCommonAnimation("MegaEvolution", battler) battler.pokemon.makeMega battler.form = battler.pokemon.form battler.pbUpdate(true) - @scene.pbChangePokemon(battler,battler.pokemon) + @scene.pbChangePokemon(battler, battler.pokemon) @scene.pbRefreshOne(idxBattler) - pbCommonAnimation("MegaEvolution2",battler) + pbCommonAnimation("MegaEvolution2", battler) megaName = battler.pokemon.megaName megaName = _INTL("Mega {1}", battler.pokemon.speciesName) if nil_or_empty?(megaName) - pbDisplay(_INTL("{1} has Mega Evolved into {2}!",battler.pbThis,megaName)) + pbDisplay(_INTL("{1} has Mega Evolved into {2}!", battler.pbThis, megaName)) side = battler.idxOwnSide owner = pbGetOwnerIndexFromBattlerIndex(idxBattler) @megaEvolution[side][owner] = -2 if battler.isSpecies?(:GENGAR) && battler.mega? battler.effects[PBEffects::Telekinesis] = 0 end - pbCalculatePriority(false,[idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION + pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION # Trigger ability battler.pbOnLosingAbility(old_ability) battler.pbTriggerAbilityOnGainingIt @@ -172,20 +172,20 @@ class Battle return if !battler || !battler.pokemon || battler.fainted? return if !battler.hasPrimal? || battler.primal? if battler.isSpecies?(:KYOGRE) - pbCommonAnimation("PrimalKyogre",battler) + pbCommonAnimation("PrimalKyogre", battler) elsif battler.isSpecies?(:GROUDON) - pbCommonAnimation("PrimalGroudon",battler) + pbCommonAnimation("PrimalGroudon", battler) end battler.pokemon.makePrimal battler.form = battler.pokemon.form battler.pbUpdate(true) - @scene.pbChangePokemon(battler,battler.pokemon) + @scene.pbChangePokemon(battler, battler.pokemon) @scene.pbRefreshOne(idxBattler) if battler.isSpecies?(:KYOGRE) - pbCommonAnimation("PrimalKyogre2",battler) + pbCommonAnimation("PrimalKyogre2", battler) elsif battler.isSpecies?(:GROUDON) - pbCommonAnimation("PrimalGroudon2",battler) + pbCommonAnimation("PrimalGroudon2", battler) end - pbDisplay(_INTL("{1}'s Primal Reversion!\nIt reverted to its primal form!",battler.pbThis)) + pbDisplay(_INTL("{1}'s Primal Reversion!\nIt reverted to its primal form!", battler.pbThis)) end end diff --git a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb index 729e57721..72c0aef96 100644 --- a/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/009_Battle_CommandPhase.rb @@ -25,8 +25,8 @@ class Battle #============================================================================= # Use main command menu (Fight/Pokémon/Bag/Run) #============================================================================= - def pbCommandMenu(idxBattler,firstAction) - return @scene.pbCommandMenu(idxBattler,firstAction) + def pbCommandMenu(idxBattler, firstAction) + return @scene.pbCommandMenu(idxBattler, firstAction) end #============================================================================= @@ -42,11 +42,11 @@ class Battle def pbCanShowFightMenu?(idxBattler) battler = @battlers[idxBattler] # Encore - return false if battler.effects[PBEffects::Encore]>0 + return false if battler.effects[PBEffects::Encore] > 0 # No moves that can be chosen (will Struggle instead) usable = false - battler.eachMoveWithIndex do |_m,i| - next if !pbCanChooseMove?(idxBattler,i,false) + battler.eachMoveWithIndex do |_m, i| + next if !pbCanChooseMove?(idxBattler, i, false) usable = true break end @@ -64,7 +64,7 @@ class Battle return true if pbAutoFightMenu(idxBattler) # Regular move selection ret = false - @scene.pbFightMenu(idxBattler,pbCanMegaEvolve?(idxBattler)) { |cmd| + @scene.pbFightMenu(idxBattler, pbCanMegaEvolve?(idxBattler)) { |cmd| case cmd when -1 # Cancel when -2 # Toggle Mega Evolution @@ -75,11 +75,11 @@ class Battle pbRegisterShift(idxBattler) ret = true else # Chose a move to use - next false if cmd<0 || !@battlers[idxBattler].moves[cmd] || + next false if cmd < 0 || !@battlers[idxBattler].moves[cmd] || !@battlers[idxBattler].moves[cmd].id - next false if !pbRegisterMove(idxBattler,cmd) + next false if !pbRegisterMove(idxBattler, cmd) next false if !singleBattle? && - !pbChooseTarget(@battlers[idxBattler],@battlers[idxBattler].moves[cmd]) + !pbChooseTarget(@battlers[idxBattler], @battlers[idxBattler].moves[cmd]) ret = true end next true @@ -89,36 +89,36 @@ class Battle def pbAutoFightMenu(idxBattler); return false; end - def pbChooseTarget(battler,move) + def pbChooseTarget(battler, move) target_data = move.pbTarget(battler) - idxTarget = @scene.pbChooseTarget(battler.index,target_data) - return false if idxTarget<0 - pbRegisterTarget(battler.index,idxTarget) + idxTarget = @scene.pbChooseTarget(battler.index, target_data) + return false if idxTarget < 0 + pbRegisterTarget(battler.index, idxTarget) return true end - def pbItemMenu(idxBattler,firstAction) + def pbItemMenu(idxBattler, firstAction) if !@internalBattle pbDisplay(_INTL("Items can't be used here.")) return false end ret = false - @scene.pbItemMenu(idxBattler,firstAction) { |item,useType,idxPkmn,idxMove,itemScene| + @scene.pbItemMenu(idxBattler, firstAction) { |item, useType, idxPkmn, idxMove, itemScene| next false if !item battler = pkmn = nil case useType when 1, 2 # Use on Pokémon/Pokémon's move next false if !ItemHandlers.hasBattleUseOnPokemon(item) - battler = pbFindBattler(idxPkmn,idxBattler) + battler = pbFindBattler(idxPkmn, idxBattler) pkmn = pbParty(idxBattler)[idxPkmn] - next false if !pbCanUseItemOnPokemon?(item,pkmn,battler,itemScene) + next false if !pbCanUseItemOnPokemon?(item, pkmn, battler, itemScene) when 3 # Use on battler next false if !ItemHandlers.hasBattleUseOnBattler(item) - battler = pbFindBattler(idxPkmn,idxBattler) + battler = pbFindBattler(idxPkmn, idxBattler) pkmn = battler.pokemon if battler - next false if !pbCanUseItemOnPokemon?(item,pkmn,battler,itemScene) + next false if !pbCanUseItemOnPokemon?(item, pkmn, battler, itemScene) when 4 # Poké Balls - next false if idxPkmn<0 + next false if idxPkmn < 0 battler = @battlers[idxPkmn] pkmn = battler.pokemon if battler when 5 # No target (Poké Doll, Guard Spec., Launcher items) @@ -129,8 +129,8 @@ class Battle end next false if !pkmn next false if !ItemHandlers.triggerCanUseInBattle(item, - pkmn,battler,idxMove,firstAction,self,itemScene) - next false if !pbRegisterItem(idxBattler,item,idxPkmn,idxMove) + pkmn, battler, idxMove, firstAction, self, itemScene) + next false if !pbRegisterItem(idxBattler, item, idxPkmn, idxMove) ret = true next true } @@ -140,16 +140,16 @@ class Battle def pbPartyMenu(idxBattler) ret = -1 if @debug - ret = @battleAI.pbDefaultChooseNewEnemy(idxBattler,pbParty(idxBattler)) + ret = @battleAI.pbDefaultChooseNewEnemy(idxBattler, pbParty(idxBattler)) else - ret = pbPartyScreen(idxBattler,false,true,true) + ret = pbPartyScreen(idxBattler, false, true, true) end - return ret>=0 + return ret >= 0 end def pbRunMenu(idxBattler) # Regardless of succeeding or failing to run, stop choosing actions - return pbRun(idxBattler)!=0 + return pbRun(idxBattler) != 0 end def pbCallMenu(idxBattler) @@ -172,19 +172,19 @@ class Battle def pbCommandPhase @scene.pbBeginCommandPhase # Reset choices if commands can be shown - @battlers.each_with_index do |b,i| + @battlers.each_with_index do |b, i| next if !b pbClearChoice(i) if pbCanShowCommands?(i) end # Reset choices to perform Mega Evolution if it wasn't done somehow for side in 0...2 - @megaEvolution[side].each_with_index do |megaEvo,i| - @megaEvolution[side][i] = -1 if megaEvo>=0 + @megaEvolution[side].each_with_index do |megaEvo, i| + @megaEvolution[side][i] = -1 if megaEvo >= 0 end end # Choose actions for the round (player first, then AI) pbCommandPhaseLoop(true) # Player chooses their actions - return if @decision!=0 # Battle ended, stop choosing actions + return if @decision != 0 # Battle ended, stop choosing actions pbCommandPhaseLoop(false) # AI chooses their actions end @@ -194,11 +194,11 @@ class Battle actioned = [] idxBattler = -1 loop do - break if @decision!=0 # Battle ended, stop choosing actions + break if @decision != 0 # Battle ended, stop choosing actions idxBattler += 1 - break if idxBattler>=@battlers.length - next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler)!=isPlayer - next if @choices[idxBattler][0]!=:None # Action is forced, can't choose one + break if idxBattler >= @battlers.length + next if !@battlers[idxBattler] || pbOwnedByPlayer?(idxBattler) != isPlayer + next if @choices[idxBattler][0] != :None # Action is forced, can't choose one next if !pbCanShowCommands?(idxBattler) # Action is forced, can't choose one # AI controls this battler if @controlPlayer || !pbOwnedByPlayer?(idxBattler) @@ -209,17 +209,17 @@ class Battle actioned.push(idxBattler) commandsEnd = false # Whether to cancel choosing all other actions this round loop do - cmd = pbCommandMenu(idxBattler,actioned.length==1) + cmd = pbCommandMenu(idxBattler, actioned.length == 1) # If being Sky Dropped, can't do anything except use a move - if cmd>0 && @battlers[idxBattler].effects[PBEffects::SkyDrop]>=0 - pbDisplay(_INTL("Sky Drop won't let {1} go!",@battlers[idxBattler].pbThis(true))) + if cmd > 0 && @battlers[idxBattler].effects[PBEffects::SkyDrop] >= 0 + pbDisplay(_INTL("Sky Drop won't let {1} go!", @battlers[idxBattler].pbThis(true))) next end case cmd when 0 # Fight break if pbFightMenu(idxBattler) when 1 # Bag - if pbItemMenu(idxBattler,actioned.length==1) + if pbItemMenu(idxBattler, actioned.length == 1) commandsEnd = true if pbItemUsesAllActions?(@choices[idxBattler][1]) break end @@ -240,10 +240,10 @@ class Battle pbDebugMenu next when -1 # Go back to previous battler's action choice - next if actioned.length<=1 + next if actioned.length <= 1 actioned.pop # Forget this battler was done - idxBattler = actioned.last-1 - pbCancelChoice(idxBattler+1) # Clear the previous battler's choice + idxBattler = actioned.last - 1 + pbCancelChoice(idxBattler + 1) # Clear the previous battler's choice actioned.pop # Forget the previous battler was done break end diff --git a/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb b/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb index f565e8544..41a3f2981 100644 --- a/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/010_Battle_AttackPhase.rb @@ -15,7 +15,7 @@ class Battle def pbAttackPhaseCall pbPriority.each do |b| - next unless @choices[b.index][0]==:Call && !b.fainted? + next unless @choices[b.index][0] == :Call && !b.fainted? b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum pbCall(b.index) end @@ -25,31 +25,31 @@ class Battle @switching = true pbPriority.each do |b| next if b.fainted? || !b.opposes?(idxSwitcher) # Shouldn't hit an ally - next if b.movedThisRound? || !pbChoseMoveFunctionCode?(b.index,"PursueSwitchingFoe") + next if b.movedThisRound? || !pbChoseMoveFunctionCode?(b.index, "PursueSwitchingFoe") # Check whether Pursuit can be used - next unless pbMoveCanTarget?(b.index,idxSwitcher,@choices[b.index][2].pbTarget(b)) - next unless pbCanChooseMove?(b.index,@choices[b.index][1],false) + next unless pbMoveCanTarget?(b.index, idxSwitcher, @choices[b.index][2].pbTarget(b)) + next unless pbCanChooseMove?(b.index, @choices[b.index][1], false) next if b.status == :SLEEP || b.status == :FROZEN - next if b.effects[PBEffects::SkyDrop]>=0 + next if b.effects[PBEffects::SkyDrop] >= 0 next if b.hasActiveAbility?(:TRUANT) && b.effects[PBEffects::Truant] # Mega Evolve if !b.wild? owner = pbGetOwnerIndexFromBattlerIndex(b.index) - pbMegaEvolve(b.index) if @megaEvolution[b.idxOwnSide][owner]==b.index + pbMegaEvolve(b.index) if @megaEvolution[b.idxOwnSide][owner] == b.index end # Use Pursuit @choices[b.index][3] = idxSwitcher # Change Pursuit's target - if b.pbProcessTurn(@choices[b.index],false) + if b.pbProcessTurn(@choices[b.index], false) b.effects[PBEffects::Pursuit] = true end - break if @decision>0 || @battlers[idxSwitcher].fainted? + break if @decision > 0 || @battlers[idxSwitcher].fainted? end @switching = false end def pbAttackPhaseSwitch pbPriority.each do |b| - next unless @choices[b.index][0]==:SwitchOut && !b.fainted? + next unless @choices[b.index][0] == :SwitchOut && !b.fainted? idxNewPkmn = @choices[b.index][1] # Party index of Pokémon to switch to b.lastMoveFailed = false # Counts as a successful move for Stomping Tantrum @lastMoveUser = b.index @@ -57,13 +57,13 @@ class Battle pbMessageOnRecall(b) # Pursuit interrupts switching pbPursuit(b.index) - return if @decision>0 + return if @decision > 0 # Switch Pokémon allBattlers.each do |b| b.droppedBelowHalfHP = false b.statsDropped = false end - pbRecallAndReplace(b.index,idxNewPkmn) + pbRecallAndReplace(b.index, idxNewPkmn) pbOnBattlerEnteringBattle(b.index, true) end end @@ -94,9 +94,9 @@ class Battle def pbAttackPhaseMegaEvolution pbPriority.each do |b| next if b.wild? - next unless @choices[b.index][0]==:UseMove && !b.fainted? + next unless @choices[b.index][0] == :UseMove && !b.fainted? owner = pbGetOwnerIndexFromBattlerIndex(b.index) - next if @megaEvolution[b.idxOwnSide][owner]!=b.index + next if @megaEvolution[b.idxOwnSide][owner] != b.index pbMegaEvolve(b.index) end end @@ -104,7 +104,7 @@ class Battle def pbAttackPhaseMoves # Show charging messages (Focus Punch) pbPriority.each do |b| - next unless @choices[b.index][0]==:UseMove && !b.fainted? + next unless @choices[b.index][0] == :UseMove && !b.fainted? next if b.movedThisRound? @choices[b.index][2].pbDisplayChargeMessage(b) end @@ -115,28 +115,28 @@ class Battle advance = false priority.each do |b| next unless b.effects[PBEffects::MoveNext] && !b.fainted? - next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift + next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift next if b.movedThisRound? advance = b.pbProcessTurn(@choices[b.index]) break if advance end - return if @decision>0 + return if @decision > 0 next if advance # Regular priority order priority.each do |b| - next if b.effects[PBEffects::Quash]>0 || b.fainted? - next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift + next if b.effects[PBEffects::Quash] > 0 || b.fainted? + next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift next if b.movedThisRound? advance = b.pbProcessTurn(@choices[b.index]) break if advance end - return if @decision>0 + return if @decision > 0 next if advance # Quashed if Settings::MECHANICS_GENERATION >= 8 priority.each do |b| next unless b.effects[PBEffects::Quash] > 0 && !b.fainted? - next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift + next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift next if b.movedThisRound? advance = b.pbProcessTurn(@choices[b.index]) break if advance @@ -147,9 +147,9 @@ class Battle quashLevel += 1 moreQuash = false priority.each do |b| - moreQuash = true if b.effects[PBEffects::Quash]>quashLevel - next unless b.effects[PBEffects::Quash]==quashLevel && !b.fainted? - next unless @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift + moreQuash = true if b.effects[PBEffects::Quash] > quashLevel + next unless b.effects[PBEffects::Quash] == quashLevel && !b.fainted? + next unless @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift next if b.movedThisRound? advance = b.pbProcessTurn(@choices[b.index]) break @@ -157,12 +157,12 @@ class Battle break if advance || !moreQuash end end - return if @decision>0 + return if @decision > 0 next if advance # Check for all done priority.each do |b| if !b.fainted? && !b.movedThisRound? - advance = true if @choices[b.index][0]==:UseMove || @choices[b.index][0]==:Shift + advance = true if @choices[b.index][0] == :UseMove || @choices[b.index][0] == :Shift end break if advance end @@ -178,15 +178,15 @@ class Battle def pbAttackPhase @scene.pbBeginAttackPhase # Reset certain effects - @battlers.each_with_index do |b,i| + @battlers.each_with_index do |b, i| next if !b b.turnCount += 1 if !b.fainted? @successStates[i].clear - if @choices[i][0]!=:UseMove && @choices[i][0]!=:Shift && @choices[i][0]!=:SwitchOut + if @choices[i][0] != :UseMove && @choices[i][0] != :Shift && @choices[i][0] != :SwitchOut b.effects[PBEffects::DestinyBond] = false b.effects[PBEffects::Grudge] = false end - b.effects[PBEffects::Rage] = false if !pbChoseMoveFunctionCode?(i,"StartRaiseUserAtk1WhenDamaged") + b.effects[PBEffects::Rage] = false if !pbChoseMoveFunctionCode?(i, "StartRaiseUserAtk1WhenDamaged") end PBDebug.log("") # Calculate move order for this round @@ -195,9 +195,9 @@ class Battle pbAttackPhasePriorityChangeMessages pbAttackPhaseCall pbAttackPhaseSwitch - return if @decision>0 + return if @decision > 0 pbAttackPhaseItems - return if @decision>0 + return if @decision > 0 pbAttackPhaseMegaEvolution pbAttackPhaseMoves end diff --git a/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb b/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb index 6d6a170c4..f4134bfce 100644 --- a/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb +++ b/Data/Scripts/011_Battle/001_Battle/011_Battle_EndOfRoundPhase.rb @@ -2,27 +2,27 @@ class Battle #============================================================================= # Decrement effect counters #============================================================================= - def pbEORCountDownBattlerEffect(priority,effect) + def pbEORCountDownBattlerEffect(priority, effect) priority.each do |b| - next if b.fainted? || b.effects[effect]==0 + next if b.fainted? || b.effects[effect] == 0 b.effects[effect] -= 1 - yield b if block_given? && b.effects[effect]==0 + yield b if block_given? && b.effects[effect] == 0 end end - def pbEORCountDownSideEffect(side,effect,msg) - if @sides[side].effects[effect]>0 + def pbEORCountDownSideEffect(side, effect, msg) + if @sides[side].effects[effect] > 0 @sides[side].effects[effect] -= 1 - pbDisplay(msg) if @sides[side].effects[effect]==0 + pbDisplay(msg) if @sides[side].effects[effect] == 0 end end - def pbEORCountDownFieldEffect(effect,msg) - if @field.effects[effect]>0 + def pbEORCountDownFieldEffect(effect, msg) + if @field.effects[effect] > 0 @field.effects[effect] -= 1 - if @field.effects[effect]==0 + if @field.effects[effect] == 0 pbDisplay(msg) - if effect==PBEffects::MagicRoom + if effect == PBEffects::MagicRoom pbPriority(true).each { |b| b.pbItemTerrainStatBoostCheck } end end @@ -36,9 +36,9 @@ class Battle # NOTE: Primordial weather doesn't need to be checked here, because if it # could wear off here, it will have worn off already. # Count down weather duration - @field.weatherDuration -= 1 if @field.weatherDuration>0 + @field.weatherDuration -= 1 if @field.weatherDuration > 0 # Weather wears off - if @field.weatherDuration==0 + if @field.weatherDuration == 0 case @field.weather when :Sun then pbDisplay(_INTL("The sunlight faded.")) when :Rain then pbDisplay(_INTL("The rain stopped.")) @@ -50,7 +50,7 @@ class Battle # Check for form changes caused by the weather changing allBattlers.each { |b| b.pbCheckFormOnWeatherChange } # Start up the default weather - pbStartWeather(nil,@field.defaultWeather) if @field.defaultWeather != :None + pbStartWeather(nil, @field.defaultWeather) if @field.defaultWeather != :None return if @field.weather == :None end # Weather continues @@ -77,23 +77,23 @@ class Battle case b.effectiveWeather when :Sandstorm next if !b.takesSandstormDamage? - pbDisplay(_INTL("{1} is buffeted by the sandstorm!",b.pbThis)) + pbDisplay(_INTL("{1} is buffeted by the sandstorm!", b.pbThis)) @scene.pbDamageAnimation(b) - b.pbReduceHP(b.totalhp/16,false) + b.pbReduceHP(b.totalhp / 16, false) b.pbItemHPHealCheck b.pbFaint if b.fainted? when :Hail next if !b.takesHailDamage? - pbDisplay(_INTL("{1} is buffeted by the hail!",b.pbThis)) + pbDisplay(_INTL("{1} is buffeted by the hail!", b.pbThis)) @scene.pbDamageAnimation(b) - b.pbReduceHP(b.totalhp/16,false) + b.pbReduceHP(b.totalhp / 16, false) b.pbItemHPHealCheck b.pbFaint if b.fainted? when :ShadowSky next if !b.takesShadowSkyDamage? - pbDisplay(_INTL("{1} is hurt by the shadow sky!",b.pbThis)) + pbDisplay(_INTL("{1} is hurt by the shadow sky!", b.pbThis)) @scene.pbDamageAnimation(b) - b.pbReduceHP(b.totalhp/16,false) + b.pbReduceHP(b.totalhp / 16, false) b.pbItemHPHealCheck b.pbFaint if b.fainted? end @@ -105,7 +105,7 @@ class Battle #============================================================================= def pbEORTerrain # Count down terrain duration - @field.terrainDuration -= 1 if @field.terrainDuration>0 + @field.terrainDuration -= 1 if @field.terrainDuration > 0 # Terrain wears off if @field.terrain != :None && @field.terrainDuration == 0 case @field.terrain @@ -149,7 +149,7 @@ class Battle if !singleBattle? swaps = [] # Each element is an array of two battler indices to swap for side in 0...2 - next if pbSideSize(side)==1 # Only battlers on sides of size 2+ need to move + next if pbSideSize(side) == 1 # Only battlers on sides of size 2+ need to move # Check if any battler on this side is near any battler on the other side anyNear = false allSameSideBattlers(side).each do |b| @@ -170,25 +170,25 @@ class Battle # Get the position to move to pos = -1 case pbSideSize(side) - when 2 then pos = [2,3,0,1][b.index] # The unoccupied position - when 3 then pos = (side==0) ? 2 : 3 # The centre position + when 2 then pos = [2, 3, 0, 1][b.index] # The unoccupied position + when 3 then pos = (side == 0) ? 2 : 3 # The centre position end - next if pos<0 + next if pos < 0 # Can't move if the same trainer doesn't control both positions idxOwner = pbGetOwnerIndexFromBattlerIndex(b.index) - next if pbGetOwnerIndexFromBattlerIndex(pos)!=idxOwner - swaps.push([b.index,pos]) + next if pbGetOwnerIndexFromBattlerIndex(pos) != idxOwner + swaps.push([b.index, pos]) end end # Move battlers around swaps.each do |pair| - next if pbSideSize(pair[0])==2 && swaps.length>1 - next if !pbSwapBattlers(pair[0],pair[1]) + next if pbSideSize(pair[0]) == 2 && swaps.length > 1 + next if !pbSwapBattlers(pair[0], pair[1]) case pbSideSize(side) when 2 - pbDisplay(_INTL("{1} moved across!",@battlers[pair[1]].pbThis)) + pbDisplay(_INTL("{1} moved across!", @battlers[pair[1]].pbThis)) when 3 - pbDisplay(_INTL("{1} moved to the center!",@battlers[pair[1]].pbThis)) + pbDisplay(_INTL("{1} moved to the center!", @battlers[pair[1]].pbThis)) end end end @@ -207,36 +207,36 @@ class Battle # Weather pbEORWeather(priority) # Future Sight/Doom Desire - @positions.each_with_index do |pos,idxPos| - next if !pos || pos.effects[PBEffects::FutureSightCounter]==0 + @positions.each_with_index do |pos, idxPos| + next if !pos || pos.effects[PBEffects::FutureSightCounter] == 0 pos.effects[PBEffects::FutureSightCounter] -= 1 - next if pos.effects[PBEffects::FutureSightCounter]>0 + next if pos.effects[PBEffects::FutureSightCounter] > 0 next if !@battlers[idxPos] || @battlers[idxPos].fainted? # No target moveUser = nil allBattlers.each do |b| next if b.opposes?(pos.effects[PBEffects::FutureSightUserIndex]) - next if b.pokemonIndex!=pos.effects[PBEffects::FutureSightUserPartyIndex] + next if b.pokemonIndex != pos.effects[PBEffects::FutureSightUserPartyIndex] moveUser = b break end - next if moveUser && moveUser.index==idxPos # Target is the user + next if moveUser && moveUser.index == idxPos # Target is the user if !moveUser # User isn't in battle, get it from the party party = pbParty(pos.effects[PBEffects::FutureSightUserIndex]) pkmn = party[pos.effects[PBEffects::FutureSightUserPartyIndex]] if pkmn && pkmn.able? - moveUser = Battler.new(self,pos.effects[PBEffects::FutureSightUserIndex]) - moveUser.pbInitDummyPokemon(pkmn,pos.effects[PBEffects::FutureSightUserPartyIndex]) + moveUser = Battler.new(self, pos.effects[PBEffects::FutureSightUserIndex]) + moveUser.pbInitDummyPokemon(pkmn, pos.effects[PBEffects::FutureSightUserPartyIndex]) end end next if !moveUser # User is fainted move = pos.effects[PBEffects::FutureSightMove] - pbDisplay(_INTL("{1} took the {2} attack!",@battlers[idxPos].pbThis, + pbDisplay(_INTL("{1} took the {2} attack!", @battlers[idxPos].pbThis, GameData::Move.get(move).name)) # NOTE: Future Sight failing against the target here doesn't count towards # Stomping Tantrum. userLastMoveFailed = moveUser.lastMoveFailed @futureSight = true - moveUser.pbUseMoveSimple(move,idxPos) + moveUser.pbUseMoveSimple(move, idxPos) @futureSight = false moveUser.lastMoveFailed = userLastMoveFailed @battlers[idxPos].pbFaint if @battlers[idxPos].fainted? @@ -246,20 +246,20 @@ class Battle pos.effects[PBEffects::FutureSightUserPartyIndex] = -1 end # Wish - @positions.each_with_index do |pos,idxPos| - next if !pos || pos.effects[PBEffects::Wish]==0 + @positions.each_with_index do |pos, idxPos| + next if !pos || pos.effects[PBEffects::Wish] == 0 pos.effects[PBEffects::Wish] -= 1 - next if pos.effects[PBEffects::Wish]>0 + next if pos.effects[PBEffects::Wish] > 0 next if !@battlers[idxPos] || !@battlers[idxPos].canHeal? - wishMaker = pbThisEx(idxPos,pos.effects[PBEffects::WishMaker]) + wishMaker = pbThisEx(idxPos, pos.effects[PBEffects::WishMaker]) @battlers[idxPos].pbRecoverHP(pos.effects[PBEffects::WishAmount]) - pbDisplay(_INTL("{1}'s wish came true!",wishMaker)) + pbDisplay(_INTL("{1}'s wish came true!", wishMaker)) end # Sea of Fire damage (Fire Pledge + Grass Pledge combination) for side in 0...2 - next if sides[side].effects[PBEffects::SeaOfFire]==0 - @battle.pbCommonAnimation("SeaOfFire") if side==0 - @battle.pbCommonAnimation("SeaOfFireOpp") if side==1 + next if sides[side].effects[PBEffects::SeaOfFire] == 0 + @battle.pbCommonAnimation("SeaOfFire") if side == 0 + @battle.pbCommonAnimation("SeaOfFireOpp") if side == 1 priority.each do |b| next if b.opposes?(side) next if !b.takesIndirectDamage? || b.pbHasType?(:FIRE) @@ -275,8 +275,8 @@ class Battle # Grassy Terrain (healing) if @field.terrain == :Grassy && b.affectedByTerrain? && b.canHeal? PBDebug.log("[Lingering effect] Grassy Terrain heals #{b.pbThis(true)}") - b.pbRecoverHP(b.totalhp/16) - pbDisplay(_INTL("{1}'s HP was restored.",b.pbThis)) + b.pbRecoverHP(b.totalhp / 16) + pbDisplay(_INTL("{1}'s HP was restored.", b.pbThis)) end # Healer, Hydration, Shed Skin Battle::AbilityEffects.triggerEndOfRoundHealing(b.ability, b, self) if b.abilityActive? @@ -309,27 +309,27 @@ class Battle priority.each do |b| next if !b.effects[PBEffects::AquaRing] next if !b.canHeal? - hpGain = b.totalhp/16 - hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT) + hpGain = b.totalhp / 16 + hpGain = (hpGain * 1.3).floor if b.hasActiveItem?(:BIGROOT) b.pbRecoverHP(hpGain) - pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",b.pbThis(true))) + pbDisplay(_INTL("Aqua Ring restored {1}'s HP!", b.pbThis(true))) end # Ingrain priority.each do |b| next if !b.effects[PBEffects::Ingrain] next if !b.canHeal? - hpGain = b.totalhp/16 - hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT) + hpGain = b.totalhp / 16 + hpGain = (hpGain * 1.3).floor if b.hasActiveItem?(:BIGROOT) b.pbRecoverHP(hpGain) - pbDisplay(_INTL("{1} absorbed nutrients with its roots!",b.pbThis)) + pbDisplay(_INTL("{1} absorbed nutrients with its roots!", b.pbThis)) end # Leech Seed priority.each do |b| - next if b.effects[PBEffects::LeechSeed]<0 + next if b.effects[PBEffects::LeechSeed] < 0 next if !b.takesIndirectDamage? recipient = @battlers[b.effects[PBEffects::LeechSeed]] next if !recipient || recipient.fainted? - pbCommonAnimation("LeechSeed",recipient,b) + pbCommonAnimation("LeechSeed", recipient, b) b.pbTakeEffectDamage(b.totalhp / 8) { |hp_lost| recipient.pbRecoverHPFromDrain(hp_lost, b, _INTL("{1}'s health is sapped by Leech Seed!", b.pbThis)) @@ -339,38 +339,38 @@ class Battle end # Damage from Hyper Mode (Shadow Pokémon) priority.each do |b| - next if !b.inHyperMode? || @choices[b.index][0]!=:UseMove - hpLoss = b.totalhp/24 + next if !b.inHyperMode? || @choices[b.index][0] != :UseMove + hpLoss = b.totalhp / 24 @scene.pbDamageAnimation(b) - b.pbReduceHP(hpLoss,false) - pbDisplay(_INTL("The Hyper Mode attack hurts {1}!",b.pbThis(true))) + b.pbReduceHP(hpLoss, false) + pbDisplay(_INTL("The Hyper Mode attack hurts {1}!", b.pbThis(true))) b.pbFaint if b.fainted? end # Damage from poisoning priority.each do |b| next if b.fainted? next if b.status != :POISON - if b.statusCount>0 + if b.statusCount > 0 b.effects[PBEffects::Toxic] += 1 - b.effects[PBEffects::Toxic] = 16 if b.effects[PBEffects::Toxic]>16 + b.effects[PBEffects::Toxic] = 16 if b.effects[PBEffects::Toxic] > 16 end if b.hasActiveAbility?(:POISONHEAL) if b.canHeal? anim_name = GameData::Status.get(:POISON).animation pbCommonAnimation(anim_name, b) if anim_name pbShowAbilitySplash(b) - b.pbRecoverHP(b.totalhp/8) + b.pbRecoverHP(b.totalhp / 8) if Scene::USE_ABILITY_SPLASH - pbDisplay(_INTL("{1}'s HP was restored.",b.pbThis)) + pbDisplay(_INTL("{1}'s HP was restored.", b.pbThis)) else - pbDisplay(_INTL("{1}'s {2} restored its HP.",b.pbThis,b.abilityName)) + pbDisplay(_INTL("{1}'s {2} restored its HP.", b.pbThis, b.abilityName)) end pbHideAbilitySplash(b) end elsif b.takesIndirectDamage? b.droppedBelowHalfHP = false - dmg = (b.statusCount==0) ? b.totalhp/8 : b.totalhp*b.effects[PBEffects::Toxic]/16 - b.pbContinueStatus { b.pbReduceHP(dmg,false) } + dmg = (b.statusCount == 0) ? b.totalhp / 8 : b.totalhp * b.effects[PBEffects::Toxic] / 16 + b.pbContinueStatus { b.pbReduceHP(dmg, false) } b.pbItemHPHealCheck b.pbAbilitiesOnDamageTaken b.pbFaint if b.fainted? @@ -381,9 +381,9 @@ class Battle priority.each do |b| next if b.status != :BURN || !b.takesIndirectDamage? b.droppedBelowHalfHP = false - dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp/16 : b.totalhp/8 - dmg = (dmg/2.0).round if b.hasActiveAbility?(:HEATPROOF) - b.pbContinueStatus { b.pbReduceHP(dmg,false) } + dmg = (Settings::MECHANICS_GENERATION >= 7) ? b.totalhp / 16 : b.totalhp / 8 + dmg = (dmg / 2.0).round if b.hasActiveAbility?(:HEATPROOF) + b.pbContinueStatus { b.pbReduceHP(dmg, false) } b.pbItemHPHealCheck b.pbAbilitiesOnDamageTaken b.pbFaint if b.fainted? @@ -406,11 +406,11 @@ class Battle end # Trapping attacks (Bind/Clamp/Fire Spin/Magma Storm/Sand Tomb/Whirlpool/Wrap) priority.each do |b| - next if b.fainted? || b.effects[PBEffects::Trapping]==0 + next if b.fainted? || b.effects[PBEffects::Trapping] == 0 b.effects[PBEffects::Trapping] -= 1 moveName = GameData::Move.get(b.effects[PBEffects::TrappingMove]).name - if b.effects[PBEffects::Trapping]==0 - pbDisplay(_INTL("{1} was freed from {2}!",b.pbThis,moveName)) + if b.effects[PBEffects::Trapping] == 0 + pbDisplay(_INTL("{1} was freed from {2}!", b.pbThis, moveName)) else case b.effects[PBEffects::TrappingMove] when :BIND then pbCommonAnimation("Bind", b) @@ -423,9 +423,9 @@ class Battle else pbCommonAnimation("Wrap", b) end if b.takesIndirectDamage? - hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp/8 : b.totalhp/16 + hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp / 8 : b.totalhp / 16 if @battlers[b.effects[PBEffects::TrappingUser]].hasActiveItem?(:BINDINGBAND) - hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp/6 : b.totalhp/8 + hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? b.totalhp / 6 : b.totalhp / 8 end @scene.pbDamageAnimation(b) b.pbTakeEffectDamage(hpLoss, false) { |hp_lost| @@ -443,18 +443,18 @@ class Battle b.pbItemOnStatDropped end # Taunt - pbEORCountDownBattlerEffect(priority,PBEffects::Taunt) { |battler| - pbDisplay(_INTL("{1}'s taunt wore off!",battler.pbThis)) + pbEORCountDownBattlerEffect(priority, PBEffects::Taunt) { |battler| + pbDisplay(_INTL("{1}'s taunt wore off!", battler.pbThis)) } # Encore priority.each do |b| - next if b.fainted? || b.effects[PBEffects::Encore]==0 + next if b.fainted? || b.effects[PBEffects::Encore] == 0 idxEncoreMove = b.pbEncoredMoveIndex - if idxEncoreMove>=0 + if idxEncoreMove >= 0 b.effects[PBEffects::Encore] -= 1 - if b.effects[PBEffects::Encore]==0 || b.moves[idxEncoreMove].pp==0 + if b.effects[PBEffects::Encore] == 0 || b.moves[idxEncoreMove].pp == 0 b.effects[PBEffects::Encore] = 0 - pbDisplay(_INTL("{1}'s encore ended!",b.pbThis)) + pbDisplay(_INTL("{1}'s encore ended!", b.pbThis)) end else PBDebug.log("[End of effect] #{b.pbThis}'s encore ended (encored move no longer known)") @@ -463,29 +463,29 @@ class Battle end end # Disable/Cursed Body - pbEORCountDownBattlerEffect(priority,PBEffects::Disable) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::Disable) { |battler| battler.effects[PBEffects::DisableMove] = nil - pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis)) + pbDisplay(_INTL("{1} is no longer disabled!", battler.pbThis)) } # Magnet Rise - pbEORCountDownBattlerEffect(priority,PBEffects::MagnetRise) { |battler| - pbDisplay(_INTL("{1}'s electromagnetism wore off!",battler.pbThis)) + pbEORCountDownBattlerEffect(priority, PBEffects::MagnetRise) { |battler| + pbDisplay(_INTL("{1}'s electromagnetism wore off!", battler.pbThis)) } # Telekinesis - pbEORCountDownBattlerEffect(priority,PBEffects::Telekinesis) { |battler| - pbDisplay(_INTL("{1} was freed from the telekinesis!",battler.pbThis)) + pbEORCountDownBattlerEffect(priority, PBEffects::Telekinesis) { |battler| + pbDisplay(_INTL("{1} was freed from the telekinesis!", battler.pbThis)) } # Heal Block - pbEORCountDownBattlerEffect(priority,PBEffects::HealBlock) { |battler| - pbDisplay(_INTL("{1}'s Heal Block wore off!",battler.pbThis)) + pbEORCountDownBattlerEffect(priority, PBEffects::HealBlock) { |battler| + pbDisplay(_INTL("{1}'s Heal Block wore off!", battler.pbThis)) } # Embargo - pbEORCountDownBattlerEffect(priority,PBEffects::Embargo) { |battler| - pbDisplay(_INTL("{1} can use items again!",battler.pbThis)) + pbEORCountDownBattlerEffect(priority, PBEffects::Embargo) { |battler| + pbDisplay(_INTL("{1} can use items again!", battler.pbThis)) battler.pbItemTerrainStatBoostCheck } # Yawn - pbEORCountDownBattlerEffect(priority,PBEffects::Yawn) { |battler| + pbEORCountDownBattlerEffect(priority, PBEffects::Yawn) { |battler| if battler.pbCanSleepYawn? PBDebug.log("[Lingering effect] #{battler.pbThis} fell asleep because of Yawn") battler.pbSleep @@ -494,59 +494,59 @@ class Battle # Perish Song perishSongUsers = [] priority.each do |b| - next if b.fainted? || b.effects[PBEffects::PerishSong]==0 + next if b.fainted? || b.effects[PBEffects::PerishSong] == 0 b.effects[PBEffects::PerishSong] -= 1 - pbDisplay(_INTL("{1}'s perish count fell to {2}!",b.pbThis,b.effects[PBEffects::PerishSong])) - if b.effects[PBEffects::PerishSong]==0 + pbDisplay(_INTL("{1}'s perish count fell to {2}!", b.pbThis, b.effects[PBEffects::PerishSong])) + if b.effects[PBEffects::PerishSong] == 0 perishSongUsers.push(b.effects[PBEffects::PerishSongUser]) b.pbReduceHP(b.hp) end b.pbItemHPHealCheck b.pbFaint if b.fainted? end - if perishSongUsers.length>0 + if perishSongUsers.length > 0 # If all remaining Pokemon fainted by a Perish Song triggered by a single side - if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length==perishSongUsers.length) || - (perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length==perishSongUsers.length) + if (perishSongUsers.find_all { |idxBattler| opposes?(idxBattler) }.length == perishSongUsers.length) || + (perishSongUsers.find_all { |idxBattler| !opposes?(idxBattler) }.length == perishSongUsers.length) pbJudgeCheckpoint(@battlers[perishSongUsers[0]]) end end # Check for end of battle - if @decision>0 + if @decision > 0 pbGainExp return end for side in 0...2 # Reflect - pbEORCountDownSideEffect(side,PBEffects::Reflect, - _INTL("{1}'s Reflect wore off!",@battlers[side].pbTeam)) + pbEORCountDownSideEffect(side, PBEffects::Reflect, + _INTL("{1}'s Reflect wore off!", @battlers[side].pbTeam)) # Light Screen - pbEORCountDownSideEffect(side,PBEffects::LightScreen, - _INTL("{1}'s Light Screen wore off!",@battlers[side].pbTeam)) + pbEORCountDownSideEffect(side, PBEffects::LightScreen, + _INTL("{1}'s Light Screen wore off!", @battlers[side].pbTeam)) # Safeguard - pbEORCountDownSideEffect(side,PBEffects::Safeguard, - _INTL("{1} is no longer protected by Safeguard!",@battlers[side].pbTeam)) + pbEORCountDownSideEffect(side, PBEffects::Safeguard, + _INTL("{1} is no longer protected by Safeguard!", @battlers[side].pbTeam)) # Mist - pbEORCountDownSideEffect(side,PBEffects::Mist, - _INTL("{1} is no longer protected by mist!",@battlers[side].pbTeam)) + pbEORCountDownSideEffect(side, PBEffects::Mist, + _INTL("{1} is no longer protected by mist!", @battlers[side].pbTeam)) # Tailwind - pbEORCountDownSideEffect(side,PBEffects::Tailwind, - _INTL("{1}'s Tailwind petered out!",@battlers[side].pbTeam)) + pbEORCountDownSideEffect(side, PBEffects::Tailwind, + _INTL("{1}'s Tailwind petered out!", @battlers[side].pbTeam)) # Lucky Chant - pbEORCountDownSideEffect(side,PBEffects::LuckyChant, - _INTL("{1}'s Lucky Chant wore off!",@battlers[side].pbTeam)) + pbEORCountDownSideEffect(side, PBEffects::LuckyChant, + _INTL("{1}'s Lucky Chant wore off!", @battlers[side].pbTeam)) # Pledge Rainbow - pbEORCountDownSideEffect(side,PBEffects::Rainbow, - _INTL("The rainbow on {1}'s side disappeared!",@battlers[side].pbTeam(true))) + pbEORCountDownSideEffect(side, PBEffects::Rainbow, + _INTL("The rainbow on {1}'s side disappeared!", @battlers[side].pbTeam(true))) # Pledge Sea of Fire - pbEORCountDownSideEffect(side,PBEffects::SeaOfFire, - _INTL("The sea of fire around {1} disappeared!",@battlers[side].pbTeam(true))) + pbEORCountDownSideEffect(side, PBEffects::SeaOfFire, + _INTL("The sea of fire around {1} disappeared!", @battlers[side].pbTeam(true))) # Pledge Swamp - pbEORCountDownSideEffect(side,PBEffects::Swamp, - _INTL("The swamp around {1} disappeared!",@battlers[side].pbTeam(true))) + pbEORCountDownSideEffect(side, PBEffects::Swamp, + _INTL("The swamp around {1} disappeared!", @battlers[side].pbTeam(true))) # Aurora Veil - pbEORCountDownSideEffect(side,PBEffects::AuroraVeil, - _INTL("{1}'s Aurora Veil wore off!",@battlers[side].pbTeam(true))) + pbEORCountDownSideEffect(side, PBEffects::AuroraVeil, + _INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam(true))) end # Trick Room pbEORCountDownFieldEffect(PBEffects::TrickRoom, @@ -572,27 +572,27 @@ class Battle next if b.fainted? # Hyper Mode (Shadow Pokémon) if b.inHyperMode? - if pbRandom(100)<10 + if pbRandom(100) < 10 b.pokemon.hyper_mode = false - pbDisplay(_INTL("{1} came to its senses!",b.pbThis)) + pbDisplay(_INTL("{1} came to its senses!", b.pbThis)) else - pbDisplay(_INTL("{1} is in Hyper Mode!",b.pbThis)) + pbDisplay(_INTL("{1} is in Hyper Mode!", b.pbThis)) end end # Uproar - if b.effects[PBEffects::Uproar]>0 + if b.effects[PBEffects::Uproar] > 0 b.effects[PBEffects::Uproar] -= 1 - if b.effects[PBEffects::Uproar]==0 - pbDisplay(_INTL("{1} calmed down.",b.pbThis)) + if b.effects[PBEffects::Uproar] == 0 + pbDisplay(_INTL("{1} calmed down.", b.pbThis)) else - pbDisplay(_INTL("{1} is making an uproar!",b.pbThis)) + pbDisplay(_INTL("{1} is making an uproar!", b.pbThis)) end end # Slow Start's end message - if b.effects[PBEffects::SlowStart]>0 + if b.effects[PBEffects::SlowStart] > 0 b.effects[PBEffects::SlowStart] -= 1 - if b.effects[PBEffects::SlowStart]==0 - pbDisplay(_INTL("{1} finally got its act together!",b.pbThis)) + if b.effects[PBEffects::SlowStart] == 0 + pbDisplay(_INTL("{1} finally got its act together!", b.pbThis)) end end # Bad Dreams, Moody, Speed Boost @@ -603,12 +603,12 @@ class Battle Battle::AbilityEffects.triggerEndOfRoundGainItem(b.ability, b, self) if b.abilityActive? end pbGainExp - return if @decision>0 + return if @decision > 0 # Form checks priority.each { |b| b.pbCheckForm(true) } # Switch Pokémon in if possible pbEORSwitch - return if @decision>0 + return if @decision > 0 # In battles with at least one side of size 3+, move battlers around if none # are near to any foes pbEORShiftDistantBattlers @@ -617,7 +617,7 @@ class Battle # Reset/count down battler-specific effects (no messages) allBattlers.each do |b| b.effects[PBEffects::BanefulBunker] = false - b.effects[PBEffects::Charge] -= 1 if b.effects[PBEffects::Charge]>0 + b.effects[PBEffects::Charge] -= 1 if b.effects[PBEffects::Charge] > 0 b.effects[PBEffects::Counter] = -1 b.effects[PBEffects::CounterTarget] = -1 b.effects[PBEffects::Electrify] = false @@ -627,12 +627,12 @@ class Battle b.effects[PBEffects::FocusPunch] = false b.effects[PBEffects::FollowMe] = 0 b.effects[PBEffects::HelpingHand] = false - b.effects[PBEffects::HyperBeam] -= 1 if b.effects[PBEffects::HyperBeam]>0 + b.effects[PBEffects::HyperBeam] -= 1 if b.effects[PBEffects::HyperBeam] > 0 b.effects[PBEffects::KingsShield] = false - b.effects[PBEffects::LaserFocus] -= 1 if b.effects[PBEffects::LaserFocus]>0 - if b.effects[PBEffects::LockOn]>0 # Also Mind Reader + b.effects[PBEffects::LaserFocus] -= 1 if b.effects[PBEffects::LaserFocus] > 0 + if b.effects[PBEffects::LockOn] > 0 # Also Mind Reader b.effects[PBEffects::LockOn] -= 1 - b.effects[PBEffects::LockOnPos] = -1 if b.effects[PBEffects::LockOn]==0 + b.effects[PBEffects::LockOnPos] = -1 if b.effects[PBEffects::LockOn] == 0 end b.effects[PBEffects::MagicBounce] = false b.effects[PBEffects::MagicCoat] = false @@ -649,7 +649,7 @@ class Battle b.effects[PBEffects::Snatch] = 0 b.effects[PBEffects::SpikyShield] = false b.effects[PBEffects::Spotlight] = 0 - b.effects[PBEffects::ThroatChop] -= 1 if b.effects[PBEffects::ThroatChop]>0 + b.effects[PBEffects::ThroatChop] -= 1 if b.effects[PBEffects::ThroatChop] > 0 b.lastHPLost = 0 b.lastHPLostFromFoe = 0 b.droppedBelowHalfHP = false @@ -677,7 +677,7 @@ class Battle end # Reset/count down field-specific effects (no messages) @field.effects[PBEffects::IonDeluge] = false - @field.effects[PBEffects::FairyLock] -= 1 if @field.effects[PBEffects::FairyLock]>0 + @field.effects[PBEffects::FairyLock] -= 1 if @field.effects[PBEffects::FairyLock] > 0 @field.effects[PBEffects::FusionBolt] = false @field.effects[PBEffects::FusionFlare] = false @endOfRound = false diff --git a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb index ead2596c7..4608e0252 100644 --- a/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb +++ b/Data/Scripts/011_Battle/002_Battler/001_Battle_Battler.rb @@ -82,14 +82,14 @@ class Battle::Battler end def defense - return @spdef if @battle.field.effects[PBEffects::WonderRoom]>0 + return @spdef if @battle.field.effects[PBEffects::WonderRoom] > 0 return @defense end attr_writer :defense def spdef - return @defense if @battle.field.effects[PBEffects::WonderRoom]>0 + return @defense if @battle.field.effects[PBEffects::WonderRoom] > 0 return @spdef end @@ -102,7 +102,7 @@ class Battle::Battler @pokemon.hp = value.to_i if @pokemon end - def fainted?; return @hp<=0; end + def fainted?; return @hp <= 0; end attr_reader :status @@ -211,12 +211,12 @@ class Battle::Battler def pbThis(lowerCase = false) if opposes? if @battle.trainerBattle? - return lowerCase ? _INTL("the opposing {1}",name) : _INTL("The opposing {1}",name) + return lowerCase ? _INTL("the opposing {1}", name) : _INTL("The opposing {1}", name) else - return lowerCase ? _INTL("the wild {1}",name) : _INTL("The wild {1}",name) + return lowerCase ? _INTL("the wild {1}", name) : _INTL("The wild {1}", name) end elsif !pbOwnedByPlayer? - return lowerCase ? _INTL("the ally {1}",name) : _INTL("The ally {1}",name) + return lowerCase ? _INTL("the ally {1}", name) : _INTL("The ally {1}", name) end return name end @@ -240,10 +240,10 @@ class Battle::Battler #============================================================================= def pbSpeed return 1 if fainted? - stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8] - stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2] + stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8] + stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2] stage = @stages[:SPEED] + 6 - speed = @speed*stageMul[stage]/stageDiv[stage] + speed = @speed * stageMul[stage] / stageDiv[stage] speedMult = 1.0 # Ability effects that alter calculated Speed if abilityActive? @@ -254,8 +254,8 @@ class Battle::Battler speedMult = Battle::ItemEffects.triggerSpeedCalc(self.item, self, speedMult) end # Other effects - speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind]>0 - speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp]>0 + speedMult *= 2 if pbOwnSide.effects[PBEffects::Tailwind] > 0 + speedMult /= 2 if pbOwnSide.effects[PBEffects::Swamp] > 0 # Paralysis if status == :PARALYSIS && !hasActiveAbility?(:QUICKFEET) speedMult /= (Settings::MECHANICS_GENERATION >= 7) ? 2 : 4 @@ -266,20 +266,20 @@ class Battle::Battler speedMult *= 1.1 end # Calculation - return [(speed*speedMult).round,1].max + return [(speed * speedMult).round, 1].max end def pbWeight ret = (@pokemon) ? @pokemon.weight : 500 ret += @effects[PBEffects::WeightChange] - ret = 1 if ret<1 + ret = 1 if ret < 1 if abilityActive? && !@battle.moldBreaker ret = Battle::AbilityEffects.triggerWeightCalc(self.ability, self, ret) end if itemActive? ret = Battle::ItemEffects.triggerWeightCalc(self.item, self, ret) end - return [ret,1].max + return [ret, 1].max end #============================================================================= @@ -415,10 +415,10 @@ class Battle::Battler def itemActive?(ignoreFainted = false) return false if fainted? && !ignoreFainted - return false if @effects[PBEffects::Embargo]>0 - return false if @battle.field.effects[PBEffects::MagicRoom]>0 + return false if @effects[PBEffects::Embargo] > 0 + return false if @battle.field.effects[PBEffects::MagicRoom] > 0 return false if @battle.corrosiveGas[@index % 2][@pokemonIndex] - return false if hasActiveAbility?(:KLUTZ,ignoreFainted) + return false if hasActiveAbility?(:KLUTZ, ignoreFainted) return true end @@ -515,9 +515,9 @@ class Battle::Battler if showMsg @battle.pbShowAbilitySplash(self) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) else - @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName)) + @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName)) end @battle.pbHideAbilitySplash(self) end @@ -531,7 +531,7 @@ class Battle::Battler return false if pbHasType?(:GROUND) || pbHasType?(:ROCK) || pbHasType?(:STEEL) return false if inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground", "TwoTurnAttackInvulnerableUnderwater") - return false if hasActiveAbility?([:OVERCOAT,:SANDFORCE,:SANDRUSH,:SANDVEIL]) + return false if hasActiveAbility?([:OVERCOAT, :SANDFORCE, :SANDRUSH, :SANDVEIL]) return false if hasActiveItem?(:SAFETYGOGGLES) return true end @@ -541,7 +541,7 @@ class Battle::Battler return false if pbHasType?(:ICE) return false if inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground", "TwoTurnAttackInvulnerableUnderwater") - return false if hasActiveAbility?([:OVERCOAT,:ICEBODY,:SNOWCLOAK]) + return false if hasActiveAbility?([:OVERCOAT, :ICEBODY, :SNOWCLOAK]) return false if hasActiveItem?(:SAFETYGOGGLES) return true end @@ -561,7 +561,7 @@ class Battle::Battler def affectedByPowder?(showMsg = false) return false if fainted? if pbHasType?(:GRASS) && Settings::MORE_TYPE_EFFECTS - @battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMsg + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMsg return false end if Settings::MECHANICS_GENERATION >= 6 @@ -569,9 +569,9 @@ class Battle::Battler if showMsg @battle.pbShowAbilitySplash(self) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) else - @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,abilityName)) + @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, abilityName)) end @battle.pbHideAbilitySplash(self) end @@ -579,7 +579,7 @@ class Battle::Battler end if hasActiveItem?(:SAFETYGOGGLES) if showMsg - @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!",pbThis,itemName)) + @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", pbThis, itemName)) end return false end @@ -588,15 +588,15 @@ class Battle::Battler end def canHeal? - return false if fainted? || @hp>=@totalhp - return false if @effects[PBEffects::HealBlock]>0 + return false if fainted? || @hp >= @totalhp + return false if @effects[PBEffects::HealBlock] > 0 return true end def affectedByContactEffect?(showMsg = false) return false if fainted? if hasActiveItem?(:PROTECTIVEPADS) - @battle.pbDisplay(_INTL("{1} protected itself with the {2}!",pbThis,itemName)) if showMsg + @battle.pbDisplay(_INTL("{1} protected itself with the {2}!", pbThis, itemName)) if showMsg return false end return true @@ -615,23 +615,23 @@ class Battle::Battler end def movedThisRound? - return @lastRoundMoved && @lastRoundMoved==@battle.turnCount + return @lastRoundMoved && @lastRoundMoved == @battle.turnCount end def usingMultiTurnAttack? return true if @effects[PBEffects::TwoTurnAttack] - return true if @effects[PBEffects::HyperBeam]>0 - return true if @effects[PBEffects::Rollout]>0 - return true if @effects[PBEffects::Outrage]>0 - return true if @effects[PBEffects::Uproar]>0 - return true if @effects[PBEffects::Bide]>0 + return true if @effects[PBEffects::HyperBeam] > 0 + return true if @effects[PBEffects::Rollout] > 0 + return true if @effects[PBEffects::Outrage] > 0 + return true if @effects[PBEffects::Uproar] > 0 + return true if @effects[PBEffects::Bide] > 0 return false end def inTwoTurnAttack?(*arg) return false if !@effects[PBEffects::TwoTurnAttack] ttaFunction = GameData::Move.get(@effects[PBEffects::TwoTurnAttack]).function_code - arg.each { |a| return true if a==ttaFunction } + arg.each { |a| return true if a == ttaFunction } return false end @@ -645,10 +645,10 @@ class Battle::Battler end def pbEncoredMoveIndex - return -1 if @effects[PBEffects::Encore]==0 || !@effects[PBEffects::EncoreMove] + return -1 if @effects[PBEffects::Encore] == 0 || !@effects[PBEffects::EncoreMove] ret = -1 - eachMoveWithIndex do |m,i| - next if m.id!=@effects[PBEffects::EncoreMove] + eachMoveWithIndex do |m, i| + next if m.id != @effects[PBEffects::EncoreMove] ret = i break end @@ -656,31 +656,31 @@ class Battle::Battler end def initialItem - return @battle.initialItems[@index&1][@pokemonIndex] + return @battle.initialItems[@index & 1][@pokemonIndex] end def setInitialItem(value) item_data = GameData::Item.try_get(value) new_item = (item_data) ? item_data.id : nil - @battle.initialItems[@index&1][@pokemonIndex] = new_item + @battle.initialItems[@index & 1][@pokemonIndex] = new_item end def recycleItem - return @battle.recycleItems[@index&1][@pokemonIndex] + return @battle.recycleItems[@index & 1][@pokemonIndex] end def setRecycleItem(value) item_data = GameData::Item.try_get(value) new_item = (item_data) ? item_data.id : nil - @battle.recycleItems[@index&1][@pokemonIndex] = new_item + @battle.recycleItems[@index & 1][@pokemonIndex] = new_item end def belched? - return @battle.belch[@index&1][@pokemonIndex] + return @battle.belch[@index & 1][@pokemonIndex] end def setBelched - @battle.belch[@index&1][@pokemonIndex] = true + @battle.belch[@index & 1][@pokemonIndex] = true end #============================================================================= @@ -689,13 +689,13 @@ class Battle::Battler # Returns whether the given position belongs to the opposing Pokémon's side. def opposes?(i = 0) i = i.index if i.respond_to?("index") - return (@index&1)!=(i&1) + return (@index & 1) != (i & 1) end # Returns whether the given position/battler is near to self. def near?(i) i = i.index if i.respond_to?("index") - return @battle.nearBattlers?(@index,i) + return @battle.nearBattlers?(@index, i) end # Returns whether self is owned by the player. @@ -710,13 +710,13 @@ class Battle::Battler # Returns 0 if self is on the player's side, or 1 if self is on the opposing # side. def idxOwnSide - return @index&1 + return @index & 1 end # Returns 1 if self is on the player's side, or 0 if self is on the opposing # side. def idxOpposingSide - return (@index&1)^1 + return (@index & 1) ^ 1 end # Returns the data structure for this battler's side. @@ -733,7 +733,7 @@ class Battle::Battler # Unused def eachAlly @battle.battlers.each do |b| - yield b if b && !b.fainted? && !b.opposes?(@index) && b.index!=@index + yield b if b && !b.fainted? && !b.opposes?(@index) && b.index != @index end end @@ -766,6 +766,6 @@ class Battle::Battler @battle.pbGetOpposingIndicesInOrder(@index).each do |i| return @battle.battlers[i] if @battle.battlers[i] end - return @battle.battlers[(@index^1)] + return @battle.battlers[(@index ^ 1)] end end diff --git a/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb b/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb index bcd1785fb..deca84d30 100644 --- a/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb +++ b/Data/Scripts/011_Battle/002_Battler/002_Battler_Initialize.rb @@ -2,7 +2,7 @@ class Battle::Battler #============================================================================= # Creating a battler #============================================================================= - def initialize(btl,idxBattler) + def initialize(btl, idxBattler) @battle = btl @index = idxBattler @captured = false @@ -33,7 +33,7 @@ class Battle::Battler end # Used by Future Sight only, when Future Sight's user is no longer in battle. - def pbInitDummyPokemon(pkmn,idxParty) + def pbInitDummyPokemon(pkmn, idxParty) raise _INTL("An egg can't be an active Pokémon.") if pkmn.egg? @name = pkmn.name @species = pkmn.species @@ -57,13 +57,13 @@ class Battle::Battler @dummy = true end - def pbInitialize(pkmn,idxParty,batonPass = false) - pbInitPokemon(pkmn,idxParty) + def pbInitialize(pkmn, idxParty, batonPass = false) + pbInitPokemon(pkmn, idxParty) pbInitEffects(batonPass) @damageState.reset end - def pbInitPokemon(pkmn,idxParty) + def pbInitPokemon(pkmn, idxParty) raise _INTL("An egg can't be an active Pokémon.") if pkmn.egg? @name = pkmn.name @species = pkmn.species @@ -85,8 +85,8 @@ class Battle::Battler @pokemonIndex = idxParty @participants = [] # Participants earn Exp. if this battler is defeated @moves = [] - pkmn.moves.each_with_index do |m,i| - @moves[i] = Battle::Move.from_pokemon_move(@battle,m) + pkmn.moves.each_with_index do |m, i| + @moves[i] = Battle::Move.from_pokemon_move(@battle, m) end end @@ -94,10 +94,10 @@ class Battle::Battler if batonPass # These effects are passed on if Baton Pass is used, but they need to be # reapplied - @effects[PBEffects::LaserFocus] = (@effects[PBEffects::LaserFocus]>0) ? 2 : 0 - @effects[PBEffects::LockOn] = (@effects[PBEffects::LockOn]>0) ? 2 : 0 + @effects[PBEffects::LaserFocus] = (@effects[PBEffects::LaserFocus] > 0) ? 2 : 0 + @effects[PBEffects::LockOn] = (@effects[PBEffects::LockOn] > 0) ? 2 : 0 if @effects[PBEffects::PowerTrick] - @attack,@defense = @defense,@attack + @attack, @defense = @defense, @attack end # These effects are passed on if Baton Pass is used, but they need to be # cancelled in certain circumstances anyway @@ -131,7 +131,7 @@ class Battle::Battler @effects[PBEffects::Substitute] = 0 @effects[PBEffects::Telekinesis] = 0 end - @fainted = (@hp==0) + @fainted = (@hp == 0) @lastAttacker = [] @lastFoeAttacker = [] @lastHPLost = 0 @@ -154,7 +154,7 @@ class Battle::Battler @turnCount = 0 @effects[PBEffects::Attract] = -1 @battle.allBattlers.each do |b| # Other battlers no longer attracted to self - b.effects[PBEffects::Attract] = -1 if b.effects[PBEffects::Attract]==@index + b.effects[PBEffects::Attract] = -1 if b.effects[PBEffects::Attract] == @index end @effects[PBEffects::BanefulBunker] = false @effects[PBEffects::BeakBlast] = false @@ -204,8 +204,8 @@ class Battle::Battler end @effects[PBEffects::KingsShield] = false @battle.allBattlers.each do |b| # Other battlers lose their lock-on against self - next if b.effects[PBEffects::LockOn]==0 - next if b.effects[PBEffects::LockOnPos]!=@index + next if b.effects[PBEffects::LockOn] == 0 + next if b.effects[PBEffects::LockOnPos] != @index b.effects[PBEffects::LockOn] = 0 b.effects[PBEffects::LockOnPos] = -1 end @@ -213,7 +213,7 @@ class Battle::Battler @effects[PBEffects::MagicCoat] = false @effects[PBEffects::MeanLook] = -1 @battle.allBattlers.each do |b| # Other battlers no longer blocked by self - b.effects[PBEffects::MeanLook] = -1 if b.effects[PBEffects::MeanLook]==@index + b.effects[PBEffects::MeanLook] = -1 if b.effects[PBEffects::MeanLook] == @index end @effects[PBEffects::MeFirst] = false @effects[PBEffects::Metronome] = 0 @@ -250,7 +250,7 @@ class Battle::Battler @effects[PBEffects::Roost] = false @effects[PBEffects::SkyDrop] = -1 @battle.allBattlers.each do |b| # Other battlers no longer Sky Dropped by self - b.effects[PBEffects::SkyDrop] = -1 if b.effects[PBEffects::SkyDrop]==@index + b.effects[PBEffects::SkyDrop] = -1 if b.effects[PBEffects::SkyDrop] == @index end @effects[PBEffects::SlowStart] = 0 @effects[PBEffects::SmackDown] = false @@ -271,7 +271,7 @@ class Battle::Battler @effects[PBEffects::TrappingMove] = nil @effects[PBEffects::TrappingUser] = -1 @battle.allBattlers.each do |b| # Other battlers no longer trapped by self - next if b.effects[PBEffects::TrappingUser]!=@index + next if b.effects[PBEffects::TrappingUser] != @index b.effects[PBEffects::Trapping] = 0 b.effects[PBEffects::TrappingUser] = -1 end diff --git a/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb b/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb index c1cd50e82..64eacc3b0 100644 --- a/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb +++ b/Data/Scripts/011_Battle/002_Battler/003_Battler_ChangeSelf.rb @@ -2,16 +2,16 @@ class Battle::Battler #============================================================================= # Change HP #============================================================================= - def pbReduceHP(amt,anim = true,registerDamage = true,anyAnim = true) + def pbReduceHP(amt, anim = true, registerDamage = true, anyAnim = true) amt = amt.round - amt = @hp if amt>@hp - amt = 1 if amt<1 && !fainted? + amt = @hp if amt > @hp + amt = 1 if amt < 1 && !fainted? oldHP = @hp self.hp -= amt - PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt>0 - raise _INTL("HP less than 0") if @hp<0 - raise _INTL("HP greater than total HP") if @hp>@totalhp - @battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0 + PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0 + raise _INTL("HP less than 0") if @hp < 0 + raise _INTL("HP greater than total HP") if @hp > @totalhp + @battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0 if amt > 0 && registerDamage @droppedBelowHalfHP = true if @hp < @totalhp / 2 && @hp + amt >= @totalhp / 2 @tookDamageThisRound = true @@ -19,32 +19,32 @@ class Battle::Battler return amt end - def pbRecoverHP(amt,anim = true,anyAnim = true) + def pbRecoverHP(amt, anim = true, anyAnim = true) amt = amt.round - amt = @totalhp-@hp if amt>@totalhp-@hp - amt = 1 if amt<1 && @hp<@totalhp + amt = @totalhp - @hp if amt > @totalhp - @hp + amt = 1 if amt < 1 && @hp < @totalhp oldHP = @hp self.hp += amt - PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt>0 - raise _INTL("HP less than 0") if @hp<0 - raise _INTL("HP greater than total HP") if @hp>@totalhp - @battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0 + PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt > 0 + raise _INTL("HP less than 0") if @hp < 0 + raise _INTL("HP greater than total HP") if @hp > @totalhp + @battle.scene.pbHPChanged(self, oldHP, anim) if anyAnim && amt > 0 @droppedBelowHalfHP = false if @hp >= @totalhp / 2 return amt end - def pbRecoverHPFromDrain(amt,target,msg = nil) + def pbRecoverHPFromDrain(amt, target, msg = nil) if target.hasActiveAbility?(:LIQUIDOOZE) @battle.pbShowAbilitySplash(target) pbReduceHP(amt) - @battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",pbThis)) + @battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!", pbThis)) @battle.pbHideAbilitySplash(target) pbItemHPHealCheck else - msg = _INTL("{1} had its energy drained!",target.pbThis) if nil_or_empty?(msg) + msg = _INTL("{1} had its energy drained!", target.pbThis) if nil_or_empty?(msg) @battle.pbDisplay(msg) if canHeal? - amt = (amt*1.3).floor if hasActiveItem?(:BIGROOT) + amt = (amt * 1.3).floor if hasActiveItem?(:BIGROOT) pbRecoverHP(amt) end end @@ -66,7 +66,7 @@ class Battle::Battler return end return if @fainted # Has already fainted properly - @battle.pbDisplayBrief(_INTL("{1} fainted!",pbThis)) if showMessage + @battle.pbDisplayBrief(_INTL("{1} fainted!", pbThis)) if showMessage PBDebug.log("[Pokémon fainted] #{pbThis} (#{@index})") if !showMessage @battle.scene.pbFaintBattler(self) @battle.pbSetDefeated(self) if opposes? @@ -80,7 +80,7 @@ class Battle::Battler @pokemon.changeHappiness((badLoss) ? "faintbad" : "faint") end # Reset form - @battle.peer.pbOnLeavingBattle(@battle,@pokemon,@battle.usedInBattle[idxOwnSide][@index/2]) + @battle.peer.pbOnLeavingBattle(@battle, @pokemon, @battle.usedInBattle[idxOwnSide][@index / 2]) @pokemon.makeUnmega if mega? @pokemon.makeUnprimal if primal? # Do other things @@ -98,26 +98,26 @@ class Battle::Battler #============================================================================= # Move PP #============================================================================= - def pbSetPP(move,pp) + def pbSetPP(move, pp) move.pp = pp # No need to care about @effects[PBEffects::Mimic], since Mimic can't copy # Mimic - if move.realMove && move.id==move.realMove.id && !@effects[PBEffects::Transform] + if move.realMove && move.id == move.realMove.id && !@effects[PBEffects::Transform] move.realMove.pp = pp end end def pbReducePP(move) return true if usingMultiTurnAttack? - return true if move.pp<0 # Don't reduce PP for special calls of moves - return true if move.total_pp<=0 # Infinite PP, can always be used - return false if move.pp==0 # Ran out of PP, couldn't reduce - pbSetPP(move,move.pp-1) if move.pp>0 + return true if move.pp < 0 # Don't reduce PP for special calls of moves + return true if move.total_pp <= 0 # Infinite PP, can always be used + return false if move.pp == 0 # Ran out of PP, couldn't reduce + pbSetPP(move, move.pp - 1) if move.pp > 0 return true end def pbReducePPOther(move) - pbSetPP(move,move.pp-1) if move.pp>0 + pbSetPP(move, move.pp - 1) if move.pp > 0 end #============================================================================= @@ -150,17 +150,17 @@ class Battle::Battler #============================================================================= # Forms #============================================================================= - def pbChangeForm(newForm,msg) - return if fainted? || @effects[PBEffects::Transform] || @form==newForm + def pbChangeForm(newForm, msg) + return if fainted? || @effects[PBEffects::Transform] || @form == newForm oldForm = @form - oldDmg = @totalhp-@hp + oldDmg = @totalhp - @hp self.form = newForm pbUpdate(true) - @hp = @totalhp-oldDmg + @hp = @totalhp - oldDmg @effects[PBEffects::WeightChange] = 0 if Settings::MECHANICS_GENERATION >= 6 - @battle.scene.pbChangePokemon(self,@pokemon) + @battle.scene.pbChangePokemon(self, @pokemon) @battle.scene.pbRefreshOne(@index) - @battle.pbDisplay(msg) if msg && msg!="" + @battle.pbDisplay(msg) if msg && msg != "" PBDebug.log("[Form changed] #{pbThis} changed from form #{oldForm} to form #{newForm}") @battle.pbSetSeen(self) end @@ -169,7 +169,7 @@ class Battle::Battler return if fainted? || @effects[PBEffects::Transform] # Shaymin - reverts if frozen if isSpecies?(:SHAYMIN) && frozen? - pbChangeForm(0,_INTL("{1} transformed!",pbThis)) + pbChangeForm(0, _INTL("{1} transformed!", pbThis)) end end @@ -179,7 +179,7 @@ class Battle::Battler if isSpecies?(:KELDEO) newForm = 0 newForm = 1 if pbHasMove?(:SECRETSWORD) - pbChangeForm(newForm,_INTL("{1} transformed!",pbThis)) + pbChangeForm(newForm, _INTL("{1} transformed!", pbThis)) end end @@ -194,13 +194,13 @@ class Battle::Battler when :Rain, :HeavyRain then newForm = 2 when :Hail then newForm = 3 end - if @form!=newForm - @battle.pbShowAbilitySplash(self,true) + if @form != newForm + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) - pbChangeForm(newForm,_INTL("{1} transformed!",pbThis)) + pbChangeForm(newForm, _INTL("{1} transformed!", pbThis)) end else - pbChangeForm(0,_INTL("{1} transformed!",pbThis)) + pbChangeForm(0, _INTL("{1} transformed!", pbThis)) end end # Cherrim - Flower Gift @@ -208,13 +208,13 @@ class Battle::Battler if hasActiveAbility?(:FLOWERGIFT) newForm = 0 newForm = 1 if [:Sun, :HarshSun].include?(effectiveWeather) - if @form!=newForm - @battle.pbShowAbilitySplash(self,true) + if @form != newForm + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) - pbChangeForm(newForm,_INTL("{1} transformed!",pbThis)) + pbChangeForm(newForm, _INTL("{1} transformed!", pbThis)) end else - pbChangeForm(0,_INTL("{1} transformed!",pbThis)) + pbChangeForm(0, _INTL("{1} transformed!", pbThis)) end end # Eiscue - Ice Face @@ -233,57 +233,57 @@ class Battle::Battler pbCheckFormOnWeatherChange if !endOfRound # Darmanitan - Zen Mode if isSpecies?(:DARMANITAN) && self.ability == :ZENMODE - if @hp<=@totalhp/2 + if @hp <= @totalhp / 2 if (@form % 2) == 0 - @battle.pbShowAbilitySplash(self,true) + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) pbChangeForm(@form + 1, _INTL("{1} triggered!", abilityName)) end elsif (@form % 2) != 0 - @battle.pbShowAbilitySplash(self,true) + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) pbChangeForm(@form - 1, _INTL("{1} triggered!", abilityName)) end end # Minior - Shields Down if isSpecies?(:MINIOR) && self.ability == :SHIELDSDOWN - if @hp>@totalhp/2 # Turn into Meteor form - newForm = (@form>=7) ? @form-7 : @form - if @form!=newForm - @battle.pbShowAbilitySplash(self,true) + if @hp > @totalhp / 2 # Turn into Meteor form + newForm = (@form >= 7) ? @form - 7 : @form + if @form != newForm + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) - pbChangeForm(newForm,_INTL("{1} deactivated!",abilityName)) + pbChangeForm(newForm, _INTL("{1} deactivated!", abilityName)) elsif !endOfRound - @battle.pbDisplay(_INTL("{1} deactivated!",abilityName)) + @battle.pbDisplay(_INTL("{1} deactivated!", abilityName)) end - elsif @form<7 # Turn into Core form - @battle.pbShowAbilitySplash(self,true) + elsif @form < 7 # Turn into Core form + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) - pbChangeForm(@form+7,_INTL("{1} activated!",abilityName)) + pbChangeForm(@form + 7, _INTL("{1} activated!", abilityName)) end end # Wishiwashi - Schooling if isSpecies?(:WISHIWASHI) && self.ability == :SCHOOLING - if @level>=20 && @hp>@totalhp/4 - if @form!=1 - @battle.pbShowAbilitySplash(self,true) + if @level >= 20 && @hp > @totalhp / 4 + if @form != 1 + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) - pbChangeForm(1,_INTL("{1} formed a school!",pbThis)) + pbChangeForm(1, _INTL("{1} formed a school!", pbThis)) end - elsif @form!=0 - @battle.pbShowAbilitySplash(self,true) + elsif @form != 0 + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) - pbChangeForm(0,_INTL("{1} stopped schooling!",pbThis)) + pbChangeForm(0, _INTL("{1} stopped schooling!", pbThis)) end end # Zygarde - Power Construct if isSpecies?(:ZYGARDE) && self.ability == :POWERCONSTRUCT && endOfRound - if @hp<=@totalhp/2 && @form<2 # Turn into Complete Forme - newForm = @form+2 + if @hp <= @totalhp / 2 && @form < 2 # Turn into Complete Forme + newForm = @form + 2 @battle.pbDisplay(_INTL("You sense the presence of many!")) - @battle.pbShowAbilitySplash(self,true) + @battle.pbShowAbilitySplash(self, true) @battle.pbHideAbilitySplash(self) - pbChangeForm(newForm,_INTL("{1} transformed into its Complete Forme!",pbThis)) + pbChangeForm(newForm, _INTL("{1} transformed into its Complete Forme!", pbThis)) end end # Morpeko - Hunger Switch @@ -311,7 +311,7 @@ class Battle::Battler @effects[PBEffects::LaserFocus] = target.effects[PBEffects::LaserFocus] end @moves.clear - target.moves.each_with_index do |m,i| + target.moves.each_with_index do |m, i| @moves[i] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(m.id)) @moves[i].pp = 5 @moves[i].total_pp = 5 @@ -320,7 +320,7 @@ class Battle::Battler @effects[PBEffects::DisableMove] = nil @effects[PBEffects::WeightChange] = target.effects[PBEffects::WeightChange] @battle.scene.pbRefreshOne(@index) - @battle.pbDisplay(_INTL("{1} transformed into {2}!",pbThis,target.pbThis(true))) + @battle.pbDisplay(_INTL("{1} transformed into {2}!", pbThis, target.pbThis(true))) pbOnLosingAbility(oldAbil) end diff --git a/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb b/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb index 501bd6bc4..c087e9ad3 100644 --- a/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb +++ b/Data/Scripts/011_Battle/002_Battler/004_Battler_Statuses.rb @@ -12,7 +12,7 @@ class Battle::Battler if Battle::AbilityEffects.triggerStatusCheckNonIgnorable(self.ability, self, checkStatus) return true end - return @status==checkStatus + return @status == checkStatus end def pbHasAnyStatus? @@ -22,11 +22,11 @@ class Battle::Battler return @status != :NONE end - def pbCanInflictStatus?(newStatus,user,showMessages,move = nil,ignoreStatus = false) + def pbCanInflictStatus?(newStatus, user, showMessages, move = nil, ignoreStatus = false) return false if fainted? - selfInflicted = (user && user.index==@index) + selfInflicted = (user && user.index == @index) # Already have that status problem - if self.status==newStatus && !ignoreStatus + if self.status == newStatus && !ignoreStatus if showMessages msg = "" case self.status @@ -42,18 +42,18 @@ class Battle::Battler end # Trying to replace a status problem with another one if self.status != :NONE && !ignoreStatus && !selfInflicted - @battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages + @battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages return false end # Trying to inflict a status problem on a Pokémon behind a substitute - if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) && + if @effects[PBEffects::Substitute] > 0 && !(move && move.ignoresSubstitute?(user)) && !selfInflicted - @battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages + @battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages return false end # Weather immunity if newStatus == :FROZEN && [:Sun, :HarshSun].include?(effectiveWeather) - @battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages + @battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages return false end # Terrains immunity @@ -66,15 +66,15 @@ class Battle::Battler return false end when :Misty - @battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages + @battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages return false end end # Uproar immunity if newStatus == :SLEEP && !(hasActiveAbility?(:SOUNDPROOF) && !@battle.moldBreaker) @battle.allBattlers.each do |b| - next if b.effects[PBEffects::Uproar]==0 - @battle.pbDisplay(_INTL("But the uproar kept {1} awake!",pbThis(true))) if showMessages + next if b.effects[PBEffects::Uproar] == 0 + @battle.pbDisplay(_INTL("But the uproar kept {1} awake!", pbThis(true))) if showMessages return false end end @@ -96,7 +96,7 @@ class Battle::Battler hasImmuneType |= pbHasType?(:ICE) end if hasImmuneType - @battle.pbDisplay(_INTL("It doesn't affect {1}...",pbThis(true))) if showMessages + @battle.pbDisplay(_INTL("It doesn't affect {1}...", pbThis(true))) if showMessages return false end # Ability immunity @@ -133,19 +133,19 @@ class Battle::Battler case newStatus when :SLEEP msg = _INTL("{1} stays awake because of {2}'s {3}!", - pbThis,immAlly.pbThis(true),immAlly.abilityName) + pbThis, immAlly.pbThis(true), immAlly.abilityName) when :POISON msg = _INTL("{1} cannot be poisoned because of {2}'s {3}!", - pbThis,immAlly.pbThis(true),immAlly.abilityName) + pbThis, immAlly.pbThis(true), immAlly.abilityName) when :BURN msg = _INTL("{1} cannot be burned because of {2}'s {3}!", - pbThis,immAlly.pbThis(true),immAlly.abilityName) + pbThis, immAlly.pbThis(true), immAlly.abilityName) when :PARALYSIS msg = _INTL("{1} cannot be paralyzed because of {2}'s {3}!", - pbThis,immAlly.pbThis(true),immAlly.abilityName) + pbThis, immAlly.pbThis(true), immAlly.abilityName) when :FROZEN msg = _INTL("{1} cannot be frozen solid because of {2}'s {3}!", - pbThis,immAlly.pbThis(true),immAlly.abilityName) + pbThis, immAlly.pbThis(true), immAlly.abilityName) end else case newStatus @@ -162,15 +162,15 @@ class Battle::Battler return false end # Safeguard immunity - if pbOwnSide.effects[PBEffects::Safeguard]>0 && !selfInflicted && move && + if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted && move && !(user && user.hasActiveAbility?(:INFILTRATOR)) - @battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!",pbThis)) if showMessages + @battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!", pbThis)) if showMessages return false end return true end - def pbCanSynchronizeStatus?(newStatus,target) + def pbCanSynchronizeStatus?(newStatus, target) return false if fainted? # Trying to replace a status problem with another one return false if self.status != :NONE @@ -204,7 +204,7 @@ class Battle::Battler return false end # Safeguard immunity - if pbOwnSide.effects[PBEffects::Safeguard]>0 && + if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !(user && user.hasActiveAbility?(:INFILTRATOR)) return false end @@ -214,7 +214,7 @@ class Battle::Battler #============================================================================= # Generalised infliction of status problem #============================================================================= - def pbInflictStatus(newStatus,newStatusCount = 0,msg = nil,user = nil) + def pbInflictStatus(newStatus, newStatusCount = 0, msg = nil, user = nil) # Inflict the new status self.status = newStatus self.statusCount = newStatusCount @@ -234,7 +234,7 @@ class Battle::Battler when :SLEEP @battle.pbDisplay(_INTL("{1} fell asleep!", pbThis)) when :POISON - if newStatusCount>0 + if newStatusCount > 0 @battle.pbDisplay(_INTL("{1} was badly poisoned!", pbThis)) else @battle.pbDisplay(_INTL("{1} was poisoned!", pbThis)) @@ -304,7 +304,7 @@ class Battle::Battler # NOTE: Bulbapedia claims that Safeguard shouldn't prevent sleep due to # drowsiness. I disagree with this too. Compare with the other sided # effects Misty/Electric Terrain, which do prevent it. - return false if pbOwnSide.effects[PBEffects::Safeguard]>0 + return false if pbOwnSide.effects[PBEffects::Safeguard] > 0 return true end @@ -438,20 +438,20 @@ class Battle::Battler #============================================================================= # Confusion #============================================================================= - def pbCanConfuse?(user = nil,showMessages = true,move = nil,selfInflicted = false) + def pbCanConfuse?(user = nil, showMessages = true, move = nil, selfInflicted = false) return false if fainted? - if @effects[PBEffects::Confusion]>0 - @battle.pbDisplay(_INTL("{1} is already confused.",pbThis)) if showMessages + if @effects[PBEffects::Confusion] > 0 + @battle.pbDisplay(_INTL("{1} is already confused.", pbThis)) if showMessages return false end - if @effects[PBEffects::Substitute]>0 && !(move && move.ignoresSubstitute?(user)) && + if @effects[PBEffects::Substitute] > 0 && !(move && move.ignoresSubstitute?(user)) && !selfInflicted @battle.pbDisplay(_INTL("But it failed!")) if showMessages return false end # Terrains immunity if affectedByTerrain? && @battle.field.terrain == :Misty && Settings::MECHANICS_GENERATION >= 7 - @battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!",pbThis(true))) if showMessages + @battle.pbDisplay(_INTL("{1} surrounds itself with misty terrain!", pbThis(true))) if showMessages return false end if selfInflicted || !@battle.moldBreaker @@ -459,31 +459,31 @@ class Battle::Battler if showMessages @battle.pbShowAbilitySplash(self) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} doesn't become confused!",pbThis)) + @battle.pbDisplay(_INTL("{1} doesn't become confused!", pbThis)) else - @battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!",pbThis,abilityName)) + @battle.pbDisplay(_INTL("{1}'s {2} prevents confusion!", pbThis, abilityName)) end @battle.pbHideAbilitySplash(self) end return false end end - if pbOwnSide.effects[PBEffects::Safeguard]>0 && !selfInflicted && + if pbOwnSide.effects[PBEffects::Safeguard] > 0 && !selfInflicted && !(user && user.hasActiveAbility?(:INFILTRATOR)) - @battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!",pbThis)) if showMessages + @battle.pbDisplay(_INTL("{1}'s team is protected by Safeguard!", pbThis)) if showMessages return false end return true end def pbCanConfuseSelf?(showMessages) - return pbCanConfuse?(nil,showMessages,nil,true) + return pbCanConfuse?(nil, showMessages, nil, true) end def pbConfuse(msg = nil) @effects[PBEffects::Confusion] = pbConfusionDuration - @battle.pbCommonAnimation("Confusion",self) - msg = _INTL("{1} became confused!",pbThis) if nil_or_empty?(msg) + @battle.pbCommonAnimation("Confusion", self) + msg = _INTL("{1} became confused!", pbThis) if nil_or_empty?(msg) @battle.pbDisplay(msg) PBDebug.log("[Lingering effect] #{pbThis}'s confusion count is #{@effects[PBEffects::Confusion]}") # Confusion cures @@ -492,7 +492,7 @@ class Battle::Battler end def pbConfusionDuration(duration = -1) - duration = 2+@battle.pbRandom(4) if duration<=0 + duration = 2 + @battle.pbRandom(4) if duration <= 0 return duration end @@ -503,27 +503,27 @@ class Battle::Battler #============================================================================= # Attraction #============================================================================= - def pbCanAttract?(user,showMessages = true) + def pbCanAttract?(user, showMessages = true) return false if fainted? return false if !user || user.fainted? - if @effects[PBEffects::Attract]>=0 - @battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMessages + if @effects[PBEffects::Attract] >= 0 + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages return false end agender = user.gender ogender = gender - if agender==2 || ogender==2 || agender==ogender - @battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) if showMessages + if agender == 2 || ogender == 2 || agender == ogender + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) if showMessages return false end if !@battle.moldBreaker - if hasActiveAbility?([:AROMAVEIL,:OBLIVIOUS]) + if hasActiveAbility?([:AROMAVEIL, :OBLIVIOUS]) if showMessages @battle.pbShowAbilitySplash(self) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) else - @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!",pbThis,abilityName)) + @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", pbThis, abilityName)) end @battle.pbHideAbilitySplash(self) end @@ -534,9 +534,9 @@ class Battle::Battler if showMessages @battle.pbShowAbilitySplash(self) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is unaffected!",pbThis)) + @battle.pbDisplay(_INTL("{1} is unaffected!", pbThis)) else - @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!",b.pbThis,b.abilityName)) + @battle.pbDisplay(_INTL("{1}'s {2} prevents romance!", b.pbThis, b.abilityName)) end @battle.pbHideAbilitySplash(self) end @@ -547,14 +547,14 @@ class Battle::Battler return true end - def pbAttract(user,msg = nil) + def pbAttract(user, msg = nil) @effects[PBEffects::Attract] = user.index - @battle.pbCommonAnimation("Attract",self) - msg = _INTL("{1} fell in love!",pbThis) if nil_or_empty?(msg) + @battle.pbCommonAnimation("Attract", self) + msg = _INTL("{1} fell in love!", pbThis) if nil_or_empty?(msg) @battle.pbDisplay(msg) # Destiny Knot - if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self,false) - user.pbAttract(self,_INTL("{1} fell in love from the {2}!",user.pbThis(true),itemName)) + if hasActiveItem?(:DESTINYKNOT) && user.pbCanAttract?(self, false) + user.pbAttract(self, _INTL("{1} fell in love from the {2}!", user.pbThis(true), itemName)) end # Attraction cures pbItemStatusCureCheck diff --git a/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb b/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb index abc64aa45..1c351eac7 100644 --- a/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb +++ b/Data/Scripts/011_Battle/002_Battler/005_Battler_StatStages.rb @@ -3,14 +3,14 @@ class Battle::Battler # Increase stat stages #============================================================================= def statStageAtMax?(stat) - return @stages[stat]>=6 + return @stages[stat] >= 6 end - def pbCanRaiseStatStage?(stat,user = nil,move = nil,showFailMsg = false,ignoreContrary = false) + def pbCanRaiseStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false) return false if fainted? # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker - return pbCanLowerStatStage?(stat,user,move,showFailMsg,true) + return pbCanLowerStatStage?(stat, user, move, showFailMsg, true) end # Check the stat stage if statStageAtMax?(stat) @@ -21,20 +21,20 @@ class Battle::Battler return true end - def pbRaiseStatStageBasic(stat,increment,ignoreContrary = false) + def pbRaiseStatStageBasic(stat, increment, ignoreContrary = false) if !@battle.moldBreaker # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary - return pbLowerStatStageBasic(stat,increment,true) + return pbLowerStatStageBasic(stat, increment, true) end # Simple increment *= 2 if hasActiveAbility?(:SIMPLE) end # Change the stat stage - increment = [increment,6-@stages[stat]].min - if increment>0 + increment = [increment, 6 - @stages[stat]].min + if increment > 0 stat_name = GameData::Stat.get(stat).name - new = @stages[stat]+increment + new = @stages[stat] + increment PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (+#{increment})") @stages[stat] += increment @statsRaisedThisRound = true @@ -42,22 +42,22 @@ class Battle::Battler return increment end - def pbRaiseStatStage(stat,increment,user,showAnim = true,ignoreContrary = false) + def pbRaiseStatStage(stat, increment, user, showAnim = true, ignoreContrary = false) # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker - return pbLowerStatStage(stat,increment,user,showAnim,true) + return pbLowerStatStage(stat, increment, user, showAnim, true) end # Perform the stat stage change - increment = pbRaiseStatStageBasic(stat,increment,ignoreContrary) - return false if increment<=0 + increment = pbRaiseStatStageBasic(stat, increment, ignoreContrary) + return false if increment <= 0 # Stat up animation and message - @battle.pbCommonAnimation("StatUp",self) if showAnim + @battle.pbCommonAnimation("StatUp", self) if showAnim arrStatTexts = [ - _INTL("{1}'s {2} rose!",pbThis,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} rose sharply!",pbThis,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} rose drastically!",pbThis,GameData::Stat.get(stat).name) + _INTL("{1}'s {2} rose!", pbThis, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} rose sharply!", pbThis, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} rose drastically!", pbThis, GameData::Stat.get(stat).name) ] - @battle.pbDisplay(arrStatTexts[[increment-1,2].min]) + @battle.pbDisplay(arrStatTexts[[increment - 1, 2].min]) # Trigger abilities upon stat gain if abilityActive? Battle::AbilityEffects.triggerOnStatGain(self.ability, self, stat, user) @@ -65,30 +65,30 @@ class Battle::Battler return true end - def pbRaiseStatStageByCause(stat,increment,user,cause,showAnim = true,ignoreContrary = false) + def pbRaiseStatStageByCause(stat, increment, user, cause, showAnim = true, ignoreContrary = false) # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary && !@battle.moldBreaker - return pbLowerStatStageByCause(stat,increment,user,cause,showAnim,true) + return pbLowerStatStageByCause(stat, increment, user, cause, showAnim, true) end # Perform the stat stage change - increment = pbRaiseStatStageBasic(stat,increment,ignoreContrary) - return false if increment<=0 + increment = pbRaiseStatStageBasic(stat, increment, ignoreContrary) + return false if increment <= 0 # Stat up animation and message - @battle.pbCommonAnimation("StatUp",self) if showAnim - if user.index==@index + @battle.pbCommonAnimation("StatUp", self) if showAnim + if user.index == @index arrStatTexts = [ - _INTL("{1}'s {2} raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} sharply raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} drastically raised its {3}!",pbThis,cause,GameData::Stat.get(stat).name) + _INTL("{1}'s {2} raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} sharply raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} drastically raised its {3}!", pbThis, cause, GameData::Stat.get(stat).name) ] else arrStatTexts = [ - _INTL("{1}'s {2} raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name), - _INTL("{1}'s {2} sharply raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name), - _INTL("{1}'s {2} drastically raised {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name) + _INTL("{1}'s {2} raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name), + _INTL("{1}'s {2} sharply raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name), + _INTL("{1}'s {2} drastically raised {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name) ] end - @battle.pbDisplay(arrStatTexts[[increment-1,2].min]) + @battle.pbDisplay(arrStatTexts[[increment - 1, 2].min]) # Trigger abilities upon stat gain if abilityActive? Battle::AbilityEffects.triggerOnStatGain(self.ability, self, stat, user) @@ -96,15 +96,15 @@ class Battle::Battler return true end - def pbRaiseStatStageByAbility(stat,increment,user,splashAnim = true) + def pbRaiseStatStageByAbility(stat, increment, user, splashAnim = true) return false if fainted? ret = false @battle.pbShowAbilitySplash(user) if splashAnim - if pbCanRaiseStatStage?(stat,user,nil,Battle::Scene::USE_ABILITY_SPLASH) + if pbCanRaiseStatStage?(stat, user, nil, Battle::Scene::USE_ABILITY_SPLASH) if Battle::Scene::USE_ABILITY_SPLASH - ret = pbRaiseStatStage(stat,increment,user) + ret = pbRaiseStatStage(stat, increment, user) else - ret = pbRaiseStatStageByCause(stat,increment,user,user.abilityName) + ret = pbRaiseStatStageByCause(stat, increment, user, user.abilityName) end end @battle.pbHideAbilitySplash(user) if splashAnim @@ -115,7 +115,7 @@ class Battle::Battler # Decrease stat stages #============================================================================= def statStageAtMin?(stat) - return @stages[stat]<=-6 + return @stages[stat] <= -6 end def pbCanLowerStatStage?(stat, user = nil, move = nil, showFailMsg = false, ignoreContrary = false, ignoreMirrorArmor = false) @@ -130,27 +130,27 @@ class Battle::Battler return true if !statStageAtMin?(stat) end end - if !user || user.index!=@index # Not self-inflicted - if @effects[PBEffects::Substitute]>0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user))) - @battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis)) if showFailMsg + if !user || user.index != @index # Not self-inflicted + if @effects[PBEffects::Substitute] > 0 && (ignoreMirrorArmor || !(move && move.ignoresSubstitute?(user))) + @battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis)) if showFailMsg return false end - if pbOwnSide.effects[PBEffects::Mist]>0 && + if pbOwnSide.effects[PBEffects::Mist] > 0 && !(user && user.hasActiveAbility?(:INFILTRATOR)) - @battle.pbDisplay(_INTL("{1} is protected by Mist!",pbThis)) if showFailMsg + @battle.pbDisplay(_INTL("{1} is protected by Mist!", pbThis)) if showFailMsg return false end if abilityActive? return false if !@battle.moldBreaker && Battle::AbilityEffects.triggerStatLossImmunity( - self.ability,self,stat,@battle,showFailMsg) + self.ability, self, stat, @battle, showFailMsg) return false if Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable( - self.ability,self,stat,@battle,showFailMsg) + self.ability, self, stat, @battle, showFailMsg) end if !@battle.moldBreaker allAllies.each do |b| next if !b.abilityActive? return false if Battle::AbilityEffects.triggerStatLossImmunityFromAlly( - b.ability,b,self,stat,@battle,showFailMsg) + b.ability, b, self, stat, @battle, showFailMsg) end end end @@ -163,20 +163,20 @@ class Battle::Battler return true end - def pbLowerStatStageBasic(stat,increment,ignoreContrary = false) + def pbLowerStatStageBasic(stat, increment, ignoreContrary = false) if !@battle.moldBreaker # Contrary if hasActiveAbility?(:CONTRARY) && !ignoreContrary - return pbRaiseStatStageBasic(stat,increment,true) + return pbRaiseStatStageBasic(stat, increment, true) end # Simple increment *= 2 if hasActiveAbility?(:SIMPLE) end # Change the stat stage - increment = [increment,6+@stages[stat]].min - if increment>0 + increment = [increment, 6 + @stages[stat]].min + if increment > 0 stat_name = GameData::Stat.get(stat).name - new = @stages[stat]-increment + new = @stages[stat] - increment PBDebug.log("[Stat change] #{pbThis}'s #{stat_name}: #{@stages[stat]} -> #{new} (-#{increment})") @stages[stat] -= increment @statsLoweredThisRound = true @@ -210,16 +210,16 @@ class Battle::Battler end end # Perform the stat stage change - increment = pbLowerStatStageBasic(stat,increment,ignoreContrary) - return false if increment<=0 + increment = pbLowerStatStageBasic(stat, increment, ignoreContrary) + return false if increment <= 0 # Stat down animation and message - @battle.pbCommonAnimation("StatDown",self) if showAnim + @battle.pbCommonAnimation("StatDown", self) if showAnim arrStatTexts = [ - _INTL("{1}'s {2} fell!",pbThis,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} harshly fell!",pbThis,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} severely fell!",pbThis,GameData::Stat.get(stat).name) + _INTL("{1}'s {2} fell!", pbThis, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} harshly fell!", pbThis, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} severely fell!", pbThis, GameData::Stat.get(stat).name) ] - @battle.pbDisplay(arrStatTexts[[increment-1,2].min]) + @battle.pbDisplay(arrStatTexts[[increment - 1, 2].min]) # Trigger abilities upon stat loss if abilityActive? Battle::AbilityEffects.triggerOnStatLoss(self.ability, self, stat, user) @@ -250,24 +250,24 @@ class Battle::Battler end end # Perform the stat stage change - increment = pbLowerStatStageBasic(stat,increment,ignoreContrary) - return false if increment<=0 + increment = pbLowerStatStageBasic(stat, increment, ignoreContrary) + return false if increment <= 0 # Stat down animation and message - @battle.pbCommonAnimation("StatDown",self) if showAnim - if user.index==@index + @battle.pbCommonAnimation("StatDown", self) if showAnim + if user.index == @index arrStatTexts = [ - _INTL("{1}'s {2} lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} harshly lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name), - _INTL("{1}'s {2} severely lowered its {3}!",pbThis,cause,GameData::Stat.get(stat).name) + _INTL("{1}'s {2} lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} harshly lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name), + _INTL("{1}'s {2} severely lowered its {3}!", pbThis, cause, GameData::Stat.get(stat).name) ] else arrStatTexts = [ - _INTL("{1}'s {2} lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name), - _INTL("{1}'s {2} harshly lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name), - _INTL("{1}'s {2} severely lowered {3}'s {4}!",user.pbThis,cause,pbThis(true),GameData::Stat.get(stat).name) + _INTL("{1}'s {2} lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name), + _INTL("{1}'s {2} harshly lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name), + _INTL("{1}'s {2} severely lowered {3}'s {4}!", user.pbThis, cause, pbThis(true), GameData::Stat.get(stat).name) ] end - @battle.pbDisplay(arrStatTexts[[increment-1,2].min]) + @battle.pbDisplay(arrStatTexts[[increment - 1, 2].min]) # Trigger abilities upon stat loss if abilityActive? Battle::AbilityEffects.triggerOnStatLoss(self.ability, self, stat, user) @@ -275,15 +275,15 @@ class Battle::Battler return true end - def pbLowerStatStageByAbility(stat,increment,user,splashAnim = true,checkContact = false) + def pbLowerStatStageByAbility(stat, increment, user, splashAnim = true, checkContact = false) ret = false @battle.pbShowAbilitySplash(user) if splashAnim - if pbCanLowerStatStage?(stat,user,nil,Battle::Scene::USE_ABILITY_SPLASH) && + if pbCanLowerStatStage?(stat, user, nil, Battle::Scene::USE_ABILITY_SPLASH) && (!checkContact || affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH)) if Battle::Scene::USE_ABILITY_SPLASH - ret = pbLowerStatStage(stat,increment,user) + ret = pbLowerStatStage(stat, increment, user) else - ret = pbLowerStatStageByCause(stat,increment,user,user.abilityName) + ret = pbLowerStatStageByCause(stat, increment, user, user.abilityName) end end @battle.pbHideAbilitySplash(user) if splashAnim @@ -293,12 +293,12 @@ class Battle::Battler def pbLowerAttackStatStageIntimidate(user) return false if fainted? # NOTE: Substitute intentially blocks Intimidate even if self has Contrary. - if @effects[PBEffects::Substitute]>0 + if @effects[PBEffects::Substitute] > 0 if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is protected by its substitute!",pbThis)) + @battle.pbDisplay(_INTL("{1} is protected by its substitute!", pbThis)) else @battle.pbDisplay(_INTL("{1}'s substitute protected it from {2}'s {3}!", - pbThis,user.pbThis(true),user.abilityName)) + pbThis, user.pbThis(true), user.abilityName)) end return false end @@ -314,22 +314,22 @@ class Battle::Battler return false end if Battle::Scene::USE_ABILITY_SPLASH - return pbLowerStatStageByAbility(:ATTACK,1,user,false) + return pbLowerStatStageByAbility(:ATTACK, 1, user, false) end # NOTE: These checks exist to ensure appropriate messages are shown if # Intimidate is blocked somehow (i.e. the messages should mention the # Intimidate ability by name). if !hasActiveAbility?(:CONTRARY) - if pbOwnSide.effects[PBEffects::Mist]>0 + if pbOwnSide.effects[PBEffects::Mist] > 0 @battle.pbDisplay(_INTL("{1} is protected from {2}'s {3} by Mist!", - pbThis,user.pbThis(true),user.abilityName)) + pbThis, user.pbThis(true), user.abilityName)) return false end if abilityActive? if Battle::AbilityEffects.triggerStatLossImmunity(self.ability, self, :ATTACK, @battle, false) || Battle::AbilityEffects.triggerStatLossImmunityNonIgnorable(self.ability, self, :ATTACK, @battle, false) @battle.pbDisplay(_INTL("{1}'s {2} prevented {3}'s {4} from working!", - pbThis,abilityName,user.pbThis(true),user.abilityName)) + pbThis, abilityName, user.pbThis(true), user.abilityName)) return false end end @@ -337,13 +337,13 @@ class Battle::Battler next if !b.abilityActive? if Battle::AbilityEffects.triggerStatLossImmunityFromAlly(b.ability, b, self, :ATTACK, @battle, false) @battle.pbDisplay(_INTL("{1} is protected from {2}'s {3} by {4}'s {5}!", - pbThis,user.pbThis(true),user.abilityName,b.pbThis(true),b.abilityName)) + pbThis, user.pbThis(true), user.abilityName, b.pbThis(true), b.abilityName)) return false end end end - return false if !pbCanLowerStatStage?(:ATTACK,user) - return pbLowerStatStageByCause(:ATTACK,1,user,user.abilityName) + return false if !pbCanLowerStatStage?(:ATTACK, user) + return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName) end #============================================================================= diff --git a/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb b/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb index 0252bc317..ea45b9db7 100644 --- a/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb +++ b/Data/Scripts/011_Battle/002_Battler/006_Battler_AbilityAndItem.rb @@ -7,7 +7,7 @@ class Battle::Battler Battle::AbilityEffects.triggerOnSwitchOut(self.ability, self, false) end # Reset form - @battle.peer.pbOnLeavingBattle(@battle,@pokemon,@battle.usedInBattle[idxOwnSide][@index/2]) + @battle.peer.pbOnLeavingBattle(@battle, @pokemon, @battle.usedInBattle[idxOwnSide][@index / 2]) # Treat self as fainted @hp = 0 @fainted = true @@ -77,11 +77,11 @@ class Battle::Battler next !b.ungainableAbility? && ![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id) } - if choices.length>0 + if choices.length > 0 choice = choices[@battle.pbRandom(choices.length)] @battle.pbShowAbilitySplash(self) self.ability = choice.ability - @battle.pbDisplay(_INTL("{1} traced {2}'s {3}!",pbThis,choice.pbThis(true),choice.abilityName)) + @battle.pbDisplay(_INTL("{1} traced {2}'s {3}!", pbThis, choice.pbThis(true), choice.abilityName)) @battle.pbHideAbilitySplash(self) if !onSwitchIn && (unstoppableAbility? || abilityActive?) Battle::AbilityEffects.triggerOnSwitchIn(self.ability, self, @battle) @@ -227,7 +227,7 @@ class Battle::Battler self.item = nil end - def pbConsumeItem(recoverable = true,symbiosis = true,belch = true) + def pbConsumeItem(recoverable = true, symbiosis = true, belch = true) PBDebug.log("[Item consumed] #{pbThis} consumed its held #{itemName}") if recoverable setRecycleItem(@item_id) @@ -250,10 +250,10 @@ class Battle::Battler @battle.pbShowAbilitySplash(b) if Battle::Scene::USE_ABILITY_SPLASH @battle.pbDisplay(_INTL("{1} shared its {2} with {3}!", - b.pbThis,b.itemName,pbThis(true))) + b.pbThis, b.itemName, pbThis(true))) else @battle.pbDisplay(_INTL("{1}'s {2} let it share its {3} with {4}!", - b.pbThis,b.abilityName,b.itemName,pbThis(true))) + b.pbThis, b.abilityName, b.itemName, pbThis(true))) end self.item = b.item b.item = nil diff --git a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb index 2389f69ce..d513f0cbb 100644 --- a/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb +++ b/Data/Scripts/011_Battle/002_Battler/007_Battler_UseMove.rb @@ -2,36 +2,36 @@ class Battle::Battler #============================================================================= # Turn processing #============================================================================= - def pbProcessTurn(choice,tryFlee = true) + def pbProcessTurn(choice, tryFlee = true) return false if fainted? # Wild roaming Pokémon always flee if possible if tryFlee && wild? && @battle.rules["alwaysflee"] && @battle.pbCanRun?(@index) pbBeginTurn(choice) pbSEPlay("Battle flee") - @battle.pbDisplay(_INTL("{1} fled from battle!",pbThis)) + @battle.pbDisplay(_INTL("{1} fled from battle!", pbThis)) @battle.decision = 3 pbEndTurn(choice) return true end # Shift with the battler next to this one - if choice[0]==:Shift + if choice[0] == :Shift idxOther = -1 case @battle.pbSideSize(@index) when 2 - idxOther = (@index+2)%4 + idxOther = (@index + 2) % 4 when 3 - if @index!=2 && @index!=3 # If not in middle spot already - idxOther = ((@index%2)==0) ? 2 : 3 + if @index != 2 && @index != 3 # If not in middle spot already + idxOther = ((@index % 2) == 0) ? 2 : 3 end end - if idxOther>=0 - @battle.pbSwapBattlers(@index,idxOther) + if idxOther >= 0 + @battle.pbSwapBattlers(@index, idxOther) case @battle.pbSideSize(@index) when 2 - @battle.pbDisplay(_INTL("{1} moved across!",pbThis)) + @battle.pbDisplay(_INTL("{1} moved across!", pbThis)) when 3 - @battle.pbDisplay(_INTL("{1} moved to the center!",pbThis)) + @battle.pbDisplay(_INTL("{1} moved to the center!", pbThis)) end end pbBeginTurn(choice) @@ -40,7 +40,7 @@ class Battle::Battler return true end # If this battler's action for this round wasn't "use a move" - if choice[0]!=:UseMove + if choice[0] != :UseMove # Clean up effects that end at battler's turn pbBeginTurn(choice) pbEndTurn(choice) @@ -57,7 +57,7 @@ class Battle::Battler # Use the move PBDebug.log("[Move usage] #{pbThis} started using #{choice[2].name}") PBDebug.logonerr { - pbUseMove(choice,choice[2]==@battle.struggle) + pbUseMove(choice, choice[2] == @battle.struggle) } @battle.pbJudge # Update priority order @@ -77,7 +77,7 @@ class Battle::Battler @effects[PBEffects::MoveNext] = false @effects[PBEffects::Quash] = 0 # Encore's effect ends if the encored move is no longer available - if @effects[PBEffects::Encore]>0 && pbEncoredMoveIndex<0 + if @effects[PBEffects::Encore] > 0 && pbEncoredMoveIndex < 0 @effects[PBEffects::Encore] = 0 @effects[PBEffects::EncoreMove] = nil end @@ -91,8 +91,8 @@ class Battle::Battler def pbCancelMoves(full_cancel = false) # Outragers get confused anyway if they are disrupted during their final # turn of using the move - if @effects[PBEffects::Outrage]==1 && pbCanConfuseSelf?(false) && !full_cancel - pbConfuse(_INTL("{1} became confused due to fatigue!",pbThis)) + if @effects[PBEffects::Outrage] == 1 && pbCanConfuseSelf?(false) && !full_cancel + pbConfuse(_INTL("{1} became confused due to fatigue!", pbThis)) end # Cancel usage of most multi-turn moves @effects[PBEffects::TwoTurnAttack] = nil @@ -102,13 +102,13 @@ class Battle::Battler @effects[PBEffects::Bide] = 0 @currentMove = nil # Reset counters for moves which increase them when used in succession - @effects[PBEffects::FuryCutter] = 0 + @effects[PBEffects::FuryCutter] = 0 end def pbEndTurn(_choice) @lastRoundMoved = @battle.turnCount # Done something this round if !@effects[PBEffects::ChoiceBand] && - (hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) || + (hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) || hasActiveAbility?(:GORILLATACTICS)) if @lastMoveUsed && pbHasMove?(@lastMoveUsed) @effects[PBEffects::ChoiceBand] = @lastMoveUsed @@ -117,7 +117,7 @@ class Battle::Battler end end @effects[PBEffects::BeakBlast] = false - @effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge]==1 + @effects[PBEffects::Charge] = 0 if @effects[PBEffects::Charge] == 1 @effects[PBEffects::GemConsumed] = nil @effects[PBEffects::ShellTrap] = false @battle.allBattlers.each { |b| b.pbContinualAbilityChecks } # Trace, end primordial weathers @@ -125,16 +125,16 @@ class Battle::Battler def pbConfusionDamage(msg) @damageState.reset - confusionMove = Battle::Move::Confusion.new(@battle,nil) + confusionMove = Battle::Move::Confusion.new(@battle, nil) confusionMove.calcType = confusionMove.pbCalcType(self) # nil - @damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType,self,self) # 8 - confusionMove.pbCheckDamageAbsorption(self,self) - confusionMove.pbCalcDamage(self,self) - confusionMove.pbReduceDamage(self,self) + @damageState.typeMod = confusionMove.pbCalcTypeMod(confusionMove.calcType, self, self) # 8 + confusionMove.pbCheckDamageAbsorption(self, self) + confusionMove.pbCalcDamage(self, self) + confusionMove.pbReduceDamage(self, self) self.hp -= @damageState.hpLost - confusionMove.pbAnimateHitAndHPLost(self,[self]) + confusionMove.pbAnimateHitAndHPLost(self, [self]) @battle.pbDisplay(msg) # "It hurt itself in its confusion!" - confusionMove.pbRecordDamageLost(self,self) + confusionMove.pbRecordDamageLost(self, self) confusionMove.pbEndureKOMessage(self) pbFaint if fainted? pbItemHPHealCheck @@ -144,11 +144,11 @@ class Battle::Battler # Simple "use move" method, used when a move calls another move and for Future # Sight's attack #============================================================================= - def pbUseMoveSimple(moveID,target = -1,idxMove = -1,specialUsage = true) + def pbUseMoveSimple(moveID, target = -1, idxMove = -1, specialUsage = true) choice = [] choice[0] = :UseMove # "Use move" choice[1] = idxMove # Index of move to be used in user's moveset - if idxMove>=0 + if idxMove >= 0 choice[2] = @moves[idxMove] else choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(moveID)) @@ -156,27 +156,27 @@ class Battle::Battler end choice[3] = target # Target (-1 means no target yet) PBDebug.log("[Move usage] #{pbThis} started using the called/simple move #{choice[2].name}") - pbUseMove(choice,specialUsage) + pbUseMove(choice, specialUsage) end #============================================================================= # Master "use move" method #============================================================================= - def pbUseMove(choice,specialUsage = false) + def pbUseMove(choice, specialUsage = false) # NOTE: This is intentionally determined before a multi-turn attack can # set specialUsage to true. - skipAccuracyCheck = (specialUsage && choice[2]!=@battle.struggle) + skipAccuracyCheck = (specialUsage && choice[2] != @battle.struggle) # Start using the move pbBeginTurn(choice) # Force the use of certain moves if they're already being used if usingMultiTurnAttack? choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(@currentMove)) specialUsage = true - elsif @effects[PBEffects::Encore]>0 && choice[1]>=0 && + elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 && @battle.pbCanShowCommands?(@index) idxEncoredMove = pbEncoredMoveIndex - if idxEncoredMove>=0 && @battle.pbCanChooseMove?(@index,idxEncoredMove,false) - if choice[1]!=idxEncoredMove # Change move if battler was Encored mid-round + if idxEncoredMove >= 0 && @battle.pbCanChooseMove?(@index, idxEncoredMove, false) + if choice[1] != idxEncoredMove # Change move if battler was Encored mid-round choice[1] = idxEncoredMove choice[2] = @moves[idxEncoredMove] choice[3] = -1 # No target chosen @@ -188,7 +188,7 @@ class Battle::Battler return if !move # if move was not chosen somehow # Try to use the move (inc. disobedience) @lastMoveFailed = false - if !pbTryUseMove(choice,move,specialUsage,skipAccuracyCheck) + if !pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck) @lastMoveUsed = nil @lastMoveUsedType = nil if !specialUsage @@ -205,7 +205,7 @@ class Battle::Battler # Subtract PP if !specialUsage if !pbReducePP(move) - @battle.pbDisplay(_INTL("{1} used {2}!",pbThis,move.name)) + @battle.pbDisplay(_INTL("{1} used {2}!", pbThis, move.name)) @battle.pbDisplay(_INTL("But there was no PP left for the move!")) @lastMoveUsed = nil @lastMoveUsedType = nil @@ -220,9 +220,9 @@ class Battle::Battler # Stance Change if isSpecies?(:AEGISLASH) && self.ability == :STANCECHANGE if move.damagingMove? - pbChangeForm(1,_INTL("{1} changed to Blade Forme!",pbThis)) + pbChangeForm(1, _INTL("{1} changed to Blade Forme!", pbThis)) elsif move.id == :KINGSSHIELD - pbChangeForm(0,_INTL("{1} changed to Shield Forme!",pbThis)) + pbChangeForm(0, _INTL("{1} changed to Shield Forme!", pbThis)) end end # Calculate the move's type during this usage @@ -238,10 +238,10 @@ class Battle::Battler @effects[PBEffects::TwoTurnAttack] = nil # Cancel use of two-turn attack end # Add to counters for moves which increase them when used in succession - move.pbChangeUsageCounters(self,specialUsage) + move.pbChangeUsageCounters(self, specialUsage) # Charge up Metronome item if hasActiveItem?(:METRONOME) && !move.callsAnotherMove? - if @lastMoveUsed && @lastMoveUsed==move.id && !@lastMoveFailed + if @lastMoveUsed && @lastMoveUsed == move.id && !@lastMoveFailed @effects[PBEffects::Metronome] += 1 else @effects[PBEffects::Metronome] = 0 @@ -259,10 +259,10 @@ class Battle::Battler @battle.lastMoveUser = @index # For "self KO" battle clause to avoid draws @battle.successStates[@index].useState = 1 # Battle Arena - assume failure # Find the default user (self or Snatcher) and target(s) - user = pbFindUser(choice,move) - user = pbChangeUser(choice,move,user) - targets = pbFindTargets(choice,move,user) - targets = pbChangeTargets(move,user,targets) + user = pbFindUser(choice, move) + user = pbChangeUser(choice, move, user) + targets = pbFindTargets(choice, move, user) + targets = pbChangeTargets(move, user, targets) # Pressure if !specialUsage targets.each do |b| @@ -282,9 +282,9 @@ class Battle::Battler @battle.pbPriority(true).each do |b| next if !b || !b.abilityActive? if Battle::AbilityEffects.triggerMoveBlocking(b.ability, b, user, targets, move, @battle) - @battle.pbDisplayBrief(_INTL("{1} used {2}!",user.pbThis,move.name)) + @battle.pbDisplayBrief(_INTL("{1} used {2}!", user.pbThis, move.name)) @battle.pbShowAbilitySplash(b) - @battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,move.name)) + @battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, move.name)) @battle.pbHideAbilitySplash(b) user.lastMoveFailed = true pbCancelMoves @@ -301,11 +301,11 @@ class Battle::Battler # Snatch's message (user is the new user, self is the original user) if move.snatched @lastMoveFailed = true # Intentionally applies to self, not user - @battle.pbDisplay(_INTL("{1} snatched {2}'s move!",user.pbThis,pbThis(true))) + @battle.pbDisplay(_INTL("{1} snatched {2}'s move!", user.pbThis, pbThis(true))) end # "But it failed!" checks - if move.pbMoveFailed?(user,targets) - PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?",move.function)) + if move.pbMoveFailed?(user, targets) + PBDebug.log(sprintf("[Move failed] In function code %s's def pbMoveFailed?", move.function)) user.lastMoveFailed = true pbCancelMoves pbEndTurn(choice) @@ -313,15 +313,15 @@ class Battle::Battler end # Perform set-up actions and display messages # Messages include Magnitude's number and Pledge moves' "it's a combo!" - move.pbOnStartUse(user,targets) + move.pbOnStartUse(user, targets) # Self-thawing due to the move if user.status == :FROZEN && move.thawsUser? user.pbCureStatus(false) - @battle.pbDisplay(_INTL("{1} melted the ice!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} melted the ice!", user.pbThis)) end # Powder if user.effects[PBEffects::Powder] && move.calcType == :FIRE - @battle.pbCommonAnimation("Powder",user) + @battle.pbCommonAnimation("Powder", user) @battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!")) user.lastMoveFailed = true if ![:Rain, :HeavyRain].include?(user.effectiveWeather) && user.takesIndirectDamage? @@ -361,15 +361,15 @@ class Battle::Battler @battle.pbShowAbilitySplash(user) user.pbChangeTypes(move.calcType) typeName = GameData::Type.get(move.calcType).name - @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName)) @battle.pbHideAbilitySplash(user) # NOTE: The GF games say that if Curse is used by a non-Ghost-type # Pokémon which becomes Ghost-type because of Protean, it should # target and curse itself. I think this is silly, so I'm making it # choose a random opponent to curse instead. - if move.function=="CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length==0 + if move.function == "CurseTargetOrLowerUserSpd1RaiseUserAtkDef1" && targets.length == 0 choice[3] = -1 - targets = pbFindTargets(choice,move,user) + targets = pbFindTargets(choice, move, user) end end end @@ -394,7 +394,7 @@ class Battle::Battler b.damageState.unaffected = true end # Magic Coat/Magic Bounce checks (for moves which don't target Pokémon) - if targets.length==0 && move.statusMove? && move.canMagicCoat? + if targets.length == 0 && move.statusMove? && move.canMagicCoat? @battle.pbPriority(true).each do |b| next if b.fainted? || !b.opposes?(user) next if b.semiInvulnerable? @@ -411,14 +411,14 @@ class Battle::Battler end end # Get the number of hits - numHits = move.pbNumHits(user,targets) + numHits = move.pbNumHits(user, targets) # Process each hit in turn realNumHits = 0 for i in 0...numHits - break if magicCoater>=0 || magicBouncer>=0 - success = pbProcessMoveHit(move,user,targets,i,skipAccuracyCheck) + break if magicCoater >= 0 || magicBouncer >= 0 + success = pbProcessMoveHit(move, user, targets, i, skipAccuracyCheck) if !success - if i==0 && targets.length>0 + if i == 0 && targets.length > 0 hasFailed = false targets.each do |t| next if t.damageState.protected @@ -439,7 +439,7 @@ class Battle::Battler end # Battle Arena only - attack is successful @battle.successStates[user.index].useState = 2 - if targets.length>0 + if targets.length > 0 @battle.successStates[user.index].typeMod = 0 targets.each do |b| next if b.damageState.unaffected @@ -449,17 +449,17 @@ class Battle::Battler # Effectiveness message for multi-hit moves # NOTE: No move is both multi-hit and multi-target, and the messages below # aren't quite right for such a hypothetical move. - if numHits>1 + if numHits > 1 if move.damagingMove? targets.each do |b| next if b.damageState.unaffected || b.damageState.substitute - move.pbEffectivenessMessage(user,b,targets.length) + move.pbEffectivenessMessage(user, b, targets.length) end end - if realNumHits==1 + if realNumHits == 1 @battle.pbDisplay(_INTL("Hit 1 time!")) - elsif realNumHits>1 - @battle.pbDisplay(_INTL("Hit {1} times!",realNumHits)) + elsif realNumHits > 1 + @battle.pbDisplay(_INTL("Hit {1} times!", realNumHits)) end end # Magic Coat's bouncing back (move has targets) @@ -467,38 +467,38 @@ class Battle::Battler next if b.fainted? next if !b.damageState.magicCoat && !b.damageState.magicBounce @battle.pbShowAbilitySplash(b) if b.damageState.magicBounce - @battle.pbDisplay(_INTL("{1} bounced the {2} back!",b.pbThis,move.name)) + @battle.pbDisplay(_INTL("{1} bounced the {2} back!", b.pbThis, move.name)) @battle.pbHideAbilitySplash(b) if b.damageState.magicBounce newChoice = choice.clone newChoice[3] = user.index - newTargets = pbFindTargets(newChoice,move,b) - newTargets = pbChangeTargets(move,b,newTargets) - success = pbProcessMoveHit(move,b,newTargets,0,false) + newTargets = pbFindTargets(newChoice, move, b) + newTargets = pbChangeTargets(move, b, newTargets) + success = pbProcessMoveHit(move, b, newTargets, 0, false) b.lastMoveFailed = true if !success targets.each { |otherB| otherB.pbFaint if otherB && otherB.fainted? } user.pbFaint if user.fainted? end # Magic Coat's bouncing back (move has no targets) - if magicCoater>=0 || magicBouncer>=0 - mc = @battle.battlers[(magicCoater>=0) ? magicCoater : magicBouncer] + if magicCoater >= 0 || magicBouncer >= 0 + mc = @battle.battlers[(magicCoater >= 0) ? magicCoater : magicBouncer] if !mc.fainted? user.lastMoveFailed = true - @battle.pbShowAbilitySplash(mc) if magicBouncer>=0 - @battle.pbDisplay(_INTL("{1} bounced the {2} back!",mc.pbThis,move.name)) - @battle.pbHideAbilitySplash(mc) if magicBouncer>=0 - success = pbProcessMoveHit(move,mc,[],0,false) + @battle.pbShowAbilitySplash(mc) if magicBouncer >= 0 + @battle.pbDisplay(_INTL("{1} bounced the {2} back!", mc.pbThis, move.name)) + @battle.pbHideAbilitySplash(mc) if magicBouncer >= 0 + success = pbProcessMoveHit(move, mc, [], 0, false) mc.lastMoveFailed = true if !success targets.each { |b| b.pbFaint if b && b.fainted? } user.pbFaint if user.fainted? end end # Move-specific effects after all hits - targets.each { |b| move.pbEffectAfterAllHits(user,b) } + targets.each { |b| move.pbEffectAfterAllHits(user, b) } # Faint if 0 HP targets.each { |b| b.pbFaint if b && b.fainted? } user.pbFaint if user.fainted? # External/general effects after all hits. Eject Button, Shell Bell, etc. - pbEffectsAfterMove(user,targets,move,realNumHits) + pbEffectsAfterMove(user, targets, move, realNumHits) @battle.allBattlers.each do |b| b.droppedBelowHalfHP = false b.statsDropped = false @@ -511,7 +511,7 @@ class Battle::Battler # Battle Arena only - update skills @battle.allBattlers.each { |b| @battle.successStates[b.index].updateSkill } # Shadow Pokémon triggering Hyper Mode - pbHyperMode if @battle.choices[@index][0]!=:None # Not if self is replaced + pbHyperMode if @battle.choices[@index][0] != :None # Not if self is replaced # End of move usage pbEndTurn(choice) # Instruct @@ -519,56 +519,56 @@ class Battle::Battler next if !b.effects[PBEffects::Instruct] || !b.lastMoveUsed b.effects[PBEffects::Instruct] = false idxMove = -1 - b.eachMoveWithIndex { |m,i| idxMove = i if m.id==b.lastMoveUsed } - next if idxMove<0 + b.eachMoveWithIndex { |m, i| idxMove = i if m.id == b.lastMoveUsed } + next if idxMove < 0 oldLastRoundMoved = b.lastRoundMoved - @battle.pbDisplay(_INTL("{1} used the move instructed by {2}!",b.pbThis,user.pbThis(true))) + @battle.pbDisplay(_INTL("{1} used the move instructed by {2}!", b.pbThis, user.pbThis(true))) b.effects[PBEffects::Instructed] = true if b.pbCanChooseMove?(@moves[idxMove], false) PBDebug.logonerr { - b.pbUseMoveSimple(b.lastMoveUsed,b.lastRegularMoveTarget,idxMove,false) + b.pbUseMoveSimple(b.lastMoveUsed, b.lastRegularMoveTarget, idxMove, false) } b.lastRoundMoved = oldLastRoundMoved @battle.pbJudge - return if @battle.decision>0 + return if @battle.decision > 0 end b.effects[PBEffects::Instructed] = false end # Dancer - if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits>0 && - !move.snatched && magicCoater<0 && @battle.pbCheckGlobalAbility(:DANCER) && + if !@effects[PBEffects::Dancer] && !user.lastMoveFailed && realNumHits > 0 && + !move.snatched && magicCoater < 0 && @battle.pbCheckGlobalAbility(:DANCER) && move.danceMove? dancers = [] @battle.pbPriority(true).each do |b| - dancers.push(b) if b.index!=user.index && b.hasActiveAbility?(:DANCER) + dancers.push(b) if b.index != user.index && b.hasActiveAbility?(:DANCER) end - while dancers.length>0 + while dancers.length > 0 nextUser = dancers.pop oldLastRoundMoved = nextUser.lastRoundMoved # NOTE: Petal Dance being used because of Dancer shouldn't lock the # Dancer into using that move, and shouldn't contribute to its # turn counter if it's already locked into Petal Dance. oldOutrage = nextUser.effects[PBEffects::Outrage] - nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage]>0 + nextUser.effects[PBEffects::Outrage] += 1 if nextUser.effects[PBEffects::Outrage] > 0 oldCurrentMove = nextUser.currentMove preTarget = choice[3] preTarget = user.index if nextUser.opposes?(user) || !nextUser.opposes?(preTarget) - @battle.pbShowAbilitySplash(nextUser,true) + @battle.pbShowAbilitySplash(nextUser, true) @battle.pbHideAbilitySplash(nextUser) if !Battle::Scene::USE_ABILITY_SPLASH @battle.pbDisplay(_INTL("{1} kept the dance going with {2}!", - nextUser.pbThis,nextUser.abilityName)) + nextUser.pbThis, nextUser.abilityName)) end nextUser.effects[PBEffects::Dancer] = true if nextUser.pbCanChooseMove?(move, false) PBDebug.logonerr { - nextUser.pbUseMoveSimple(move.id,preTarget) + nextUser.pbUseMoveSimple(move.id, preTarget) } nextUser.lastRoundMoved = oldLastRoundMoved nextUser.effects[PBEffects::Outrage] = oldOutrage nextUser.currentMove = oldCurrentMove @battle.pbJudge - return if @battle.decision>0 + return if @battle.decision > 0 end nextUser.effects[PBEffects::Dancer] = false end @@ -578,19 +578,19 @@ class Battle::Battler #============================================================================= # Attack a single target #============================================================================= - def pbProcessMoveHit(move,user,targets,hitNum,skipAccuracyCheck) + def pbProcessMoveHit(move, user, targets, hitNum, skipAccuracyCheck) return false if user.fainted? # For two-turn attacks being used in a single turn - move.pbInitialEffect(user,targets,hitNum) + move.pbInitialEffect(user, targets, hitNum) numTargets = 0 # Number of targets that are affected by this hit # Count a hit for Parental Bond (if it applies) - user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond]>0 + user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond] > 0 # Accuracy check (accuracy/evasion calc) - if hitNum==0 || move.successCheckPerHit? + if hitNum == 0 || move.successCheckPerHit? targets.each do |b| b.damageState.missed = false next if b.damageState.unaffected - if pbSuccessCheckPerHit(move,user,b,skipAccuracyCheck) + if pbSuccessCheckPerHit(move, user, b, skipAccuracyCheck) numTargets += 1 else b.damageState.missed = true @@ -598,10 +598,10 @@ class Battle::Battler end end # If failed against all targets - if targets.length>0 && numTargets==0 && !move.worksWithNoTargets? + if targets.length > 0 && numTargets == 0 && !move.worksWithNoTargets? targets.each do |b| next if !b.damageState.missed || b.damageState.magicCoat - pbMissMessage(move,user,b) + pbMissMessage(move, user, b) if user.itemActive? Battle::ItemEffects.triggerOnMissingTarget(user.item, user, b, move, hitNum, @battle) end @@ -623,25 +623,25 @@ class Battle::Battler targets.each do |b| next if b.damageState.unaffected # Check whether Substitute/Disguise will absorb the damage - move.pbCheckDamageAbsorption(user,b) + move.pbCheckDamageAbsorption(user, b) # Calculate the damage against b # pbCalcDamage shows the "eat berry" animation for SE-weakening # berries, although the message about it comes after the additional # effect below - move.pbCalcDamage(user,b,targets.length) # Stored in damageState.calcDamage + move.pbCalcDamage(user, b, targets.length) # Stored in damageState.calcDamage # Lessen damage dealt because of False Swipe/Endure/etc. - move.pbReduceDamage(user,b) # Stored in damageState.hpLost + move.pbReduceDamage(user, b) # Stored in damageState.hpLost end end # Show move animation (for this hit) - move.pbShowAnimation(move.id,user,targets,hitNum) + move.pbShowAnimation(move.id, user, targets, hitNum) # Type-boosting Gem consume animation/message - if user.effects[PBEffects::GemConsumed] && hitNum==0 + if user.effects[PBEffects::GemConsumed] && hitNum == 0 # NOTE: The consume animation and message for Gems are shown now, but the # actual removal of the item happens in def pbEffectsAfterMove. - @battle.pbCommonAnimation("UseItem",user) + @battle.pbCommonAnimation("UseItem", user) @battle.pbDisplay(_INTL("The {1} strengthened {2}'s power!", - GameData::Item.get(user.effects[PBEffects::GemConsumed]).name,move.name)) + GameData::Item.get(user.effects[PBEffects::GemConsumed]).name, move.name)) end # Messages about missed target(s) (relevant for multi-target moves only) if !move.pbRepeatHit? @@ -659,29 +659,29 @@ class Battle::Battler # This just changes the HP amounts and does nothing else targets.each { |b| move.pbInflictHPDamage(b) if !b.damageState.unaffected } # Animate the hit flashing and HP bar changes - move.pbAnimateHitAndHPLost(user,targets) + move.pbAnimateHitAndHPLost(user, targets) end # Self-Destruct/Explosion's damaging and fainting of user - move.pbSelfKO(user) if hitNum==0 + move.pbSelfKO(user) if hitNum == 0 user.pbFaint if user.fainted? if move.pbDamagingMove? targets.each do |b| next if b.damageState.unaffected # NOTE: This method is also used for the OHKO special message. - move.pbHitEffectivenessMessages(user,b,targets.length) + move.pbHitEffectivenessMessages(user, b, targets.length) # Record data about the hit for various effects' purposes - move.pbRecordDamageLost(user,b) + move.pbRecordDamageLost(user, b) end # Close Combat/Superpower's stat-lowering, Flame Burst's splash damage, # and Incinerate's berry destruction targets.each do |b| next if b.damageState.unaffected - move.pbEffectWhenDealingDamage(user,b) + move.pbEffectWhenDealingDamage(user, b) end # Ability/item effects such as Static/Rocky Helmet, and Grudge, etc. targets.each do |b| next if b.damageState.unaffected - pbEffectsOnMakingHit(move,user,b) + pbEffectsOnMakingHit(move, user, b) end # Disguise/Endure/Sturdy/Focus Sash/Focus Band messages targets.each do |b| @@ -695,11 +695,11 @@ class Battle::Battler # because Flame Burst's splash damage affects non-targets) @battle.pbPriority(true).each { |b| b.pbFaint if b && b.fainted? } end - @battle.pbJudgeCheckpoint(user,move) + @battle.pbJudgeCheckpoint(user, move) # Main effect (recoil/drain, etc.) targets.each do |b| next if b.damageState.unaffected - move.pbEffectAgainstTarget(user,b) + move.pbEffectAgainstTarget(user, b) end move.pbEffectGeneral(user) targets.each { |b| b.pbFaint if b && b.fainted? } @@ -707,21 +707,21 @@ class Battle::Battler # Additional effect if !user.hasActiveAbility?(:SHEERFORCE) targets.each do |b| - next if b.damageState.calcDamage==0 - chance = move.pbAdditionalEffectChance(user,b) - next if chance<=0 - if @battle.pbRandom(100)=strength - next if b.effects[PBEffects::SkyDrop]>=0 + next if b.effects[PBEffects::Snatch] == 0 || + b.effects[PBEffects::Snatch] >= strength + next if b.effects[PBEffects::SkyDrop] >= 0 newUser = b strength = b.effects[PBEffects::Snatch] end @@ -33,59 +33,59 @@ class Battle::Battler #============================================================================= # Get move's default target(s) #============================================================================= - def pbFindTargets(choice,move,user) + def pbFindTargets(choice, move, user) preTarget = choice[3] # A target that was already chosen targets = [] # Get list of targets case move.pbTarget(user).id # Curse can change its target type when :NearAlly - targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil - if !pbAddTarget(targets,user,targetBattler,move) - pbAddTargetRandomAlly(targets,user,move) + targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil + if !pbAddTarget(targets, user, targetBattler, move) + pbAddTargetRandomAlly(targets, user, move) end when :UserOrNearAlly - targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil - if !pbAddTarget(targets,user,targetBattler,move,true,true) - pbAddTarget(targets,user,user,move,true,true) + targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil + if !pbAddTarget(targets, user, targetBattler, move, true, true) + pbAddTarget(targets, user, user, move, true, true) end when :AllAllies @battle.allSameSideBattlers(user.index).each do |b| - pbAddTarget(targets,user,b,move,false,true) if b.index != user.index + pbAddTarget(targets, user, b, move, false, true) if b.index != user.index end when :UserAndAllies - pbAddTarget(targets,user,user,move,true,true) + pbAddTarget(targets, user, user, move, true, true) @battle.allSameSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move, false, true) } when :NearFoe, :NearOther - targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil - if !pbAddTarget(targets,user,targetBattler,move) - if preTarget>=0 && !user.opposes?(preTarget) - pbAddTargetRandomAlly(targets,user,move) + targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil + if !pbAddTarget(targets, user, targetBattler, move) + if preTarget >= 0 && !user.opposes?(preTarget) + pbAddTargetRandomAlly(targets, user, move) else - pbAddTargetRandomFoe(targets,user,move) + pbAddTargetRandomFoe(targets, user, move) end end when :RandomNearFoe - pbAddTargetRandomFoe(targets,user,move) + pbAddTargetRandomFoe(targets, user, move) when :AllNearFoes - @battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets,user,b,move) } + @battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move) } when :Foe, :Other - targetBattler = (preTarget>=0) ? @battle.battlers[preTarget] : nil - if !pbAddTarget(targets,user,targetBattler,move,false) - if preTarget>=0 && !user.opposes?(preTarget) - pbAddTargetRandomAlly(targets,user,move,false) + targetBattler = (preTarget >= 0) ? @battle.battlers[preTarget] : nil + if !pbAddTarget(targets, user, targetBattler, move, false) + if preTarget >= 0 && !user.opposes?(preTarget) + pbAddTargetRandomAlly(targets, user, move, false) else - pbAddTargetRandomFoe(targets,user,move,false) + pbAddTargetRandomFoe(targets, user, move, false) end end when :AllFoes - @battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets,user,b,move,false) } + @battle.allOtherSideBattlers(user.index).each { |b| pbAddTarget(targets, user, b, move, false) } when :AllNearOthers @battle.allBattlers.each { |b| pbAddTarget(targets, user, b, move) } when :AllBattlers @battle.allBattlers.each { |b| pbAddTarget(targets, user, b, move, false, true) } else # Used by Counter/Mirror Coat/Metal Burst/Bide - move.pbAddTarget(targets,user) # Move-specific pbAddTarget, not the def below + move.pbAddTarget(targets, user) # Move-specific pbAddTarget, not the def below end return targets end @@ -93,7 +93,7 @@ class Battle::Battler #============================================================================= # Redirect attack to another target #============================================================================= - def pbChangeTargets(move,user,targets) + def pbChangeTargets(move, user, targets) target_data = move.pbTarget(user) return targets if @battle.switching # For Pursuit interrupting a switch return targets if move.cannotRedirect? || move.targetsPosition? @@ -106,9 +106,9 @@ class Battle::Battler newTarget = nil strength = 100 # Lower strength takes priority priority.each do |b| - next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0 - next if b.effects[PBEffects::Spotlight]==0 || - b.effects[PBEffects::Spotlight]>=strength + next if b.fainted? || b.effects[PBEffects::SkyDrop] >= 0 + next if b.effects[PBEffects::Spotlight] == 0 || + b.effects[PBEffects::Spotlight] >= strength next if !b.opposes?(user) next if nearOnly && !b.near?(user) newTarget = b @@ -117,17 +117,17 @@ class Battle::Battler if newTarget PBDebug.log("[Move target changed] #{newTarget.pbThis}'s Spotlight made it the target") targets = [] - pbAddTarget(targets,user,newTarget,move,nearOnly) + pbAddTarget(targets, user, newTarget, move, nearOnly) return targets end # Follow Me/Rage Powder (takes priority over Lightning Rod/Storm Drain) newTarget = nil strength = 100 # Lower strength takes priority priority.each do |b| - next if b.fainted? || b.effects[PBEffects::SkyDrop]>=0 + next if b.fainted? || b.effects[PBEffects::SkyDrop] >= 0 next if b.effects[PBEffects::RagePowder] && !user.affectedByPowder? - next if b.effects[PBEffects::FollowMe]==0 || - b.effects[PBEffects::FollowMe]>=strength + next if b.effects[PBEffects::FollowMe] == 0 || + b.effects[PBEffects::FollowMe] >= strength next if !b.opposes?(user) next if nearOnly && !b.near?(user) newTarget = b @@ -136,30 +136,30 @@ class Battle::Battler if newTarget PBDebug.log("[Move target changed] #{newTarget.pbThis}'s Follow Me/Rage Powder made it the target") targets = [] - pbAddTarget(targets,user,newTarget,move,nearOnly) + pbAddTarget(targets, user, newTarget, move, nearOnly) return targets end # Lightning Rod - targets = pbChangeTargetByAbility(:LIGHTNINGROD,:ELECTRIC,move,user,targets,priority,nearOnly) + targets = pbChangeTargetByAbility(:LIGHTNINGROD, :ELECTRIC, move, user, targets, priority, nearOnly) # Storm Drain - targets = pbChangeTargetByAbility(:STORMDRAIN,:WATER,move,user,targets,priority,nearOnly) + targets = pbChangeTargetByAbility(:STORMDRAIN, :WATER, move, user, targets, priority, nearOnly) return targets end - def pbChangeTargetByAbility(drawingAbility,drawnType,move,user,targets,priority,nearOnly) + def pbChangeTargetByAbility(drawingAbility, drawnType, move, user, targets, priority, nearOnly) return targets if move.calcType != drawnType return targets if targets[0].hasActiveAbility?(drawingAbility) priority.each do |b| - next if b.index==user.index || b.index==targets[0].index + next if b.index == user.index || b.index == targets[0].index next if !b.hasActiveAbility?(drawingAbility) next if nearOnly && !b.near?(user) @battle.pbShowAbilitySplash(b) targets.clear - pbAddTarget(targets,user,b,move,nearOnly) + pbAddTarget(targets, user, b, move, nearOnly) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} took the attack!",b.pbThis)) + @battle.pbDisplay(_INTL("{1} took the attack!", b.pbThis)) else - @battle.pbDisplay(_INTL("{1} took the attack with its {2}!",b.pbThis,b.abilityName)) + @battle.pbDisplay(_INTL("{1} took the attack with its {2}!", b.pbThis, b.abilityName)) end @battle.pbHideAbilitySplash(b) break @@ -170,11 +170,11 @@ class Battle::Battler #============================================================================= # Register target #============================================================================= - def pbAddTarget(targets,user,target,move,nearOnly = true,allowUser = false) + def pbAddTarget(targets, user, target, move, nearOnly = true, allowUser = false) return false if !target || (target.fainted? && !move.targetsPosition?) return false if !allowUser && target == user return false if nearOnly && !user.near?(target) && target != user - targets.each { |b| return true if b.index==target.index } # Already added + targets.each { |b| return true if b.index == target.index } # Already added targets.push(target) return true end @@ -185,7 +185,7 @@ class Battle::Battler next if nearOnly && !user.near?(b) pbAddTarget(choices, user, b, move, nearOnly) end - if choices.length>0 + if choices.length > 0 pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly) end end @@ -196,7 +196,7 @@ class Battle::Battler next if nearOnly && !user.near?(b) pbAddTarget(choices, user, b, move, nearOnly) end - if choices.length>0 + if choices.length > 0 pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly) end end diff --git a/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb b/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb index 087fce1d9..a22aa8683 100644 --- a/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb +++ b/Data/Scripts/011_Battle/002_Battler/009_Battler_UseMoveSuccessChecks.rb @@ -7,35 +7,35 @@ class Battle::Battler # earlier in the same round (after choosing the command but before using the # move) or an unusable move may be called by another move such as Metronome. #============================================================================= - def pbCanChooseMove?(move,commandPhase,showMessages = true,specialUsage = false) + def pbCanChooseMove?(move, commandPhase, showMessages = true, specialUsage = false) # Disable - if @effects[PBEffects::DisableMove]==move.id && !specialUsage + if @effects[PBEffects::DisableMove] == move.id && !specialUsage if showMessages - msg = _INTL("{1}'s {2} is disabled!",pbThis,move.name) + msg = _INTL("{1}'s {2} is disabled!", pbThis, move.name) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false end # Heal Block - if @effects[PBEffects::HealBlock]>0 && move.healingMove? + if @effects[PBEffects::HealBlock] > 0 && move.healingMove? if showMessages - msg = _INTL("{1} can't use {2} because of Heal Block!",pbThis,move.name) + msg = _INTL("{1} can't use {2} because of Heal Block!", pbThis, move.name) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false end # Gravity - if @battle.field.effects[PBEffects::Gravity]>0 && move.unusableInGravity? + if @battle.field.effects[PBEffects::Gravity] > 0 && move.unusableInGravity? if showMessages - msg = _INTL("{1} can't use {2} because of gravity!",pbThis,move.name) + msg = _INTL("{1} can't use {2} because of gravity!", pbThis, move.name) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false end # Throat Chop - if @effects[PBEffects::ThroatChop]>0 && move.soundMove? + if @effects[PBEffects::ThroatChop] > 0 && move.soundMove? if showMessages - msg = _INTL("{1} can't use {2} because of Throat Chop!",pbThis,move.name) + msg = _INTL("{1} can't use {2} because of Throat Chop!", pbThis, move.name) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false @@ -46,7 +46,7 @@ class Battle::Battler choiced_move_name = GameData::Move.get(@effects[PBEffects::ChoiceBand]).name if hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) if showMessages - msg = _INTL("The {1} only allows the use of {2}!",itemName, choiced_move_name) + msg = _INTL("The {1} only allows the use of {2}!", itemName, choiced_move_name) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false @@ -59,18 +59,18 @@ class Battle::Battler end end # Taunt - if @effects[PBEffects::Taunt]>0 && move.statusMove? + if @effects[PBEffects::Taunt] > 0 && move.statusMove? if showMessages - msg = _INTL("{1} can't use {2} after the taunt!",pbThis,move.name) + msg = _INTL("{1} can't use {2} after the taunt!", pbThis, move.name) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false end # Torment if @effects[PBEffects::Torment] && !@effects[PBEffects::Instructed] && - @lastMoveUsed && move.id==@lastMoveUsed && move.id!=@battle.struggle.id + @lastMoveUsed && move.id == @lastMoveUsed && move.id != @battle.struggle.id if showMessages - msg = _INTL("{1} can't use the same move twice in a row due to the torment!",pbThis) + msg = _INTL("{1} can't use the same move twice in a row due to the torment!", pbThis) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false @@ -78,7 +78,7 @@ class Battle::Battler # Imprison if @battle.allOtherSideBattlers(@index).any? { |b| b.effects[PBEffects::Imprison] && b.pbHasMove?(move.id) } if showMessages - msg = _INTL("{1} can't use its sealed {2}!",pbThis,move.name) + msg = _INTL("{1} can't use its sealed {2}!", pbThis, move.name) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false @@ -94,7 +94,7 @@ class Battle::Battler return false end # Belch - return false if !move.pbCanChooseMove?(self,commandPhase,showMessages) + return false if !move.pbCanChooseMove?(self, commandPhase, showMessages) return true end @@ -105,7 +105,7 @@ class Battle::Battler # use a different move in disobedience), or false if attack stops. def pbObedienceCheck?(choice) return true if usingMultiTurnAttack? - return true if choice[0]!=:UseMove + return true if choice[0] != :UseMove return true if !@battle.internalBattle return true if !@battle.pbOwnedByPlayer?(@index) disobedient = false @@ -115,61 +115,61 @@ class Battle::Battler badgeLevel = 10 * (@battle.pbPlayer.badge_count + 1) badgeLevel = GameData::GrowthRate.max_level if @battle.pbPlayer.badge_count >= 8 if @level > badgeLevel - a = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor - disobedient |= (a>=badgeLevel) + a = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor + disobedient |= (a >= badgeLevel) end end disobedient |= !pbHyperModeObedience(choice[2]) return true if !disobedient # Pokémon is disobedient; make it do something else - return pbDisobey(choice,badgeLevel) + return pbDisobey(choice, badgeLevel) end - def pbDisobey(choice,badgeLevel) + def pbDisobey(choice, badgeLevel) move = choice[2] PBDebug.log("[Disobedience] #{pbThis} disobeyed") @effects[PBEffects::Rage] = false # Do nothing if using Snore/Sleep Talk if @status == :SLEEP && move.usableWhenAsleep? - @battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!",pbThis)) + @battle.pbDisplay(_INTL("{1} ignored orders and kept sleeping!", pbThis)) return false end - b = ((@level+badgeLevel)*@battle.pbRandom(256)/256).floor + b = ((@level + badgeLevel) * @battle.pbRandom(256) / 256).floor # Use another move - if b=0 # Intentionally no message here + if @effects[PBEffects::SkyDrop] >= 0 # Intentionally no message here PBDebug.log("[Move failed] #{pbThis} can't use #{move.name} because of being Sky Dropped") return false end - if @effects[PBEffects::HyperBeam]>0 # Intentionally before Truant - @battle.pbDisplay(_INTL("{1} must recharge!",pbThis)) + if @effects[PBEffects::HyperBeam] > 0 # Intentionally before Truant + @battle.pbDisplay(_INTL("{1} must recharge!", pbThis)) return false end - if choice[1]==-2 # Battle Palace - @battle.pbDisplay(_INTL("{1} appears incapable of using its power!",pbThis)) + if choice[1] == -2 # Battle Palace + @battle.pbDisplay(_INTL("{1} appears incapable of using its power!", pbThis)) return false end # Skip checking all applied effects that could make self fail doing something @@ -206,7 +206,7 @@ class Battle::Battler case @status when :SLEEP self.statusCount -= 1 - if @statusCount<=0 + if @statusCount <= 0 pbCureStatus else pbContinueStatus @@ -217,7 +217,7 @@ class Battle::Battler end when :FROZEN if !move.thawsUser? - if @battle.pbRandom(100)<20 + if @battle.pbRandom(100) < 20 pbCureStatus else pbContinueStatus @@ -233,7 +233,7 @@ class Battle::Battler @effects[PBEffects::Truant] = !@effects[PBEffects::Truant] if !@effects[PBEffects::Truant] # True means loafing, but was just inverted @battle.pbShowAbilitySplash(self) - @battle.pbDisplay(_INTL("{1} is loafing around!",pbThis)) + @battle.pbDisplay(_INTL("{1} is loafing around!", pbThis)) @lastMoveFailed = true @battle.pbHideAbilitySplash(self) return false @@ -241,7 +241,7 @@ class Battle::Battler end # Flinching if @effects[PBEffects::Flinch] - @battle.pbDisplay(_INTL("{1} flinched and couldn't move!",pbThis)) + @battle.pbDisplay(_INTL("{1} flinched and couldn't move!", pbThis)) if abilityActive? Battle::AbilityEffects.triggerOnFlinch(self.ability, self, @battle) end @@ -249,16 +249,16 @@ class Battle::Battler return false end # Confusion - if @effects[PBEffects::Confusion]>0 + if @effects[PBEffects::Confusion] > 0 @effects[PBEffects::Confusion] -= 1 - if @effects[PBEffects::Confusion]<=0 + if @effects[PBEffects::Confusion] <= 0 pbCureConfusion - @battle.pbDisplay(_INTL("{1} snapped out of its confusion.",pbThis)) + @battle.pbDisplay(_INTL("{1} snapped out of its confusion.", pbThis)) else - @battle.pbCommonAnimation("Confusion",self) - @battle.pbDisplay(_INTL("{1} is confused!",pbThis)) + @battle.pbCommonAnimation("Confusion", self) + @battle.pbDisplay(_INTL("{1} is confused!", pbThis)) threshold = (Settings::MECHANICS_GENERATION >= 7) ? 33 : 50 # % chance - if @battle.pbRandom(100)=0 - @battle.pbCommonAnimation("Attract",self) - @battle.pbDisplay(_INTL("{1} is in love with {2}!",pbThis, + if @effects[PBEffects::Attract] >= 0 + @battle.pbCommonAnimation("Attract", self) + @battle.pbDisplay(_INTL("{1} is in love with {2}!", pbThis, @battle.battlers[@effects[PBEffects::Attract]].pbThis(true))) - if @battle.pbRandom(100)<50 - @battle.pbDisplay(_INTL("{1} is immobilized by love!",pbThis)) + if @battle.pbRandom(100) < 50 + @battle.pbDisplay(_INTL("{1} is immobilized by love!", pbThis)) @lastMoveFailed = true return false end @@ -293,7 +293,7 @@ class Battle::Battler #============================================================================= def pbSuccessCheckAgainstTarget(move, user, target, targets) show_message = move.pbShowFailMessages?(targets) - typeMod = move.pbCalcTypeMod(move.calcType,user,target) + typeMod = move.pbCalcTypeMod(move.calcType, user, target) target.damageState.typeMod = typeMod # Two-turn attacks can't fail here in the charging turn return true if user.effects[PBEffects::TwoTurnAttack] @@ -301,12 +301,12 @@ class Battle::Battler return false if move.pbFailsAgainstTarget?(user, target, show_message) # Immunity to priority moves because of Psychic Terrain if @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) && - @battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority + @battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority @battle.pbDisplay(_INTL("{1} surrounds itself with psychic terrain!", target.pbThis)) if show_message return false end # Crafty Shield - if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index!=target.index && + if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index != target.index && move.statusMove? && !move.pbTarget(user).targets_all if show_message @battle.pbCommonAnimation("CraftyShield", target) @@ -318,7 +318,7 @@ class Battle::Battler end if !(user.hasActiveAbility?(:UNSEENFIST) && move.contactMove?) # Wide Guard - if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index!=target.index && + if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index != target.index && move.pbTarget(user).num_targets > 1 && (Settings::MECHANICS_GENERATION >= 7 || move.damagingMove?) if show_message @@ -332,7 +332,7 @@ class Battle::Battler if move.canProtectAgainst? # Quick Guard if target.pbOwnSide.effects[PBEffects::QuickGuard] && - @battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority + @battle.choices[user.index][4] > 0 # Move priority saved from pbCalculatePriority if show_message @battle.pbCommonAnimation("QuickGuard", target) @battle.pbDisplay(_INTL("Quick Guard protected {1}!", target.pbThis(true))) @@ -376,8 +376,8 @@ class Battle::Battler @battle.successStates[user.index].protected = true if move.pbContactMove?(user) && user.affectedByContactEffect? @battle.scene.pbDamageAnimation(user) - user.pbReduceHP(user.totalhp/8,false) - @battle.pbDisplay(_INTL("{1} was hurt!",user.pbThis)) + user.pbReduceHP(user.totalhp / 8, false) + @battle.pbDisplay(_INTL("{1} was hurt!", user.pbThis)) user.pbItemHPHealCheck end return false @@ -391,14 +391,14 @@ class Battle::Battler target.damageState.protected = true @battle.successStates[user.index].protected = true if move.pbContactMove?(user) && user.affectedByContactEffect? - user.pbPoison(target) if user.pbCanPoison?(target,false) + user.pbPoison(target) if user.pbCanPoison?(target, false) end return false end # Obstruct if target.effects[PBEffects::Obstruct] && move.damagingMove? if show_message - @battle.pbCommonAnimation("Obstruct",target) + @battle.pbCommonAnimation("Obstruct", target) @battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis)) end target.damageState.protected = true @@ -468,11 +468,11 @@ class Battle::Battler @battle.pbDisplay(_INTL("{1}'s {2} makes Ground moves miss!", target.pbThis, target.itemName)) if show_message return false end - if target.effects[PBEffects::MagnetRise]>0 + if target.effects[PBEffects::MagnetRise] > 0 @battle.pbDisplay(_INTL("{1} makes Ground moves miss with Magnet Rise!", target.pbThis)) if show_message return false end - if target.effects[PBEffects::Telekinesis]>0 + if target.effects[PBEffects::Telekinesis] > 0 @battle.pbDisplay(_INTL("{1} makes Ground moves miss with Telekinesis!", target.pbThis)) if show_message return false end @@ -505,8 +505,8 @@ class Battle::Battler end end # Substitute - if target.effects[PBEffects::Substitute]>0 && move.statusMove? && - !move.ignoresSubstitute?(user) && user.index!=target.index + if target.effects[PBEffects::Substitute] > 0 && move.statusMove? && + !move.ignoresSubstitute?(user) && user.index != target.index PBDebug.log("[Target immune] #{target.pbThis} is protected by its Substitute") @battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis(true))) if show_message return false @@ -518,14 +518,14 @@ class Battle::Battler # Per-hit success check against the target. # Includes semi-invulnerable move use and accuracy calculation. #============================================================================= - def pbSuccessCheckPerHit(move,user,target,skipAccuracyCheck) + def pbSuccessCheckPerHit(move, user, target, skipAccuracyCheck) # Two-turn attacks can't fail here in the charging turn return true if user.effects[PBEffects::TwoTurnAttack] # Lock-On - return true if user.effects[PBEffects::LockOn]>0 && - user.effects[PBEffects::LockOnPos]==target.index + return true if user.effects[PBEffects::LockOn] > 0 && + user.effects[PBEffects::LockOnPos] == target.index # Toxic - return true if move.pbOverrideSuccessCheckPerHit(user,target) + return true if move.pbOverrideSuccessCheckPerHit(user, target) miss = false hitsInvul = false # No Guard @@ -534,7 +534,7 @@ class Battle::Battler # Future Sight hitsInvul = true if @battle.futureSight # Helping Hand - hitsInvul = true if move.function=="PowerUpAllyMove" + hitsInvul = true if move.function == "PowerUpAllyMove" if !hitsInvul # Semi-invulnerable moves if target.effects[PBEffects::TwoTurnAttack] @@ -550,8 +550,8 @@ class Battle::Battler miss = true end end - if target.effects[PBEffects::SkyDrop]>=0 && - target.effects[PBEffects::SkyDrop]!=user.index + if target.effects[PBEffects::SkyDrop] >= 0 && + target.effects[PBEffects::SkyDrop] != user.index miss = true if !move.hitsFlyingTargets? end end @@ -560,7 +560,7 @@ class Battle::Battler # Called by another move return true if skipAccuracyCheck # Accuracy check - return true if move.pbAccuracyCheck(user,target) # Includes Counter/Mirror Coat + return true if move.pbAccuracyCheck(user, target) # Includes Counter/Mirror Coat end # Missed PBDebug.log("[Move failed] Failed pbAccuracyCheck or target is semi-invulnerable") @@ -570,15 +570,15 @@ class Battle::Battler #============================================================================= # Message shown when a move fails the per-hit success check above. #============================================================================= - def pbMissMessage(move,user,target) + def pbMissMessage(move, user, target) if target.damageState.affection_missed @battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis)) elsif move.pbTarget(user).num_targets > 1 - @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis)) elsif target.effects[PBEffects::TwoTurnAttack] - @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis)) - elsif !move.pbMissMessage(user,target) - @battle.pbDisplay(_INTL("{1}'s attack missed!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis)) + elsif !move.pbMissMessage(user, target) + @battle.pbDisplay(_INTL("{1}'s attack missed!", user.pbThis)) end end end diff --git a/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb b/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb index f8c875e5a..a7eb44f6c 100644 --- a/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb +++ b/Data/Scripts/011_Battle/002_Battler/010_Battler_UseMoveTriggerEffects.rb @@ -2,13 +2,13 @@ class Battle::Battler #============================================================================= # Effect per hit #============================================================================= - def pbEffectsOnMakingHit(move,user,target) - if target.damageState.calcDamage>0 && !target.damageState.substitute + def pbEffectsOnMakingHit(move, user, target) + if target.damageState.calcDamage > 0 && !target.damageState.substitute # Target's ability if target.abilityActive?(true) oldHP = user.hp Battle::AbilityEffects.triggerOnBeingHit(target.ability, user, target, move, @battle) - user.pbItemHPHealCheck if user.hp0 && !target.damageState.substitute && move.physicalMove? + @battle.choices[target.index][0] == :UseMove && !target.movedThisRound? + if target.damageState.hpLost > 0 && !target.damageState.substitute && move.physicalMove? target.tookPhysicalHit = true target.effects[PBEffects::MoveNext] = true target.effects[PBEffects::Quash] = 0 @@ -70,11 +70,11 @@ class Battle::Battler if target.effects[PBEffects::Grudge] && target.fainted? move.pp = 0 @battle.pbDisplay(_INTL("{1}'s {2} lost all of its PP due to the grudge!", - user.pbThis,move.name)) + user.pbThis, move.name)) end # Destiny Bond (recording that it should apply) if target.effects[PBEffects::DestinyBond] && target.fainted? - if user.effects[PBEffects::DestinyBondTarget]<0 + if user.effects[PBEffects::DestinyBondTarget] < 0 user.effects[PBEffects::DestinyBondTarget] = target.index end end @@ -84,7 +84,7 @@ class Battle::Battler #============================================================================= # Effects after all hits (i.e. at end of move usage) #============================================================================= - def pbEffectsAfterMove(user,targets,move,numHits) + def pbEffectsAfterMove(user, targets, move, numHits) # Defrost if move.damagingMove? targets.each do |b| @@ -101,10 +101,10 @@ class Battle::Battler # NOTE: Although Destiny Bond is similar to Grudge, they don't apply at # the same time (although Destiny Bond does check whether it's going # to trigger at the same time as Grudge). - if user.effects[PBEffects::DestinyBondTarget]>=0 && !user.fainted? + if user.effects[PBEffects::DestinyBondTarget] >= 0 && !user.fainted? dbName = @battle.battlers[user.effects[PBEffects::DestinyBondTarget]].pbThis - @battle.pbDisplay(_INTL("{1} took its attacker down with it!",dbName)) - user.pbReduceHP(user.hp,false) + @battle.pbDisplay(_INTL("{1} took its attacker down with it!", dbName)) + user.pbReduceHP(user.hp, false) user.pbItemHPHealCheck user.pbFaint @battle.pbJudgeCheckpoint(user) @@ -117,15 +117,15 @@ class Battle::Battler if !user.fainted? && !user.effects[PBEffects::Transform] && user.isSpecies?(:GRENINJA) && user.ability == :BATTLEBOND if !@battle.pbAllFainted?(user.idxOpposingSide) && - !@battle.battleBond[user.index&1][user.pokemonIndex] + !@battle.battleBond[user.index & 1][user.pokemonIndex] numFainted = 0 targets.each { |b| numFainted += 1 if b.damageState.fainted } - if numFainted>0 && user.form==1 - @battle.battleBond[user.index&1][user.pokemonIndex] = true - @battle.pbDisplay(_INTL("{1} became fully charged due to its bond with its Trainer!",user.pbThis)) - @battle.pbShowAbilitySplash(user,true) + if numFainted > 0 && user.form == 1 + @battle.battleBond[user.index & 1][user.pokemonIndex] = true + @battle.pbDisplay(_INTL("{1} became fully charged due to its bond with its Trainer!", user.pbThis)) + @battle.pbShowAbilitySplash(user, true) @battle.pbHideAbilitySplash(user) - user.pbChangeForm(2,_INTL("{1} became Ash-Greninja!",user.pbThis)) + user.pbChangeForm(2, _INTL("{1} became Ash-Greninja!", user.pbThis)) end end end @@ -165,13 +165,13 @@ class Battle::Battler # U-turn/Volt Switch/Baton Pass/Parting Shot, Relic Song's form changing, # Fling/Natural Gift consuming item. if !switched_battlers.include?(user.index) - move.pbEndOfMoveUsageEffect(user,targets,numHits,switched_battlers) + move.pbEndOfMoveUsageEffect(user, targets, numHits, switched_battlers) end # User's ability/item that switches the user out (all negated by Sheer Force) if !(user.hasActiveAbility?(:SHEERFORCE) && move.addlEffect > 0) pbEffectsAfterMove3(user, targets, move, numHits, switched_battlers) end - if numHits>0 + if numHits > 0 @battle.allBattlers.each { |b| b.pbItemEndOfMoveCheck } end end @@ -180,7 +180,7 @@ class Battle::Battler def pbEffectsAfterMove2(user, targets, move, numHits, switched_battlers) # Target's held item (Eject Button, Red Card, Eject Pack) @battle.pbPriority(true).each do |b| - if targets.any? { |targetB| targetB.index==b.index } + if targets.any? { |targetB| targetB.index == b.index } if !b.damageState.unaffected && b.damageState.calcDamage > 0 && b.itemActive? Battle::ItemEffects.triggerAfterMoveUseFromTarget(b.item, b, user, move, switched_battlers, @battle) end @@ -198,7 +198,7 @@ class Battle::Battler end # Target's ability (Berserk, Color Change, Emergency Exit, Pickpocket, Wimp Out) @battle.pbPriority(true).each do |b| - if targets.any? { |targetB| targetB.index==b.index } + if targets.any? { |targetB| targetB.index == b.index } if !b.damageState.unaffected && !switched_battlers.include?(b.index) && b.abilityActive? Battle::AbilityEffects.triggerAfterMoveUseFromTarget(b.ability, b, user, move, switched_battlers, @battle) end diff --git a/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb b/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb index c75fd3401..967f9cf1d 100644 --- a/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb +++ b/Data/Scripts/011_Battle/003_Move/001_Battle_Move.rb @@ -67,7 +67,7 @@ class Battle::Move def pbTarget(_user); return GameData::Target.get(@target); end def total_pp - return @total_pp if @total_pp && @total_pp>0 # Usually undefined + return @total_pp if @total_pp && @total_pp > 0 # Usually undefined return @realMove.total_pp if @realMove return 0 end @@ -75,7 +75,7 @@ class Battle::Move # NOTE: This method is only ever called while using a move (and also by the # AI), so using @calcType here is acceptable. def physicalMove?(thisType = nil) - return (@category==0) if Settings::MOVE_CATEGORY_PER_MOVE + return (@category == 0) if Settings::MOVE_CATEGORY_PER_MOVE thisType ||= @calcType thisType ||= @type return true if !thisType @@ -85,15 +85,15 @@ class Battle::Move # NOTE: This method is only ever called while using a move (and also by the # AI), so using @calcType here is acceptable. def specialMove?(thisType = nil) - return (@category==1) if Settings::MOVE_CATEGORY_PER_MOVE + return (@category == 1) if Settings::MOVE_CATEGORY_PER_MOVE thisType ||= @calcType thisType ||= @type return false if !thisType return GameData::Type.get(thisType).special? end - def damagingMove?; return @category!=2; end - def statusMove?; return @category==2; end + def damagingMove?; return @category != 2; end + def statusMove?; return @category == 2; end def pbPriority(user); return @priority; end @@ -135,7 +135,7 @@ class Battle::Move # 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 nonLethal?(_user, _target); return false; end # For False Swipe def ignoresSubstitute?(user) # user is the Pokémon using this move if Settings::MECHANICS_GENERATION >= 6 diff --git a/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb b/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb index 6fab891f5..49e558f5c 100644 --- a/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb +++ b/Data/Scripts/011_Battle/003_Move/002_Move_Usage.rb @@ -2,14 +2,14 @@ class Battle::Move #============================================================================= # Effect methods per move usage #============================================================================= - def pbCanChooseMove?(user,commandPhase,showMessages); return true; end # For Belch + def pbCanChooseMove?(user, commandPhase, showMessages); return true; end # For Belch def pbDisplayChargeMessage(user); end # For Focus Punch/shell Trap/Beak Blast - def pbOnStartUse(user,targets); end - def pbAddTarget(targets,user); end # For Counter, etc. and Bide + def pbOnStartUse(user, targets); end + def pbAddTarget(targets, user); end # For Counter, etc. and Bide def pbModifyTargets(targets, user); end # For Dragon Darts # Reset move usage counters (child classes can increment them). - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) user.effects[PBEffects::FuryCutter] = 0 user.effects[PBEffects::ParentalBond] = 0 user.effects[PBEffects::ProtectRate] = 1 @@ -18,11 +18,11 @@ class Battle::Move end def pbDisplayUseMessage(user) - @battle.pbDisplayBrief(_INTL("{1} used {2}!",user.pbThis,@name)) + @battle.pbDisplayBrief(_INTL("{1} used {2}!", user.pbThis, @name)) end def pbShowFailMessages?(targets); return true; end - def pbMissMessage(user,target); return false; end + def pbMissMessage(user, target); return false; end #============================================================================= # @@ -42,9 +42,9 @@ class Battle::Move # The maximum number of hits in a round this move will actually perform. This # can be 1 for Beat Up, and can be 2 for any moves affected by Parental Bond. - def pbNumHits(user,targets) + def pbNumHits(user, targets) if user.hasActiveAbility?(:PARENTALBOND) && pbDamagingMove? && - !chargingTurnMove? && targets.length==1 + !chargingTurnMove? && targets.length == 1 # Record that Parental Bond applies, to weaken the second attack user.effects[PBEffects::ParentalBond] = 3 return 2 @@ -55,29 +55,29 @@ class Battle::Move #============================================================================= # Effect methods per hit #============================================================================= - def pbOverrideSuccessCheckPerHit(user,target); return false; end + def pbOverrideSuccessCheckPerHit(user, target); return false; end def pbCrashDamage(user); end - def pbInitialEffect(user,targets,hitNum); end + def pbInitialEffect(user, targets, hitNum); end def pbDesignateTargetsForHit(targets, hitNum); return targets; end # For Dragon Darts def pbRepeatHit?; return false; end # For Dragon Darts - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) return if !showAnimation - if user.effects[PBEffects::ParentalBond]==1 - @battle.pbCommonAnimation("ParentalBond",user,targets) + if user.effects[PBEffects::ParentalBond] == 1 + @battle.pbCommonAnimation("ParentalBond", user, targets) else - @battle.pbAnimation(id,user,targets,hitNum) + @battle.pbAnimation(id, user, targets, hitNum) end end def pbSelfKO(user); end - def pbEffectWhenDealingDamage(user,target); end - def pbEffectAgainstTarget(user,target); end + def pbEffectWhenDealingDamage(user, target); end + def pbEffectAgainstTarget(user, target); end def pbEffectGeneral(user); end - def pbAdditionalEffect(user,target); end - def pbEffectAfterAllHits(user,target); end # Move effects that occur after all hits + def pbAdditionalEffect(user, target); end + def pbEffectAfterAllHits(user, target); end # Move effects that occur after all hits def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers); end - def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers); end + def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers); end #============================================================================= # Check if target is immune to the move because of its ability @@ -96,7 +96,7 @@ class Battle::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, show_message); return false; end @@ -114,24 +114,24 @@ class Battle::Move end def pbMoveFailedTargetAlreadyMoved?(target, showMessage = true) - if (@battle.choices[target.index][0]!=:UseMove && - @battle.choices[target.index][0]!=:Shift) || target.movedThisRound? + if (@battle.choices[target.index][0] != :UseMove && + @battle.choices[target.index][0] != :Shift) || target.movedThisRound? @battle.pbDisplay(_INTL("But it failed!")) if showMessage return true end return false end - def pbMoveFailedAromaVeil?(user,target,showMessage = true) + def pbMoveFailedAromaVeil?(user, target, showMessage = true) return false if @battle.moldBreaker if target.hasActiveAbility?(:AROMAVEIL) if showMessage @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) else @battle.pbDisplay(_INTL("{1} is unaffected because of its {2}!", - target.pbThis,target.abilityName)) + target.pbThis, target.abilityName)) end @battle.pbHideAbilitySplash(target) end @@ -142,10 +142,10 @@ class Battle::Move if showMessage @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) else @battle.pbDisplay(_INTL("{1} is unaffected because of {2}'s {3}!", - target.pbThis,b.pbThis(true),b.abilityName)) + target.pbThis, b.pbThis(true), b.abilityName)) end @battle.pbHideAbilitySplash(target) end @@ -157,10 +157,10 @@ class Battle::Move #============================================================================= # Weaken the damage dealt (doesn't actually change a battler's HP) #============================================================================= - def pbCheckDamageAbsorption(user,target) + def pbCheckDamageAbsorption(user, target) # Substitute will take the damage - if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user) && - (!user || user.index!=target.index) + if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) && + (!user || user.index != target.index) target.damageState.substitute = true return end @@ -172,17 +172,17 @@ class Battle::Move end # Disguise will take the damage if !@battle.moldBreaker && target.isSpecies?(:MIMIKYU) && - target.form==0 && target.ability == :DISGUISE + target.form == 0 && target.ability == :DISGUISE target.damageState.disguise = true return end end - def pbReduceDamage(user,target) + def pbReduceDamage(user, target) damage = target.damageState.calcDamage # Substitute takes the damage if target.damageState.substitute - damage = target.effects[PBEffects::Substitute] if damage>target.effects[PBEffects::Substitute] + damage = target.effects[PBEffects::Substitute] if damage > target.effects[PBEffects::Substitute] target.damageState.hpLost = damage target.damageState.totalHPLost += damage return @@ -190,22 +190,22 @@ class Battle::Move # Disguise/Ice Face takes the damage return if target.damageState.disguise || target.damageState.iceFace # Target takes the damage - if damage>=target.hp + if damage >= target.hp damage = target.hp # Survive a lethal hit with 1 HP effects - if nonLethal?(user,target) + if nonLethal?(user, target) damage -= 1 elsif target.effects[PBEffects::Endure] target.damageState.endured = true damage -= 1 - elsif damage==target.totalhp + elsif damage == target.totalhp if target.hasActiveAbility?(:STURDY) && !@battle.moldBreaker target.damageState.sturdy = true damage -= 1 - elsif target.hasActiveItem?(:FOCUSSASH) && target.hp==target.totalhp + elsif target.hasActiveItem?(:FOCUSSASH) && target.hp == target.totalhp target.damageState.focusSash = true damage -= 1 - elsif target.hasActiveItem?(:FOCUSBAND) && @battle.pbRandom(100)<10 + elsif target.hasActiveItem?(:FOCUSBAND) && @battle.pbRandom(100) < 10 target.damageState.focusBand = true damage -= 1 elsif Settings::AFFECTION_EFFECTS && @battle.internalBattle && @@ -218,7 +218,7 @@ class Battle::Move end end end - damage = 0 if damage<0 + damage = 0 if damage < 0 target.damageState.hpLost = damage target.damageState.totalHPLost += damage end @@ -238,14 +238,14 @@ class Battle::Move # Animate the damage dealt, including lowering the HP #============================================================================= # Animate being damaged and losing HP (by a move) - def pbAnimateHitAndHPLost(user,targets) + def pbAnimateHitAndHPLost(user, targets) # Animate allies first, then foes animArray = [] for side in 0...2 # side here means "allies first, then foes" targets.each do |b| - next if b.damageState.unaffected || b.damageState.hpLost==0 - next if (side==0 && b.opposes?(user)) || (side==1 && !b.opposes?(user)) - oldHP = b.hp+b.damageState.hpLost + next if b.damageState.unaffected || b.damageState.hpLost == 0 + next if (side == 0 && b.opposes?(user)) || (side == 1 && !b.opposes?(user)) + oldHP = b.hp + b.damageState.hpLost PBDebug.log("[Move damage] #{b.pbThis} lost #{b.damageState.hpLost} HP (#{oldHP}=>#{b.hp})") effectiveness = 0 if Effectiveness.resistant?(b.damageState.typeMod) @@ -253,9 +253,9 @@ class Battle::Move elsif Effectiveness.super_effective?(b.damageState.typeMod) effectiveness = 2 end - animArray.push([b,oldHP,effectiveness]) + animArray.push([b, oldHP, effectiveness]) end - if animArray.length>0 + if animArray.length > 0 @battle.scene.pbHitAndHPLossAnimation(animArray) animArray.clear end @@ -265,27 +265,27 @@ class Battle::Move #============================================================================= # Messages upon being hit #============================================================================= - def pbEffectivenessMessage(user,target,numTargets = 1) + def pbEffectivenessMessage(user, target, numTargets = 1) return if target.damageState.disguise || target.damageState.iceFace if Effectiveness.super_effective?(target.damageState.typeMod) - if numTargets>1 - @battle.pbDisplay(_INTL("It's super effective on {1}!",target.pbThis(true))) + if numTargets > 1 + @battle.pbDisplay(_INTL("It's super effective on {1}!", target.pbThis(true))) else @battle.pbDisplay(_INTL("It's super effective!")) end elsif Effectiveness.not_very_effective?(target.damageState.typeMod) - if numTargets>1 - @battle.pbDisplay(_INTL("It's not very effective on {1}...",target.pbThis(true))) + if numTargets > 1 + @battle.pbDisplay(_INTL("It's not very effective on {1}...", target.pbThis(true))) else @battle.pbDisplay(_INTL("It's not very effective...")) end end end - def pbHitEffectivenessMessages(user,target,numTargets = 1) + def pbHitEffectivenessMessages(user, target, numTargets = 1) return if target.damageState.disguise || target.damageState.iceFace if target.damageState.substitute - @battle.pbDisplay(_INTL("The substitute took damage for {1}!",target.pbThis(true))) + @battle.pbDisplay(_INTL("The substitute took damage for {1}!", target.pbThis(true))) end if target.damageState.critical if $game_temp.party_critical_hits_dealt && user.pbOwnedByPlayer? @@ -307,12 +307,12 @@ class Battle::Move end end # Effectiveness message, for moves with 1 hit - if !multiHitMove? && user.effects[PBEffects::ParentalBond]==0 - pbEffectivenessMessage(user,target,numTargets) + if !multiHitMove? && user.effects[PBEffects::ParentalBond] == 0 + pbEffectivenessMessage(user, target, numTargets) end - if target.damageState.substitute && target.effects[PBEffects::Substitute]==0 + if target.damageState.substitute && target.effects[PBEffects::Substitute] == 0 target.effects[PBEffects::Substitute] = 0 - @battle.pbDisplay(_INTL("{1}'s substitute faded!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s substitute faded!", target.pbThis)) end end @@ -322,10 +322,10 @@ class Battle::Move if Battle::Scene::USE_ABILITY_SPLASH @battle.pbDisplay(_INTL("Its disguise served it as a decoy!")) else - @battle.pbDisplay(_INTL("{1}'s disguise served it as a decoy!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s disguise served it as a decoy!", target.pbThis)) end @battle.pbHideAbilitySplash(target) - target.pbChangeForm(1,_INTL("{1}'s disguise was busted!",target.pbThis)) + target.pbChangeForm(1, _INTL("{1}'s disguise was busted!", target.pbThis)) target.pbReduceHP(target.totalhp / 8, false) if Settings::MECHANICS_GENERATION >= 8 elsif target.damageState.iceFace @battle.pbShowAbilitySplash(target) @@ -335,36 +335,36 @@ class Battle::Move target.pbChangeForm(1, _INTL("{1} transformed!", target.pbThis)) @battle.pbHideAbilitySplash(target) elsif target.damageState.endured - @battle.pbDisplay(_INTL("{1} endured the hit!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} endured the hit!", target.pbThis)) elsif target.damageState.sturdy @battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} endured the hit!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} endured the hit!", target.pbThis)) else - @battle.pbDisplay(_INTL("{1} hung on with Sturdy!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} hung on with Sturdy!", target.pbThis)) end @battle.pbHideAbilitySplash(target) elsif target.damageState.focusSash - @battle.pbCommonAnimation("UseItem",target) - @battle.pbDisplay(_INTL("{1} hung on using its Focus Sash!",target.pbThis)) + @battle.pbCommonAnimation("UseItem", target) + @battle.pbDisplay(_INTL("{1} hung on using its Focus Sash!", target.pbThis)) target.pbConsumeItem elsif target.damageState.focusBand - @battle.pbCommonAnimation("UseItem",target) - @battle.pbDisplay(_INTL("{1} hung on using its Focus Band!",target.pbThis)) + @battle.pbCommonAnimation("UseItem", target) + @battle.pbDisplay(_INTL("{1} hung on using its Focus Band!", target.pbThis)) elsif target.damageState.affection_endured @battle.pbDisplay(_INTL("{1} toughed it out so you wouldn't feel sad!", target.pbThis)) end end # Used by Counter/Mirror Coat/Metal Burst/Revenge/Focus Punch/Bide/Assurance. - def pbRecordDamageLost(user,target) + def pbRecordDamageLost(user, target) damage = target.damageState.hpLost # NOTE: In Gen 3 where a move's category depends on its type, Hidden Power # is for some reason countered by Counter rather than Mirror Coat, # regardless of its calculated type. Hence the following two lines of # code. moveType = nil - moveType = :NORMAL if @function=="TypeDependsOnUserIVs" # Hidden Power + moveType = :NORMAL if @function == "TypeDependsOnUserIVs" # Hidden Power if physicalMove?(moveType) target.effects[PBEffects::Counter] = damage target.effects[PBEffects::CounterTarget] = user.index @@ -372,7 +372,7 @@ class Battle::Move target.effects[PBEffects::MirrorCoat] = damage target.effects[PBEffects::MirrorCoatTarget] = user.index end - if target.effects[PBEffects::Bide]>0 + if target.effects[PBEffects::Bide] > 0 target.effects[PBEffects::BideDamage] += damage target.effects[PBEffects::BideTarget] = user.index end diff --git a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb index f86a04442..b247e7c50 100644 --- a/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb +++ b/Data/Scripts/011_Battle/003_Move/003_Move_UsageCalculations.rb @@ -29,7 +29,7 @@ class Battle::Move #============================================================================= # Type effectiveness calculation #============================================================================= - def pbCalcTypeModSingle(moveType,defType,user,target) + def pbCalcTypeModSingle(moveType, defType, user, target) ret = Effectiveness.calculate_one(moveType, defType) # Ring Target if target.hasActiveItem?(:RINGTARGET) @@ -57,7 +57,7 @@ class Battle::Move return ret end - def pbCalcTypeMod(moveType,user,target) + def pbCalcTypeMod(moveType, user, target) return Effectiveness::NORMAL_EFFECTIVE if !moveType return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND && target.pbHasType?(:FLYING) && @@ -73,8 +73,8 @@ class Battle::Move typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE end else - tTypes.each_with_index do |type,i| - typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) + tTypes.each_with_index do |type, i| + typeMods[i] = pbCalcTypeModSingle(moveType, type, user, target) end end # Multiply all effectivenesses together @@ -87,15 +87,15 @@ class Battle::Move #============================================================================= # Accuracy check #============================================================================= - def pbBaseAccuracy(user,target); return @accuracy; end + def pbBaseAccuracy(user, target); return @accuracy; end # Accuracy calculations for one-hit KO moves are handled elsewhere. - def pbAccuracyCheck(user,target) + def pbAccuracyCheck(user, target) # "Always hit" effects and "always hit" accuracy - return true if target.effects[PBEffects::Telekinesis]>0 + return true if target.effects[PBEffects::Telekinesis] > 0 return true if target.effects[PBEffects::Minimize] && tramplesMinimize?(1) - baseAcc = pbBaseAccuracy(user,target) - return true if baseAcc==0 + baseAcc = pbBaseAccuracy(user, target) + return true if baseAcc == 0 # Calculate all multiplier effects modifiers = {} modifiers[:base_accuracy] = baseAcc @@ -103,14 +103,14 @@ class Battle::Move modifiers[:evasion_stage] = target.stages[:EVASION] modifiers[:accuracy_multiplier] = 1.0 modifiers[:evasion_multiplier] = 1.0 - pbCalcAccuracyModifiers(user,target,modifiers) + pbCalcAccuracyModifiers(user, target, modifiers) # Check if move can't miss return true if modifiers[:base_accuracy] == 0 # Calculation accStage = [[modifiers[:accuracy_stage], -6].max, 6].min + 6 evaStage = [[modifiers[:evasion_stage], -6].max, 6].min + 6 - stageMul = [3,3,3,3,3,3, 3, 4,5,6,7,8,9] - stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3] + stageMul = [3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9] + stageDiv = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3] accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage] evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage] accuracy = (accuracy * modifiers[:accuracy_multiplier]).round @@ -128,29 +128,29 @@ class Battle::Move return r < threshold end - def pbCalcAccuracyModifiers(user,target,modifiers) + def pbCalcAccuracyModifiers(user, target, modifiers) # Ability effects that alter accuracy calculation if user.abilityActive? Battle::AbilityEffects.triggerAccuracyCalcFromUser(user.ability, - modifiers,user,target,self,@calcType) + modifiers, user, target, self, @calcType) end user.allAllies.each do |b| next if !b.abilityActive? Battle::AbilityEffects.triggerAccuracyCalcFromAlly(b.ability, - modifiers,user,target,self,@calcType) + modifiers, user, target, self, @calcType) end if target.abilityActive? && !@battle.moldBreaker Battle::AbilityEffects.triggerAccuracyCalcFromTarget(target.ability, - modifiers,user,target,self,@calcType) + modifiers, user, target, self, @calcType) end # Item effects that alter accuracy calculation if user.itemActive? Battle::ItemEffects.triggerAccuracyCalcFromUser(user.item, - modifiers,user,target,self,@calcType) + modifiers, user, target, self, @calcType) end if target.itemActive? Battle::ItemEffects.triggerAccuracyCalcFromTarget(target.item, - modifiers,user,target,self,@calcType) + modifiers, user, target, self, @calcType) end # Other effects, inc. ones that set accuracy_multiplier or evasion_stage to # specific values @@ -172,41 +172,41 @@ class Battle::Move # -1: Never a critical hit. # 0: Calculate normally. # 1: Always a critical hit. - def pbCritialOverride(user,target); return 0; end + def pbCritialOverride(user, target); return 0; end # Returns whether the move will be a critical hit. - def pbIsCritical?(user,target) - return false if target.pbOwnSide.effects[PBEffects::LuckyChant]>0 + def pbIsCritical?(user, target) + return false if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0 # Set up the critical hit ratios - ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24,8,2,1] : [16,8,4,3,2] + ratios = (Settings::NEW_CRITICAL_HIT_RATE_MECHANICS) ? [24, 8, 2, 1] : [16, 8, 4, 3, 2] c = 0 # Ability effects that alter critical hit rate - if c>=0 && user.abilityActive? + if c >= 0 && user.abilityActive? c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c) end - if c>=0 && target.abilityActive? && !@battle.moldBreaker + if c >= 0 && target.abilityActive? && !@battle.moldBreaker c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c) end # Item effects that alter critical hit rate - if c>=0 && user.itemActive? + if c >= 0 && user.itemActive? c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c) end - if c>=0 && target.itemActive? + if c >= 0 && target.itemActive? c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c) end - return false if c<0 + return false if c < 0 # Move-specific "always/never a critical hit" effects - case pbCritialOverride(user,target) + case pbCritialOverride(user, target) when 1 then return true when -1 then return false end # Other effects - return true if c>50 # Merciless - return true if user.effects[PBEffects::LaserFocus]>0 + return true if c > 50 # Merciless + return true if user.effects[PBEffects::LaserFocus] > 0 c += 1 if highCriticalRate? c += user.effects[PBEffects::FocusEnergy] c += 1 if user.inHyperMode? && @type == :SHADOW - c = ratios.length-1 if c>=ratios.length + c = ratios.length - 1 if c >= ratios.length # Calculation return true if ratios[c] == 1 r = @battle.pbRandom(ratios[c]) @@ -222,49 +222,49 @@ class Battle::Move #============================================================================= # Damage calculation #============================================================================= - def pbBaseDamage(baseDmg,user,target); return baseDmg; end - def pbBaseDamageMultiplier(damageMult,user,target); return damageMult; end - def pbModifyDamage(damageMult,user,target); return damageMult; end + def pbBaseDamage(baseDmg, user, target); return baseDmg; end + def pbBaseDamageMultiplier(damageMult, user, target); return damageMult; end + def pbModifyDamage(damageMult, user, target); return damageMult; end - def pbGetAttackStats(user,target) + def pbGetAttackStats(user, target) if specialMove? - return user.spatk, user.stages[:SPECIAL_ATTACK]+6 + return user.spatk, user.stages[:SPECIAL_ATTACK] + 6 end - return user.attack, user.stages[:ATTACK]+6 + return user.attack, user.stages[:ATTACK] + 6 end - def pbGetDefenseStats(user,target) + def pbGetDefenseStats(user, target) if specialMove? - return target.spdef, target.stages[:SPECIAL_DEFENSE]+6 + return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6 end - return target.defense, target.stages[:DEFENSE]+6 + return target.defense, target.stages[:DEFENSE] + 6 end - def pbCalcDamage(user,target,numTargets = 1) + def pbCalcDamage(user, target, numTargets = 1) return if statusMove? if target.damageState.disguise || target.damageState.iceFace target.damageState.calcDamage = 1 return end - stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8] - stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2] + stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8] + stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2] # Get the move's type type = @calcType # nil is treated as physical # Calculate whether this hit deals critical damage - target.damageState.critical = pbIsCritical?(user,target) + target.damageState.critical = pbIsCritical?(user, target) # Calcuate base power of move - baseDmg = pbBaseDamage(@baseDamage,user,target) + baseDmg = pbBaseDamage(@baseDamage, user, target) # Calculate user's attack stat - atk, atkStage = pbGetAttackStats(user,target) + atk, atkStage = pbGetAttackStats(user, target) if !target.hasActiveAbility?(:UNAWARE) || @battle.moldBreaker - atkStage = 6 if target.damageState.critical && atkStage<6 - atk = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor + atkStage = 6 if target.damageState.critical && atkStage < 6 + atk = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor end # Calculate target's defense stat - defense, defStage = pbGetDefenseStats(user,target) + defense, defStage = pbGetDefenseStats(user, target) if !user.hasActiveAbility?(:UNAWARE) - defStage = 6 if target.damageState.critical && defStage>6 - defense = (defense.to_f*stageMul[defStage]/stageDiv[defStage]).floor + defStage = 6 if target.damageState.critical && defStage > 6 + defense = (defense.to_f * stageMul[defStage] / stageDiv[defStage]).floor end # Calculate all multiplier effects multipliers = { @@ -273,17 +273,17 @@ class Battle::Move :defense_multiplier => 1.0, :final_damage_multiplier => 1.0 } - pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers) + pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers) # Main damage calculation baseDmg = [(baseDmg * multipliers[:base_damage_multiplier]).round, 1].max atk = [(atk * multipliers[:attack_multiplier]).round, 1].max defense = [(defense * multipliers[:defense_multiplier]).round, 1].max damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2 - damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max + damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max target.damageState.calcDamage = damage end - def pbCalcDamageMultipliers(user,target,numTargets,type,baseDmg,multipliers) + def pbCalcDamageMultipliers(user, target, numTargets, type, baseDmg, multipliers) # Global abilities if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) || (@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY) @@ -296,7 +296,7 @@ class Battle::Move # Ability effects that alter damage if user.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromUser(user.ability, - user,target,self,multipliers,baseDmg,type) + user, target, self, multipliers, baseDmg, type) end if !@battle.moldBreaker # NOTE: It's odd that the user's Mold Breaker prevents its partner's @@ -305,31 +305,31 @@ class Battle::Move user.allAllies.each do |b| next if !b.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromAlly(b.ability, - user,target,self,multipliers,baseDmg,type) + user, target, self, multipliers, baseDmg, type) end if target.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromTarget(target.ability, - user,target,self,multipliers,baseDmg,type) if !@battle.moldBreaker + user, target, self, multipliers, baseDmg, type) if !@battle.moldBreaker Battle::AbilityEffects.triggerDamageCalcFromTargetNonIgnorable(target.ability, - user,target,self,multipliers,baseDmg,type) + user, target, self, multipliers, baseDmg, type) end target.allAllies.each do |b| next if !b.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromTargetAlly(b.ability, - user,target,self,multipliers,baseDmg,type) + user, target, self, multipliers, baseDmg, type) end end # Item effects that alter damage if user.itemActive? Battle::ItemEffects.triggerDamageCalcFromUser(user.item, - user,target,self,multipliers,baseDmg,type) + user, target, self, multipliers, baseDmg, type) end if target.itemActive? Battle::ItemEffects.triggerDamageCalcFromTarget(target.item, - user,target,self,multipliers,baseDmg,type) + user, target, self, multipliers, baseDmg, type) end # Parental Bond's second attack - if user.effects[PBEffects::ParentalBond]==1 + if user.effects[PBEffects::ParentalBond] == 1 multipliers[:base_damage_multiplier] /= (Settings::MECHANICS_GENERATION >= 7) ? 4 : 2 end # Other @@ -339,7 +339,7 @@ class Battle::Move if user.effects[PBEffects::HelpingHand] && !self.is_a?(Battle::Move::Confusion) multipliers[:base_damage_multiplier] *= 1.5 end - if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC + if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC multipliers[:base_damage_multiplier] *= 2 end # Mud Sport @@ -347,7 +347,7 @@ class Battle::Move if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] } multipliers[:base_damage_multiplier] /= 3 end - if @battle.field.effects[PBEffects::MudSportField]>0 + if @battle.field.effects[PBEffects::MudSportField] > 0 multipliers[:base_damage_multiplier] /= 3 end end @@ -356,7 +356,7 @@ class Battle::Move if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] } multipliers[:base_damage_multiplier] /= 3 end - if @battle.field.effects[PBEffects::WaterSportField]>0 + if @battle.field.effects[PBEffects::WaterSportField] > 0 multipliers[:base_damage_multiplier] /= 3 end end @@ -390,7 +390,7 @@ class Battle::Move end end # Multi-targeting attacks - if numTargets>1 + if numTargets > 1 multipliers[:final_damage_multiplier] *= 0.75 end # Weather @@ -422,7 +422,7 @@ class Battle::Move end # Random variance if !self.is_a?(Battle::Move::Confusion) - random = 85+@battle.pbRandom(16) + random = 85 + @battle.pbRandom(16) multipliers[:final_damage_multiplier] *= random / 100.0 end # STAB @@ -444,13 +444,13 @@ class Battle::Move if !ignoresReflect? && !target.damageState.critical && !user.hasActiveAbility?(:INFILTRATOR) if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 - if @battle.pbSideBattlerCount(target)>1 + if @battle.pbSideBattlerCount(target) > 1 multipliers[:final_damage_multiplier] *= 2 / 3.0 else multipliers[:final_damage_multiplier] /= 2 end elsif target.pbOwnSide.effects[PBEffects::Reflect] > 0 && physicalMove? - if @battle.pbSideBattlerCount(target)>1 + if @battle.pbSideBattlerCount(target) > 1 multipliers[:final_damage_multiplier] *= 2 / 3.0 else multipliers[:final_damage_multiplier] /= 2 @@ -476,12 +476,12 @@ class Battle::Move #============================================================================= # Additional effect chance #============================================================================= - def pbAdditionalEffectChance(user,target,effectChance = 0) + def pbAdditionalEffectChance(user, target, effectChance = 0) return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker - ret = (effectChance>0) ? effectChance : @addlEffect + ret = (effectChance > 0) ? effectChance : @addlEffect if Settings::MECHANICS_GENERATION >= 6 || @function != "EffectDependsOnEnvironment" ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) || - user.pbOwnSide.effects[PBEffects::Rainbow]>0 + user.pbOwnSide.effects[PBEffects::Rainbow] > 0 end ret = 100 if $DEBUG && Input.press?(Input::CTRL) return ret @@ -489,17 +489,17 @@ class Battle::Move # NOTE: Flinching caused by a move's effect is applied in that move's code, # not here. - def pbFlinchChance(user,target) + def pbFlinchChance(user, target) return 0 if flinchingMove? return 0 if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker ret = 0 - if user.hasActiveAbility?(:STENCH,true) + if user.hasActiveAbility?(:STENCH, true) ret = 10 - elsif user.hasActiveItem?([:KINGSROCK,:RAZORFANG],true) + elsif user.hasActiveItem?([:KINGSROCK, :RAZORFANG], true) ret = 10 end ret *= 2 if user.hasActiveAbility?(:SERENEGRACE) || - user.pbOwnSide.effects[PBEffects::Rainbow]>0 + user.pbOwnSide.effects[PBEffects::Rainbow] > 0 return ret end end diff --git a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb index 829cb5526..3fd27fead 100644 --- a/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb +++ b/Data/Scripts/011_Battle/003_Move/004_Move_BaseEffects.rb @@ -8,7 +8,7 @@ # Status moves always fail. #=============================================================================== class Battle::Move::Unimplemented < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if statusMove? @battle.pbDisplay(_INTL("But it failed!")) return true @@ -21,7 +21,7 @@ end # Pseudomove for confusion damage. #=============================================================================== class Battle::Move::Confusion < Battle::Move - def initialize(battle,move) + def initialize(battle, move) @battle = battle @realMove = move @id = :CONFUSEDAMAGE @@ -41,16 +41,16 @@ class Battle::Move::Confusion < Battle::Move @snatched = false end - def physicalMove?(thisType = nil); return true; end - def specialMove?(thisType = nil); return false; end - def pbCritialOverride(user,target); return -1; end + def physicalMove?(thisType = nil); return true; end + def specialMove?(thisType = nil); return false; end + def pbCritialOverride(user, target); return -1; end end #=============================================================================== # Struggle. #=============================================================================== class Battle::Move::Struggle < Battle::Move - def initialize(battle,move) + def initialize(battle, move) @battle = battle @realMove = nil # Not associated with a move @id = (move) ? move.id : :STRUGGLE @@ -73,10 +73,10 @@ class Battle::Move::Struggle < Battle::Move def physicalMove?(thisType = nil); return true; end def specialMove?(thisType = nil); return false; end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if target.damageState.unaffected - user.pbReduceHP((user.totalhp/4.0).round,false) - @battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis)) + user.pbReduceHP((user.totalhp / 4.0).round, false) + @battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis)) user.pbItemHPHealCheck end end @@ -87,19 +87,19 @@ end class Battle::Move::StatUpMove < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) return false if damagingMove? - return !user.pbCanRaiseStatStage?(@statUp[0],user,self,true) + return !user.pbCanRaiseStatStage?(@statUp[0], user, self, true) end def pbEffectGeneral(user) return if damagingMove? - user.pbRaiseStatStage(@statUp[0],@statUp[1],user) + user.pbRaiseStatStage(@statUp[0], @statUp[1], user) end - def pbAdditionalEffect(user,target) - if user.pbCanRaiseStatStage?(@statUp[0],user,self) - user.pbRaiseStatStage(@statUp[0],@statUp[1],user) + def pbAdditionalEffect(user, target) + if user.pbCanRaiseStatStage?(@statUp[0], user, self) + user.pbRaiseStatStage(@statUp[0], @statUp[1], user) end end end @@ -110,16 +110,16 @@ end class Battle::Move::MultiStatUpMove < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) return false if damagingMove? failed = true - for i in 0...@statUp.length/2 - next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self) + for i in 0...@statUp.length / 2 + next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) failed = false break end if failed - @battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis)) + @battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis)) return true end return false @@ -128,19 +128,19 @@ class Battle::Move::MultiStatUpMove < Battle::Move def pbEffectGeneral(user) return if damagingMove? showAnim = true - for i in 0...@statUp.length/2 - next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self) - if user.pbRaiseStatStage(@statUp[i*2],@statUp[i*2+1],user,showAnim) + for i in 0...@statUp.length / 2 + next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) + if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim) showAnim = false end end end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) showAnim = true - for i in 0...@statUp.length/2 - next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self) - if user.pbRaiseStatStage(@statUp[i*2],@statUp[i*2+1],user,showAnim) + for i in 0...@statUp.length / 2 + next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) + if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim) showAnim = false end end @@ -151,12 +151,12 @@ end # Lower multiple of user's stats. #=============================================================================== class Battle::Move::StatDownMove < Battle::Move - def pbEffectWhenDealingDamage(user,target) + def pbEffectWhenDealingDamage(user, target) return if @battle.pbAllFainted?(target.idxOwnSide) showAnim = true - for i in 0...@statDown.length/2 - next if !user.pbCanLowerStatStage?(@statDown[i*2],user,self) - if user.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim) + for i in 0...@statDown.length / 2 + next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self) + if user.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, showAnim) showAnim = false end end @@ -174,15 +174,15 @@ class Battle::Move::TargetStatDownMove < Battle::Move return !target.pbCanLowerStatStage?(@statDown[0], user, self, show_message) end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? - target.pbLowerStatStage(@statDown[0],@statDown[1],user) + target.pbLowerStatStage(@statDown[0], @statDown[1], user) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - return if !target.pbCanLowerStatStage?(@statDown[0],user,self) - target.pbLowerStatStage(@statDown[0],@statDown[1],user) + return if !target.pbCanLowerStatStage?(@statDown[0], user, self) + target.pbLowerStatStage(@statDown[0], @statDown[1], user) end end @@ -195,8 +195,8 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move def pbFailsAgainstTarget?(user, target, show_message) return false if damagingMove? failed = true - for i in 0...@statDown.length/2 - next if !target.pbCanLowerStatStage?(@statDown[i*2],user,self) + for i in 0...@statDown.length / 2 + next if !target.pbCanLowerStatStage?(@statDown[i * 2], user, self) failed = false break end @@ -205,19 +205,19 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move # is shown here, I know. canLower = false if target.hasActiveAbility?(:CONTRARY) && !@battle.moldBreaker - for i in 0...@statDown.length/2 - next if target.statStageAtMax?(@statDown[i*2]) + for i in 0...@statDown.length / 2 + next if target.statStageAtMax?(@statDown[i * 2]) canLower = true break end - @battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis)) if !canLower && show_message + @battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis)) if !canLower && show_message else - for i in 0...@statDown.length/2 - next if target.statStageAtMin?(@statDown[i*2]) + for i in 0...@statDown.length / 2 + next if target.statStageAtMin?(@statDown[i * 2]) canLower = true break end - @battle.pbDisplay(_INTL("{1}'s stats won't go any lower!",user.pbThis)) if !canLower && show_message + @battle.pbDisplay(_INTL("{1}'s stats won't go any lower!", user.pbThis)) if !canLower && show_message end if canLower target.pbCanLowerStatStage?(@statDown[0], user, self, show_message) @@ -264,11 +264,11 @@ class Battle::Move::TargetMultiStatDownMove < Battle::Move @battle.pbHideAbilitySplash(target) # To hide target's Mirror Armor splash end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) pbLowerTargetMultipleStats(user, target) if !damagingMove? end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) pbLowerTargetMultipleStats(user, target) if !target.damageState.substitute end end @@ -277,12 +277,12 @@ end # Fixed damage-inflicting move. #=============================================================================== class Battle::Move::FixedDamageMove < Battle::Move - def pbFixedDamage(user,target); return 1; end + def pbFixedDamage(user, target); return 1; end - def pbCalcDamage(user,target,numTargets = 1) + def pbCalcDamage(user, target, numTargets = 1) target.damageState.critical = false - target.damageState.calcDamage = pbFixedDamage(user,target) - target.damageState.calcDamage = 1 if target.damageState.calcDamage<1 + target.damageState.calcDamage = pbFixedDamage(user, target) + target.damageState.calcDamage = 1 if target.damageState.calcDamage < 1 end end @@ -315,16 +315,16 @@ class Battle::Move::TwoTurnMove < Battle::Move return super end - def pbAccuracyCheck(user,target) + def pbAccuracyCheck(user, target) return true if !@damagingTurn return super end - def pbInitialEffect(user,targets,hitNum) - pbChargingTurnMessage(user,targets) if @chargingTurn + def pbInitialEffect(user, targets, hitNum) + pbChargingTurnMessage(user, targets) if @chargingTurn if @chargingTurn && @damagingTurn # Move only takes one turn to use - pbShowAnimation(@id,user,targets,1) # Charging anim - targets.each { |b| pbChargingTurnEffect(user,b) } + pbShowAnimation(@id, user, targets, 1) # Charging anim + targets.each { |b| pbChargingTurnEffect(user, b) } if @powerHerb # Moves that would make the user semi-invulnerable will hide the user # after the charging animation, so the "UseItem" animation shouldn't show @@ -335,39 +335,39 @@ class Battle::Move::TwoTurnMove < Battle::Move "TwoTurnAttackInvulnerableInSkyParalyzeTarget", "TwoTurnAttackInvulnerableRemoveProtections", "TwoTurnAttackInvulnerableInSkyTargetCannotAct"].include?(@function) - @battle.pbCommonAnimation("UseItem",user) + @battle.pbCommonAnimation("UseItem", user) end - @battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} became fully charged due to its Power Herb!", user.pbThis)) user.pbConsumeItem end end - pbAttackingTurnMessage(user,targets) if @damagingTurn + pbAttackingTurnMessage(user, targets) if @damagingTurn end - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} began charging up!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} began charging up!", user.pbThis)) end - def pbAttackingTurnMessage(user,targets) + def pbAttackingTurnMessage(user, targets) end - def pbChargingTurnEffect(user,target) + def pbChargingTurnEffect(user, target) # Skull Bash/Sky Drop are the only two-turn moves with an effect here, and # the latter just records the target is being Sky Dropped end - def pbAttackingTurnEffect(user,target) + def pbAttackingTurnEffect(user, target) end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) if @damagingTurn - pbAttackingTurnEffect(user,target) + pbAttackingTurnEffect(user, target) elsif @chargingTurn - pbChargingTurnEffect(user,target) + pbChargingTurnEffect(user, target) end end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) hitNum = 1 if @chargingTurn && !@damagingTurn # Charging anim super end @@ -381,9 +381,9 @@ class Battle::Move::HealingMove < Battle::Move def pbHealAmount(user); return 1; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.hp==user.totalhp - @battle.pbDisplay(_INTL("{1}'s HP is full!",user.pbThis)) + def pbMoveFailed?(user, targets) + if user.hp == user.totalhp + @battle.pbDisplay(_INTL("{1}'s HP is full!", user.pbThis)) return true end return false @@ -392,7 +392,7 @@ class Battle::Move::HealingMove < Battle::Move def pbEffectGeneral(user) amt = pbHealAmount(user) user.pbRecoverHP(amt) - @battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis)) + @battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis)) end end @@ -401,16 +401,16 @@ end #=============================================================================== class Battle::Move::RecoilMove < Battle::Move def recoilMove?; return true; end - def pbRecoilDamage(user,target); return 1; end + def pbRecoilDamage(user, target); return 1; end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if target.damageState.unaffected return if !user.takesIndirectDamage? return if user.hasActiveAbility?(:ROCKHEAD) - amt = pbRecoilDamage(user,target) - amt = 1 if amt<1 - user.pbReduceHP(amt,false) - @battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis)) + amt = pbRecoilDamage(user, target) + amt = 1 if amt < 1 + user.pbReduceHP(amt, false) + @battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis)) user.pbItemHPHealCheck end end @@ -419,18 +419,18 @@ end # Protect move. #=============================================================================== class Battle::Move::ProtectMove < Battle::Move - def initialize(battle,move) + def initialize(battle, move) super @sidedEffect = false end - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) oldVal = user.effects[PBEffects::ProtectRate] super user.effects[PBEffects::ProtectRate] = oldVal end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @sidedEffect if user.pbOwnSide.effects[@effect] user.effects[PBEffects::ProtectRate] = 1 @@ -443,8 +443,8 @@ class Battle::Move::ProtectMove < Battle::Move return true end if (!@sidedEffect || Settings::MECHANICS_GENERATION <= 5) && - user.effects[PBEffects::ProtectRate]>1 && - @battle.pbRandom(user.effects[PBEffects::ProtectRate])!=0 + user.effects[PBEffects::ProtectRate] > 1 && + @battle.pbRandom(user.effects[PBEffects::ProtectRate]) != 0 user.effects[PBEffects::ProtectRate] = 1 @battle.pbDisplay(_INTL("But it failed!")) return true @@ -468,9 +468,9 @@ class Battle::Move::ProtectMove < Battle::Move def pbProtectMessage(user) if @sidedEffect - @battle.pbDisplay(_INTL("{1} protected {2}!",@name,user.pbTeam(true))) + @battle.pbDisplay(_INTL("{1} protected {2}!", @name, user.pbTeam(true))) else - @battle.pbDisplay(_INTL("{1} protected itself!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} protected itself!", user.pbThis)) end end end @@ -479,12 +479,12 @@ end # Weather-inducing move. #=============================================================================== class Battle::Move::WeatherMove < Battle::Move - def initialize(battle,move) + def initialize(battle, move) super @weatherType = :None end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) case @battle.field.weather when :HarshSun @battle.pbDisplay(_INTL("The extremely harsh sunlight was not lessened at all!")) @@ -503,7 +503,7 @@ class Battle::Move::WeatherMove < Battle::Move end def pbEffectGeneral(user) - @battle.pbStartWeather(user,@weatherType,true,false) + @battle.pbStartWeather(user, @weatherType, true, false) end end @@ -511,7 +511,7 @@ end # Pledge move. #=============================================================================== class Battle::Move::PledgeMove < Battle::Move - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) @pledgeSetup = false @pledgeCombo = false @pledgeOtherUser = nil @@ -519,7 +519,7 @@ class Battle::Move::PledgeMove < Battle::Move @overrideAnim = nil # Check whether this is the use of a combo move @combos.each do |i| - next if i[0]!=user.effects[PBEffects::FirstPledge] + next if i[0] != user.effects[PBEffects::FirstPledge] @battle.pbDisplay(_INTL("The two moves have become one! It's a combined move!")) @pledgeCombo = true @comboEffect = i[1] @@ -529,11 +529,11 @@ class Battle::Move::PledgeMove < Battle::Move return if @pledgeCombo # Check whether this is the setup of a combo move user.allAllies.each do |b| - next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound? + next if @battle.choices[b.index][0] != :UseMove || b.movedThisRound? move = @battle.choices[b.index][2] next if !move @combos.each do |i| - next if i[0]!=move.function + next if i[0] != move.function @pledgeSetup = true @pledgeOtherUser = b break @@ -558,7 +558,7 @@ class Battle::Move::PledgeMove < Battle::Move return super end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if @pledgeCombo return baseDmg end @@ -567,33 +567,33 @@ class Battle::Move::PledgeMove < Battle::Move user.effects[PBEffects::FirstPledge] = nil return if !@pledgeSetup @battle.pbDisplay(_INTL("{1} is waiting for {2}'s move...", - user.pbThis,@pledgeOtherUser.pbThis(true))) + user.pbThis, @pledgeOtherUser.pbThis(true))) @pledgeOtherUser.effects[PBEffects::FirstPledge] = @function @pledgeOtherUser.effects[PBEffects::MoveNext] = true user.lastMoveFailed = true # Treated as a failure for Stomping Tantrum end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if !@pledgeCombo msg = nil animName = nil case @comboEffect when :SeaOfFire # Grass + Fire - if user.pbOpposingSide.effects[PBEffects::SeaOfFire]==0 + if user.pbOpposingSide.effects[PBEffects::SeaOfFire] == 0 user.pbOpposingSide.effects[PBEffects::SeaOfFire] = 4 - msg = _INTL("A sea of fire enveloped {1}!",user.pbOpposingTeam(true)) + msg = _INTL("A sea of fire enveloped {1}!", user.pbOpposingTeam(true)) animName = (user.opposes?) ? "SeaOfFire" : "SeaOfFireOpp" end when :Rainbow # Fire + Water - if user.pbOwnSide.effects[PBEffects::Rainbow]==0 + if user.pbOwnSide.effects[PBEffects::Rainbow] == 0 user.pbOwnSide.effects[PBEffects::Rainbow] = 4 - msg = _INTL("A rainbow appeared in the sky on {1}'s side!",user.pbTeam(true)) + msg = _INTL("A rainbow appeared in the sky on {1}'s side!", user.pbTeam(true)) animName = (user.opposes?) ? "RainbowOpp" : "Rainbow" end when :Swamp # Water + Grass - if user.pbOpposingSide.effects[PBEffects::Swamp]==0 + if user.pbOpposingSide.effects[PBEffects::Swamp] == 0 user.pbOpposingSide.effects[PBEffects::Swamp] = 4 - msg = _INTL("A swamp enveloped {1}!",user.pbOpposingTeam(true)) + msg = _INTL("A swamp enveloped {1}!", user.pbOpposingTeam(true)) animName = (user.opposes?) ? "Swamp" : "SwampOpp" end end @@ -601,7 +601,7 @@ class Battle::Move::PledgeMove < Battle::Move @battle.pbCommonAnimation(animName) if animName end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) return if @pledgeSetup # No animation for setting up id = @overrideAnim if @overrideAnim return super diff --git a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb index 3bb310057..f6c0b96bc 100644 --- a/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb +++ b/Data/Scripts/011_Battle/003_Move/005_MoveEffects_Misc.rb @@ -10,9 +10,9 @@ end class Battle::Move::DoesNothingCongratulations < Battle::Move def pbEffectGeneral(user) if user.wild? - @battle.pbDisplay(_INTL("Congratulations from {1}!",user.pbThis(true))) + @battle.pbDisplay(_INTL("Congratulations from {1}!", user.pbThis(true))) else - @battle.pbDisplay(_INTL("Congratulations, {1}!",@battle.pbGetOwnerName(user.index))) + @battle.pbDisplay(_INTL("Congratulations, {1}!", @battle.pbGetOwnerName(user.index))) end end end @@ -23,7 +23,7 @@ end class Battle::Move::DoesNothingFailsIfNoAlly < Battle::Move def ignoresSubstitute?(user); return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.allAllies.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true @@ -53,7 +53,7 @@ end class Battle::Move::AddMoneyGainedFromBattle < Battle::Move def pbEffectGeneral(user) if user.pbOwnedByPlayer? - @battle.field.effects[PBEffects::PayDay] += 5*user.level + @battle.field.effects[PBEffects::PayDay] += 5 * user.level end @battle.pbDisplay(_INTL("Coins were scattered everywhere!")) end @@ -73,7 +73,7 @@ end # Fails if this isn't the user's first turn. (First Impression) #=============================================================================== class Battle::Move::FailsIfNotUserFirstTurn < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.turnCount > 1 @battle.pbDisplay(_INTL("But it failed!")) return true @@ -91,9 +91,9 @@ class Battle::Move::FailsIfUserHasUnusedMove < Battle::Move hasOtherMoves = false hasUnusedMoves = false user.eachMove do |m| - hasThisMove = true if m.id==@id - hasOtherMoves = true if m.id!=@id - hasUnusedMoves = true if m.id!=@id && !user.movesUsed.include?(m.id) + hasThisMove = true if m.id == @id + hasOtherMoves = true if m.id != @id + hasUnusedMoves = true if m.id != @id && !user.movesUsed.include?(m.id) end if !hasThisMove || !hasOtherMoves || hasUnusedMoves @battle.pbDisplay(_INTL("But it failed!")) if show_message @@ -107,10 +107,10 @@ end # Fails unless user has consumed a berry at some point. (Belch) #=============================================================================== class Battle::Move::FailsIfUserNotConsumedBerry < Battle::Move - def pbCanChooseMove?(user,commandPhase,showMessages) + def pbCanChooseMove?(user, commandPhase, showMessages) if !user.belched? if showMessages - msg = _INTL("{1} hasn't eaten any held berry, so it can't possibly belch!",user.pbThis) + msg = _INTL("{1} hasn't eaten any held berry, so it can't possibly belch!", user.pbThis) (commandPhase) ? @battle.pbDisplayPaused(msg) : @battle.pbDisplay(msg) end return false @@ -118,7 +118,7 @@ class Battle::Move::FailsIfUserNotConsumedBerry < Battle::Move return true end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.belched? @battle.pbDisplay(_INTL("But it failed!")) return true @@ -156,7 +156,7 @@ class Battle::Move::FailsUnlessTargetSharesTypeWithUser < Battle::Move break end if !sharesType - @battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis)) if show_message + @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message return true end return false @@ -169,17 +169,17 @@ end class Battle::Move::FailsIfUserDamagedThisTurn < Battle::Move def pbDisplayChargeMessage(user) user.effects[PBEffects::FocusPunch] = true - @battle.pbCommonAnimation("FocusPunch",user) - @battle.pbDisplay(_INTL("{1} is tightening its focus!",user.pbThis)) + @battle.pbCommonAnimation("FocusPunch", user) + @battle.pbDisplay(_INTL("{1} is tightening its focus!", user.pbThis)) end def pbDisplayUseMessage(user) - super if !user.effects[PBEffects::FocusPunch] || user.lastHPLost==0 + super if !user.effects[PBEffects::FocusPunch] || user.lastHPLost == 0 end - def pbMoveFailed?(user,targets) - if user.effects[PBEffects::FocusPunch] && user.lastHPLost>0 - @battle.pbDisplay(_INTL("{1} lost its focus and couldn't move!",user.pbThis)) + def pbMoveFailed?(user, targets) + if user.effects[PBEffects::FocusPunch] && user.lastHPLost > 0 + @battle.pbDisplay(_INTL("{1} lost its focus and couldn't move!", user.pbThis)) return true end return false @@ -192,13 +192,13 @@ end #=============================================================================== class Battle::Move::FailsIfTargetActed < Battle::Move def pbFailsAgainstTarget?(user, target, show_message) - if @battle.choices[target.index][0]!=:UseMove + if @battle.choices[target.index][0] != :UseMove @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end oppMove = @battle.choices[target.index][2] if !oppMove || - (oppMove.function!="UseMoveTargetIsAboutToUse" && + (oppMove.function != "UseMoveTargetIsAboutToUse" && (target.movedThisRound? || oppMove.statusMove?)) @battle.pbDisplay(_INTL("But it failed!")) if show_message return true @@ -217,9 +217,9 @@ class Battle::Move::CrashDamageIfFailsUnusableInGravity < Battle::Move def pbCrashDamage(user) return if !user.takesIndirectDamage? - @battle.pbDisplay(_INTL("{1} kept going and crashed!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} kept going and crashed!", user.pbThis)) @battle.scene.pbDamageAnimation(user) - user.pbReduceHP(user.totalhp/2,false) + user.pbReduceHP(user.totalhp / 2, false) user.pbItemHPHealCheck user.pbFaint if user.fainted? end @@ -229,7 +229,7 @@ end # Starts sunny weather. (Sunny Day) #=============================================================================== class Battle::Move::StartSunWeather < Battle::Move::WeatherMove - def initialize(battle,move) + def initialize(battle, move) super @weatherType = :Sun end @@ -239,7 +239,7 @@ end # Starts rainy weather. (Rain Dance) #=============================================================================== class Battle::Move::StartRainWeather < Battle::Move::WeatherMove - def initialize(battle,move) + def initialize(battle, move) super @weatherType = :Rain end @@ -249,7 +249,7 @@ end # Starts sandstorm weather. (Sandstorm) #=============================================================================== class Battle::Move::StartSandstormWeather < Battle::Move::WeatherMove - def initialize(battle,move) + def initialize(battle, move) super @weatherType = :Sandstorm end @@ -259,7 +259,7 @@ end # Starts hail weather. (Hail) #=============================================================================== class Battle::Move::StartHailWeather < Battle::Move::WeatherMove - def initialize(battle,move) + def initialize(battle, move) super @weatherType = :Hail end @@ -271,7 +271,7 @@ end # (Electric Terrain) #=============================================================================== class Battle::Move::StartElectricTerrain < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @battle.field.terrain == :Electric @battle.pbDisplay(_INTL("But it failed!")) return true @@ -290,7 +290,7 @@ end # (Grassy Terrain) #=============================================================================== class Battle::Move::StartGrassyTerrain < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @battle.field.terrain == :Grassy @battle.pbDisplay(_INTL("But it failed!")) return true @@ -309,7 +309,7 @@ end # (Misty Terrain) #=============================================================================== class Battle::Move::StartMistyTerrain < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @battle.field.terrain == :Misty @battle.pbDisplay(_INTL("But it failed!")) return true @@ -328,7 +328,7 @@ end # Pokémon only. (Psychic Terrain) #=============================================================================== class Battle::Move::StartPsychicTerrain < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @battle.field.terrain == :Psychic @battle.pbDisplay(_INTL("But it failed!")) return true @@ -375,8 +375,8 @@ end class Battle::Move::AddSpikesToFoeSide < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) - if user.pbOpposingSide.effects[PBEffects::Spikes]>=3 + def pbMoveFailed?(user, targets) + if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -397,8 +397,8 @@ end class Battle::Move::AddToxicSpikesToFoeSide < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) - if user.pbOpposingSide.effects[PBEffects::ToxicSpikes]>=2 + def pbMoveFailed?(user, targets) + if user.pbOpposingSide.effects[PBEffects::ToxicSpikes] >= 2 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -418,7 +418,7 @@ end class Battle::Move::AddStealthRocksToFoeSide < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.pbOpposingSide.effects[PBEffects::StealthRock] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -439,7 +439,7 @@ end class Battle::Move::AddStickyWebToFoeSide < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.pbOpposingSide.effects[PBEffects::StickyWeb] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -523,22 +523,22 @@ end class Battle::Move::UserMakeSubstitute < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.effects[PBEffects::Substitute]>0 - @battle.pbDisplay(_INTL("{1} already has a substitute!",user.pbThis)) + def pbMoveFailed?(user, targets) + if user.effects[PBEffects::Substitute] > 0 + @battle.pbDisplay(_INTL("{1} already has a substitute!", user.pbThis)) return true end - @subLife = user.totalhp/4 - @subLife = 1 if @subLife<1 - if user.hp<=@subLife + @subLife = user.totalhp / 4 + @subLife = 1 if @subLife < 1 + if user.hp <= @subLife @battle.pbDisplay(_INTL("But it does not have enough HP left to make a substitute!")) return true end return false end - def pbOnStartUse(user,targets) - user.pbReduceHP(@subLife,false,false) + def pbOnStartUse(user, targets) + user.pbReduceHP(@subLife, false, false) user.pbItemHPHealCheck end @@ -546,7 +546,7 @@ class Battle::Move::UserMakeSubstitute < Battle::Move user.effects[PBEffects::Trapping] = 0 user.effects[PBEffects::TrappingMove] = nil user.effects[PBEffects::Substitute] = @subLife - @battle.pbDisplay(_INTL("{1} put in a substitute!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} put in a substitute!", user.pbThis)) end end @@ -555,44 +555,44 @@ end # Raises user's Speed by 1 stage (Gen 8+). (Rapid Spin) #=============================================================================== class Battle::Move::RemoveUserBindingAndEntryHazards < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super @statUp = [:SPEED, 1] end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if user.fainted? || target.damageState.unaffected - if user.effects[PBEffects::Trapping]>0 + if user.effects[PBEffects::Trapping] > 0 trapMove = GameData::Move.get(user.effects[PBEffects::TrappingMove]).name trapUser = @battle.battlers[user.effects[PBEffects::TrappingUser]] - @battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!",user.pbThis,trapUser.pbThis(true),trapMove)) + @battle.pbDisplay(_INTL("{1} got free of {2}'s {3}!", user.pbThis, trapUser.pbThis(true), trapMove)) user.effects[PBEffects::Trapping] = 0 user.effects[PBEffects::TrappingMove] = nil user.effects[PBEffects::TrappingUser] = -1 end - if user.effects[PBEffects::LeechSeed]>=0 + if user.effects[PBEffects::LeechSeed] >= 0 user.effects[PBEffects::LeechSeed] = -1 - @battle.pbDisplay(_INTL("{1} shed Leech Seed!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} shed Leech Seed!", user.pbThis)) end if user.pbOwnSide.effects[PBEffects::StealthRock] user.pbOwnSide.effects[PBEffects::StealthRock] = false - @battle.pbDisplay(_INTL("{1} blew away stealth rocks!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away stealth rocks!", user.pbThis)) end - if user.pbOwnSide.effects[PBEffects::Spikes]>0 + if user.pbOwnSide.effects[PBEffects::Spikes] > 0 user.pbOwnSide.effects[PBEffects::Spikes] = 0 - @battle.pbDisplay(_INTL("{1} blew away spikes!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away spikes!", user.pbThis)) end - if user.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 + if user.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0 user.pbOwnSide.effects[PBEffects::ToxicSpikes] = 0 - @battle.pbDisplay(_INTL("{1} blew away poison spikes!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away poison spikes!", user.pbThis)) end if user.pbOwnSide.effects[PBEffects::StickyWeb] user.pbOwnSide.effects[PBEffects::StickyWeb] = false - @battle.pbDisplay(_INTL("{1} blew away sticky webs!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away sticky webs!", user.pbThis)) end end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) super if Settings::MECHANICS_GENERATION >= 8 end end @@ -608,7 +608,7 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move return super end - def pbAccuracyCheck(user,target) + def pbAccuracyCheck(user, target) return true if !@battle.futureSight return super end @@ -619,14 +619,14 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move def pbFailsAgainstTarget?(user, target, show_message) if !@battle.futureSight && - @battle.positions[target.index].effects[PBEffects::FutureSightCounter]>0 + @battle.positions[target.index].effects[PBEffects::FutureSightCounter] > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if @battle.futureSight # Attack is hitting effects = @battle.positions[target.index].effects effects[PBEffects::FutureSightCounter] = 3 @@ -634,13 +634,13 @@ class Battle::Move::AttackTwoTurnsLater < Battle::Move effects[PBEffects::FutureSightUserIndex] = user.index effects[PBEffects::FutureSightUserPartyIndex] = user.pokemonIndex if @id == :DOOMDESIRE - @battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} chose Doom Desire as its destiny!", user.pbThis)) else - @battle.pbDisplay(_INTL("{1} foresaw an attack!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} foresaw an attack!", user.pbThis)) end end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) hitNum = 1 if !@battle.futureSight # Charging anim super end @@ -650,17 +650,17 @@ end # User switches places with its ally. (Ally Switch) #=============================================================================== class Battle::Move::UserSwapsPositionsWithAlly < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) numTargets = 0 @idxAlly = -1 idxUserOwner = @battle.pbGetOwnerIndexFromBattlerIndex(user.index) user.allAllies.each do |b| - next if @battle.pbGetOwnerIndexFromBattlerIndex(b.index)!=idxUserOwner + next if @battle.pbGetOwnerIndexFromBattlerIndex(b.index) != idxUserOwner next if !b.near?(user) numTargets += 1 @idxAlly = b.index end - if numTargets!=1 + if numTargets != 1 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -670,9 +670,9 @@ class Battle::Move::UserSwapsPositionsWithAlly < Battle::Move def pbEffectGeneral(user) idxA = user.index idxB = @idxAlly - if @battle.pbSwapBattlers(idxA,idxB) + if @battle.pbSwapBattlers(idxA, idxB) @battle.pbDisplay(_INTL("{1} and {2} switched places!", - @battle.battlers[idxB].pbThis,@battle.battlers[idxA].pbThis(true))) + @battle.battlers[idxB].pbThis, @battle.battlers[idxA].pbThis(true))) [idxA, idxB].each { |idx| @battle.pbEffectsOnBattlerEnteringPosition(@battle.battlers[idx]) } end end @@ -685,7 +685,7 @@ end class Battle::Move::BurnAttackerBeforeUserActs < Battle::Move def pbDisplayChargeMessage(user) user.effects[PBEffects::BeakBlast] = true - @battle.pbCommonAnimation("BeakBlast",user) - @battle.pbDisplay(_INTL("{1} started heating up its beak!",user.pbThis)) + @battle.pbCommonAnimation("BeakBlast", user) + @battle.pbDisplay(_INTL("{1} started heating up its beak!", user.pbThis)) end end diff --git a/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb b/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb index 9b5061c54..98e4ca469 100644 --- a/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb +++ b/Data/Scripts/011_Battle/003_Move/006_MoveEffects_BattlerStats.rb @@ -2,9 +2,9 @@ # Increases the user's Attack by 1 stage. #=============================================================================== class Battle::Move::RaiseUserAttack1 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1] + @statUp = [:ATTACK, 1] end end @@ -12,9 +12,9 @@ end # Increases the user's Attack by 2 stages. (Swords Dance) #=============================================================================== class Battle::Move::RaiseUserAttack2 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,2] + @statUp = [:ATTACK, 2] end end @@ -45,10 +45,10 @@ end # (Fell Stinger (Gen 7+)) #=============================================================================== class Battle::Move::RaiseUserAttack3IfTargetFaints < Battle::Move - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if !target.damageState.fainted - return if !user.pbCanRaiseStatStage?(:ATTACK,user,self) - user.pbRaiseStatStage(:ATTACK,3,user) + return if !user.pbCanRaiseStatStage?(:ATTACK, user, self) + user.pbRaiseStatStage(:ATTACK, 3, user) end end @@ -59,30 +59,30 @@ end class Battle::Move::MaxUserAttackLoseHalfOfTotalHP < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - hpLoss = [user.totalhp/2,1].max - if user.hp<=hpLoss + def pbMoveFailed?(user, targets) + hpLoss = [user.totalhp / 2, 1].max + if user.hp <= hpLoss @battle.pbDisplay(_INTL("But it failed!")) return true end - return true if !user.pbCanRaiseStatStage?(:ATTACK,user,self,true) + return true if !user.pbCanRaiseStatStage?(:ATTACK, user, self, true) return false end def pbEffectGeneral(user) - hpLoss = [user.totalhp/2,1].max + hpLoss = [user.totalhp / 2, 1].max user.pbReduceHP(hpLoss, false, false) if user.hasActiveAbility?(:CONTRARY) user.stages[:ATTACK] = -6 user.statsLoweredThisRound = true user.statsDropped = true - @battle.pbCommonAnimation("StatDown",user) - @battle.pbDisplay(_INTL("{1} cut its own HP and minimized its Attack!",user.pbThis)) + @battle.pbCommonAnimation("StatDown", user) + @battle.pbDisplay(_INTL("{1} cut its own HP and minimized its Attack!", user.pbThis)) else user.stages[:ATTACK] = 6 user.statsRaisedThisRound = true - @battle.pbCommonAnimation("StatUp",user) - @battle.pbDisplay(_INTL("{1} cut its own HP and maximized its Attack!",user.pbThis)) + @battle.pbCommonAnimation("StatUp", user) + @battle.pbDisplay(_INTL("{1} cut its own HP and maximized its Attack!", user.pbThis)) end user.pbItemHPHealCheck end @@ -92,9 +92,9 @@ end # Increases the user's Defense by 1 stage. (Harden, Steel Wing, Withdraw) #=============================================================================== class Battle::Move::RaiseUserDefense1 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:DEFENSE,1] + @statUp = [:DEFENSE, 1] end end @@ -102,9 +102,9 @@ end # Increases the user's Defense by 1 stage. User curls up. (Defense Curl) #=============================================================================== class Battle::Move::RaiseUserDefense1CurlUpUser < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:DEFENSE,1] + @statUp = [:DEFENSE, 1] end def pbEffectGeneral(user) @@ -117,9 +117,9 @@ end # Increases the user's Defense by 2 stages. (Acid Armor, Barrier, Iron Defense) #=============================================================================== class Battle::Move::RaiseUserDefense2 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:DEFENSE,2] + @statUp = [:DEFENSE, 2] end end @@ -127,9 +127,9 @@ end # Increases the user's Defense by 3 stages. (Cotton Guard) #=============================================================================== class Battle::Move::RaiseUserDefense3 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:DEFENSE,3] + @statUp = [:DEFENSE, 3] end end @@ -137,9 +137,9 @@ end # Increases the user's Special Attack by 1 stage. (Charge Beam, Fiery Dance) #=============================================================================== class Battle::Move::RaiseUserSpAtk1 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPECIAL_ATTACK,1] + @statUp = [:SPECIAL_ATTACK, 1] end end @@ -147,9 +147,9 @@ end # Increases the user's Special Attack by 2 stages. (Nasty Plot) #=============================================================================== class Battle::Move::RaiseUserSpAtk2 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPECIAL_ATTACK,2] + @statUp = [:SPECIAL_ATTACK, 2] end end @@ -157,9 +157,9 @@ end # Increases the user's Special Attack by 3 stages. (Tail Glow) #=============================================================================== class Battle::Move::RaiseUserSpAtk3 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPECIAL_ATTACK,3] + @statUp = [:SPECIAL_ATTACK, 3] end end @@ -178,14 +178,14 @@ end # Charges up user's next attack if it is Electric-type. (Charge) #=============================================================================== class Battle::Move::RaiseUserSpDef1PowerUpElectricMove < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPECIAL_DEFENSE,1] + @statUp = [:SPECIAL_DEFENSE, 1] end def pbEffectGeneral(user) user.effects[PBEffects::Charge] = 2 - @battle.pbDisplay(_INTL("{1} began charging power!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} began charging power!", user.pbThis)) super end end @@ -194,9 +194,9 @@ end # Increases the user's Special Defense by 2 stages. (Amnesia) #=============================================================================== class Battle::Move::RaiseUserSpDef2 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPECIAL_DEFENSE,2] + @statUp = [:SPECIAL_DEFENSE, 2] end end @@ -214,9 +214,9 @@ end # Increases the user's Speed by 1 stage. (Flame Charge) #=============================================================================== class Battle::Move::RaiseUserSpeed1 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPEED,1] + @statUp = [:SPEED, 1] end end @@ -224,9 +224,9 @@ end # Increases the user's Speed by 2 stages. (Agility, Rock Polish) #=============================================================================== class Battle::Move::RaiseUserSpeed2 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPEED,2] + @statUp = [:SPEED, 2] end end @@ -235,15 +235,15 @@ end # (Autotomize) #=============================================================================== class Battle::Move::RaiseUserSpeed2LowerUserWeight < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPEED,2] + @statUp = [:SPEED, 2] end def pbEffectGeneral(user) - if user.pbWeight+user.effects[PBEffects::WeightChange]>1 + if user.pbWeight + user.effects[PBEffects::WeightChange] > 1 user.effects[PBEffects::WeightChange] -= 1000 - @battle.pbDisplay(_INTL("{1} became nimble!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} became nimble!", user.pbThis)) end super end @@ -293,9 +293,9 @@ end # Increases the user's evasion by 1 stage. (Double Team) #=============================================================================== class Battle::Move::RaiseUserEvasion1 < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:EVASION,1] + @statUp = [:EVASION, 1] end end @@ -313,9 +313,9 @@ end # Increases the user's evasion by 2 stages. Minimizes the user. (Minimize) #=============================================================================== class Battle::Move::RaiseUserEvasion2MinimizeUser < Battle::Move::StatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:EVASION,2] + @statUp = [:EVASION, 2] end def pbEffectGeneral(user) @@ -340,8 +340,8 @@ end class Battle::Move::RaiseUserCriticalHitRate2 < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.effects[PBEffects::FocusEnergy]>=2 + def pbMoveFailed?(user, targets) + if user.effects[PBEffects::FocusEnergy] >= 2 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -350,7 +350,7 @@ class Battle::Move::RaiseUserCriticalHitRate2 < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::FocusEnergy] = 2 - @battle.pbDisplay(_INTL("{1} is getting pumped!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} is getting pumped!", user.pbThis)) end end @@ -358,9 +358,9 @@ end # Increases the user's Attack and Defense by 1 stage each. (Bulk Up) #=============================================================================== class Battle::Move::RaiseUserAtkDef1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1,:DEFENSE,1] + @statUp = [:ATTACK, 1, :DEFENSE, 1] end end @@ -368,9 +368,9 @@ end # Increases the user's Attack, Defense and accuracy by 1 stage each. (Coil) #=============================================================================== class Battle::Move::RaiseUserAtkDefAcc1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1,:DEFENSE,1,:ACCURACY,1] + @statUp = [:ATTACK, 1, :DEFENSE, 1, :ACCURACY, 1] end end @@ -378,9 +378,9 @@ end # Increases the user's Attack and Special Attack by 1 stage each. (Work Up) #=============================================================================== class Battle::Move::RaiseUserAtkSpAtk1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1,:SPECIAL_ATTACK,1] + @statUp = [:ATTACK, 1, :SPECIAL_ATTACK, 1] end end @@ -389,12 +389,12 @@ end # In sunny weather, increases are 2 stages each instead. (Growth) #=============================================================================== class Battle::Move::RaiseUserAtkSpAtk1Or2InSun < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1,:SPECIAL_ATTACK,1] + @statUp = [:ATTACK, 1, :SPECIAL_ATTACK, 1] end - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) increment = 1 increment = 2 if [:Sun, :HarshSun].include?(user.effectiveWeather) @statUp[1] = @statUp[3] = increment @@ -409,28 +409,28 @@ end class Battle::Move::LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2 < Battle::Move def canSnatch?; return true; end - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,2,:SPECIAL_ATTACK,2,:SPEED,2] - @statDown = [:DEFENSE,1,:SPECIAL_DEFENSE,1] + @statUp = [:ATTACK, 2, :SPECIAL_ATTACK, 2, :SPEED, 2] + @statDown = [:DEFENSE, 1, :SPECIAL_DEFENSE, 1] end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) failed = true - for i in 0...@statUp.length/2 - if user.pbCanRaiseStatStage?(@statUp[i*2],user,self) + for i in 0...@statUp.length / 2 + if user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) failed = false break end end - for i in 0...@statDown.length/2 - if user.pbCanLowerStatStage?(@statDown[i*2],user,self) + for i in 0...@statDown.length / 2 + if user.pbCanLowerStatStage?(@statDown[i * 2], user, self) failed = false break end end if failed - @battle.pbDisplay(_INTL("{1}'s stats can't be changed further!",user.pbThis)) + @battle.pbDisplay(_INTL("{1}'s stats can't be changed further!", user.pbThis)) return true end return false @@ -438,16 +438,16 @@ class Battle::Move::LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2 < Battle::Move def pbEffectGeneral(user) showAnim = true - for i in 0...@statDown.length/2 - next if !user.pbCanLowerStatStage?(@statDown[i*2],user,self) - if user.pbLowerStatStage(@statDown[i*2],@statDown[i*2+1],user,showAnim) + for i in 0...@statDown.length / 2 + next if !user.pbCanLowerStatStage?(@statDown[i * 2], user, self) + if user.pbLowerStatStage(@statDown[i * 2], @statDown[i * 2 + 1], user, showAnim) showAnim = false end end showAnim = true - for i in 0...@statUp.length/2 - next if !user.pbCanRaiseStatStage?(@statUp[i*2],user,self) - if user.pbRaiseStatStage(@statUp[i*2],@statUp[i*2+1],user,showAnim) + for i in 0...@statUp.length / 2 + next if !user.pbCanRaiseStatStage?(@statUp[i * 2], user, self) + if user.pbRaiseStatStage(@statUp[i * 2], @statUp[i * 2 + 1], user, showAnim) showAnim = false end end @@ -458,9 +458,9 @@ end # Increases the user's Attack and Speed by 1 stage each. (Dragon Dance) #=============================================================================== class Battle::Move::RaiseUserAtkSpd1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1,:SPEED,1] + @statUp = [:ATTACK, 1, :SPEED, 1] end end @@ -468,9 +468,9 @@ end # Increases the user's Speed by 2 stages, and its Attack by 1 stage. (Shift Gear) #=============================================================================== class Battle::Move::RaiseUserAtk1Spd2 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPEED,2,:ATTACK,1] + @statUp = [:SPEED, 2, :ATTACK, 1] end end @@ -478,9 +478,9 @@ end # Increases the user's Attack and accuracy by 1 stage each. (Hone Claws) #=============================================================================== class Battle::Move::RaiseUserAtkAcc1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1,:ACCURACY,1] + @statUp = [:ATTACK, 1, :ACCURACY, 1] end end @@ -489,9 +489,9 @@ end # (Cosmic Power, Defend Order) #=============================================================================== class Battle::Move::RaiseUserDefSpDef1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:DEFENSE,1,:SPECIAL_DEFENSE,1] + @statUp = [:DEFENSE, 1, :SPECIAL_DEFENSE, 1] end end @@ -499,9 +499,9 @@ end # Increases the user's Sp. Attack and Sp. Defense by 1 stage each. (Calm Mind) #=============================================================================== class Battle::Move::RaiseUserSpAtkSpDef1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPECIAL_ATTACK,1,:SPECIAL_DEFENSE,1] + @statUp = [:SPECIAL_ATTACK, 1, :SPECIAL_DEFENSE, 1] end end @@ -510,9 +510,9 @@ end # (Quiver Dance) #=============================================================================== class Battle::Move::RaiseUserSpAtkSpDefSpd1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:SPECIAL_ATTACK,1,:SPECIAL_DEFENSE,1,:SPEED,1] + @statUp = [:SPECIAL_ATTACK, 1, :SPECIAL_DEFENSE, 1, :SPEED, 1] end end @@ -521,9 +521,9 @@ end # by 1 stage each. (Ancient Power, Ominous Wind, Silver Wind) #=============================================================================== class Battle::Move::RaiseUserMainStats1 < Battle::Move::MultiStatUpMove - def initialize(battle,move) + def initialize(battle, move) super - @statUp = [:ATTACK,1,:DEFENSE,1,:SPECIAL_ATTACK,1,:SPECIAL_DEFENSE,1,:SPEED,1] + @statUp = [:ATTACK, 1, :DEFENSE, 1, :SPECIAL_ATTACK, 1, :SPECIAL_DEFENSE, 1, :SPEED, 1] end end @@ -621,9 +621,9 @@ end # Decreases the user's Defense by 1 stage. (Clanging Scales) #=============================================================================== class Battle::Move::LowerUserDefense1 < Battle::Move::StatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:DEFENSE,1] + @statDown = [:DEFENSE, 1] end end @@ -651,9 +651,9 @@ end # Decreases the user's Special Attack by 2 stages. #=============================================================================== class Battle::Move::LowerUserSpAtk2 < Battle::Move::StatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPECIAL_ATTACK,2] + @statDown = [:SPECIAL_ATTACK, 2] end end @@ -681,9 +681,9 @@ end # Decreases the user's Speed by 1 stage. (Hammer Arm, Ice Hammer) #=============================================================================== class Battle::Move::LowerUserSpeed1 < Battle::Move::StatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPEED,1] + @statDown = [:SPEED, 1] end end @@ -701,9 +701,9 @@ end # Decreases the user's Attack and Defense by 1 stage each. (Superpower) #=============================================================================== class Battle::Move::LowerUserAtkDef1 < Battle::Move::StatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ATTACK,1,:DEFENSE,1] + @statDown = [:ATTACK, 1, :DEFENSE, 1] end end @@ -712,9 +712,9 @@ end # (Close Combat, Dragon Ascent) #=============================================================================== class Battle::Move::LowerUserDefSpDef1 < Battle::Move::StatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:DEFENSE,1,:SPECIAL_DEFENSE,1] + @statDown = [:DEFENSE, 1, :SPECIAL_DEFENSE, 1] end end @@ -725,9 +725,9 @@ end # (V-create) #=============================================================================== class Battle::Move::LowerUserDefSpDefSpd1 < Battle::Move::StatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPEED,1,:DEFENSE,1,:SPECIAL_DEFENSE,1] + @statDown = [:SPEED, 1, :DEFENSE, 1, :SPECIAL_DEFENSE, 1] end end @@ -774,11 +774,11 @@ end class Battle::Move::RaiseTargetAttack2ConfuseTarget < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) failed = true targets.each do |b| - next if !b.pbCanRaiseStatStage?(:ATTACK,user,self) && - !b.pbCanConfuse?(user,false,self) + next if !b.pbCanRaiseStatStage?(:ATTACK, user, self) && + !b.pbCanConfuse?(user, false, self) failed = false break end @@ -789,11 +789,11 @@ class Battle::Move::RaiseTargetAttack2ConfuseTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - if target.pbCanRaiseStatStage?(:ATTACK,user,self) - target.pbRaiseStatStage(:ATTACK,2,user) + def pbEffectAgainstTarget(user, target) + if target.pbCanRaiseStatStage?(:ATTACK, user, self) + target.pbRaiseStatStage(:ATTACK, 2, user) end - target.pbConfuse if target.pbCanConfuse?(user,false,self) + target.pbConfuse if target.pbCanConfuse?(user, false, self) end end @@ -803,11 +803,11 @@ end class Battle::Move::RaiseTargetSpAtk1ConfuseTarget < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) failed = true targets.each do |b| - next if !b.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) && - !b.pbCanConfuse?(user,false,self) + next if !b.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) && + !b.pbCanConfuse?(user, false, self) failed = false break end @@ -818,11 +818,11 @@ class Battle::Move::RaiseTargetSpAtk1ConfuseTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) - target.pbRaiseStatStage(:SPECIAL_ATTACK,1,user) + def pbEffectAgainstTarget(user, target) + if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) + target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user) end - target.pbConfuse if target.pbCanConfuse?(user,false,self) + target.pbConfuse if target.pbCanConfuse?(user, false, self) end end @@ -837,8 +837,8 @@ class Battle::Move::RaiseTargetSpDef1 < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - target.pbRaiseStatStage(:SPECIAL_DEFENSE,1,user) + def pbEffectAgainstTarget(user, target) + target.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user) end end @@ -849,18 +849,18 @@ class Battle::Move::RaiseTargetRandomStat2 < Battle::Move def pbFailsAgainstTarget?(user, target, show_message) @statArray = [] GameData::Stat.each_battle do |s| - @statArray.push(s.id) if target.pbCanRaiseStatStage?(s.id,user,self) + @statArray.push(s.id) if target.pbCanRaiseStatStage?(s.id, user, self) end - if @statArray.length==0 + if @statArray.length == 0 @battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", target.pbThis)) if show_message return true end return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) stat = @statArray[@battle.pbRandom(@statArray.length)] - target.pbRaiseStatStage(stat,2,user) + target.pbRaiseStatStage(stat, 2, user) end end @@ -897,9 +897,9 @@ end # Decreases the target's Attack by 1 stage. #=============================================================================== class Battle::Move::LowerTargetAttack1 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ATTACK,1] + @statDown = [:ATTACK, 1] end end @@ -909,9 +909,9 @@ end class Battle::Move::LowerTargetAttack1BypassSubstitute < Battle::Move::TargetStatDownMove def ignoresSubstitute?(user); return true; end - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ATTACK,1] + @statDown = [:ATTACK, 1] end end @@ -919,9 +919,9 @@ end # Decreases the target's Attack by 2 stages. (Charm, Feather Dance) #=============================================================================== class Battle::Move::LowerTargetAttack2 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ATTACK,2] + @statDown = [:ATTACK, 2] end end @@ -939,9 +939,9 @@ end # Decreases the target's Defense by 1 stage. #=============================================================================== class Battle::Move::LowerTargetDefense1 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:DEFENSE,1] + @statDown = [:DEFENSE, 1] end end @@ -960,9 +960,9 @@ end # Decreases the target's Defense by 2 stages. (Screech) #=============================================================================== class Battle::Move::LowerTargetDefense2 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:DEFENSE,2] + @statDown = [:DEFENSE, 2] end end @@ -980,9 +980,9 @@ end # Decreases the target's Special Attack by 1 stage. #=============================================================================== class Battle::Move::LowerTargetSpAtk1 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPECIAL_ATTACK,1] + @statDown = [:SPECIAL_ATTACK, 1] end end @@ -990,9 +990,9 @@ end # Decreases the target's Special Attack by 2 stages. (Eerie Impulse) #=============================================================================== class Battle::Move::LowerTargetSpAtk2 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPECIAL_ATTACK,2] + @statDown = [:SPECIAL_ATTACK, 2] end end @@ -1001,16 +1001,16 @@ end # gender. (Captivate) #=============================================================================== class Battle::Move::LowerTargetSpAtk2IfCanAttract < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPECIAL_ATTACK,2] + @statDown = [:SPECIAL_ATTACK, 2] end def pbFailsAgainstTarget?(user, target, show_message) return true if super return false if damagingMove? - if user.gender==2 || target.gender==2 || user.gender==target.gender - @battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis)) if show_message + if user.gender == 2 || target.gender == 2 || user.gender == target.gender + @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message return true end if target.hasActiveAbility?(:OBLIVIOUS) && !@battle.moldBreaker @@ -1028,8 +1028,8 @@ class Battle::Move::LowerTargetSpAtk2IfCanAttract < Battle::Move::TargetStatDown return false end - def pbAdditionalEffect(user,target) - return if user.gender==2 || target.gender==2 || user.gender==target.gender + def pbAdditionalEffect(user, target) + return if user.gender == 2 || target.gender == 2 || user.gender == target.gender return if target.hasActiveAbility?(:OBLIVIOUS) && !@battle.moldBreaker super end @@ -1049,9 +1049,9 @@ end # Decreases the target's Special Defense by 1 stage. #=============================================================================== class Battle::Move::LowerTargetSpDef1 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPECIAL_DEFENSE,1] + @statDown = [:SPECIAL_DEFENSE, 1] end end @@ -1059,9 +1059,9 @@ end # Decreases the target's Special Defense by 2 stages. #=============================================================================== class Battle::Move::LowerTargetSpDef2 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPECIAL_DEFENSE,2] + @statDown = [:SPECIAL_DEFENSE, 2] end end @@ -1079,9 +1079,9 @@ end # Decreases the target's Speed by 1 stage. #=============================================================================== class Battle::Move::LowerTargetSpeed1 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPEED,1] + @statDown = [:SPEED, 1] end end @@ -1090,13 +1090,13 @@ end # (Bulldoze) #=============================================================================== class Battle::Move::LowerTargetSpeed1WeakerInGrassyTerrain < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPEED,1] + @statDown = [:SPEED, 1] end - def pbBaseDamage(baseDmg,user,target) - baseDmg = (baseDmg/2.0).round if @battle.field.terrain == :Grassy + def pbBaseDamage(baseDmg, user, target) + baseDmg = (baseDmg / 2.0).round if @battle.field.terrain == :Grassy return baseDmg end end @@ -1107,9 +1107,9 @@ end # neither of these effects can be applied. (Tar Shot) #=============================================================================== class Battle::Move::LowerTargetSpeed1MakeTargetWeakerToFire < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:SPEED,1] + @statDown = [:SPEED, 1] end def pbFailsAgainstTarget?(user, target, show_message) @@ -1130,7 +1130,7 @@ end # Decreases the target's Speed by 2 stages. (Cotton Spore, Scary Face, String Shot) #=============================================================================== class Battle::Move::LowerTargetSpeed2 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super @statDown = [:SPEED, 2] end @@ -1150,9 +1150,9 @@ end # Decreases the target's accuracy by 1 stage. #=============================================================================== class Battle::Move::LowerTargetAccuracy1 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ACCURACY,1] + @statDown = [:ACCURACY, 1] end end @@ -1180,7 +1180,7 @@ end # Decreases the target's evasion by 1 stage. (Sweet Scent (Gen 5-)) #=============================================================================== class Battle::Move::LowerTargetEvasion1 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super @statDown = [:EVASION, 1] end @@ -1193,83 +1193,83 @@ end class Battle::Move::LowerTargetEvasion1RemoveSideEffects < Battle::Move::TargetStatDownMove def ignoresSubstitute?(user); return true; end - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:EVASION,1] + @statDown = [:EVASION, 1] end def pbFailsAgainstTarget?(user, target, show_message) targetSide = target.pbOwnSide targetOpposingSide = target.pbOpposingSide - return false if targetSide.effects[PBEffects::AuroraVeil]>0 || - targetSide.effects[PBEffects::LightScreen]>0 || - targetSide.effects[PBEffects::Reflect]>0 || - targetSide.effects[PBEffects::Mist]>0 || - targetSide.effects[PBEffects::Safeguard]>0 + return false if targetSide.effects[PBEffects::AuroraVeil] > 0 || + targetSide.effects[PBEffects::LightScreen] > 0 || + targetSide.effects[PBEffects::Reflect] > 0 || + targetSide.effects[PBEffects::Mist] > 0 || + targetSide.effects[PBEffects::Safeguard] > 0 return false if targetSide.effects[PBEffects::StealthRock] || - targetSide.effects[PBEffects::Spikes]>0 || - targetSide.effects[PBEffects::ToxicSpikes]>0 || + targetSide.effects[PBEffects::Spikes] > 0 || + targetSide.effects[PBEffects::ToxicSpikes] > 0 || targetSide.effects[PBEffects::StickyWeb] return false if Settings::MECHANICS_GENERATION >= 6 && (targetOpposingSide.effects[PBEffects::StealthRock] || - targetOpposingSide.effects[PBEffects::Spikes]>0 || - targetOpposingSide.effects[PBEffects::ToxicSpikes]>0 || + targetOpposingSide.effects[PBEffects::Spikes] > 0 || + targetOpposingSide.effects[PBEffects::ToxicSpikes] > 0 || targetOpposingSide.effects[PBEffects::StickyWeb]) return false if Settings::MECHANICS_GENERATION >= 8 && @battle.field.terrain != :None return super end - def pbEffectAgainstTarget(user,target) - if target.pbCanLowerStatStage?(@statDown[0],user,self) - target.pbLowerStatStage(@statDown[0],@statDown[1],user) + def pbEffectAgainstTarget(user, target) + if target.pbCanLowerStatStage?(@statDown[0], user, self) + target.pbLowerStatStage(@statDown[0], @statDown[1], user) end - if target.pbOwnSide.effects[PBEffects::AuroraVeil]>0 + if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 target.pbOwnSide.effects[PBEffects::AuroraVeil] = 0 - @battle.pbDisplay(_INTL("{1}'s Aurora Veil wore off!",target.pbTeam)) + @battle.pbDisplay(_INTL("{1}'s Aurora Veil wore off!", target.pbTeam)) end - if target.pbOwnSide.effects[PBEffects::LightScreen]>0 + if target.pbOwnSide.effects[PBEffects::LightScreen] > 0 target.pbOwnSide.effects[PBEffects::LightScreen] = 0 - @battle.pbDisplay(_INTL("{1}'s Light Screen wore off!",target.pbTeam)) + @battle.pbDisplay(_INTL("{1}'s Light Screen wore off!", target.pbTeam)) end - if target.pbOwnSide.effects[PBEffects::Reflect]>0 + if target.pbOwnSide.effects[PBEffects::Reflect] > 0 target.pbOwnSide.effects[PBEffects::Reflect] = 0 - @battle.pbDisplay(_INTL("{1}'s Reflect wore off!",target.pbTeam)) + @battle.pbDisplay(_INTL("{1}'s Reflect wore off!", target.pbTeam)) end - if target.pbOwnSide.effects[PBEffects::Mist]>0 + if target.pbOwnSide.effects[PBEffects::Mist] > 0 target.pbOwnSide.effects[PBEffects::Mist] = 0 - @battle.pbDisplay(_INTL("{1}'s Mist faded!",target.pbTeam)) + @battle.pbDisplay(_INTL("{1}'s Mist faded!", target.pbTeam)) end - if target.pbOwnSide.effects[PBEffects::Safeguard]>0 + if target.pbOwnSide.effects[PBEffects::Safeguard] > 0 target.pbOwnSide.effects[PBEffects::Safeguard] = 0 - @battle.pbDisplay(_INTL("{1} is no longer protected by Safeguard!!",target.pbTeam)) + @battle.pbDisplay(_INTL("{1} is no longer protected by Safeguard!!", target.pbTeam)) end if target.pbOwnSide.effects[PBEffects::StealthRock] || (Settings::MECHANICS_GENERATION >= 6 && target.pbOpposingSide.effects[PBEffects::StealthRock]) target.pbOwnSide.effects[PBEffects::StealthRock] = false target.pbOpposingSide.effects[PBEffects::StealthRock] = false if Settings::MECHANICS_GENERATION >= 6 - @battle.pbDisplay(_INTL("{1} blew away stealth rocks!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away stealth rocks!", user.pbThis)) end - if target.pbOwnSide.effects[PBEffects::Spikes]>0 || + if target.pbOwnSide.effects[PBEffects::Spikes] > 0 || (Settings::MECHANICS_GENERATION >= 6 && - target.pbOpposingSide.effects[PBEffects::Spikes]>0) + target.pbOpposingSide.effects[PBEffects::Spikes] > 0) target.pbOwnSide.effects[PBEffects::Spikes] = 0 target.pbOpposingSide.effects[PBEffects::Spikes] = 0 if Settings::MECHANICS_GENERATION >= 6 - @battle.pbDisplay(_INTL("{1} blew away spikes!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away spikes!", user.pbThis)) end - if target.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 || + if target.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0 || (Settings::MECHANICS_GENERATION >= 6 && - target.pbOpposingSide.effects[PBEffects::ToxicSpikes]>0) + target.pbOpposingSide.effects[PBEffects::ToxicSpikes] > 0) target.pbOwnSide.effects[PBEffects::ToxicSpikes] = 0 target.pbOpposingSide.effects[PBEffects::ToxicSpikes] = 0 if Settings::MECHANICS_GENERATION >= 6 - @battle.pbDisplay(_INTL("{1} blew away poison spikes!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away poison spikes!", user.pbThis)) end if target.pbOwnSide.effects[PBEffects::StickyWeb] || (Settings::MECHANICS_GENERATION >= 6 && target.pbOpposingSide.effects[PBEffects::StickyWeb]) target.pbOwnSide.effects[PBEffects::StickyWeb] = false target.pbOpposingSide.effects[PBEffects::StickyWeb] = false if Settings::MECHANICS_GENERATION >= 6 - @battle.pbDisplay(_INTL("{1} blew away sticky webs!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} blew away sticky webs!", user.pbThis)) end if Settings::MECHANICS_GENERATION >= 8 && @battle.field.terrain != :None case @battle.field.terrain @@ -1291,7 +1291,7 @@ end # Decreases the target's evasion by 2 stages. (Sweet Scent (Gen 6+)) #=============================================================================== class Battle::Move::LowerTargetEvasion2 < Battle::Move::TargetStatDownMove - def initialize(battle,move) + def initialize(battle, move) super @statDown = [:EVASION, 2] end @@ -1311,9 +1311,9 @@ end # Decreases the target's Attack and Defense by 1 stage each. (Tickle) #=============================================================================== class Battle::Move::LowerTargetAtkDef1 < Battle::Move::TargetMultiStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ATTACK,1,:DEFENSE,1] + @statDown = [:ATTACK, 1, :DEFENSE, 1] end end @@ -1321,9 +1321,9 @@ end # Decreases the target's Attack and Special Attack by 1 stage each. (Noble Roar) #=============================================================================== class Battle::Move::LowerTargetAtkSpAtk1 < Battle::Move::TargetMultiStatDownMove - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ATTACK,1,:SPECIAL_ATTACK,1] + @statDown = [:ATTACK, 1, :SPECIAL_ATTACK, 1] end end @@ -1334,22 +1334,22 @@ end class Battle::Move::LowerPoisonedTargetAtkSpAtkSpd1 < Battle::Move def canMagicCoat?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @statDown = [:ATTACK, 1, :SPECIAL_ATTACK, 1, :SPEED, 1] end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @validTargets = [] targets.each do |b| next if !b || b.fainted? next if !b.poisoned? - next if !b.pbCanLowerStatStage?(:ATTACK,user,self) && - !b.pbCanLowerStatStage?(:SPECIAL_ATTACK,user,self) && - !b.pbCanLowerStatStage?(:SPEED,user,self) + next if !b.pbCanLowerStatStage?(:ATTACK, user, self) && + !b.pbCanLowerStatStage?(:SPECIAL_ATTACK, user, self) && + !b.pbCanLowerStatStage?(:SPEED, user, self) @validTargets.push(b.index) end - if @validTargets.length==0 + if @validTargets.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1378,7 +1378,7 @@ class Battle::Move::LowerPoisonedTargetAtkSpAtkSpd1 < Battle::Move return true end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if !@validTargets.include?(target.index) return if !pbCheckForMirrorArmor(user, target) showAnim = true @@ -1452,15 +1452,15 @@ class Battle::Move::RaisePlusMinusUserAndAlliesAtkSpAtk1 < Battle::Move def ignoresSubstitute?(user); return true; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @validTargets = [] @battle.allSameSideBattlers(user).each do |b| - next if !b.hasActiveAbility?([:MINUS,:PLUS]) - next if !b.pbCanRaiseStatStage?(:ATTACK,user,self) && - !b.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) + next if !b.hasActiveAbility?([:MINUS, :PLUS]) + next if !b.pbCanRaiseStatStage?(:ATTACK, user, self) && + !b.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) @validTargets.push(b) end - if @validTargets.length==0 + if @validTargets.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1468,27 +1468,27 @@ class Battle::Move::RaisePlusMinusUserAndAlliesAtkSpAtk1 < Battle::Move end def pbFailsAgainstTarget?(user, target, show_message) - return false if @validTargets.any? { |b| b.index==target.index } - return true if !target.hasActiveAbility?([:MINUS,:PLUS]) + return false if @validTargets.any? { |b| b.index == target.index } + return true if !target.hasActiveAbility?([:MINUS, :PLUS]) @battle.pbDisplay(_INTL("{1}'s stats can't be raised further!", target.pbThis)) if show_message return true end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) showAnim = true - if target.pbCanRaiseStatStage?(:ATTACK,user,self) - if target.pbRaiseStatStage(:ATTACK,1,user,showAnim) + if target.pbCanRaiseStatStage?(:ATTACK, user, self) + if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim) showAnim = false end end - if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) - target.pbRaiseStatStage(:SPECIAL_ATTACK,1,user,showAnim) + if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) + target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim) end end def pbEffectGeneral(user) return if pbTarget(user) != :UserSide - @validTargets.each { |b| pbEffectAgainstTarget(user,b) } + @validTargets.each { |b| pbEffectAgainstTarget(user, b) } end end @@ -1507,15 +1507,15 @@ class Battle::Move::RaisePlusMinusUserAndAlliesDefSpDef1 < Battle::Move def ignoresSubstitute?(user); return true; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @validTargets = [] @battle.allSameSideBattlers(user).each do |b| - next if !b.hasActiveAbility?([:MINUS,:PLUS]) - next if !b.pbCanRaiseStatStage?(:DEFENSE,user,self) && - !b.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self) + next if !b.hasActiveAbility?([:MINUS, :PLUS]) + next if !b.pbCanRaiseStatStage?(:DEFENSE, user, self) && + !b.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self) @validTargets.push(b) end - if @validTargets.length==0 + if @validTargets.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1523,27 +1523,27 @@ class Battle::Move::RaisePlusMinusUserAndAlliesDefSpDef1 < Battle::Move end def pbFailsAgainstTarget?(user, target, show_message) - return false if @validTargets.any? { |b| b.index==target.index } - return true if !target.hasActiveAbility?([:MINUS,:PLUS]) + return false if @validTargets.any? { |b| b.index == target.index } + return true if !target.hasActiveAbility?([:MINUS, :PLUS]) @battle.pbDisplay(_INTL("{1}'s stats can't be raised further!", target.pbThis)) if show_message return true end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) showAnim = true - if target.pbCanRaiseStatStage?(:DEFENSE,user,self) - if target.pbRaiseStatStage(:DEFENSE,1,user,showAnim) + if target.pbCanRaiseStatStage?(:DEFENSE, user, self) + if target.pbRaiseStatStage(:DEFENSE, 1, user, showAnim) showAnim = false end end - if target.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self) - target.pbRaiseStatStage(:SPECIAL_DEFENSE,1,user,showAnim) + if target.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self) + target.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user, showAnim) end end def pbEffectGeneral(user) return if pbTarget(user) != :UserSide - @validTargets.each { |b| pbEffectAgainstTarget(user,b) } + @validTargets.each { |b| pbEffectAgainstTarget(user, b) } end end @@ -1552,16 +1552,16 @@ end # 1 stage each. Doesn't affect airborne Pokémon. (Rototiller) #=============================================================================== class Battle::Move::RaiseGroundedGrassBattlersAtkSpAtk1 < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @validTargets = [] @battle.allBattlers.each do |b| next if !b.pbHasType?(:GRASS) next if b.airborne? || b.semiInvulnerable? - next if !b.pbCanRaiseStatStage?(:ATTACK,user,self) && - !b.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) + next if !b.pbCanRaiseStatStage?(:ATTACK, user, self) && + !b.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) @validTargets.push(b.index) end - if @validTargets.length==0 + if @validTargets.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1576,15 +1576,15 @@ class Battle::Move::RaiseGroundedGrassBattlersAtkSpAtk1 < Battle::Move return true end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) showAnim = true - if target.pbCanRaiseStatStage?(:ATTACK,user,self) - if target.pbRaiseStatStage(:ATTACK,1,user,showAnim) + if target.pbCanRaiseStatStage?(:ATTACK, user, self) + if target.pbRaiseStatStage(:ATTACK, 1, user, showAnim) showAnim = false end end - if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) - target.pbRaiseStatStage(:SPECIAL_ATTACK,1,user,showAnim) + if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) + target.pbRaiseStatStage(:SPECIAL_ATTACK, 1, user, showAnim) end end end @@ -1594,15 +1594,15 @@ end # (Flower Shield) #=============================================================================== class Battle::Move::RaiseGrassBattlersDef1 < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @validTargets = [] @battle.allBattlers.each do |b| next if !b.pbHasType?(:GRASS) next if b.semiInvulnerable? - next if !b.pbCanRaiseStatStage?(:DEFENSE,user,self) + next if !b.pbCanRaiseStatStage?(:DEFENSE, user, self) @validTargets.push(b.index) end - if @validTargets.length==0 + if @validTargets.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1615,8 +1615,8 @@ class Battle::Move::RaiseGrassBattlersDef1 < Battle::Move return !target.pbCanRaiseStatStage?(:DEFENSE, user, self, show_message) end - def pbEffectAgainstTarget(user,target) - target.pbRaiseStatStage(:DEFENSE,1,user) + def pbEffectAgainstTarget(user, target) + target.pbRaiseStatStage(:DEFENSE, 1, user) end end @@ -1626,8 +1626,8 @@ end class Battle::Move::UserTargetSwapAtkSpAtkStages < Battle::Move def ignoresSubstitute?(user); return true; end - def pbEffectAgainstTarget(user,target) - [:ATTACK,:SPECIAL_ATTACK].each do |s| + def pbEffectAgainstTarget(user, target) + [:ATTACK, :SPECIAL_ATTACK].each do |s| if user.stages[s] > target.stages[s] user.statsLoweredThisRound = true user.statsDropped = true @@ -1637,9 +1637,9 @@ class Battle::Move::UserTargetSwapAtkSpAtkStages < Battle::Move target.statsLoweredThisRound = true target.statsDropped = true end - user.stages[s],target.stages[s] = target.stages[s],user.stages[s] + user.stages[s], target.stages[s] = target.stages[s], user.stages[s] end - @battle.pbDisplay(_INTL("{1} switched all changes to its Attack and Sp. Atk with the target!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} switched all changes to its Attack and Sp. Atk with the target!", user.pbThis)) end end @@ -1649,8 +1649,8 @@ end class Battle::Move::UserTargetSwapDefSpDefStages < Battle::Move def ignoresSubstitute?(user); return true; end - def pbEffectAgainstTarget(user,target) - [:DEFENSE,:SPECIAL_DEFENSE].each do |s| + def pbEffectAgainstTarget(user, target) + [:DEFENSE, :SPECIAL_DEFENSE].each do |s| if user.stages[s] > target.stages[s] user.statsLoweredThisRound = true user.statsDropped = true @@ -1660,9 +1660,9 @@ class Battle::Move::UserTargetSwapDefSpDefStages < Battle::Move target.statsLoweredThisRound = true target.statsDropped = true end - user.stages[s],target.stages[s] = target.stages[s],user.stages[s] + user.stages[s], target.stages[s] = target.stages[s], user.stages[s] end - @battle.pbDisplay(_INTL("{1} switched all changes to its Defense and Sp. Def with the target!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} switched all changes to its Defense and Sp. Def with the target!", user.pbThis)) end end @@ -1672,7 +1672,7 @@ end class Battle::Move::UserTargetSwapStatStages < Battle::Move def ignoresSubstitute?(user); return true; end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) GameData::Stat.each_battle do |s| if user.stages[s.id] > target.stages[s.id] user.statsLoweredThisRound = true @@ -1683,9 +1683,9 @@ class Battle::Move::UserTargetSwapStatStages < Battle::Move target.statsLoweredThisRound = true target.statsDropped = true end - user.stages[s.id],target.stages[s.id] = target.stages[s.id],user.stages[s.id] + user.stages[s.id], target.stages[s.id] = target.stages[s.id], user.stages[s.id] end - @battle.pbDisplay(_INTL("{1} switched stat changes with the target!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} switched stat changes with the target!", user.pbThis)) end end @@ -1695,7 +1695,7 @@ end class Battle::Move::UserCopyTargetStatStages < Battle::Move def ignoresSubstitute?(user); return true; end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) GameData::Stat.each_battle do |s| if user.stages[s.id] > target.stages[s.id] user.statsLoweredThisRound = true @@ -1709,7 +1709,7 @@ class Battle::Move::UserCopyTargetStatStages < Battle::Move user.effects[PBEffects::FocusEnergy] = target.effects[PBEffects::FocusEnergy] user.effects[PBEffects::LaserFocus] = target.effects[PBEffects::LaserFocus] end - @battle.pbDisplay(_INTL("{1} copied {2}'s stat changes!",user.pbThis,target.pbThis(true))) + @battle.pbDisplay(_INTL("{1} copied {2}'s stat changes!", user.pbThis, target.pbThis(true))) end end @@ -1721,15 +1721,15 @@ end class Battle::Move::UserStealTargetPositiveStatStages < Battle::Move def ignoresSubstitute?(user); return true; end - def pbCalcDamage(user,target,numTargets = 1) + def pbCalcDamage(user, target, numTargets = 1) if target.hasRaisedStatStages? - pbShowAnimation(@id,user,target,1) # Stat stage-draining animation - @battle.pbDisplay(_INTL("{1} stole the target's boosted stats!",user.pbThis)) + pbShowAnimation(@id, user, target, 1) # Stat stage-draining animation + @battle.pbDisplay(_INTL("{1} stole the target's boosted stats!", user.pbThis)) showAnim = true GameData::Stat.each_battle do |s| next if target.stages[s.id] <= 0 - if user.pbCanRaiseStatStage?(s.id,user,self) - if user.pbRaiseStatStage(s.id,target.stages[s.id],user,showAnim) + if user.pbCanRaiseStatStage?(s.id, user, self) + if user.pbRaiseStatStage(s.id, target.stages[s.id], user, showAnim) showAnim = false end end @@ -1756,7 +1756,7 @@ class Battle::Move::InvertTargetStatStages < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) GameData::Stat.each_battle do |s| if target.stages[s.id] > 0 target.statsLoweredThisRound = true @@ -1766,7 +1766,7 @@ class Battle::Move::InvertTargetStatStages < Battle::Move end target.stages[s.id] *= -1 end - @battle.pbDisplay(_INTL("{1}'s stats were reversed!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s stats were reversed!", target.pbThis)) end end @@ -1774,11 +1774,11 @@ end # Resets all target's stat stages to 0. (Clear Smog) #=============================================================================== class Battle::Move::ResetTargetStatStages < Battle::Move - def pbEffectAgainstTarget(user,target) - if target.damageState.calcDamage>0 && !target.damageState.substitute && + def pbEffectAgainstTarget(user, target) + if target.damageState.calcDamage > 0 && !target.damageState.substitute && target.hasAlteredStatStages? target.pbResetStatStages - @battle.pbDisplay(_INTL("{1}'s stat changes were removed!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s stat changes were removed!", target.pbThis)) end end end @@ -1787,7 +1787,7 @@ end # Resets all stat stages for all battlers to 0. (Haze) #=============================================================================== class Battle::Move::ResetAllBattlersStatStages < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @battle.allBattlers.none? { |b| b.hasAlteredStatStages? } @battle.pbDisplay(_INTL("But it failed!")) return true @@ -1807,8 +1807,8 @@ end class Battle::Move::StartUserSideImmunityToStatStageLowering < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.pbOwnSide.effects[PBEffects::Mist]>0 + def pbMoveFailed?(user, targets) + if user.pbOwnSide.effects[PBEffects::Mist] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1817,7 +1817,7 @@ class Battle::Move::StartUserSideImmunityToStatStageLowering < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::Mist] = 5 - @battle.pbDisplay(_INTL("{1} became shrouded in mist!",user.pbTeam)) + @battle.pbDisplay(_INTL("{1} became shrouded in mist!", user.pbTeam)) end end @@ -1828,9 +1828,9 @@ class Battle::Move::UserSwapBaseAtkDef < Battle::Move def canSnatch?; return true; end def pbEffectGeneral(user) - user.attack,user.defense = user.defense,user.attack + user.attack, user.defense = user.defense, user.attack user.effects[PBEffects::PowerTrick] = !user.effects[PBEffects::PowerTrick] - @battle.pbDisplay(_INTL("{1} switched its Attack and Defense!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} switched its Attack and Defense!", user.pbThis)) end end @@ -1840,9 +1840,9 @@ end class Battle::Move::UserTargetSwapBaseSpeed < Battle::Move def ignoresSubstitute?(user); return true; end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) user.speed, target.speed = target.speed, user.speed - @battle.pbDisplay(_INTL("{1} switched Speed with its target!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} switched Speed with its target!", user.pbThis)) end end @@ -1851,12 +1851,12 @@ end # Averages the user's and target's Special Attack. (Power Split) #=============================================================================== class Battle::Move::UserTargetAverageBaseAtkSpAtk < Battle::Move - def pbEffectAgainstTarget(user,target) - newatk = ((user.attack+target.attack)/2).floor - newspatk = ((user.spatk+target.spatk)/2).floor + def pbEffectAgainstTarget(user, target) + newatk = ((user.attack + target.attack) / 2).floor + newspatk = ((user.spatk + target.spatk) / 2).floor user.attack = target.attack = newatk user.spatk = target.spatk = newspatk - @battle.pbDisplay(_INTL("{1} shared its power with the target!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} shared its power with the target!", user.pbThis)) end end @@ -1865,12 +1865,12 @@ end # Averages the user's and target's Special Defense. (Guard Split) #=============================================================================== class Battle::Move::UserTargetAverageBaseDefSpDef < Battle::Move - def pbEffectAgainstTarget(user,target) - newdef = ((user.defense+target.defense)/2).floor - newspdef = ((user.spdef+target.spdef)/2).floor + def pbEffectAgainstTarget(user, target) + newdef = ((user.defense + target.defense) / 2).floor + newspdef = ((user.spdef + target.spdef) / 2).floor user.defense = target.defense = newdef user.spdef = target.spdef = newspdef - @battle.pbDisplay(_INTL("{1} shared its guard with the target!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} shared its guard with the target!", user.pbThis)) end end @@ -1878,17 +1878,17 @@ end # Averages the user's and target's current HP. (Pain Split) #=============================================================================== class Battle::Move::UserTargetAverageHP < Battle::Move - def pbEffectAgainstTarget(user,target) - newHP = (user.hp+target.hp)/2 - if user.hp>newHP - user.pbReduceHP(user.hp-newHP,false,false) - elsif user.hp newHP + user.pbReduceHP(user.hp - newHP, false, false) + elsif user.hp < newHP + user.pbRecoverHP(newHP - user.hp, false) end - if target.hp>newHP - target.pbReduceHP(target.hp-newHP,false,false) - elsif target.hp newHP + target.pbReduceHP(target.hp - newHP, false, false) + elsif target.hp < newHP + target.pbRecoverHP(newHP - target.hp, false) end @battle.pbDisplay(_INTL("The battlers shared their pain!")) user.pbItemHPHealCheck @@ -1902,8 +1902,8 @@ end class Battle::Move::StartUserSideDoubleSpeed < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.pbOwnSide.effects[PBEffects::Tailwind]>0 + def pbMoveFailed?(user, targets) + if user.pbOwnSide.effects[PBEffects::Tailwind] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1912,7 +1912,7 @@ class Battle::Move::StartUserSideDoubleSpeed < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::Tailwind] = 4 - @battle.pbDisplay(_INTL("The Tailwind blew from behind {1}!",user.pbTeam(true))) + @battle.pbDisplay(_INTL("The Tailwind blew from behind {1}!", user.pbTeam(true))) end end @@ -1922,7 +1922,7 @@ end #=============================================================================== class Battle::Move::StartSwapAllBattlersBaseDefensiveStats < Battle::Move def pbEffectGeneral(user) - if @battle.field.effects[PBEffects::WonderRoom]>0 + if @battle.field.effects[PBEffects::WonderRoom] > 0 @battle.field.effects[PBEffects::WonderRoom] = 0 @battle.pbDisplay(_INTL("Wonder Room wore off, and the Defense and Sp. Def stats returned to normal!")) else @@ -1931,8 +1931,8 @@ class Battle::Move::StartSwapAllBattlersBaseDefensiveStats < Battle::Move end end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) - return if @battle.field.effects[PBEffects::WonderRoom]>0 # No animation + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) + return if @battle.field.effects[PBEffects::WonderRoom] > 0 # No animation super end end diff --git a/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb b/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb index 7f445fcf6..e7a1c644f 100644 --- a/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb +++ b/Data/Scripts/011_Battle/003_Move/007_MoveEffects_BattlerOther.rb @@ -9,14 +9,14 @@ class Battle::Move::SleepTarget < Battle::Move return !target.pbCanSleep?(user, show_message, self) end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? target.pbSleep end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbSleep if target.pbCanSleep?(user,false,self) + target.pbSleep if target.pbCanSleep?(user, false, self) end end @@ -24,9 +24,9 @@ end # Puts the target to sleep. Fails if user is not Darkrai. (Dark Void (Gen 7+)) #=============================================================================== class Battle::Move::SleepTargetIfUserDarkrai < Battle::Move::SleepTarget - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.isSpecies?(:DARKRAI) && user.effects[PBEffects::TransformSpecies] != :DARKRAI - @battle.pbDisplay(_INTL("But {1} can't use the move!",user.pbThis)) + @battle.pbDisplay(_INTL("But {1} can't use the move!", user.pbThis)) return true end return false @@ -38,13 +38,13 @@ end # (Relic Song) #=============================================================================== class Battle::Move::SleepTargetChangeUserMeloettaForm < Battle::Move::SleepTarget - def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers) - return if numHits==0 + def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers) + return if numHits == 0 return if user.fainted? || user.effects[PBEffects::Transform] return if !user.isSpecies?(:MELOETTA) - return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect>0 - newForm = (user.form+1)%2 - user.pbChangeForm(newForm,_INTL("{1} transformed!",user.pbThis)) + return if user.hasActiveAbility?(:SHEERFORCE) && @addlEffect > 0 + newForm = (user.form + 1) % 2 + user.pbChangeForm(newForm, _INTL("{1} transformed!", user.pbThis)) end end @@ -55,17 +55,17 @@ class Battle::Move::SleepTargetNextTurn < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.effects[PBEffects::Yawn]>0 + if target.effects[PBEffects::Yawn] > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end - return true if !target.pbCanSleep?(user,true,self) + return true if !target.pbCanSleep?(user, true, self) return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Yawn] = 2 - @battle.pbDisplay(_INTL("{1} made {2} drowsy!",user.pbThis,target.pbThis(true))) + @battle.pbDisplay(_INTL("{1} made {2} drowsy!", user.pbThis, target.pbThis(true))) end end @@ -75,7 +75,7 @@ end class Battle::Move::PoisonTarget < Battle::Move def canMagicCoat?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @toxic = false end @@ -85,14 +85,14 @@ class Battle::Move::PoisonTarget < Battle::Move return !target.pbCanPoison?(user, show_message, self) end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? - target.pbPoison(user,nil,@toxic) + target.pbPoison(user, nil, @toxic) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbPoison(user,nil,@toxic) if target.pbCanPoison?(user,false,self) + target.pbPoison(user, nil, @toxic) if target.pbCanPoison?(user, false, self) end end @@ -103,18 +103,18 @@ class Battle::Move::PoisonTargetLowerTargetSpeed1 < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if !target.pbCanPoison?(user,false,self) && - !target.pbCanLowerStatStage?(:SPEED,user,self) + if !target.pbCanPoison?(user, false, self) && + !target.pbCanLowerStatStage?(:SPEED, user, self) @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbEffectAgainstTarget(user,target) - target.pbPoison(user) if target.pbCanPoison?(user,false,self) - if target.pbCanLowerStatStage?(:SPEED,user,self) - target.pbLowerStatStage(:SPEED,1,user) + def pbEffectAgainstTarget(user, target) + target.pbPoison(user) if target.pbCanPoison?(user, false, self) + if target.pbCanLowerStatStage?(:SPEED, user, self) + target.pbLowerStatStage(:SPEED, 1, user) end end end @@ -123,12 +123,12 @@ end # Badly poisons the target. (Poison Fang, Toxic) #=============================================================================== class Battle::Move::BadPoisonTarget < Battle::Move::PoisonTarget - def initialize(battle,move) + def initialize(battle, move) super @toxic = true end - def pbOverrideSuccessCheckPerHit(user,target) + def pbOverrideSuccessCheckPerHit(user, target) return (Settings::MORE_TYPE_EFFECTS && statusMove? && user.pbHasType?(:POISON)) end end @@ -144,14 +144,14 @@ class Battle::Move::ParalyzeTarget < Battle::Move return !target.pbCanParalyze?(user, show_message, self) end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? target.pbParalyze(user) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbParalyze(user) if target.pbCanParalyze?(user,false,self) + target.pbParalyze(user) if target.pbCanParalyze?(user, false, self) end end @@ -175,8 +175,8 @@ end #=============================================================================== class Battle::Move::ParalyzeTargetTrampleMinimize < Battle::Move::ParalyzeTarget def tramplesMinimize?(param = 1) - return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy - return true if param==2 # Double damage + return true if param == 1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy + return true if param == 2 # Double damage return super end end @@ -188,7 +188,7 @@ end class Battle::Move::ParalyzeTargetAlwaysHitsInRainHitsTargetInSky < Battle::Move::ParalyzeTarget def hitsFlyingTargets?; return true; end - def pbBaseAccuracy(user,target) + def pbBaseAccuracy(user, target) case target.effectiveWeather when :Sun, :HarshSun return 50 @@ -205,14 +205,14 @@ end class Battle::Move::ParalyzeFlinchTarget < Battle::Move def flinchingMove?; return true; end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - chance = pbAdditionalEffectChance(user,target,10) - return if chance==0 - if @battle.pbRandom(100)0 + def pbMoveFailed?(user, targets) + if user.pbOwnSide.effects[PBEffects::Safeguard] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -526,7 +526,7 @@ class Battle::Move::StartUserSideImmunityToInflictedStatus < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::Safeguard] = 5 - @battle.pbDisplay(_INTL("{1} became cloaked in a mystical veil!",user.pbTeam)) + @battle.pbDisplay(_INTL("{1} became cloaked in a mystical veil!", user.pbTeam)) end end @@ -536,12 +536,12 @@ end class Battle::Move::FlinchTarget < Battle::Move def flinchingMove?; return true; end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? target.pbFlinch(user) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute target.pbFlinch(user) end @@ -553,8 +553,8 @@ end #=============================================================================== class Battle::Move::FlinchTargetTrampleMinimize < Battle::Move::FlinchTarget def tramplesMinimize?(param = 1) - return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy - return true if param==2 # Double damage + return true if param == 1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy + return true if param == 2 # Double damage return super end end @@ -565,7 +565,7 @@ end class Battle::Move::FlinchTargetFailsIfUserNotAsleep < Battle::Move::FlinchTarget def usableWhenAsleep?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.asleep? @battle.pbDisplay(_INTL("But it failed!")) return true @@ -579,7 +579,7 @@ end # (Fake Out) #=============================================================================== class Battle::Move::FlinchTargetFailsIfNotUserFirstTurn < Battle::Move::FlinchTarget - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.turnCount > 1 @battle.pbDisplay(_INTL("But it failed!")) return true @@ -595,11 +595,11 @@ end class Battle::Move::FlinchTargetDoublePowerIfTargetInSky < Battle::Move::FlinchTarget def hitsFlyingTargets?; return true; end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", "TwoTurnAttackInvulnerableInSkyParalyzeTarget", "TwoTurnAttackInvulnerableInSkyTargetCannotAct") || - target.effects[PBEffects::SkyDrop]>=0 + target.effects[PBEffects::SkyDrop] >= 0 return baseDmg end end @@ -615,14 +615,14 @@ class Battle::Move::ConfuseTarget < Battle::Move return !target.pbCanConfuse?(user, show_message, self) end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? target.pbConfuse end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - return if !target.pbCanConfuse?(user,false,self) + return if !target.pbCanConfuse?(user, false, self) target.pbConfuse end end @@ -634,7 +634,7 @@ end class Battle::Move::ConfuseTargetAlwaysHitsInRainHitsTargetInSky < Battle::Move::ConfuseTarget def hitsFlyingTargets?; return true; end - def pbBaseAccuracy(user,target) + def pbBaseAccuracy(user, target) case target.effectiveWeather when :Sun, :HarshSun return 50 @@ -659,14 +659,14 @@ class Battle::Move::AttractTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? target.pbAttract(user) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbAttract(user) if target.pbCanAttract?(user,false) + target.pbAttract(user) if target.pbCanAttract?(user, false) end end @@ -676,7 +676,7 @@ end class Battle::Move::SetUserTypesBasedOnEnvironment < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.canChangeType? @battle.pbDisplay(_INTL("But it failed!")) return true @@ -742,7 +742,7 @@ class Battle::Move::SetUserTypesBasedOnEnvironment < Battle::Move def pbEffectGeneral(user) user.pbChangeTypes(@newType) typeName = GameData::Type.get(@newType).name - @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName)) end end @@ -794,7 +794,7 @@ end class Battle::Move::SetUserTypesToTargetTypes < Battle::Move def ignoresSubstitute?(user); return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.canChangeType? @battle.pbDisplay(_INTL("But it failed!")) return true @@ -804,22 +804,22 @@ class Battle::Move::SetUserTypesToTargetTypes < Battle::Move def pbFailsAgainstTarget?(user, target, show_message) newTypes = target.pbTypes(true) - if newTypes.length==0 # Target has no type to copy + if newTypes.length == 0 # Target has no type to copy @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end - if user.pbTypes==target.pbTypes && - user.effects[PBEffects::Type3]==target.effects[PBEffects::Type3] + if user.pbTypes == target.pbTypes && + user.effects[PBEffects::Type3] == target.effects[PBEffects::Type3] @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) user.pbChangeTypes(target) @battle.pbDisplay(_INTL("{1}'s type changed to match {2}'s!", - user.pbThis,target.pbThis(true))) + user.pbThis, target.pbThis(true))) end end @@ -831,20 +831,20 @@ end class Battle::Move::SetUserTypesToUserMoveType < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.canChangeType? @battle.pbDisplay(_INTL("But it failed!")) return true end userTypes = user.pbTypes(true) @newTypes = [] - user.eachMoveWithIndex do |m,i| - break if Settings::MECHANICS_GENERATION >= 6 && i>0 + user.eachMoveWithIndex do |m, i| + break if Settings::MECHANICS_GENERATION >= 6 && i > 0 next if GameData::Type.get(m.type).pseudo_type next if userTypes.include?(m.type) @newTypes.push(m.type) if !@newTypes.include?(m.type) end - if @newTypes.length==0 + if @newTypes.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -855,7 +855,7 @@ class Battle::Move::SetUserTypesToUserMoveType < Battle::Move newType = @newTypes[@battle.pbRandom(@newTypes.length)] user.pbChangeTypes(newType) typeName = GameData::Type.get(newType).name - @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",user.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!", user.pbThis, typeName)) end end @@ -896,10 +896,10 @@ class Battle::Move::SetTargetTypesToWater < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.pbChangeTypes(:WATER) typeName = GameData::Type.get(:WATER).name - @battle.pbDisplay(_INTL("{1}'s type changed to {2}!",target.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1}'s type changed to {2}!", target.pbThis, typeName)) end end @@ -917,10 +917,10 @@ class Battle::Move::AddGhostTypeToTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Type3] = :GHOST typeName = GameData::Type.get(:GHOST).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName)) end end @@ -938,10 +938,10 @@ class Battle::Move::AddGrassTypeToTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Type3] = :GRASS typeName = GameData::Type.get(:GRASS).name - @battle.pbDisplay(_INTL("{1} transformed into the {2} type!",target.pbThis,typeName)) + @battle.pbDisplay(_INTL("{1} transformed into the {2} type!", target.pbThis, typeName)) end end @@ -949,7 +949,7 @@ end # User loses their Fire type. Fails if user is not Fire-type. (Burn Up) #=============================================================================== class Battle::Move::UserLosesFireType < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.pbHasType?(:FIRE) @battle.pbDisplay(_INTL("But it failed!")) return true @@ -957,10 +957,10 @@ class Battle::Move::UserLosesFireType < Battle::Move return false end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) if !user.effects[PBEffects::BurnUp] user.effects[PBEffects::BurnUp] = true - @battle.pbDisplay(_INTL("{1} burned itself out!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} burned itself out!", user.pbThis)) end end end @@ -971,7 +971,7 @@ end class Battle::Move::SetTargetAbilityToSimple < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !GameData::Ability.exists?(:SIMPLE) @battle.pbDisplay(_INTL("But it failed!")) return true @@ -987,12 +987,12 @@ class Battle::Move::SetTargetAbilityToSimple < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - @battle.pbShowAbilitySplash(target,true,false) + def pbEffectAgainstTarget(user, target) + @battle.pbShowAbilitySplash(target, true, false) oldAbil = target.ability target.ability = :SIMPLE @battle.pbReplaceAbilitySplash(target) - @battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName)) + @battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName)) @battle.pbHideAbilitySplash(target) target.pbOnLosingAbility(oldAbil) target.pbTriggerAbilityOnGainingIt @@ -1005,7 +1005,7 @@ end class Battle::Move::SetTargetAbilityToInsomnia < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !GameData::Ability.exists?(:INSOMNIA) @battle.pbDisplay(_INTL("But it failed!")) return true @@ -1021,12 +1021,12 @@ class Battle::Move::SetTargetAbilityToInsomnia < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - @battle.pbShowAbilitySplash(target,true,false) + def pbEffectAgainstTarget(user, target) + @battle.pbShowAbilitySplash(target, true, false) oldAbil = target.ability target.ability = :INSOMNIA @battle.pbReplaceAbilitySplash(target) - @battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName)) + @battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName)) @battle.pbHideAbilitySplash(target) target.pbOnLosingAbility(oldAbil) target.pbTriggerAbilityOnGainingIt @@ -1039,7 +1039,7 @@ end class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move def ignoresSubstitute?(user); return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.unstoppableAbility? @battle.pbDisplay(_INTL("But it failed!")) return true @@ -1048,7 +1048,7 @@ class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move end def pbFailsAgainstTarget?(user, target, show_message) - if !target.ability || user.ability==target.ability + if !target.ability || user.ability == target.ability @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -1060,13 +1060,13 @@ class Battle::Move::SetUserAbilityToTargetAbility < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - @battle.pbShowAbilitySplash(user,true,false) + def pbEffectAgainstTarget(user, target) + @battle.pbShowAbilitySplash(user, true, false) oldAbil = user.ability user.ability = target.ability @battle.pbReplaceAbilitySplash(user) @battle.pbDisplay(_INTL("{1} copied {2}'s {3}!", - user.pbThis,target.pbThis(true),target.abilityName)) + user.pbThis, target.pbThis(true), target.abilityName)) @battle.pbHideAbilitySplash(user) user.pbOnLosingAbility(oldAbil) user.pbTriggerAbilityOnGainingIt @@ -1079,7 +1079,7 @@ end class Battle::Move::SetTargetAbilityToUserAbility < Battle::Move def canMagicCoat?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.ability @battle.pbDisplay(_INTL("But it failed!")) return true @@ -1100,12 +1100,12 @@ class Battle::Move::SetTargetAbilityToUserAbility < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - @battle.pbShowAbilitySplash(target,true,false) + def pbEffectAgainstTarget(user, target) + @battle.pbShowAbilitySplash(target, true, false) oldAbil = target.ability target.ability = user.ability @battle.pbReplaceAbilitySplash(target) - @battle.pbDisplay(_INTL("{1} acquired {2}!",target.pbThis,target.abilityName)) + @battle.pbDisplay(_INTL("{1} acquired {2}!", target.pbThis, target.abilityName)) @battle.pbHideAbilitySplash(target) target.pbOnLosingAbility(oldAbil) target.pbTriggerAbilityOnGainingIt @@ -1118,7 +1118,7 @@ end class Battle::Move::UserTargetSwapAbilities < Battle::Move def ignoresSubstitute?(user); return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.ability @battle.pbDisplay(_INTL("But it failed!")) return true @@ -1151,10 +1151,10 @@ class Battle::Move::UserTargetSwapAbilities < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) if user.opposes?(target) - @battle.pbShowAbilitySplash(user,false,false) - @battle.pbShowAbilitySplash(target,true,false) + @battle.pbShowAbilitySplash(user, false, false) + @battle.pbShowAbilitySplash(target, true, false) end oldUserAbil = user.ability oldTargetAbil = target.ability @@ -1165,10 +1165,10 @@ class Battle::Move::UserTargetSwapAbilities < Battle::Move @battle.pbReplaceAbilitySplash(target) end if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} swapped Abilities with its target!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} swapped Abilities with its target!", user.pbThis)) else @battle.pbDisplay(_INTL("{1} swapped its {2} Ability with its target's {3} Ability!", - user.pbThis,target.abilityName,user.abilityName)) + user.pbThis, target.abilityName, user.abilityName)) end if user.opposes?(target) @battle.pbHideAbilitySplash(user) @@ -1195,10 +1195,10 @@ class Battle::Move::NegateTargetAbility < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::GastroAcid] = true target.effects[PBEffects::Truant] = false - @battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s Ability was suppressed!", target.pbThis)) target.pbOnLosingAbility(target.ability, true) end end @@ -1208,15 +1208,15 @@ end # performed its action this round. (Core Enforcer) #=============================================================================== class Battle::Move::NegateTargetAbilityIfTargetActed < Battle::Move - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if target.damageState.substitute || target.effects[PBEffects::GastroAcid] return if target.unstoppableAbility? - return if @battle.choices[target.index][0]!=:UseItem && - !((@battle.choices[target.index][0]==:UseMove || - @battle.choices[target.index][0]==:Shift) && target.movedThisRound?) + return if @battle.choices[target.index][0] != :UseItem && + !((@battle.choices[target.index][0] == :UseMove || + @battle.choices[target.index][0] == :Shift) && target.movedThisRound?) target.effects[PBEffects::GastroAcid] = true target.effects[PBEffects::Truant] = false - @battle.pbDisplay(_INTL("{1}'s Ability was suppressed!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s Ability was suppressed!", target.pbThis)) target.pbOnLosingAbility(target.ability, true) end end @@ -1226,7 +1226,7 @@ end # (Moongeist Beam, Sunsteel Strike) #=============================================================================== class Battle::Move::IgnoreTargetAbility < Battle::Move - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) super @battle.moldBreaker = true if !specialUsage end @@ -1239,10 +1239,10 @@ class Battle::Move::StartUserAirborne < Battle::Move def unusableInGravity?; return true; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.effects[PBEffects::Ingrain] || user.effects[PBEffects::SmackDown] || - user.effects[PBEffects::MagnetRise]>0 + user.effects[PBEffects::MagnetRise] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1251,7 +1251,7 @@ class Battle::Move::StartUserAirborne < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::MagnetRise] = 5 - @battle.pbDisplay(_INTL("{1} levitated with electromagnetism!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} levitated with electromagnetism!", user.pbThis)) end end @@ -1265,7 +1265,7 @@ class Battle::Move::StartTargetAirborneAndAlwaysHitByMoves < Battle::Move def pbFailsAgainstTarget?(user, target, show_message) if target.effects[PBEffects::Ingrain] || target.effects[PBEffects::SmackDown] || - target.effects[PBEffects::Telekinesis]>0 + target.effects[PBEffects::Telekinesis] > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -1280,9 +1280,9 @@ class Battle::Move::StartTargetAirborneAndAlwaysHitByMoves < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Telekinesis] = 3 - @battle.pbDisplay(_INTL("{1} was hurled into the air!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} was hurled into the air!", target.pbThis)) end end @@ -1300,19 +1300,19 @@ end class Battle::Move::HitsTargetInSkyGroundsTarget < Battle::Move def hitsFlyingTargets?; return true; end - def pbCalcTypeModSingle(moveType,defType,user,target) + def pbCalcTypeModSingle(moveType, defType, user, target) return Effectiveness::NORMAL_EFFECTIVE_ONE if moveType == :GROUND && defType == :FLYING return super end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if target.fainted? return if target.damageState.unaffected || target.damageState.substitute return if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSkyTargetCannotAct") || - target.effects[PBEffects::SkyDrop]>=0 # Sky Drop + target.effects[PBEffects::SkyDrop] >= 0 # Sky Drop return if !target.airborne? && !target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", "TwoTurnAttackInvulnerableInSkyParalyzeTarget") - target.effects[PBEffects::SmackDown] = true + target.effects[PBEffects::SmackDown] = true if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", "TwoTurnAttackInvulnerableInSkyParalyzeTarget") # NOTE: Not Sky Drop. target.effects[PBEffects::TwoTurnAttack] = nil @@ -1320,7 +1320,7 @@ class Battle::Move::HitsTargetInSkyGroundsTarget < Battle::Move end target.effects[PBEffects::MagnetRise] = 0 target.effects[PBEffects::Telekinesis] = 0 - @battle.pbDisplay(_INTL("{1} fell straight down!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} fell straight down!", target.pbThis)) end end @@ -1329,8 +1329,8 @@ end # (Gravity) #=============================================================================== class Battle::Move::StartGravity < Battle::Move - def pbMoveFailed?(user,targets) - if @battle.field.effects[PBEffects::Gravity]>0 + def pbMoveFailed?(user, targets) + if @battle.field.effects[PBEffects::Gravity] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1349,9 +1349,9 @@ class Battle::Move::StartGravity < Battle::Move @battle.pbClearChoice(b.index) if !b.movedThisRound? showMessage = true end - if b.effects[PBEffects::MagnetRise]>0 || - b.effects[PBEffects::Telekinesis]>0 || - b.effects[PBEffects::SkyDrop]>=0 + if b.effects[PBEffects::MagnetRise] > 0 || + b.effects[PBEffects::Telekinesis] > 0 || + b.effects[PBEffects::SkyDrop] >= 0 b.effects[PBEffects::MagnetRise] = 0 b.effects[PBEffects::Telekinesis] = 0 b.effects[PBEffects::SkyDrop] = -1 @@ -1367,7 +1367,7 @@ end # User transforms into the target. (Transform) #=============================================================================== class Battle::Move::TransformUserIntoTarget < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.effects[PBEffects::Transform] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -1384,12 +1384,12 @@ class Battle::Move::TransformUserIntoTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) user.pbTransform(target) end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) super - @battle.scene.pbChangePokemon(user,targets[0].pokemon) + @battle.scene.pbChangePokemon(user, targets[0].pokemon) end end diff --git a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb index d025f53b6..1e494beef 100644 --- a/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb +++ b/Data/Scripts/011_Battle/003_Move/008_MoveEffects_MoveAttributes.rb @@ -2,7 +2,7 @@ # Inflicts a fixed 20HP damage. (Sonic Boom) #=============================================================================== class Battle::Move::FixedDamage20 < Battle::Move::FixedDamageMove - def pbFixedDamage(user,target) + def pbFixedDamage(user, target) return 20 end end @@ -11,7 +11,7 @@ end # Inflicts a fixed 40HP damage. (Dragon Rage) #=============================================================================== class Battle::Move::FixedDamage40 < Battle::Move::FixedDamageMove - def pbFixedDamage(user,target) + def pbFixedDamage(user, target) return 40 end end @@ -20,8 +20,8 @@ end # Halves the target's current HP. (Nature's Madness, Super Fang) #=============================================================================== class Battle::Move::FixedDamageHalfTargetHP < Battle::Move::FixedDamageMove - def pbFixedDamage(user,target) - return (target.hp/2.0).round + def pbFixedDamage(user, target) + return (target.hp / 2.0).round end end @@ -29,7 +29,7 @@ end # Inflicts damage equal to the user's level. (Night Shade, Seismic Toss) #=============================================================================== class Battle::Move::FixedDamageUserLevel < Battle::Move::FixedDamageMove - def pbFixedDamage(user,target) + def pbFixedDamage(user, target) return user.level end end @@ -38,10 +38,10 @@ end # Inflicts damage between 0.5 and 1.5 times the user's level. (Psywave) #=============================================================================== class Battle::Move::FixedDamageUserLevelRandom < Battle::Move::FixedDamageMove - def pbFixedDamage(user,target) - min = (user.level/2).floor - max = (user.level*3/2).floor - return min+@battle.pbRandom(max-min+1) + def pbFixedDamage(user, target) + min = (user.level / 2).floor + max = (user.level * 3 / 2).floor + return min + @battle.pbRandom(max - min + 1) end end @@ -50,17 +50,17 @@ end #=============================================================================== class Battle::Move::LowerTargetHPToUserHP < Battle::Move::FixedDamageMove def pbFailsAgainstTarget?(user, target, show_message) - if user.hp>=target.hp + if user.hp >= target.hp @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbNumHits(user,targets); return 1; end + def pbNumHits(user, targets); return 1; end - def pbFixedDamage(user,target) - return target.hp-user.hp + def pbFixedDamage(user, target) + return target.hp - user.hp end end @@ -69,7 +69,7 @@ end #=============================================================================== class Battle::Move::OHKO < Battle::Move::FixedDamageMove def pbFailsAgainstTarget?(user, target, show_message) - if target.level>user.level + if target.level > user.level @battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) if show_message return true end @@ -89,16 +89,16 @@ class Battle::Move::OHKO < Battle::Move::FixedDamageMove return false end - def pbAccuracyCheck(user,target) - acc = @accuracy+user.level-target.level - return @battle.pbRandom(100)0 + elsif hitAlly.length > 0 hitAlly.each do |b| @battle.pbDisplay(_INTL("The bursting flame hit {1}!", @battle.battlers[b[0]].pbThis(true))) @@ -165,8 +165,8 @@ end # Power increases with the user's HP. (Eruption, Water Spout) #=============================================================================== class Battle::Move::PowerHigherWithUserHP < Battle::Move - def pbBaseDamage(baseDmg,user,target) - return [150*user.hp/user.totalhp,1].max + def pbBaseDamage(baseDmg, user, target) + return [150 * user.hp / user.totalhp, 1].max end end @@ -174,18 +174,18 @@ end # Power increases the less HP the user has. (Flail, Reversal) #=============================================================================== class Battle::Move::PowerLowerWithUserHP < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) ret = 20 - n = 48*user.hp/user.totalhp - if n<2 + n = 48 * user.hp / user.totalhp + if n < 2 ret = 200 - elsif n<5 + elsif n < 5 ret = 150 - elsif n<10 + elsif n < 10 ret = 100 - elsif n<17 + elsif n < 17 ret = 80 - elsif n<33 + elsif n < 33 ret = 40 end return ret @@ -196,8 +196,8 @@ end # Power increases with the target's HP. (Crush Grip, Wring Out) #=============================================================================== class Battle::Move::PowerHigherWithTargetHP < Battle::Move - def pbBaseDamage(baseDmg,user,target) - return [120*target.hp/target.totalhp,1].max + def pbBaseDamage(baseDmg, user, target) + return [120 * target.hp / target.totalhp, 1].max end end @@ -205,8 +205,8 @@ end # Power increases with the user's happiness. (Return) #=============================================================================== class Battle::Move::PowerHigherWithUserHappiness < Battle::Move - def pbBaseDamage(baseDmg,user,target) - return [(user.happiness*2/5).floor,1].max + def pbBaseDamage(baseDmg, user, target) + return [(user.happiness * 2 / 5).floor, 1].max end end @@ -214,8 +214,8 @@ end # Power decreases with the user's happiness. (Frustration) #=============================================================================== class Battle::Move::PowerLowerWithUserHappiness < Battle::Move - def pbBaseDamage(baseDmg,user,target) - return [((255-user.happiness)*2/5).floor,1].max + def pbBaseDamage(baseDmg, user, target) + return [((255 - user.happiness) * 2 / 5).floor, 1].max end end @@ -224,7 +224,7 @@ end # (Power Trip, Stored Power) #=============================================================================== class Battle::Move::PowerHigherWithUserPositiveStatStages < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) mult = 1 GameData::Stat.each_battle { |s| mult += user.stages[s.id] if user.stages[s.id] > 0 } return 20 * mult @@ -236,7 +236,7 @@ end # (Punishment) #=============================================================================== class Battle::Move::PowerHigherWithTargetPositiveStatStages < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) mult = 3 GameData::Stat.each_battle { |s| mult += target.stages[s.id] if target.stages[s.id] > 0 } return [20 * mult, 200].min @@ -247,16 +247,16 @@ end # Power increases the quicker the user is than the target. (Electro Ball) #=============================================================================== class Battle::Move::PowerHigherWithUserFasterThanTarget < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) ret = 40 - n = user.pbSpeed/target.pbSpeed - if n>=4 + n = user.pbSpeed / target.pbSpeed + if n >= 4 ret = 150 - elsif n>=3 + elsif n >= 3 ret = 120 - elsif n>=2 + elsif n >= 2 ret = 80 - elsif n>=1 + elsif n >= 1 ret = 60 end return ret @@ -267,8 +267,8 @@ end # Power increases the quicker the target is than the user. (Gyro Ball) #=============================================================================== class Battle::Move::PowerHigherWithTargetFasterThanUser < Battle::Move - def pbBaseDamage(baseDmg,user,target) - return [[(25*target.pbSpeed/user.pbSpeed).floor,150].min,1].max + def pbBaseDamage(baseDmg, user, target) + return [[(25 * target.pbSpeed / user.pbSpeed).floor, 150].min, 1].max end end @@ -276,9 +276,9 @@ end # Power increases the less PP this move has. (Trump Card) #=============================================================================== class Battle::Move::PowerHigherWithLessPP < Battle::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 + 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 return dmgs[ppLeft] end end @@ -287,18 +287,18 @@ end # Power increases the heavier the target is. (Grass Knot, Low Kick) #=============================================================================== class Battle::Move::PowerHigherWithTargetWeight < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) ret = 20 weight = target.pbWeight - if weight>=2000 + if weight >= 2000 ret = 120 - elsif weight>=1000 + elsif weight >= 1000 ret = 100 - elsif weight>=500 + elsif weight >= 500 ret = 80 - elsif weight>=250 + elsif weight >= 250 ret = 60 - elsif weight>=100 + elsif weight >= 100 ret = 40 end return ret @@ -315,16 +315,16 @@ class Battle::Move::PowerHigherWithUserHeavierThanTarget < Battle::Move return super end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) ret = 40 - n = (user.pbWeight/target.pbWeight).floor - if n>=5 + n = (user.pbWeight / target.pbWeight).floor + if n >= 5 ret = 120 - elsif n>=4 + elsif n >= 4 ret = 100 - elsif n>=3 + elsif n >= 3 ret = 80 - elsif n>=2 + elsif n >= 2 ret = 60 end return ret @@ -335,18 +335,18 @@ end # Power doubles for each consecutive use. (Fury Cutter) #=============================================================================== class Battle::Move::PowerHigherWithConsecutiveUse < Battle::Move - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) oldVal = user.effects[PBEffects::FuryCutter] super maxMult = 1 - while (@baseDamage<<(maxMult-1))<160 + while (@baseDamage << (maxMult - 1)) < 160 maxMult += 1 # 1-4 for base damage of 20, 1-3 for base damage of 40 end - user.effects[PBEffects::FuryCutter] = (oldVal>=maxMult) ? maxMult : oldVal+1 + user.effects[PBEffects::FuryCutter] = (oldVal >= maxMult) ? maxMult : oldVal + 1 end - def pbBaseDamage(baseDmg,user,target) - return baseDmg<<(user.effects[PBEffects::FuryCutter]-1) + def pbBaseDamage(baseDmg, user, target) + return baseDmg << (user.effects[PBEffects::FuryCutter] - 1) end end @@ -355,17 +355,17 @@ end # used by any Pokémon on the user's side. (Echoed Voice) #=============================================================================== class Battle::Move::PowerHigherWithConsecutiveUseOnUserSide < Battle::Move - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) oldVal = user.pbOwnSide.effects[PBEffects::EchoedVoiceCounter] super if !user.pbOwnSide.effects[PBEffects::EchoedVoiceUsed] - user.pbOwnSide.effects[PBEffects::EchoedVoiceCounter] = (oldVal>=5) ? 5 : oldVal+1 + user.pbOwnSide.effects[PBEffects::EchoedVoiceCounter] = (oldVal >= 5) ? 5 : oldVal + 1 end user.pbOwnSide.effects[PBEffects::EchoedVoiceUsed] = true end - def pbBaseDamage(baseDmg,user,target) - return baseDmg*user.pbOwnSide.effects[PBEffects::EchoedVoiceCounter] # 1-5 + def pbBaseDamage(baseDmg, user, target) + return baseDmg * user.pbOwnSide.effects[PBEffects::EchoedVoiceCounter] # 1-5 end end @@ -376,27 +376,27 @@ end class Battle::Move::RandomPowerDoublePowerIfTargetUnderground < Battle::Move def hitsDiggingTargets?; return true; end - def pbOnStartUse(user,targets) - baseDmg = [10,30,50,70,90,110,150] + def pbOnStartUse(user, targets) + baseDmg = [10, 30, 50, 70, 90, 110, 150] magnitudes = [ 4, - 5,5, - 6,6,6,6, - 7,7,7,7,7,7, - 8,8,8,8, - 9,9, + 5, 5, + 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, + 9, 9, 10 ] magni = magnitudes[@battle.pbRandom(magnitudes.length)] - @magnitudeDmg = baseDmg[magni-4] - @battle.pbDisplay(_INTL("Magnitude {1}!",magni)) + @magnitudeDmg = baseDmg[magni - 4] + @battle.pbDisplay(_INTL("Magnitude {1}!", magni)) end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) return @magnitudeDmg end - def pbModifyDamage(damageMult,user,target) + def pbModifyDamage(damageMult, user, target) damageMult *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground") damageMult /= 2 if @battle.field.terrain == :Grassy return damageMult @@ -407,8 +407,8 @@ end # Power is doubled if the target's HP is down to 1/2 or less. (Brine) #=============================================================================== class Battle::Move::DoublePowerIfTargetHPLessThanHalf < Battle::Move - def pbBaseDamage(baseDmg,user,target) - baseDmg *= 2 if target.hp<=target.totalhp/2 + def pbBaseDamage(baseDmg, user, target) + baseDmg *= 2 if target.hp <= target.totalhp / 2 return baseDmg end end @@ -420,7 +420,7 @@ end class Battle::Move::DoublePowerIfUserPoisonedBurnedParalyzed < Battle::Move def damageReducedByBurn?; return Settings::MECHANICS_GENERATION <= 5; end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if user.poisoned? || user.burned? || user.paralyzed? return baseDmg end @@ -430,15 +430,15 @@ end # Power is doubled if the target is asleep. Wakes the target up. (Wake-Up Slap) #=============================================================================== class Battle::Move::DoublePowerIfTargetAsleepCureTarget < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) if target.asleep? && - (target.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(user)) + (target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user)) baseDmg *= 2 end return baseDmg end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if target.fainted? return if target.damageState.unaffected || target.damageState.substitute return if target.status != :SLEEP @@ -450,9 +450,9 @@ end # Power is doubled if the target is poisoned. (Venoshock) #=============================================================================== class Battle::Move::DoublePowerIfTargetPoisoned < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) if target.poisoned? && - (target.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(user)) + (target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user)) baseDmg *= 2 end return baseDmg @@ -466,15 +466,15 @@ end # (Smelling Salts) #=============================================================================== class Battle::Move::DoublePowerIfTargetParalyzedCureTarget < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) if target.paralyzed? && - (target.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(user)) + (target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user)) baseDmg *= 2 end return baseDmg end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if target.fainted? return if target.damageState.unaffected || target.damageState.substitute return if target.status != :PARALYSIS @@ -486,9 +486,9 @@ end # Power is doubled if the target has a status problem. (Hex) #=============================================================================== class Battle::Move::DoublePowerIfTargetStatusProblem < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) if target.pbHasAnyStatus? && - (target.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(user)) + (target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user)) baseDmg *= 2 end return baseDmg @@ -499,7 +499,7 @@ end # Power is doubled if the user has no held item. (Acrobatics) #=============================================================================== class Battle::Move::DoublePowerIfUserHasNoItem < Battle::Move - def pbBaseDamageMultiplier(damageMult,user,target) + def pbBaseDamageMultiplier(damageMult, user, target) damageMult *= 2 if !user.item || user.effects[PBEffects::GemConsumed] return damageMult end @@ -512,7 +512,7 @@ end class Battle::Move::DoublePowerIfTargetUnderwater < Battle::Move def hitsDivingTargets?; return true; end - def pbModifyDamage(damageMult,user,target) + def pbModifyDamage(damageMult, user, target) damageMult *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater") return damageMult end @@ -525,7 +525,7 @@ end class Battle::Move::DoublePowerIfTargetUnderground < Battle::Move def hitsDiggingTargets?; return true; end - def pbModifyDamage(damageMult,user,target) + def pbModifyDamage(damageMult, user, target) damageMult *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderground") damageMult /= 2 if @battle.field.terrain == :Grassy return damageMult @@ -539,11 +539,11 @@ end class Battle::Move::DoublePowerIfTargetInSky < Battle::Move def hitsFlyingTargets?; return true; end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", "TwoTurnAttackInvulnerableInSkyParalyzeTarget", "TwoTurnAttackInvulnerableInSkyTargetCannotAct") || - target.effects[PBEffects::SkyDrop]>=0 + target.effects[PBEffects::SkyDrop] >= 0 return baseDmg end end @@ -562,7 +562,7 @@ end # Power is doubled if the user's last move failed. (Stomping Tantrum) #=============================================================================== class Battle::Move::DoublePowerIfUserLastMoveFailed < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if user.lastRoundMoveFailed return baseDmg end @@ -572,9 +572,9 @@ end # Power is doubled if a user's teammate fainted last round. (Retaliate) #=============================================================================== class Battle::Move::DoublePowerIfAllyFaintedLastTurn < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) lrf = user.pbOwnSide.effects[PBEffects::LastRoundFainted] - baseDmg *= 2 if lrf>=0 && lrf==@battle.turnCount-1 + baseDmg *= 2 if lrf >= 0 && lrf == @battle.turnCount - 1 return baseDmg end end @@ -584,7 +584,7 @@ end # (Avalanche, Revenge) #=============================================================================== class Battle::Move::DoublePowerIfUserLostHPThisTurn < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if user.lastAttacker.include?(target.index) return baseDmg end @@ -594,7 +594,7 @@ end # Power is doubled if the target has already lost HP this round. (Assurance) #=============================================================================== class Battle::Move::DoublePowerIfTargetLostHPThisTurn < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if target.tookDamageThisRound return baseDmg end @@ -614,10 +614,10 @@ end # Power is doubled if the target has already moved this round. (Payback) #=============================================================================== class Battle::Move::DoublePowerIfTargetActed < Battle::Move - def pbBaseDamage(baseDmg,user,target) - if @battle.choices[target.index][0]!=:None && - ((@battle.choices[target.index][0]!=:UseMove && - @battle.choices[target.index][0]!=:Shift) || target.movedThisRound?) + def pbBaseDamage(baseDmg, user, target) + if @battle.choices[target.index][0] != :None && + ((@battle.choices[target.index][0] != :UseMove && + @battle.choices[target.index][0] != :Shift) || target.movedThisRound?) baseDmg *= 2 end return baseDmg @@ -642,7 +642,7 @@ end # This attack is always a critical hit. (Frost Breath, Storm Throw) #=============================================================================== class Battle::Move::AlwaysCriticalHit < Battle::Move - def pbCritialOverride(user,target); return 1; end + def pbCritialOverride(user, target); return 1; end end #=============================================================================== @@ -654,7 +654,7 @@ class Battle::Move::EnsureNextCriticalHit < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::LaserFocus] = 2 - @battle.pbDisplay(_INTL("{1} concentrated intensely!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} concentrated intensely!", user.pbThis)) end end @@ -664,8 +664,8 @@ end class Battle::Move::StartPreventCriticalHitsAgainstUserSide < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.pbOwnSide.effects[PBEffects::LuckyChant]>0 + def pbMoveFailed?(user, targets) + if user.pbOwnSide.effects[PBEffects::LuckyChant] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -674,7 +674,7 @@ class Battle::Move::StartPreventCriticalHitsAgainstUserSide < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::LuckyChant] = 5 - @battle.pbDisplay(_INTL("The Lucky Chant shielded {1} from critical hits!",user.pbTeam(true))) + @battle.pbDisplay(_INTL("The Lucky Chant shielded {1} from critical hits!", user.pbTeam(true))) end end @@ -683,20 +683,20 @@ end # (False Swipe, Hold Back) #=============================================================================== class Battle::Move::CannotMakeTargetFaint < Battle::Move - def nonLethal?(user,target); return true; end + def nonLethal?(user, target); return true; end end #=============================================================================== # If user would be KO'd this round, it survives with 1HP instead. (Endure) #=============================================================================== class Battle::Move::UserEnduresFaintingThisTurn < Battle::Move::ProtectMove - def initialize(battle,move) + def initialize(battle, move) super @effect = PBEffects::Endure end def pbProtectMessage(user) - @battle.pbDisplay(_INTL("{1} braced itself!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} braced itself!", user.pbThis)) end end @@ -704,9 +704,9 @@ end # Weakens Electric attacks. (Mud Sport) #=============================================================================== class Battle::Move::StartWeakenElectricMoves < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if Settings::MECHANICS_GENERATION >= 6 - if @battle.field.effects[PBEffects::MudSportField]>0 + if @battle.field.effects[PBEffects::MudSportField] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -733,9 +733,9 @@ end # Weakens Fire attacks. (Water Sport) #=============================================================================== class Battle::Move::StartWeakenFireMoves < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if Settings::MECHANICS_GENERATION >= 6 - if @battle.field.effects[PBEffects::WaterSportField]>0 + if @battle.field.effects[PBEffects::WaterSportField] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -765,8 +765,8 @@ end class Battle::Move::StartWeakenPhysicalDamageAgainstUserSide < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.pbOwnSide.effects[PBEffects::Reflect]>0 + def pbMoveFailed?(user, targets) + if user.pbOwnSide.effects[PBEffects::Reflect] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -776,7 +776,7 @@ class Battle::Move::StartWeakenPhysicalDamageAgainstUserSide < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::Reflect] = 5 user.pbOwnSide.effects[PBEffects::Reflect] = 8 if user.hasActiveItem?(:LIGHTCLAY) - @battle.pbDisplay(_INTL("{1} raised {2}'s Defense!",@name,user.pbTeam(true))) + @battle.pbDisplay(_INTL("{1} raised {2}'s Defense!", @name, user.pbTeam(true))) end end @@ -786,8 +786,8 @@ end class Battle::Move::StartWeakenSpecialDamageAgainstUserSide < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.pbOwnSide.effects[PBEffects::LightScreen]>0 + def pbMoveFailed?(user, targets) + if user.pbOwnSide.effects[PBEffects::LightScreen] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -797,7 +797,7 @@ class Battle::Move::StartWeakenSpecialDamageAgainstUserSide < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::LightScreen] = 5 user.pbOwnSide.effects[PBEffects::LightScreen] = 8 if user.hasActiveItem?(:LIGHTCLAY) - @battle.pbDisplay(_INTL("{1} raised {2}'s Special Defense!",@name,user.pbTeam(true))) + @battle.pbDisplay(_INTL("{1} raised {2}'s Special Defense!", @name, user.pbTeam(true))) end end @@ -808,12 +808,12 @@ end class Battle::Move::StartWeakenDamageAgainstUserSideIfHail < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.effectiveWeather != :Hail @battle.pbDisplay(_INTL("But it failed!")) return true end - if user.pbOwnSide.effects[PBEffects::AuroraVeil]>0 + if user.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -824,7 +824,7 @@ class Battle::Move::StartWeakenDamageAgainstUserSideIfHail < Battle::Move user.pbOwnSide.effects[PBEffects::AuroraVeil] = 5 user.pbOwnSide.effects[PBEffects::AuroraVeil] = 8 if user.hasActiveItem?(:LIGHTCLAY) @battle.pbDisplay(_INTL("{1} made {2} stronger against physical and special moves!", - @name,user.pbTeam(true))) + @name, user.pbTeam(true))) end end @@ -836,24 +836,24 @@ class Battle::Move::RemoveScreens < Battle::Move def ignoresReflect?; return true; end def pbEffectGeneral(user) - if user.pbOpposingSide.effects[PBEffects::LightScreen]>0 + if user.pbOpposingSide.effects[PBEffects::LightScreen] > 0 user.pbOpposingSide.effects[PBEffects::LightScreen] = 0 - @battle.pbDisplay(_INTL("{1}'s Light Screen wore off!",user.pbOpposingTeam)) + @battle.pbDisplay(_INTL("{1}'s Light Screen wore off!", user.pbOpposingTeam)) end - if user.pbOpposingSide.effects[PBEffects::Reflect]>0 + if user.pbOpposingSide.effects[PBEffects::Reflect] > 0 user.pbOpposingSide.effects[PBEffects::Reflect] = 0 - @battle.pbDisplay(_INTL("{1}'s Reflect wore off!",user.pbOpposingTeam)) + @battle.pbDisplay(_INTL("{1}'s Reflect wore off!", user.pbOpposingTeam)) end - if user.pbOpposingSide.effects[PBEffects::AuroraVeil]>0 + if user.pbOpposingSide.effects[PBEffects::AuroraVeil] > 0 user.pbOpposingSide.effects[PBEffects::AuroraVeil] = 0 - @battle.pbDisplay(_INTL("{1}'s Aurora Veil wore off!",user.pbOpposingTeam)) + @battle.pbDisplay(_INTL("{1}'s Aurora Veil wore off!", user.pbOpposingTeam)) end end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) - if user.pbOpposingSide.effects[PBEffects::LightScreen]>0 || - user.pbOpposingSide.effects[PBEffects::Reflect]>0 || - user.pbOpposingSide.effects[PBEffects::AuroraVeil]>0 + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) + if user.pbOpposingSide.effects[PBEffects::LightScreen] > 0 || + user.pbOpposingSide.effects[PBEffects::Reflect] > 0 || + user.pbOpposingSide.effects[PBEffects::AuroraVeil] > 0 hitNum = 1 # Wall-breaking anim end super @@ -864,7 +864,7 @@ end # User is protected against moves with the "B" flag this round. (Detect, Protect) #=============================================================================== class Battle::Move::ProtectUser < Battle::Move::ProtectMove - def initialize(battle,move) + def initialize(battle, move) super @effect = PBEffects::Protect end @@ -876,7 +876,7 @@ end # poisoned. (Baneful Bunker) #=============================================================================== class Battle::Move::ProtectUserBanefulBunker < Battle::Move::ProtectMove - def initialize(battle,move) + def initialize(battle, move) super @effect = PBEffects::BanefulBunker end @@ -887,7 +887,7 @@ end # the user of a stopped contact move by 2 stages. (King's Shield) #=============================================================================== class Battle::Move::ProtectUserFromDamagingMovesKingsShield < Battle::Move::ProtectMove - def initialize(battle,move) + def initialize(battle, move) super @effect = PBEffects::KingsShield end @@ -911,7 +911,7 @@ end # a stopped contact move by 1/8 of its max HP. (Spiky Shield) #=============================================================================== class Battle::Move::ProtectUserFromTargetingMovesSpikyShield < Battle::Move::ProtectMove - def initialize(battle,move) + def initialize(battle, move) super @effect = PBEffects::SpikyShield end @@ -923,7 +923,7 @@ end class Battle::Move::ProtectUserSideFromDamagingMovesIfUserFirstTurn < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.turnCount > 1 @battle.pbDisplay(_INTL("But it failed!")) return true @@ -934,7 +934,7 @@ class Battle::Move::ProtectUserSideFromDamagingMovesIfUserFirstTurn < Battle::Mo def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::MatBlock] = true - @battle.pbDisplay(_INTL("{1} intends to flip up a mat and block incoming attacks!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} intends to flip up a mat and block incoming attacks!", user.pbThis)) end end @@ -942,7 +942,7 @@ end # User's side is protected against status moves this round. (Crafty Shield) #=============================================================================== class Battle::Move::ProtectUserSideFromStatusMoves < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.pbOwnSide.effects[PBEffects::CraftyShield] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -953,7 +953,7 @@ class Battle::Move::ProtectUserSideFromStatusMoves < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::CraftyShield] = true - @battle.pbDisplay(_INTL("Crafty Shield protected {1}!",user.pbTeam(true))) + @battle.pbDisplay(_INTL("Crafty Shield protected {1}!", user.pbTeam(true))) end end @@ -964,7 +964,7 @@ end class Battle::Move::ProtectUserSideFromPriorityMoves < Battle::Move::ProtectMove def canSnatch?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @effect = PBEffects::QuickGuard @sidedEffect = true @@ -978,7 +978,7 @@ end class Battle::Move::ProtectUserSideFromMultiTargetDamagingMoves < Battle::Move::ProtectMove def canSnatch?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @effect = PBEffects::WideGuard @sidedEffect = true @@ -989,7 +989,7 @@ end # Ends target's protections immediately. (Feint) #=============================================================================== class Battle::Move::RemoveProtections < Battle::Move - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::BanefulBunker] = false target.effects[PBEffects::KingsShield] = false target.effects[PBEffects::Obstruct] = false @@ -1008,7 +1008,7 @@ end class Battle::Move::RemoveProtectionsBypassSubstitute < Battle::Move def ignoresSubstitute?(user); return true; end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::BanefulBunker] = false target.effects[PBEffects::KingsShield] = false target.effects[PBEffects::Obstruct] = false @@ -1028,23 +1028,23 @@ end class Battle::Move::HoopaRemoveProtectionsBypassSubstituteLowerUserDef1 < Battle::Move::StatDownMove def ignoresSubstitute?(user); return true; end - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:DEFENSE,1] + @statDown = [:DEFENSE, 1] end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.isSpecies?(:HOOPA) - @battle.pbDisplay(_INTL("But {1} can't use the move!",user.pbThis(true))) + @battle.pbDisplay(_INTL("But {1} can't use the move!", user.pbThis(true))) return true - elsif user.form!=1 - @battle.pbDisplay(_INTL("But {1} can't use it the way it is now!",user.pbThis(true))) + elsif user.form != 1 + @battle.pbDisplay(_INTL("But {1} can't use it the way it is now!", user.pbThis(true))) return true end return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::BanefulBunker] = false target.effects[PBEffects::KingsShield] = false target.effects[PBEffects::Obstruct] = false @@ -1061,8 +1061,8 @@ end # User takes recoil damage equal to 1/4 of the damage this move dealt. #=============================================================================== class Battle::Move::RecoilQuarterOfDamageDealt < Battle::Move::RecoilMove - def pbRecoilDamage(user,target) - return (target.damageState.totalHPLost/4.0).round + def pbRecoilDamage(user, target) + return (target.damageState.totalHPLost / 4.0).round end end @@ -1070,8 +1070,8 @@ end # User takes recoil damage equal to 1/3 of the damage this move dealt. #=============================================================================== class Battle::Move::RecoilThirdOfDamageDealt < Battle::Move::RecoilMove - def pbRecoilDamage(user,target) - return (target.damageState.totalHPLost/3.0).round + def pbRecoilDamage(user, target) + return (target.damageState.totalHPLost / 3.0).round end end @@ -1080,13 +1080,13 @@ end # May paralyze the target. (Volt Tackle) #=============================================================================== class Battle::Move::RecoilThirdOfDamageDealtParalyzeTarget < Battle::Move::RecoilMove - def pbRecoilDamage(user,target) - return (target.damageState.totalHPLost/3.0).round + def pbRecoilDamage(user, target) + return (target.damageState.totalHPLost / 3.0).round end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbParalyze(user) if target.pbCanParalyze?(user,false,self) + target.pbParalyze(user) if target.pbCanParalyze?(user, false, self) end end @@ -1095,13 +1095,13 @@ end # May burn the target. (Flare Blitz) #=============================================================================== class Battle::Move::RecoilThirdOfDamageDealtBurnTarget < Battle::Move::RecoilMove - def pbRecoilDamage(user,target) - return (target.damageState.totalHPLost/3.0).round + def pbRecoilDamage(user, target) + return (target.damageState.totalHPLost / 3.0).round end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbBurn(user) if target.pbCanBurn?(user,false,self) + target.pbBurn(user) if target.pbCanBurn?(user, false, self) end end @@ -1110,8 +1110,8 @@ end # (Head Smash, Light of Ruin) #=============================================================================== class Battle::Move::RecoilHalfOfDamageDealt < Battle::Move::RecoilMove - def pbRecoilDamage(user,target) - return (target.damageState.totalHPLost/2.0).round + def pbRecoilDamage(user, target) + return (target.damageState.totalHPLost / 2.0).round end end @@ -1122,12 +1122,12 @@ end #=============================================================================== class Battle::Move::EffectivenessIncludesFlyingType < Battle::Move def tramplesMinimize?(param = 1) - return true if param==1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy - return true if param==2 # Double damage + return true if param == 1 && Settings::MECHANICS_GENERATION >= 6 # Perfect accuracy + return true if param == 2 # Double damage return super end - def pbCalcTypeModSingle(moveType,defType,user,target) + def pbCalcTypeModSingle(moveType, defType, user, target) ret = super if GameData::Type.exists?(:FLYING) flyingEff = Effectiveness.calculate_one(:FLYING, defType) @@ -1190,26 +1190,26 @@ end # stat stages), and special otherwise. (Photon Geyser) #=============================================================================== class Battle::Move::CategoryDependsOnHigherDamageIgnoreTargetAbility < Battle::Move::IgnoreTargetAbility - def initialize(battle,move) + def initialize(battle, move) super @calcCategory = 1 end - def physicalMove?(thisType = nil); return (@calcCategory==0); end - def specialMove?(thisType = nil); return (@calcCategory==1); end + def physicalMove?(thisType = nil); return (@calcCategory == 0); end + def specialMove?(thisType = nil); return (@calcCategory == 1); end - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) # Calculate user's effective attacking value - stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8] - stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2] + stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8] + stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2] atk = user.attack - atkStage = user.stages[:ATTACK]+6 - realAtk = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor + atkStage = user.stages[:ATTACK] + 6 + realAtk = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor spAtk = user.spatk - spAtkStage = user.stages[:SPECIAL_ATTACK]+6 - realSpAtk = (spAtk.to_f*stageMul[spAtkStage]/stageDiv[spAtkStage]).floor + spAtkStage = user.stages[:SPECIAL_ATTACK] + 6 + realSpAtk = (spAtk.to_f * stageMul[spAtkStage] / stageDiv[spAtkStage]).floor # Determine move's category - @calcCategory = (realAtk>realSpAtk) ? 0 : 1 + @calcCategory = (realAtk > realSpAtk) ? 0 : 1 end end @@ -1230,11 +1230,11 @@ end # (Foul Play) #=============================================================================== class Battle::Move::UseTargetAttackInsteadOfUserAttack < Battle::Move - def pbGetAttackStats(user,target) + def pbGetAttackStats(user, target) if specialMove? - return target.spatk, target.stages[:SPECIAL_ATTACK]+6 + return target.spatk, target.stages[:SPECIAL_ATTACK] + 6 end - return target.attack, target.stages[:ATTACK]+6 + return target.attack, target.stages[:ATTACK] + 6 end end @@ -1243,8 +1243,8 @@ end # calculations. (Psyshock, Psystrike, Secret Sword) #=============================================================================== class Battle::Move::UseTargetDefenseInsteadOfTargetSpDef < Battle::Move - def pbGetDefenseStats(user,target) - return target.defense, target.stages[:DEFENSE]+6 + def pbGetDefenseStats(user, target) + return target.defense, target.stages[:DEFENSE] + 6 end end @@ -1253,10 +1253,10 @@ end # (Lock-On, Mind Reader) #=============================================================================== class Battle::Move::EnsureNextMoveAlwaysHits < Battle::Move - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) user.effects[PBEffects::LockOn] = 2 user.effects[PBEffects::LockOnPos] = target.index - @battle.pbDisplay(_INTL("{1} took aim at {2}!",user.pbThis,target.pbThis(true))) + @battle.pbDisplay(_INTL("{1} took aim at {2}!", user.pbThis, target.pbThis(true))) end end @@ -1268,9 +1268,9 @@ class Battle::Move::StartNegateTargetEvasionStatStageAndGhostImmunity < Battle:: def ignoresSubstitute?(user); return true; end def canMagicCoat?; return true; end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Foresight] = true - @battle.pbDisplay(_INTL("{1} was identified!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} was identified!", target.pbThis)) end end @@ -1282,9 +1282,9 @@ class Battle::Move::StartNegateTargetEvasionStatStageAndDarkImmunity < Battle::M def ignoresSubstitute?(user); return true; end def canMagicCoat?; return true; end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::MiracleEye] = true - @battle.pbDisplay(_INTL("{1} was identified!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} was identified!", target.pbThis)) end end @@ -1293,12 +1293,12 @@ end # (Chip Away, Darkest Lariat, Sacred Sword) #=============================================================================== class Battle::Move::IgnoreTargetDefSpDefEvaStatStages < Battle::Move - def pbCalcAccuracyMultipliers(user,target,multipliers) + def pbCalcAccuracyMultipliers(user, target, multipliers) super modifiers[:evasion_stage] = 0 end - def pbGetDefenseStats(user,target) + def pbGetDefenseStats(user, target) ret1, _ret2 = super return ret1, 6 # Def/SpDef stat stage end @@ -1323,7 +1323,7 @@ class Battle::Move::TypeDependsOnUserIVs < Battle::Move return hp[0] end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) return super if Settings::MECHANICS_GENERATION >= 6 hp = pbHiddenPower(user) return hp[1] @@ -1342,26 +1342,26 @@ def pbHiddenPower(pkmn) types[t.icon_position].push(t.id) if !t.pseudo_type && ![:NORMAL, :SHADOW].include?(t.id) end types.flatten!.compact! - idxType |= (iv[:HP]&1) - idxType |= (iv[:ATTACK]&1)<<1 - idxType |= (iv[:DEFENSE]&1)<<2 - idxType |= (iv[:SPEED]&1)<<3 - idxType |= (iv[:SPECIAL_ATTACK]&1)<<4 - idxType |= (iv[:SPECIAL_DEFENSE]&1)<<5 - idxType = (types.length-1)*idxType/63 + idxType |= (iv[:HP] & 1) + idxType |= (iv[:ATTACK] & 1) << 1 + idxType |= (iv[:DEFENSE] & 1) << 2 + idxType |= (iv[:SPEED] & 1) << 3 + idxType |= (iv[:SPECIAL_ATTACK] & 1) << 4 + idxType |= (iv[:SPECIAL_DEFENSE] & 1) << 5 + idxType = (types.length - 1) * idxType / 63 type = types[idxType] if Settings::MECHANICS_GENERATION <= 5 powerMin = 30 powerMax = 70 - power |= (iv[:HP]&2)>>1 - power |= (iv[:ATTACK]&2) - power |= (iv[:DEFENSE]&2)<<1 - power |= (iv[:SPEED]&2)<<2 - power |= (iv[:SPECIAL_ATTACK]&2)<<3 - power |= (iv[:SPECIAL_DEFENSE]&2)<<4 - power = powerMin+(powerMax-powerMin)*power/63 + power |= (iv[:HP] & 2) >> 1 + power |= (iv[:ATTACK] & 2) + power |= (iv[:DEFENSE] & 2) << 1 + power |= (iv[:SPEED] & 2) << 2 + power |= (iv[:SPECIAL_ATTACK] & 2) << 3 + power |= (iv[:SPECIAL_DEFENSE] & 2) << 4 + power = powerMin + (powerMax - powerMin) * power / 63 end - return [type,power] + return [type, power] end #=============================================================================== @@ -1369,7 +1369,7 @@ end # (Natural Gift) #=============================================================================== class Battle::Move::TypeAndPowerDependOnUserBerry < Battle::Move - def initialize(battle,move) + def initialize(battle, move) super @typeArray = { :NORMAL => [:CHILANBERRY], @@ -1410,7 +1410,7 @@ class Battle::Move::TypeAndPowerDependOnUserBerry < Battle::Move } end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) # NOTE: Unnerve does not stop a Pokémon using this move. item = user.item if !item || !item.is_berry? || !user.itemActive? @@ -1449,16 +1449,16 @@ class Battle::Move::TypeAndPowerDependOnUserBerry < Battle::Move return ret end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) return pbNaturalGiftBaseDamage(user.item.id) end - def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers) + def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers) # NOTE: The item is consumed even if this move was Protected against or it # missed. The item is not consumed if the target was switched out by # an effect like a target's Red Card. # NOTE: There is no item consumption animation. - user.pbConsumeItem(true,true,false) if user.item + user.pbConsumeItem(true, true, false) if user.item end end @@ -1466,7 +1466,7 @@ end # Type depends on the user's held Plate. (Judgment) #=============================================================================== class Battle::Move::TypeDependsOnUserPlate < Battle::Move - def initialize(battle,move) + def initialize(battle, move) super @itemTypes = { :FISTPLATE => :FIGHTING, @@ -1506,7 +1506,7 @@ end # Type depends on the user's held Memory. (Multi-Attack) #=============================================================================== class Battle::Move::TypeDependsOnUserMemory < Battle::Move - def initialize(battle,move) + def initialize(battle, move) super @itemTypes = { :FIGHTINGMEMORY => :FIGHTING, @@ -1546,7 +1546,7 @@ end # Type depends on the user's held Drive. (Techno Blast) #=============================================================================== class Battle::Move::TypeDependsOnUserDrive < Battle::Move - def initialize(battle,move) + def initialize(battle, move) super @itemTypes = { :SHOCKDRIVE => :ELECTRIC, @@ -1568,7 +1568,7 @@ class Battle::Move::TypeDependsOnUserDrive < Battle::Move return ret end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) t = pbBaseType(user) hitNum = 0 hitNum = 1 if t == :ELECTRIC @@ -1603,7 +1603,7 @@ end # Power is doubled in weather. Type changes depending on the weather. (Weather Ball) #=============================================================================== class Battle::Move::TypeAndPowerDependOnWeather < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if user.effectiveWeather != :None return baseDmg end @@ -1623,7 +1623,7 @@ class Battle::Move::TypeAndPowerDependOnWeather < Battle::Move return ret end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) t = pbBaseType(user) hitNum = 1 if t == :FIRE # Type-specific anims hitNum = 2 if t == :WATER @@ -1681,9 +1681,9 @@ class Battle::Move::TargetMovesBecomeElectric < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Electrify] = true - @battle.pbDisplay(_INTL("{1}'s moves have been electrified!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s moves have been electrified!", target.pbThis)) end end @@ -1692,7 +1692,7 @@ end # (Ion Deluge, Plasma Fists) #=============================================================================== class Battle::Move::NormalMovesBecomeElectric < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) return false if damagingMove? if @battle.field.effects[PBEffects::IonDeluge] @battle.pbDisplay(_INTL("But it failed!")) diff --git a/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb b/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb index d47339ad3..7080653e1 100644 --- a/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb +++ b/Data/Scripts/011_Battle/003_Move/009_MoveEffects_MultiHit.rb @@ -2,16 +2,16 @@ # Hits twice. #=============================================================================== class Battle::Move::HitTwoTimes < Battle::Move - def multiHitMove?; return true; end - def pbNumHits(user,targets); return 2; end + def multiHitMove?; return true; end + def pbNumHits(user, targets); return 2; end end #=============================================================================== # Hits twice. May poison the target on each hit. (Twineedle) #=============================================================================== class Battle::Move::HitTwoTimesPoisonTarget < Battle::Move::PoisonTarget - def multiHitMove?; return true; end - def pbNumHits(user,targets); return 2; end + def multiHitMove?; return true; end + def pbNumHits(user, targets); return 2; end end #=============================================================================== @@ -69,19 +69,19 @@ end # An accuracy check is performed for each hit. #=============================================================================== class Battle::Move::HitThreeTimesPowersUpWithEachHit < Battle::Move - def multiHitMove?; return true; end - def pbNumHits(user,targets); return 3; end + def multiHitMove?; return true; end + def pbNumHits(user, targets); return 3; end def successCheckPerHit? return @accCheckPerHit end - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) @calcBaseDmg = 0 @accCheckPerHit = !user.hasActiveAbility?(:SKILLLINK) end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) @calcBaseDmg += baseDmg return @calcBaseDmg end @@ -103,7 +103,7 @@ end class Battle::Move::HitTwoToFiveTimes < Battle::Move def multiHitMove?; return true; end - def pbNumHits(user,targets) + def pbNumHits(user, targets) hitChances = [ 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, @@ -111,7 +111,7 @@ class Battle::Move::HitTwoToFiveTimes < Battle::Move 5, 5, 5 ] r = @battle.pbRandom(hitChances.length) - r = hitChances.length-1 if user.hasActiveAbility?(:SKILLLINK) + r = hitChances.length - 1 if user.hasActiveAbility?(:SKILLLINK) return hitChances[r] end end @@ -121,12 +121,12 @@ end # (Water Shuriken) #=============================================================================== class Battle::Move::HitTwoToFiveTimesOrThreeForAshGreninja < Battle::Move::HitTwoToFiveTimes - def pbNumHits(user,targets) + def pbNumHits(user, targets) return 3 if user.isSpecies?(:GRENINJA) && user.form == 2 return super end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) return 20 if user.isSpecies?(:GRENINJA) && user.form == 2 return super end @@ -171,27 +171,27 @@ end class Battle::Move::HitOncePerUserTeamMember < Battle::Move def multiHitMove?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @beatUpList = [] - @battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,i| + @battle.eachInTeamFromBattlerIndex(user.index) do |pkmn, i| next if !pkmn.able? || pkmn.status != :NONE @beatUpList.push(i) end - if @beatUpList.length==0 + if @beatUpList.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end return false end - def pbNumHits(user,targets) + def pbNumHits(user, targets) return @beatUpList.length end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) i = @beatUpList.shift # First element in array, and removes it from array atk = @battle.pbParty(user.index)[i].baseStats[:ATTACK] - return 5+(atk/10) + return 5 + (atk / 10) end end @@ -209,8 +209,8 @@ end # Two turn attack. Skips first turn, attacks second turn. (Razor Wind) #=============================================================================== class Battle::Move::TwoTurnAttack < Battle::Move::TwoTurnMove - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} whipped up a whirlwind!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} whipped up a whirlwind!", user.pbThis)) end end @@ -232,11 +232,11 @@ class Battle::Move::TwoTurnAttackOneTurnInSun < Battle::Move::TwoTurnMove return ret end - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} took in sunlight!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} took in sunlight!", user.pbThis)) end - def pbBaseDamageMultiplier(damageMult,user,target) + def pbBaseDamageMultiplier(damageMult, user, target) damageMult /= 2 if ![:None, :Sun, :HarshSun].include?(user.effectiveWeather) return damageMult end @@ -247,13 +247,13 @@ end # May paralyze the target. #=============================================================================== class Battle::Move::TwoTurnAttackParalyzeTarget < Battle::Move::TwoTurnMove - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} became cloaked in a freezing light!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} became cloaked in a freezing light!", user.pbThis)) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbParalyze(user) if target.pbCanParalyze?(user,false,self) + target.pbParalyze(user) if target.pbCanParalyze?(user, false, self) end end @@ -262,13 +262,13 @@ end # May burn the target. #=============================================================================== class Battle::Move::TwoTurnAttackBurnTarget < Battle::Move::TwoTurnMove - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} became cloaked in freezing air!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} became cloaked in freezing air!", user.pbThis)) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbBurn(user) if target.pbCanBurn?(user,false,self) + target.pbBurn(user) if target.pbCanBurn?(user, false, self) end end @@ -279,11 +279,11 @@ end class Battle::Move::TwoTurnAttackFlinchTarget < Battle::Move::TwoTurnMove def flinchingMove?; return true; end - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} became cloaked in a harsh light!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} became cloaked in a harsh light!", user.pbThis)) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute target.pbFlinch(user) end @@ -294,27 +294,27 @@ end # Special Defense and Speed by 2 stages each in the second turn. (Geomancy) #=============================================================================== class Battle::Move::TwoTurnAttackRaiseUserSpAtkSpDefSpd2 < Battle::Move::TwoTurnMove - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) return false if user.effects[PBEffects::TwoTurnAttack] # Charging turn - if !user.pbCanRaiseStatStage?(:SPECIAL_ATTACK,user,self) && - !user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self) && - !user.pbCanRaiseStatStage?(:SPEED,user,self) - @battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",user.pbThis)) + if !user.pbCanRaiseStatStage?(:SPECIAL_ATTACK, user, self) && + !user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self) && + !user.pbCanRaiseStatStage?(:SPEED, user, self) + @battle.pbDisplay(_INTL("{1}'s stats won't go any higher!", user.pbThis)) return true end return false end - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} is absorbing power!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} is absorbing power!", user.pbThis)) end def pbEffectGeneral(user) return if !@damagingTurn showAnim = true - [:SPECIAL_ATTACK,:SPECIAL_DEFENSE,:SPEED].each do |s| - next if !user.pbCanRaiseStatStage?(s,user,self) - if user.pbRaiseStatStage(s,2,user,showAnim) + [:SPECIAL_ATTACK, :SPECIAL_DEFENSE, :SPEED].each do |s| + next if !user.pbCanRaiseStatStage?(s, user, self) + if user.pbRaiseStatStage(s, 2, user, showAnim) showAnim = false end end @@ -326,13 +326,13 @@ end # (Skull Bash) #=============================================================================== class Battle::Move::TwoTurnAttackChargeRaiseUserDefense1 < Battle::Move::TwoTurnMove - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} tucked in its head!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} tucked in its head!", user.pbThis)) end - def pbChargingTurnEffect(user,target) - if user.pbCanRaiseStatStage?(:DEFENSE,user,self) - user.pbRaiseStatStage(:DEFENSE,1,user) + def pbChargingTurnEffect(user, target) + if user.pbCanRaiseStatStage?(:DEFENSE, user, self) + user.pbRaiseStatStage(:DEFENSE, 1, user) end end end @@ -358,8 +358,8 @@ end # (Handled in Battler's pbSuccessCheckPerHit): Is semi-invulnerable during use. #=============================================================================== class Battle::Move::TwoTurnAttackInvulnerableUnderground < Battle::Move::TwoTurnMove - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} burrowed its way under the ground!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} burrowed its way under the ground!", user.pbThis)) end end @@ -368,8 +368,8 @@ end # (Handled in Battler's pbSuccessCheckPerHit): Is semi-invulnerable during use. #=============================================================================== class Battle::Move::TwoTurnAttackInvulnerableUnderwater < Battle::Move::TwoTurnMove - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} hid underwater!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} hid underwater!", user.pbThis)) end end @@ -380,8 +380,8 @@ end class Battle::Move::TwoTurnAttackInvulnerableInSky < Battle::Move::TwoTurnMove def unusableInGravity?; return true; end - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} flew up high!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} flew up high!", user.pbThis)) end end @@ -393,13 +393,13 @@ end class Battle::Move::TwoTurnAttackInvulnerableInSkyParalyzeTarget < Battle::Move::TwoTurnMove def unusableInGravity?; return true; end - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} sprang up!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} sprang up!", user.pbThis)) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.damageState.substitute - target.pbParalyze(user) if target.pbCanParalyze?(user,false,self) + target.pbParalyze(user) if target.pbCanParalyze?(user, false, self) end end @@ -426,44 +426,44 @@ class Battle::Move::TwoTurnAttackInvulnerableInSkyTargetCannotAct < Battle::Move @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end - if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user) + if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end - if Settings::MECHANICS_GENERATION >= 6 && target.pbWeight>=2000 # 200.0kg + if Settings::MECHANICS_GENERATION >= 6 && target.pbWeight >= 2000 # 200.0kg @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end if target.semiInvulnerable? || - (target.effects[PBEffects::SkyDrop]>=0 && @chargingTurn) + (target.effects[PBEffects::SkyDrop] >= 0 && @chargingTurn) @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end - if target.effects[PBEffects::SkyDrop]!=user.index && @damagingTurn + if target.effects[PBEffects::SkyDrop] != user.index && @damagingTurn @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbCalcTypeMod(movetype,user,target) + def pbCalcTypeMod(movetype, user, target) return Effectiveness::INEFFECTIVE if target.pbHasType?(:FLYING) return super end - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} took {2} into the sky!",user.pbThis,targets[0].pbThis(true))) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} took {2} into the sky!", user.pbThis, targets[0].pbThis(true))) end - def pbAttackingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} was freed from the Sky Drop!",targets[0].pbThis)) + def pbAttackingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} was freed from the Sky Drop!", targets[0].pbThis)) end - def pbChargingTurnEffect(user,target) + def pbChargingTurnEffect(user, target) target.effects[PBEffects::SkyDrop] = user.index end - def pbAttackingTurnEffect(user,target) + def pbAttackingTurnEffect(user, target) target.effects[PBEffects::SkyDrop] = -1 end end @@ -473,11 +473,11 @@ end # use. Ends target's protections upon hit. (Shadow Force, Phantom Force) #=============================================================================== class Battle::Move::TwoTurnAttackInvulnerableRemoveProtections < Battle::Move::TwoTurnMove - def pbChargingTurnMessage(user,targets) - @battle.pbDisplay(_INTL("{1} vanished instantly!",user.pbThis)) + def pbChargingTurnMessage(user, targets) + @battle.pbDisplay(_INTL("{1} vanished instantly!", user.pbThis)) end - def pbAttackingTurnEffect(user,target) + def pbAttackingTurnEffect(user, target) target.effects[PBEffects::BanefulBunker] = false target.effects[PBEffects::KingsShield] = false target.effects[PBEffects::Obstruct] = false @@ -499,10 +499,10 @@ end #=============================================================================== class Battle::Move::MultiTurnAttackPreventSleeping < Battle::Move def pbEffectGeneral(user) - return if user.effects[PBEffects::Uproar]>0 + return if user.effects[PBEffects::Uproar] > 0 user.effects[PBEffects::Uproar] = 3 user.currentMove = @id - @battle.pbDisplay(_INTL("{1} caused an uproar!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} caused an uproar!", user.pbThis)) @battle.pbPriority(true).each do |b| next if b.fainted? || b.status != :SLEEP next if b.hasActiveAbility?(:SOUNDPROOF) @@ -516,15 +516,15 @@ end # (Outrage, Petal Dange, Thrash) #=============================================================================== class Battle::Move::MultiTurnAttackConfuseUserAtEnd < Battle::Move - def pbEffectAfterAllHits(user,target) - if !target.damageState.unaffected && user.effects[PBEffects::Outrage]==0 - user.effects[PBEffects::Outrage] = 2+@battle.pbRandom(2) + def pbEffectAfterAllHits(user, target) + if !target.damageState.unaffected && user.effects[PBEffects::Outrage] == 0 + user.effects[PBEffects::Outrage] = 2 + @battle.pbRandom(2) user.currentMove = @id end - if user.effects[PBEffects::Outrage]>0 + if user.effects[PBEffects::Outrage] > 0 user.effects[PBEffects::Outrage] -= 1 - if user.effects[PBEffects::Outrage]==0 && user.pbCanConfuseSelf?(false) - user.pbConfuse(_INTL("{1} became confused due to fatigue!",user.pbThis)) + if user.effects[PBEffects::Outrage] == 0 && user.pbCanConfuseSelf?(false) + user.pbConfuse(_INTL("{1} became confused due to fatigue!", user.pbThis)) end end end @@ -535,7 +535,7 @@ end # Power is also doubled if user has curled up. (Ice Ball, Rollout) #=============================================================================== class Battle::Move::MultiTurnAttackPowersUpEachTurn < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) shift = (5 - user.effects[PBEffects::Rollout]) # 0-4, where 0 is most powerful shift = 0 if user.effects[PBEffects::Rollout] == 0 # For first turn shift += 1 if user.effects[PBEffects::DefenseCurl] @@ -543,7 +543,7 @@ class Battle::Move::MultiTurnAttackPowersUpEachTurn < Battle::Move return baseDmg end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) if !target.damageState.unaffected && user.effects[PBEffects::Rollout] == 0 user.effects[PBEffects::Rollout] = 5 user.currentMove = @id @@ -558,23 +558,23 @@ end # (Bide) #=============================================================================== class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::FixedDamageMove - def pbAddTarget(targets,user) - return if user.effects[PBEffects::Bide]!=1 # Not the attack turn + def pbAddTarget(targets, user) + return if user.effects[PBEffects::Bide] != 1 # Not the attack turn idxTarget = user.effects[PBEffects::BideTarget] - t = (idxTarget>=0) ? @battle.battlers[idxTarget] : nil - if !user.pbAddTarget(targets,user,t,self,false) - user.pbAddTargetRandomFoe(targets,user,self,false) + t = (idxTarget >= 0) ? @battle.battlers[idxTarget] : nil + if !user.pbAddTarget(targets, user, t, self, false) + user.pbAddTargetRandomFoe(targets, user, self, false) end end - def pbMoveFailed?(user,targets) - return false if user.effects[PBEffects::Bide]!=1 # Not the attack turn - if user.effects[PBEffects::BideDamage]==0 + def pbMoveFailed?(user, targets) + return false if user.effects[PBEffects::Bide] != 1 # Not the attack turn + if user.effects[PBEffects::BideDamage] == 0 @battle.pbDisplay(_INTL("But it failed!")) user.effects[PBEffects::Bide] = 0 # No need to reset other Bide variables return true end - if targets.length==0 + if targets.length == 0 @battle.pbDisplay(_INTL("But there was no target...")) user.effects[PBEffects::Bide] = 0 # No need to reset other Bide variables return true @@ -582,15 +582,15 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi return false end - def pbOnStartUse(user,targets) - @damagingTurn = (user.effects[PBEffects::Bide]==1) # If attack turn + def pbOnStartUse(user, targets) + @damagingTurn = (user.effects[PBEffects::Bide] == 1) # If attack turn end def pbDisplayUseMessage(user) if @damagingTurn # Attack turn - @battle.pbDisplayBrief(_INTL("{1} unleashed energy!",user.pbThis)) - elsif user.effects[PBEffects::Bide]>1 # Charging turns - @battle.pbDisplayBrief(_INTL("{1} is storing energy!",user.pbThis)) + @battle.pbDisplayBrief(_INTL("{1} unleashed energy!", user.pbThis)) + elsif user.effects[PBEffects::Bide] > 1 # Charging turns + @battle.pbDisplayBrief(_INTL("{1} is storing energy!", user.pbThis)) else super # Start using Bide end @@ -601,12 +601,12 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi return super end - def pbFixedDamage(user,target) - return user.effects[PBEffects::BideDamage]*2 + def pbFixedDamage(user, target) + return user.effects[PBEffects::BideDamage] * 2 end def pbEffectGeneral(user) - if user.effects[PBEffects::Bide]==0 # Starting using Bide + if user.effects[PBEffects::Bide] == 0 # Starting using Bide user.effects[PBEffects::Bide] = 3 user.effects[PBEffects::BideDamage] = 0 user.effects[PBEffects::BideTarget] = -1 @@ -615,7 +615,7 @@ class Battle::Move::MultiTurnAttackBideThenReturnDoubleDamage < Battle::Move::Fi user.effects[PBEffects::Bide] -= 1 end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) hitNum = 1 if !@damagingTurn # Charging anim super end diff --git a/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb b/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb index 5b4a8d8f0..efb8e6733 100644 --- a/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb +++ b/Data/Scripts/011_Battle/003_Move/010_MoveEffects_Healing.rb @@ -2,22 +2,22 @@ # Heals user to full HP. User falls asleep for 2 more rounds. (Rest) #=============================================================================== class Battle::Move::HealUserFullyAndFallAsleep < Battle::Move::HealingMove - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.asleep? @battle.pbDisplay(_INTL("But it failed!")) return true end - return true if !user.pbCanSleep?(user,true,self,true) + return true if !user.pbCanSleep?(user, true, self, true) return true if super return false end def pbHealAmount(user) - return user.totalhp-user.hp + return user.totalhp - user.hp end def pbEffectGeneral(user) - user.pbSleepSelf(_INTL("{1} slept and became healthy!",user.pbThis),3) + user.pbSleepSelf(_INTL("{1} slept and became healthy!", user.pbThis), 3) super end end @@ -27,7 +27,7 @@ end #=============================================================================== class Battle::Move::HealUserHalfOfTotalHP < Battle::Move::HealingMove def pbHealAmount(user) - return (user.totalhp/2.0).round + return (user.totalhp / 2.0).round end end @@ -36,14 +36,14 @@ end # Synthesis) #=============================================================================== class Battle::Move::HealUserDependingOnWeather < Battle::Move::HealingMove - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) case user.effectiveWeather when :Sun, :HarshSun - @healAmount = (user.totalhp*2/3.0).round + @healAmount = (user.totalhp * 2 / 3.0).round when :None, :StrongWinds - @healAmount = (user.totalhp/2.0).round + @healAmount = (user.totalhp / 2.0).round else - @healAmount = (user.totalhp/4.0).round + @healAmount = (user.totalhp / 4.0).round end end @@ -68,7 +68,7 @@ end #=============================================================================== class Battle::Move::HealUserHalfOfTotalHPLoseFlyingTypeThisTurn < Battle::Move::HealingMove def pbHealAmount(user) - return (user.totalhp/2.0).round + return (user.totalhp / 2.0).round end def pbEffectGeneral(user) @@ -94,10 +94,10 @@ class Battle::Move::CureTargetStatusHealUserHalfOfTotalHP < Battle::Move::Healin end def pbHealAmount(user) - return (user.totalhp/2.0).round + return (user.totalhp / 2.0).round end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.pbCureStatus super end @@ -129,28 +129,28 @@ class Battle::Move::HealUserByTargetAttackLowerTargetAttack1 < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) # Calculate target's effective attack value - stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8] - stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2] + stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8] + stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2] atk = target.attack - atkStage = target.stages[:ATTACK]+6 - healAmt = (atk.to_f*stageMul[atkStage]/stageDiv[atkStage]).floor + atkStage = target.stages[:ATTACK] + 6 + healAmt = (atk.to_f * stageMul[atkStage] / stageDiv[atkStage]).floor # Reduce target's Attack stat - if target.pbCanLowerStatStage?(:ATTACK,user,self) - target.pbLowerStatStage(:ATTACK,1,user) + if target.pbCanLowerStatStage?(:ATTACK, user, self) + target.pbLowerStatStage(:ATTACK, 1, user) end # Heal user if target.hasActiveAbility?(:LIQUIDOOZE) @battle.pbShowAbilitySplash(target) user.pbReduceHP(healAmt) - @battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!", user.pbThis)) @battle.pbHideAbilitySplash(target) user.pbItemHPHealCheck elsif user.canHeal? - healAmt = (healAmt*1.3).floor if user.hasActiveItem?(:BIGROOT) + healAmt = (healAmt * 1.3).floor if user.hasActiveItem?(:BIGROOT) user.pbRecoverHP(healAmt) - @battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis)) + @battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis)) end end end @@ -161,10 +161,10 @@ end class Battle::Move::HealUserByHalfOfDamageDone < Battle::Move def healingMove?; return Settings::MECHANICS_GENERATION >= 6; end - def pbEffectAgainstTarget(user,target) - return if target.damageState.hpLost<=0 - hpGain = (target.damageState.hpLost/2.0).round - user.pbRecoverHPFromDrain(hpGain,target) + def pbEffectAgainstTarget(user, target) + return if target.damageState.hpLost <= 0 + hpGain = (target.damageState.hpLost / 2.0).round + user.pbRecoverHPFromDrain(hpGain, target) end end @@ -183,10 +183,10 @@ class Battle::Move::HealUserByHalfOfDamageDoneIfTargetAsleep < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - return if target.damageState.hpLost<=0 - hpGain = (target.damageState.hpLost/2.0).round - user.pbRecoverHPFromDrain(hpGain,target) + def pbEffectAgainstTarget(user, target) + return if target.damageState.hpLost <= 0 + hpGain = (target.damageState.hpLost / 2.0).round + user.pbRecoverHPFromDrain(hpGain, target) end end @@ -196,10 +196,10 @@ end class Battle::Move::HealUserByThreeQuartersOfDamageDone < Battle::Move def healingMove?; return Settings::MECHANICS_GENERATION >= 6; end - def pbEffectAgainstTarget(user,target) - return if target.damageState.hpLost<=0 - hpGain = (target.damageState.hpLost*0.75).round - user.pbRecoverHPFromDrain(hpGain,target) + def pbEffectAgainstTarget(user, target) + return if target.damageState.hpLost <= 0 + hpGain = (target.damageState.hpLost * 0.75).round + user.pbRecoverHPFromDrain(hpGain, target) end end @@ -278,7 +278,7 @@ class Battle::Move::HealTargetHalfOfTotalHP < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.hp==target.totalhp + if target.hp == target.totalhp @battle.pbDisplay(_INTL("{1}'s HP is full!", target.pbThis)) if show_message return true elsif !target.canHeal? @@ -288,13 +288,13 @@ class Battle::Move::HealTargetHalfOfTotalHP < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - hpGain = (target.totalhp/2.0).round + def pbEffectAgainstTarget(user, target) + hpGain = (target.totalhp / 2.0).round if pulseMove? && user.hasActiveAbility?(:MEGALAUNCHER) - hpGain = (target.totalhp*3/4.0).round + hpGain = (target.totalhp * 3 / 4.0).round end target.pbRecoverHP(hpGain) - @battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis)) end end @@ -307,7 +307,7 @@ class Battle::Move::HealTargetDependingOnGrassyTerrain < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.hp==target.totalhp + if target.hp == target.totalhp @battle.pbDisplay(_INTL("{1}'s HP is full!", target.pbThis)) if show_message return true elsif !target.canHeal? @@ -317,11 +317,11 @@ class Battle::Move::HealTargetDependingOnGrassyTerrain < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - hpGain = (target.totalhp/2.0).round - hpGain = (target.totalhp*2/3.0).round if @battle.field.terrain == :Grassy + def pbEffectAgainstTarget(user, target) + hpGain = (target.totalhp / 2.0).round + hpGain = (target.totalhp * 2 / 3.0).round if @battle.field.terrain == :Grassy target.pbRecoverHP(hpGain) - @battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis)) end end @@ -333,8 +333,8 @@ class Battle::Move::HealUserPositionNextTurn < Battle::Move def healingMove?; return true; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if @battle.positions[user.index].effects[PBEffects::Wish]>0 + def pbMoveFailed?(user, targets) + if @battle.positions[user.index].effects[PBEffects::Wish] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -343,7 +343,7 @@ class Battle::Move::HealUserPositionNextTurn < Battle::Move def pbEffectGeneral(user) @battle.positions[user.index].effects[PBEffects::Wish] = 2 - @battle.positions[user.index].effects[PBEffects::WishAmount] = (user.totalhp/2.0).round + @battle.positions[user.index].effects[PBEffects::WishAmount] = (user.totalhp / 2.0).round @battle.positions[user.index].effects[PBEffects::WishMaker] = user.pokemonIndex end end @@ -355,7 +355,7 @@ end class Battle::Move::StartHealUserEachTurn < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.effects[PBEffects::AquaRing] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -365,7 +365,7 @@ class Battle::Move::StartHealUserEachTurn < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::AquaRing] = true - @battle.pbDisplay(_INTL("{1} surrounded itself with a veil of water!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} surrounded itself with a veil of water!", user.pbThis)) end end @@ -376,7 +376,7 @@ end class Battle::Move::StartHealUserEachTurnTrapUserInBattle < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.effects[PBEffects::Ingrain] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -386,7 +386,7 @@ class Battle::Move::StartHealUserEachTurnTrapUserInBattle < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::Ingrain] = true - @battle.pbDisplay(_INTL("{1} planted its roots!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} planted its roots!", user.pbThis)) end end @@ -402,9 +402,9 @@ class Battle::Move::StartDamageTargetEachTurnIfTargetAsleep < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Nightmare] = true - @battle.pbDisplay(_INTL("{1} began having a nightmare!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} began having a nightmare!", target.pbThis)) end end @@ -416,7 +416,7 @@ class Battle::Move::StartLeechSeedTarget < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.effects[PBEffects::LeechSeed]>=0 + if target.effects[PBEffects::LeechSeed] >= 0 @battle.pbDisplay(_INTL("{1} evaded the attack!", target.pbThis)) if show_message return true end @@ -427,14 +427,14 @@ class Battle::Move::StartLeechSeedTarget < Battle::Move return false end - def pbMissMessage(user,target) - @battle.pbDisplay(_INTL("{1} evaded the attack!",target.pbThis)) + def pbMissMessage(user, target) + @battle.pbDisplay(_INTL("{1} evaded the attack!", target.pbThis)) return true end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::LeechSeed] = user.index - @battle.pbDisplay(_INTL("{1} was seeded!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} was seeded!", target.pbThis)) end end @@ -459,16 +459,16 @@ end class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move def worksWithNoTargets?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !@battle.moldBreaker bearer = @battle.pbCheckGlobalAbility(:DAMP) - if bearer!=nil + if bearer != nil @battle.pbShowAbilitySplash(bearer) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,@name)) + @battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name)) else @battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", - user.pbThis,@name,bearer.pbThis(true),bearer.abilityName)) + user.pbThis, @name, bearer.pbThis(true), bearer.abilityName)) end @battle.pbHideAbilitySplash(bearer) return true @@ -479,7 +479,7 @@ class Battle::Move::UserLosesHalfOfTotalHPExplosive < Battle::Move def pbSelfKO(user) return if !user.takesIndirectDamage? - user.pbReduceHP((user.totalhp/2.0).round,false) + user.pbReduceHP((user.totalhp / 2.0).round, false) user.pbItemHPHealCheck end end @@ -489,18 +489,18 @@ end #=============================================================================== class Battle::Move::UserFaintsExplosive < Battle::Move def worksWithNoTargets?; return true; end - def pbNumHits(user,targets); return 1; end + def pbNumHits(user, targets); return 1; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !@battle.moldBreaker bearer = @battle.pbCheckGlobalAbility(:DAMP) - if bearer!=nil + if bearer != nil @battle.pbShowAbilitySplash(bearer) if Battle::Scene::USE_ABILITY_SPLASH - @battle.pbDisplay(_INTL("{1} cannot use {2}!",user.pbThis,@name)) + @battle.pbDisplay(_INTL("{1} cannot use {2}!", user.pbThis, @name)) else @battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", - user.pbThis,@name,bearer.pbThis(true),bearer.abilityName)) + user.pbThis, @name, bearer.pbThis(true), bearer.abilityName)) end @battle.pbHideAbilitySplash(bearer) return true @@ -511,7 +511,7 @@ class Battle::Move::UserFaintsExplosive < Battle::Move def pbSelfKO(user) return if user.fainted? - user.pbReduceHP(user.hp,false) + user.pbReduceHP(user.hp, false) user.pbItemHPHealCheck end end @@ -532,19 +532,19 @@ end # User faints (if successful). #=============================================================================== class Battle::Move::UserFaintsFixedDamageUserHP < Battle::Move::FixedDamageMove - def pbNumHits(user,targets); return 1; end + def pbNumHits(user, targets); return 1; end - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) @finalGambitDamage = user.hp end - def pbFixedDamage(user,target) + def pbFixedDamage(user, target) return @finalGambitDamage end def pbSelfKO(user) return if user.fainted? - user.pbReduceHP(user.hp,false) + user.pbReduceHP(user.hp, false) user.pbItemHPHealCheck end end @@ -556,9 +556,9 @@ end class Battle::Move::UserFaintsLowerTargetAtkSpAtk2 < Battle::Move::TargetMultiStatDownMove def canMagicCoat?; return false; end - def initialize(battle,move) + def initialize(battle, move) super - @statDown = [:ATTACK,2,:SPECIAL_ATTACK,2] + @statDown = [:ATTACK, 2, :SPECIAL_ATTACK, 2] end # NOTE: The user faints even if the target's stats cannot be changed, so this @@ -569,7 +569,7 @@ class Battle::Move::UserFaintsLowerTargetAtkSpAtk2 < Battle::Move::TargetMultiSt def pbSelfKO(user) return if user.fainted? - user.pbReduceHP(user.hp,false) + user.pbReduceHP(user.hp, false) user.pbItemHPHealCheck end end @@ -582,7 +582,7 @@ class Battle::Move::UserFaintsHealAndCureReplacement < Battle::Move def healingMove?; return true; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !@battle.pbCanChooseNonActive?(user.index) @battle.pbDisplay(_INTL("But it failed!")) return true @@ -592,7 +592,7 @@ class Battle::Move::UserFaintsHealAndCureReplacement < Battle::Move def pbSelfKO(user) return if user.fainted? - user.pbReduceHP(user.hp,false) + user.pbReduceHP(user.hp, false) user.pbItemHPHealCheck @battle.positions[user.index].effects[PBEffects::HealingWish] = true end @@ -606,7 +606,7 @@ class Battle::Move::UserFaintsHealAndCureReplacementRestorePP < Battle::Move def healingMove?; return true; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !@battle.pbCanChooseNonActive?(user.index) @battle.pbDisplay(_INTL("But it failed!")) return true @@ -616,7 +616,7 @@ class Battle::Move::UserFaintsHealAndCureReplacementRestorePP < Battle::Move def pbSelfKO(user) return if user.fainted? - user.pbReduceHP(user.hp,false) + user.pbReduceHP(user.hp, false) user.pbItemHPHealCheck @battle.positions[user.index].effects[PBEffects::LunarDance] = true end @@ -626,10 +626,10 @@ end # All current battlers will perish after 3 more rounds. (Perish Song) #=============================================================================== class Battle::Move::StartPerishCountsForAllBattlers < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) failed = true targets.each do |b| - next if b.effects[PBEffects::PerishSong]>0 # Heard it before + next if b.effects[PBEffects::PerishSong] > 0 # Heard it before failed = false break end @@ -641,15 +641,15 @@ class Battle::Move::StartPerishCountsForAllBattlers < Battle::Move end def pbFailsAgainstTarget?(user, target, show_message) - return target.effects[PBEffects::PerishSong]>0 # Heard it before + return target.effects[PBEffects::PerishSong] > 0 # Heard it before end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::PerishSong] = 4 target.effects[PBEffects::PerishSongUser] = user.index end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) super @battle.pbDisplay(_INTL("All Pokémon that hear the song will faint in three turns!")) end @@ -660,7 +660,7 @@ end # (Destiny Bond) #=============================================================================== class Battle::Move::AttackerFaintsIfUserFaints < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if Settings::MECHANICS_GENERATION >= 7 && user.effects[PBEffects::DestinyBondPrevious] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -670,7 +670,7 @@ class Battle::Move::AttackerFaintsIfUserFaints < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::DestinyBond] = true - @battle.pbDisplay(_INTL("{1} is hoping to take its attacker down with it!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} is hoping to take its attacker down with it!", user.pbThis)) end end @@ -681,6 +681,6 @@ end class Battle::Move::SetAttackerMovePPTo0IfUserFaints < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::Grudge] = true - @battle.pbDisplay(_INTL("{1} wants its target to bear a grudge!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} wants its target to bear a grudge!", user.pbThis)) end end diff --git a/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb b/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb index 5dbea8eb5..658111fca 100644 --- a/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb +++ b/Data/Scripts/011_Battle/003_Move/011_MoveEffects_Items.rb @@ -3,7 +3,7 @@ # Items stolen from wild Pokémon are kept after the battle. #=============================================================================== class Battle::Move::UserTakesTargetItem < Battle::Move - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if user.wild? # Wild Pokémon can't thieve return if user.fainted? return if target.damageState.unaffected || target.damageState.substitute @@ -20,7 +20,7 @@ class Battle::Move::UserTakesTargetItem < Battle::Move else target.pbRemoveItem(false) end - @battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis,target.pbThis(true),itemName)) + @battle.pbDisplay(_INTL("{1} stole {2}'s {3}!", user.pbThis, target.pbThis(true), itemName)) user.pbHeldItemTriggerCheck end end @@ -35,7 +35,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move return super end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.item || user.unlosableItem?(user.item) @battle.pbDisplay(_INTL("But it failed!")) return true @@ -51,7 +51,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) itemName = user.itemName target.item = user.item # Permanently steal the item from wild Pokémon @@ -61,7 +61,7 @@ class Battle::Move::TargetTakesUserItem < Battle::Move else user.pbRemoveItem(false) end - @battle.pbDisplay(_INTL("{1} received {2} from {3}!",target.pbThis,itemName,user.pbThis(true))) + @battle.pbDisplay(_INTL("{1} received {2} from {3}!", target.pbThis, itemName, user.pbThis(true))) target.pbHeldItemTriggerCheck end end @@ -71,7 +71,7 @@ end # (Switcheroo, Trick) #=============================================================================== class Battle::Move::UserTargetSwapItems < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.wild? @battle.pbDisplay(_INTL("But it failed!")) return true @@ -107,7 +107,7 @@ class Battle::Move::UserTargetSwapItems < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) oldUserItem = user.item oldUserItemName = user.itemName oldTargetItem = target.item @@ -122,9 +122,9 @@ class Battle::Move::UserTargetSwapItems < Battle::Move if target.wild? && !user.initialItem && oldTargetItem == target.initialItem user.setInitialItem(oldTargetItem) end - @battle.pbDisplay(_INTL("{1} switched items with its opponent!",user.pbThis)) - @battle.pbDisplay(_INTL("{1} obtained {2}.",user.pbThis,oldTargetItemName)) if oldTargetItem - @battle.pbDisplay(_INTL("{1} obtained {2}.",target.pbThis,oldUserItemName)) if oldUserItem + @battle.pbDisplay(_INTL("{1} switched items with its opponent!", user.pbThis)) + @battle.pbDisplay(_INTL("{1} obtained {2}.", user.pbThis, oldTargetItemName)) if oldTargetItem + @battle.pbDisplay(_INTL("{1} obtained {2}.", target.pbThis, oldUserItemName)) if oldUserItem user.pbHeldItemTriggerCheck target.pbHeldItemTriggerCheck end @@ -136,7 +136,7 @@ end class Battle::Move::RestoreUserConsumedItem < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.recycleItem @battle.pbDisplay(_INTL("But it failed!")) return true @@ -153,9 +153,9 @@ class Battle::Move::RestoreUserConsumedItem < Battle::Move user.effects[PBEffects::PickupUse] = 0 itemName = GameData::Item.get(item).name if itemName.starts_with_vowel? - @battle.pbDisplay(_INTL("{1} found an {2}!",user.pbThis,itemName)) + @battle.pbDisplay(_INTL("{1} found an {2}!", user.pbThis, itemName)) else - @battle.pbDisplay(_INTL("{1} found a {2}!",user.pbThis,itemName)) + @battle.pbDisplay(_INTL("{1} found a {2}!", user.pbThis, itemName)) end user.pbHeldItemTriggerCheck end @@ -166,17 +166,17 @@ end # If target has a losable item, damage is multiplied by 1.5. #=============================================================================== class Battle::Move::RemoveTargetItem < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) if Settings::MECHANICS_GENERATION >= 6 && target.item && !target.unlosableItem?(target.item) # NOTE: Damage is still boosted even if target has Sticky Hold or a # substitute. - baseDmg = (baseDmg*1.5).round + baseDmg = (baseDmg * 1.5).round end return baseDmg end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if user.wild? # Wild Pokémon can't knock off return if user.fainted? return if target.damageState.unaffected || target.damageState.substitute @@ -184,7 +184,7 @@ class Battle::Move::RemoveTargetItem < Battle::Move return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker itemName = target.itemName target.pbRemoveItem(false) - @battle.pbDisplay(_INTL("{1} dropped its {2}!",target.pbThis,itemName)) + @battle.pbDisplay(_INTL("{1} dropped its {2}!", target.pbThis, itemName)) end end @@ -192,12 +192,12 @@ end # Target's berry/Gem is destroyed. (Incinerate) #=============================================================================== class Battle::Move::DestroyTargetBerryOrGem < Battle::Move - def pbEffectWhenDealingDamage(user,target) + def pbEffectWhenDealingDamage(user, target) return if target.damageState.substitute || target.damageState.berryWeakened return if !target.item || (!target.item.is_berry? && !(Settings::MECHANICS_GENERATION >= 6 && target.item.is_gem?)) target.pbRemoveItem - @battle.pbDisplay(_INTL("{1}'s {2} was incinerated!",target.pbThis,target.itemName)) + @battle.pbDisplay(_INTL("{1}'s {2} was incinerated!", target.pbThis, target.itemName)) end end @@ -251,16 +251,16 @@ class Battle::Move::StartTargetCannotUseItem < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.effects[PBEffects::Embargo]>0 + if target.effects[PBEffects::Embargo] > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Embargo] = 5 - @battle.pbDisplay(_INTL("{1} can't use items anymore!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} can't use items anymore!", target.pbThis)) end end @@ -270,7 +270,7 @@ end #=============================================================================== class Battle::Move::StartNegateHeldItems < Battle::Move def pbEffectGeneral(user) - if @battle.field.effects[PBEffects::MagicRoom]>0 + if @battle.field.effects[PBEffects::MagicRoom] > 0 @battle.field.effects[PBEffects::MagicRoom] = 0 @battle.pbDisplay(_INTL("The area returned to normal!")) else @@ -279,8 +279,8 @@ class Battle::Move::StartNegateHeldItems < Battle::Move end end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) - return if @battle.field.effects[PBEffects::MagicRoom]>0 # No animation + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) + return if @battle.field.effects[PBEffects::MagicRoom] > 0 # No animation super end end @@ -374,7 +374,7 @@ end # User consumes target's berry and gains its effect. (Bug Bite, Pluck) #=============================================================================== class Battle::Move::UserConsumeTargetBerry < Battle::Move - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if user.fainted? || target.fainted? return if target.damageState.unaffected || target.damageState.substitute return if !target.item || !target.item.is_berry? @@ -382,8 +382,8 @@ class Battle::Move::UserConsumeTargetBerry < Battle::Move item = target.item itemName = target.itemName target.pbRemoveItem - @battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!",user.pbThis,itemName)) - user.pbHeldItemTriggerCheck(item,false) + @battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!", user.pbThis, itemName)) + user.pbHeldItemTriggerCheck(item, false) end end @@ -391,114 +391,114 @@ end # User flings its item at the target. Power/effect depend on the item. (Fling) #=============================================================================== class Battle::Move::ThrowUserItemAtTarget < Battle::Move - def initialize(battle,move) + def initialize(battle, move) super # 80 => all Mega Stones # 10 => all Berries @flingPowers = { 130 => [:IRONBALL], - 100 => [:HARDSTONE,:RAREBONE, + 100 => [:HARDSTONE, :RAREBONE, # Fossils - :ARMORFOSSIL,:CLAWFOSSIL,:COVERFOSSIL,:DOMEFOSSIL,:HELIXFOSSIL, - :JAWFOSSIL,:OLDAMBER,:PLUMEFOSSIL,:ROOTFOSSIL,:SAILFOSSIL, + :ARMORFOSSIL, :CLAWFOSSIL, :COVERFOSSIL, :DOMEFOSSIL, :HELIXFOSSIL, + :JAWFOSSIL, :OLDAMBER, :PLUMEFOSSIL, :ROOTFOSSIL, :SAILFOSSIL, :SKULLFOSSIL], - 90 => [:DEEPSEATOOTH,:GRIPCLAW,:THICKCLUB, + 90 => [:DEEPSEATOOTH, :GRIPCLAW, :THICKCLUB, # Plates - :DRACOPLATE,:DREADPLATE,:EARTHPLATE,:FISTPLATE,:FLAMEPLATE, - :ICICLEPLATE,:INSECTPLATE,:IRONPLATE,:MEADOWPLATE,:MINDPLATE, - :PIXIEPLATE,:SKYPLATE,:SPLASHPLATE,:SPOOKYPLATE,:STONEPLATE, - :TOXICPLATE,:ZAPPLATE], - 80 => [:ASSAULTVEST,:CHIPPEDPOT,:CRACKEDPOT,:DAWNSTONE,:DUSKSTONE, - :ELECTIRIZER,:HEAVYDUTYBOOTS,:MAGMARIZER,:ODDKEYSTONE,:OVALSTONE, - :PROTECTOR,:QUICKCLAW,:RAZORCLAW,:SACHET,:SAFETYGOGGLES, - :SHINYSTONE,:STICKYBARB,:WEAKNESSPOLICY,:WHIPPEDDREAM], - 70 => [:DRAGONFANG,:POISONBARB, + :DRACOPLATE, :DREADPLATE, :EARTHPLATE, :FISTPLATE, :FLAMEPLATE, + :ICICLEPLATE, :INSECTPLATE, :IRONPLATE, :MEADOWPLATE, :MINDPLATE, + :PIXIEPLATE, :SKYPLATE, :SPLASHPLATE, :SPOOKYPLATE, :STONEPLATE, + :TOXICPLATE, :ZAPPLATE], + 80 => [:ASSAULTVEST, :CHIPPEDPOT, :CRACKEDPOT, :DAWNSTONE, :DUSKSTONE, + :ELECTIRIZER, :HEAVYDUTYBOOTS, :MAGMARIZER, :ODDKEYSTONE, :OVALSTONE, + :PROTECTOR, :QUICKCLAW, :RAZORCLAW, :SACHET, :SAFETYGOGGLES, + :SHINYSTONE, :STICKYBARB, :WEAKNESSPOLICY, :WHIPPEDDREAM], + 70 => [:DRAGONFANG, :POISONBARB, # EV-training items (Macho Brace is 60) - :POWERANKLET,:POWERBAND,:POWERBELT,:POWERBRACER,:POWERLENS, + :POWERANKLET, :POWERBAND, :POWERBELT, :POWERBRACER, :POWERLENS, :POWERWEIGHT, # Drives - :BURNDRIVE,:CHILLDRIVE,:DOUSEDRIVE,:SHOCKDRIVE], - 60 => [:ADAMANTORB,:DAMPROCK,:GRISEOUSORB,:HEATROCK,:LEEK,:LUSTROUSORB, - :MACHOBRACE,:ROCKYHELMET,:STICK,:TERRAINEXTENDER], - 50 => [:DUBIOUSDISC,:SHARPBEAK, + :BURNDRIVE, :CHILLDRIVE, :DOUSEDRIVE, :SHOCKDRIVE], + 60 => [:ADAMANTORB, :DAMPROCK, :GRISEOUSORB, :HEATROCK, :LEEK, :LUSTROUSORB, + :MACHOBRACE, :ROCKYHELMET, :STICK, :TERRAINEXTENDER], + 50 => [:DUBIOUSDISC, :SHARPBEAK, # Memories - :BUGMEMORY,:DARKMEMORY,:DRAGONMEMORY,:ELECTRICMEMORY,:FAIRYMEMORY, - :FIGHTINGMEMORY,:FIREMEMORY,:FLYINGMEMORY,:GHOSTMEMORY, - :GRASSMEMORY,:GROUNDMEMORY,:ICEMEMORY,:POISONMEMORY, - :PSYCHICMEMORY,:ROCKMEMORY,:STEELMEMORY,:WATERMEMORY], - 40 => [:EVIOLITE,:ICYROCK,:LUCKYPUNCH], - 30 => [:ABSORBBULB,:ADRENALINEORB,:AMULETCOIN,:BINDINGBAND,:BLACKBELT, - :BLACKGLASSES,:BLACKSLUDGE,:BOTTLECAP,:CELLBATTERY,:CHARCOAL, - :CLEANSETAG,:DEEPSEASCALE,:DRAGONSCALE,:EJECTBUTTON,:ESCAPEROPE, - :EXPSHARE,:FLAMEORB,:FLOATSTONE,:FLUFFYTAIL,:GOLDBOTTLECAP, - :HEARTSCALE,:HONEY,:KINGSROCK,:LIFEORB,:LIGHTBALL,:LIGHTCLAY, - :LUCKYEGG,:LUMINOUSMOSS,:MAGNET,:METALCOAT,:METRONOME, - :MIRACLESEED,:MYSTICWATER,:NEVERMELTICE,:PASSORB,:POKEDOLL, - :POKETOY,:PRISMSCALE,:PROTECTIVEPADS,:RAZORFANG,:SACREDASH, - :SCOPELENS,:SHELLBELL,:SHOALSALT,:SHOALSHELL,:SMOKEBALL,:SNOWBALL, - :SOULDEW,:SPELLTAG,:TOXICORB,:TWISTEDSPOON,:UPGRADE, + :BUGMEMORY, :DARKMEMORY, :DRAGONMEMORY, :ELECTRICMEMORY, :FAIRYMEMORY, + :FIGHTINGMEMORY, :FIREMEMORY, :FLYINGMEMORY, :GHOSTMEMORY, + :GRASSMEMORY, :GROUNDMEMORY, :ICEMEMORY, :POISONMEMORY, + :PSYCHICMEMORY, :ROCKMEMORY, :STEELMEMORY, :WATERMEMORY], + 40 => [:EVIOLITE, :ICYROCK, :LUCKYPUNCH], + 30 => [:ABSORBBULB, :ADRENALINEORB, :AMULETCOIN, :BINDINGBAND, :BLACKBELT, + :BLACKGLASSES, :BLACKSLUDGE, :BOTTLECAP, :CELLBATTERY, :CHARCOAL, + :CLEANSETAG, :DEEPSEASCALE, :DRAGONSCALE, :EJECTBUTTON, :ESCAPEROPE, + :EXPSHARE, :FLAMEORB, :FLOATSTONE, :FLUFFYTAIL, :GOLDBOTTLECAP, + :HEARTSCALE, :HONEY, :KINGSROCK, :LIFEORB, :LIGHTBALL, :LIGHTCLAY, + :LUCKYEGG, :LUMINOUSMOSS, :MAGNET, :METALCOAT, :METRONOME, + :MIRACLESEED, :MYSTICWATER, :NEVERMELTICE, :PASSORB, :POKEDOLL, + :POKETOY, :PRISMSCALE, :PROTECTIVEPADS, :RAZORFANG, :SACREDASH, + :SCOPELENS, :SHELLBELL, :SHOALSALT, :SHOALSHELL, :SMOKEBALL, :SNOWBALL, + :SOULDEW, :SPELLTAG, :TOXICORB, :TWISTEDSPOON, :UPGRADE, # Healing items - :ANTIDOTE,:AWAKENING,:BERRYJUICE,:BIGMALASADA,:BLUEFLUTE, - :BURNHEAL,:CASTELIACONE,:ELIXIR,:ENERGYPOWDER,:ENERGYROOT,:ETHER, - :FRESHWATER,:FULLHEAL,:FULLRESTORE,:HEALPOWDER,:HYPERPOTION, - :ICEHEAL,:LAVACOOKIE,:LEMONADE,:LUMIOSEGALETTE,:MAXELIXIR, - :MAXETHER,:MAXHONEY,:MAXPOTION,:MAXREVIVE,:MOOMOOMILK,:OLDGATEAU, - :PARALYZEHEAL,:PARLYZHEAL,:PEWTERCRUNCHIES,:POTION,:RAGECANDYBAR, - :REDFLUTE,:REVIVALHERB,:REVIVE,:SHALOURSABLE,:SODAPOP, - :SUPERPOTION,:SWEETHEART,:YELLOWFLUTE, + :ANTIDOTE, :AWAKENING, :BERRYJUICE, :BIGMALASADA, :BLUEFLUTE, + :BURNHEAL, :CASTELIACONE, :ELIXIR, :ENERGYPOWDER, :ENERGYROOT, :ETHER, + :FRESHWATER, :FULLHEAL, :FULLRESTORE, :HEALPOWDER, :HYPERPOTION, + :ICEHEAL, :LAVACOOKIE, :LEMONADE, :LUMIOSEGALETTE, :MAXELIXIR, + :MAXETHER, :MAXHONEY, :MAXPOTION, :MAXREVIVE, :MOOMOOMILK, :OLDGATEAU, + :PARALYZEHEAL, :PARLYZHEAL, :PEWTERCRUNCHIES, :POTION, :RAGECANDYBAR, + :REDFLUTE, :REVIVALHERB, :REVIVE, :SHALOURSABLE, :SODAPOP, + :SUPERPOTION, :SWEETHEART, :YELLOWFLUTE, # Battle items - :XACCURACY,:XACCURACY2,:XACCURACY3,:XACCURACY6, - :XATTACK,:XATTACK2,:XATTACK3,:XATTACK6, - :XDEFEND,:XDEFEND2,:XDEFEND3,:XDEFEND6, - :XDEFENSE,:XDEFENSE2,:XDEFENSE3,:XDEFENSE6, - :XSPATK,:XSPATK2,:XSPATK3,:XSPATK6, - :XSPECIAL,:XSPECIAL2,:XSPECIAL3,:XSPECIAL6, - :XSPDEF,:XSPDEF2,:XSPDEF3,:XSPDEF6, - :XSPEED,:XSPEED2,:XSPEED3,:XSPEED6, - :DIREHIT,:DIREHIT2,:DIREHIT3, - :ABILITYURGE,:GUARDSPEC,:ITEMDROP,:ITEMURGE,:RESETURGE, + :XACCURACY, :XACCURACY2, :XACCURACY3, :XACCURACY6, + :XATTACK, :XATTACK2, :XATTACK3, :XATTACK6, + :XDEFEND, :XDEFEND2, :XDEFEND3, :XDEFEND6, + :XDEFENSE, :XDEFENSE2, :XDEFENSE3, :XDEFENSE6, + :XSPATK, :XSPATK2, :XSPATK3, :XSPATK6, + :XSPECIAL, :XSPECIAL2, :XSPECIAL3, :XSPECIAL6, + :XSPDEF, :XSPDEF2, :XSPDEF3, :XSPDEF6, + :XSPEED, :XSPEED2, :XSPEED3, :XSPEED6, + :DIREHIT, :DIREHIT2, :DIREHIT3, + :ABILITYURGE, :GUARDSPEC, :ITEMDROP, :ITEMURGE, :RESETURGE, :MAXMUSHROOMS, # Vitamins - :CALCIUM,:CARBOS,:HPUP,:IRON,:PPUP,:PPMAX,:PROTEIN,:ZINC, + :CALCIUM, :CARBOS, :HPUP, :IRON, :PPUP, :PPMAX, :PROTEIN, :ZINC, :RARECANDY, # Most evolution stones (see also 80) - :EVERSTONE,:FIRESTONE,:ICESTONE,:LEAFSTONE,:MOONSTONE,:SUNSTONE, - :THUNDERSTONE,:WATERSTONE,:SWEETAPPLE,:TARTAPPLE, :GALARICACUFF, + :EVERSTONE, :FIRESTONE, :ICESTONE, :LEAFSTONE, :MOONSTONE, :SUNSTONE, + :THUNDERSTONE, :WATERSTONE, :SWEETAPPLE, :TARTAPPLE, :GALARICACUFF, :GALARICAWREATH, # Repels - :MAXREPEL,:REPEL,:SUPERREPEL, + :MAXREPEL, :REPEL, :SUPERREPEL, # Mulches - :AMAZEMULCH,:BOOSTMULCH,:DAMPMULCH,:GOOEYMULCH,:GROWTHMULCH, - :RICHMULCH,:STABLEMULCH,:SURPRISEMULCH, + :AMAZEMULCH, :BOOSTMULCH, :DAMPMULCH, :GOOEYMULCH, :GROWTHMULCH, + :RICHMULCH, :STABLEMULCH, :SURPRISEMULCH, # Shards - :BLUESHARD,:GREENSHARD,:REDSHARD,:YELLOWSHARD, + :BLUESHARD, :GREENSHARD, :REDSHARD, :YELLOWSHARD, # Valuables - :BALMMUSHROOM,:BIGMUSHROOM,:BIGNUGGET,:BIGPEARL,:COMETSHARD, - :NUGGET,:PEARL,:PEARLSTRING,:RELICBAND,:RELICCOPPER,:RELICCROWN, - :RELICGOLD,:RELICSILVER,:RELICSTATUE,:RELICVASE,:STARDUST, - :STARPIECE,:STRANGESOUVENIR,:TINYMUSHROOM, + :BALMMUSHROOM, :BIGMUSHROOM, :BIGNUGGET, :BIGPEARL, :COMETSHARD, + :NUGGET, :PEARL, :PEARLSTRING, :RELICBAND, :RELICCOPPER, :RELICCROWN, + :RELICGOLD, :RELICSILVER, :RELICSTATUE, :RELICVASE, :STARDUST, + :STARPIECE, :STRANGESOUVENIR, :TINYMUSHROOM, # Exp Candies :EXPCANDYXS, :EXPCANDYS, :EXPCANDYM, :EXPCANDYL, :EXPCANDYXL], 20 => [ # Feathers - :CLEVERFEATHER,:GENIUSFEATHER,:HEALTHFEATHER,:MUSCLEFEATHER, - :PRETTYFEATHER,:RESISTFEATHER,:SWIFTFEATHER, - :CLEVERWING,:GENIUSWING,:HEALTHWING,:MUSCLEWING,:PRETTYWING, - :RESISTWING,:SWIFTWING], - 10 => [:AIRBALLOON,:BIGROOT,:BRIGHTPOWDER,:CHOICEBAND,:CHOICESCARF, - :CHOICESPECS,:DESTINYKNOT,:DISCOUNTCOUPON,:EXPERTBELT,:FOCUSBAND, - :FOCUSSASH,:LAGGINGTAIL,:LEFTOVERS,:MENTALHERB,:METALPOWDER, - :MUSCLEBAND,:POWERHERB,:QUICKPOWDER,:REAPERCLOTH,:REDCARD, - :RINGTARGET,:SHEDSHELL,:SILKSCARF,:SILVERPOWDER,:SMOOTHROCK, - :SOFTSAND,:SOOTHEBELL,:WHITEHERB,:WIDELENS,:WISEGLASSES,:ZOOMLENS, + :CLEVERFEATHER, :GENIUSFEATHER, :HEALTHFEATHER, :MUSCLEFEATHER, + :PRETTYFEATHER, :RESISTFEATHER, :SWIFTFEATHER, + :CLEVERWING, :GENIUSWING, :HEALTHWING, :MUSCLEWING, :PRETTYWING, + :RESISTWING, :SWIFTWING], + 10 => [:AIRBALLOON, :BIGROOT, :BRIGHTPOWDER, :CHOICEBAND, :CHOICESCARF, + :CHOICESPECS, :DESTINYKNOT, :DISCOUNTCOUPON, :EXPERTBELT, :FOCUSBAND, + :FOCUSSASH, :LAGGINGTAIL, :LEFTOVERS, :MENTALHERB, :METALPOWDER, + :MUSCLEBAND, :POWERHERB, :QUICKPOWDER, :REAPERCLOTH, :REDCARD, + :RINGTARGET, :SHEDSHELL, :SILKSCARF, :SILVERPOWDER, :SMOOTHROCK, + :SOFTSAND, :SOOTHEBELL, :WHITEHERB, :WIDELENS, :WISEGLASSES, :ZOOMLENS, # Terrain seeds - :ELECTRICSEED,:GRASSYSEED,:MISTYSEED,:PSYCHICSEED, + :ELECTRICSEED, :GRASSYSEED, :MISTYSEED, :PSYCHICSEED, # Nectar - :PINKNECTAR,:PURPLENECTAR,:REDNECTAR,:YELLOWNECTAR, + :PINKNECTAR, :PURPLENECTAR, :REDNECTAR, :YELLOWNECTAR, # Incenses - :FULLINCENSE,:LAXINCENSE,:LUCKINCENSE,:ODDINCENSE,:PUREINCENSE, - :ROCKINCENSE,:ROSEINCENSE,:SEAINCENSE,:WAVEINCENSE, + :FULLINCENSE, :LAXINCENSE, :LUCKINCENSE, :ODDINCENSE, :PUREINCENSE, + :ROCKINCENSE, :ROSEINCENSE, :SEAINCENSE, :WAVEINCENSE, # Scarves - :BLUESCARF,:GREENSCARF,:PINKSCARF,:REDSCARF,:YELLOWSCARF, + :BLUESCARF, :GREENSCARF, :PINKSCARF, :REDSCARF, :YELLOWSCARF, # Mints :LONELYMINT, :ADAMANTMINT, :NAUGHTYMINT, :BRAVEMINT, :BOLDMINT, :IMPISHMINT, :LAXMINT, :RELAXEDMINT, :MODESTMINT, :MILDMINT, @@ -527,7 +527,7 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move @willFail = true if !flingableItem end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @willFail @battle.pbDisplay(_INTL("But it failed!")) return true @@ -539,13 +539,13 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move super pbCheckFlingSuccess(user) if !@willFail - @battle.pbDisplay(_INTL("{1} flung its {2}!",user.pbThis,user.itemName)) + @battle.pbDisplay(_INTL("{1} flung its {2}!", user.pbThis, user.itemName)) end end - def pbNumHits(user,targets); return 1; end + def pbNumHits(user, targets); return 1; end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) return 0 if !user.item return 10 if user.item.is_berry? return 80 if user.item.is_mega_stone? @@ -554,36 +554,36 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move ret = 10 if ret < 10 return ret end - @flingPowers.each do |power,items| + @flingPowers.each do |power, items| return power if items.include?(user.item_id) end return 10 end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if target.damageState.substitute return if target.hasActiveAbility?(:SHIELDDUST) && !@battle.moldBreaker case user.item_id when :POISONBARB - target.pbPoison(user) if target.pbCanPoison?(user,false,self) + target.pbPoison(user) if target.pbCanPoison?(user, false, self) when :TOXICORB - target.pbPoison(user,nil,true) if target.pbCanPoison?(user,false,self) + target.pbPoison(user, nil, true) if target.pbCanPoison?(user, false, self) when :FLAMEORB - target.pbBurn(user) if target.pbCanBurn?(user,false,self) + target.pbBurn(user) if target.pbCanBurn?(user, false, self) when :LIGHTBALL - target.pbParalyze(user) if target.pbCanParalyze?(user,false,self) + target.pbParalyze(user) if target.pbCanParalyze?(user, false, self) when :KINGSROCK, :RAZORFANG target.pbFlinch(user) else - target.pbHeldItemTriggerCheck(user.item,true) + target.pbHeldItemTriggerCheck(user.item, true) end end - def pbEndOfMoveUsageEffect(user,targets,numHits,switchedBattlers) + def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers) # NOTE: The item is consumed even if this move was Protected against or it # missed. The item is not consumed if the target was switched out by # an effect like a target's Red Card. # NOTE: There is no item consumption animation. - user.pbConsumeItem(true,true,false) if user.item + user.pbConsumeItem(true, true, false) if user.item end end diff --git a/Data/Scripts/011_Battle/003_Move/012_MoveEffects_ChangeMoveEffect.rb b/Data/Scripts/011_Battle/003_Move/012_MoveEffects_ChangeMoveEffect.rb index e930de708..b1cb136b8 100644 --- a/Data/Scripts/011_Battle/003_Move/012_MoveEffects_ChangeMoveEffect.rb +++ b/Data/Scripts/011_Battle/003_Move/012_MoveEffects_ChangeMoveEffect.rb @@ -6,11 +6,11 @@ class Battle::Move::RedirectAllMovesToUser < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::FollowMe] = 1 user.allAllies.each do |b| - next if b.effects[PBEffects::FollowMe]0 = damage r = @battle.pbRandom(100) - if r<40 + if r < 40 @presentDmg = 40 - elsif r<70 + elsif r < 70 @presentDmg = 80 - elsif r<80 + elsif r < 80 @presentDmg = 120 end end def pbFailsAgainstTarget?(user, target, show_message) - return false if @presentDmg>0 + return false if @presentDmg > 0 if !target.canHeal? @battle.pbDisplay(_INTL("But it failed!")) if show_message return true @@ -66,22 +66,22 @@ class Battle::Move::RandomlyDamageOrHealTarget < Battle::Move end def pbDamagingMove? - return false if @presentDmg==0 + return false if @presentDmg == 0 return super end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) return @presentDmg end - def pbEffectAgainstTarget(user,target) - return if @presentDmg>0 - target.pbRecoverHP(target.totalhp/4) - @battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis)) + def pbEffectAgainstTarget(user, target) + return if @presentDmg > 0 + target.pbRecoverHP(target.totalhp / 4) + @battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis)) end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) - hitNum = 1 if @presentDmg==0 # Healing anim + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) + hitNum = 1 if @presentDmg == 0 # Healing anim super end end @@ -92,18 +92,18 @@ end #=============================================================================== class Battle::Move::HealAllyOrDamageFoe < Battle::Move def pbTarget(user) - return GameData::Target.get(:NearFoe) if user.effects[PBEffects::HealBlock]>0 + return GameData::Target.get(:NearFoe) if user.effects[PBEffects::HealBlock] > 0 return super end - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) @healing = false - @healing = !user.opposes?(targets[0]) if targets.length>0 + @healing = !user.opposes?(targets[0]) if targets.length > 0 end def pbFailsAgainstTarget?(user, target, show_message) return false if !@healing - if target.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(user) + if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -119,13 +119,13 @@ class Battle::Move::HealAllyOrDamageFoe < Battle::Move return super end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if !@healing - target.pbRecoverHP(target.totalhp/2) - @battle.pbDisplay(_INTL("{1}'s HP was restored.",target.pbThis)) + target.pbRecoverHP(target.totalhp / 2) + @battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis)) end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) hitNum = 1 if @healing # Healing anim super end @@ -148,11 +148,11 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move return super end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) return false if user.pbHasType?(:GHOST) - if !user.pbCanLowerStatStage?(:SPEED,user,self) && - !user.pbCanRaiseStatStage?(:ATTACK,user,self) && - !user.pbCanRaiseStatStage?(:DEFENSE,user,self) + if !user.pbCanLowerStatStage?(:SPEED, user, self) && + !user.pbCanRaiseStatStage?(:ATTACK, user, self) && + !user.pbCanRaiseStatStage?(:DEFENSE, user, self) @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -170,30 +170,30 @@ class Battle::Move::CurseTargetOrLowerUserSpd1RaiseUserAtkDef1 < Battle::Move def pbEffectGeneral(user) return if user.pbHasType?(:GHOST) # Non-Ghost effect - if user.pbCanLowerStatStage?(:SPEED,user,self) - user.pbLowerStatStage(:SPEED,1,user) + if user.pbCanLowerStatStage?(:SPEED, user, self) + user.pbLowerStatStage(:SPEED, 1, user) end showAnim = true - if user.pbCanRaiseStatStage?(:ATTACK,user,self) - if user.pbRaiseStatStage(:ATTACK,1,user,showAnim) + if user.pbCanRaiseStatStage?(:ATTACK, user, self) + if user.pbRaiseStatStage(:ATTACK, 1, user, showAnim) showAnim = false end end - if user.pbCanRaiseStatStage?(:DEFENSE,user,self) - user.pbRaiseStatStage(:DEFENSE,1,user,showAnim) + if user.pbCanRaiseStatStage?(:DEFENSE, user, self) + user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim) end end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if !user.pbHasType?(:GHOST) # Ghost effect - @battle.pbDisplay(_INTL("{1} cut its own HP and laid a curse on {2}!",user.pbThis,target.pbThis(true))) + @battle.pbDisplay(_INTL("{1} cut its own HP and laid a curse on {2}!", user.pbThis, target.pbThis(true))) target.effects[PBEffects::Curse] = true - user.pbReduceHP(user.totalhp/2, false, false) + user.pbReduceHP(user.totalhp / 2, false, false) user.pbItemHPHealCheck end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) hitNum = 1 if !user.pbHasType?(:GHOST) # Non-Ghost anim super end @@ -203,9 +203,9 @@ end # Effect depends on the environment. (Secret Power) #=============================================================================== class Battle::Move::EffectDependsOnEnvironment < Battle::Move - def flinchingMove?; return [6,10,12].include?(@secretPower); end + def flinchingMove?; return [6, 10, 12].include?(@secretPower); end - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) # NOTE: This is Gen 7's list plus some of Gen 6 plus a bit of my own. @secretPower = 0 # Body Slam, paralysis case @battle.field.terrain @@ -249,46 +249,46 @@ class Battle::Move::EffectDependsOnEnvironment < Battle::Move # method is called per hit and this move's additional effect only occurs # once per use, after all the hits have happened (two hits are possible # via Parental Bond). - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if target.fainted? return if target.damageState.unaffected || target.damageState.substitute - chance = pbAdditionalEffectChance(user,target) - return if @battle.pbRandom(100)>=chance + chance = pbAdditionalEffectChance(user, target) + return if @battle.pbRandom(100) >= chance case @secretPower when 2 - target.pbSleep if target.pbCanSleep?(user,false,self) + target.pbSleep if target.pbCanSleep?(user, false, self) when 10 - target.pbBurn(user) if target.pbCanBurn?(user,false,self) + target.pbBurn(user) if target.pbCanBurn?(user, false, self) when 0, 1 - target.pbParalyze(user) if target.pbCanParalyze?(user,false,self) + target.pbParalyze(user) if target.pbCanParalyze?(user, false, self) when 9 - target.pbFreeze if target.pbCanFreeze?(user,false,self) + target.pbFreeze if target.pbCanFreeze?(user, false, self) when 5 - if target.pbCanLowerStatStage?(:ATTACK,user,self) - target.pbLowerStatStage(:ATTACK,1,user) + if target.pbCanLowerStatStage?(:ATTACK, user, self) + target.pbLowerStatStage(:ATTACK, 1, user) end when 14 - if target.pbCanLowerStatStage?(:DEFENSE,user,self) - target.pbLowerStatStage(:DEFENSE,1,user) + if target.pbCanLowerStatStage?(:DEFENSE, user, self) + target.pbLowerStatStage(:DEFENSE, 1, user) end when 3 - if target.pbCanLowerStatStage?(:SPECIAL_ATTACK,user,self) - target.pbLowerStatStage(:SPECIAL_ATTACK,1,user) + if target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user, self) + target.pbLowerStatStage(:SPECIAL_ATTACK, 1, user) end when 4, 6, 12 - if target.pbCanLowerStatStage?(:SPEED,user,self) - target.pbLowerStatStage(:SPEED,1,user) + if target.pbCanLowerStatStage?(:SPEED, user, self) + target.pbLowerStatStage(:SPEED, 1, user) end when 8 - if target.pbCanLowerStatStage?(:ACCURACY,user,self) - target.pbLowerStatStage(:ACCURACY,1,user) + if target.pbCanLowerStatStage?(:ACCURACY, user, self) + target.pbLowerStatStage(:ACCURACY, 1, user) end when 7, 11, 13 target.pbFlinch(user) end end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) id = :BODYSLAM # Environment-specific anim case @secretPower when 1 then id = :THUNDERSHOCK if GameData::Move.exists?(:THUNDERSHOCK) @@ -347,9 +347,9 @@ class Battle::Move::TargetNextFireMoveDamagesTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Powder] = true - @battle.pbDisplay(_INTL("{1} is covered in powder!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} is covered in powder!", user.pbThis)) end end @@ -357,12 +357,12 @@ end # Power is doubled if Fusion Flare has already been used this round. (Fusion Bolt) #=============================================================================== class Battle::Move::DoublePowerAfterFusionFlare < Battle::Move - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) @doublePower = @battle.field.effects[PBEffects::FusionFlare] super end - def pbBaseDamageMultiplier(damageMult,user,target) + def pbBaseDamageMultiplier(damageMult, user, target) damageMult *= 2 if @doublePower return damageMult end @@ -371,8 +371,8 @@ class Battle::Move::DoublePowerAfterFusionFlare < Battle::Move @battle.field.effects[PBEffects::FusionBolt] = true end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) - hitNum = 1 if (targets.length>0 && targets[0].damageState.critical) || + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) + hitNum = 1 if (targets.length > 0 && targets[0].damageState.critical) || @doublePower # Charged anim super end @@ -382,12 +382,12 @@ end # Power is doubled if Fusion Bolt has already been used this round. (Fusion Flare) #=============================================================================== class Battle::Move::DoublePowerAfterFusionBolt < Battle::Move - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) @doublePower = @battle.field.effects[PBEffects::FusionBolt] super end - def pbBaseDamageMultiplier(damageMult,user,target) + def pbBaseDamageMultiplier(damageMult, user, target) damageMult *= 2 if @doublePower return damageMult end @@ -396,8 +396,8 @@ class Battle::Move::DoublePowerAfterFusionBolt < Battle::Move @battle.field.effects[PBEffects::FusionFlare] = true end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) - hitNum = 1 if (targets.length>0 && targets[0].damageState.critical) || + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) + hitNum = 1 if (targets.length > 0 && targets[0].damageState.critical) || @doublePower # Charged anim super end @@ -418,9 +418,9 @@ class Battle::Move::PowerUpAllyMove < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::HelpingHand] = true - @battle.pbDisplay(_INTL("{1} is ready to help {2}!",user.pbThis,target.pbThis(true))) + @battle.pbDisplay(_INTL("{1} is ready to help {2}!", user.pbThis, target.pbThis(true))) end end @@ -429,23 +429,23 @@ end # (Counter) #=============================================================================== class Battle::Move::CounterPhysicalDamage < Battle::Move::FixedDamageMove - def pbAddTarget(targets,user) + def pbAddTarget(targets, user) t = user.effects[PBEffects::CounterTarget] - return if t<0 || !user.opposes?(t) - user.pbAddTarget(targets,user,@battle.battlers[t],self,false) + return if t < 0 || !user.opposes?(t) + user.pbAddTarget(targets, user, @battle.battlers[t], self, false) end - def pbMoveFailed?(user,targets) - if targets.length==0 + def pbMoveFailed?(user, targets) + if targets.length == 0 @battle.pbDisplay(_INTL("But there was no target...")) return true end return false end - def pbFixedDamage(user,target) - dmg = user.effects[PBEffects::Counter]*2 - dmg = 1 if dmg==0 + def pbFixedDamage(user, target) + dmg = user.effects[PBEffects::Counter] * 2 + dmg = 1 if dmg == 0 return dmg end end @@ -455,23 +455,23 @@ end # (Mirror Coat) #=============================================================================== class Battle::Move::CounterSpecialDamage < Battle::Move::FixedDamageMove - def pbAddTarget(targets,user) + def pbAddTarget(targets, user) t = user.effects[PBEffects::MirrorCoatTarget] - return if t<0 || !user.opposes?(t) - user.pbAddTarget(targets,user,@battle.battlers[t],self,false) + return if t < 0 || !user.opposes?(t) + user.pbAddTarget(targets, user, @battle.battlers[t], self, false) end - def pbMoveFailed?(user,targets) - if targets.length==0 + def pbMoveFailed?(user, targets) + if targets.length == 0 @battle.pbDisplay(_INTL("But there was no target...")) return true end return false end - def pbFixedDamage(user,target) - dmg = user.effects[PBEffects::MirrorCoat]*2 - dmg = 1 if dmg==0 + def pbFixedDamage(user, target) + dmg = user.effects[PBEffects::MirrorCoat] * 2 + dmg = 1 if dmg == 0 return dmg end end @@ -481,24 +481,24 @@ end # the power. (Metal Burst) #=============================================================================== class Battle::Move::CounterDamagePlusHalf < Battle::Move::FixedDamageMove - def pbAddTarget(targets,user) - return if user.lastFoeAttacker.length==0 + def pbAddTarget(targets, user) + return if user.lastFoeAttacker.length == 0 lastAttacker = user.lastFoeAttacker.last - return if lastAttacker<0 || !user.opposes?(lastAttacker) - user.pbAddTarget(targets,user,@battle.battlers[lastAttacker],self,false) + return if lastAttacker < 0 || !user.opposes?(lastAttacker) + user.pbAddTarget(targets, user, @battle.battlers[lastAttacker], self, false) end - def pbMoveFailed?(user,targets) - if targets.length==0 + def pbMoveFailed?(user, targets) + if targets.length == 0 @battle.pbDisplay(_INTL("But there was no target...")) return true end return false end - def pbFixedDamage(user,target) - dmg = (user.lastHPLostFromFoe*1.5).floor - dmg = 1 if dmg==0 + def pbFixedDamage(user, target) + dmg = (user.lastHPLostFromFoe * 1.5).floor + dmg = 1 if dmg == 0 return dmg end end @@ -510,9 +510,9 @@ end class Battle::Move::UserAddStockpileRaiseDefSpDef1 < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.effects[PBEffects::Stockpile]>=3 - @battle.pbDisplay(_INTL("{1} can't stockpile any more!",user.pbThis)) + def pbMoveFailed?(user, targets) + if user.effects[PBEffects::Stockpile] >= 3 + @battle.pbDisplay(_INTL("{1} can't stockpile any more!", user.pbThis)) return true end return false @@ -521,16 +521,16 @@ class Battle::Move::UserAddStockpileRaiseDefSpDef1 < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::Stockpile] += 1 @battle.pbDisplay(_INTL("{1} stockpiled {2}!", - user.pbThis,user.effects[PBEffects::Stockpile])) + user.pbThis, user.effects[PBEffects::Stockpile])) showAnim = true - if user.pbCanRaiseStatStage?(:DEFENSE,user,self) - if user.pbRaiseStatStage(:DEFENSE,1,user,showAnim) + if user.pbCanRaiseStatStage?(:DEFENSE, user, self) + if user.pbRaiseStatStage(:DEFENSE, 1, user, showAnim) user.effects[PBEffects::StockpileDef] += 1 showAnim = false end end - if user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,user,self) - if user.pbRaiseStatStage(:SPECIAL_DEFENSE,1,user,showAnim) + if user.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, user, self) + if user.pbRaiseStatStage(:SPECIAL_DEFENSE, 1, user, showAnim) user.effects[PBEffects::StockpileSpDef] += 1 end end @@ -542,33 +542,33 @@ end # 0. Decreases the user's Defense and Special Defense by X stages each. (Spit Up) #=============================================================================== class Battle::Move::PowerDependsOnUserStockpile < Battle::Move - def pbMoveFailed?(user,targets) - if user.effects[PBEffects::Stockpile]==0 + def pbMoveFailed?(user, targets) + if user.effects[PBEffects::Stockpile] == 0 @battle.pbDisplay(_INTL("But it failed to spit up a thing!")) return true end return false end - def pbBaseDamage(baseDmg,user,target) - return 100*user.effects[PBEffects::Stockpile] + def pbBaseDamage(baseDmg, user, target) + return 100 * user.effects[PBEffects::Stockpile] end - def pbEffectAfterAllHits(user,target) - return if user.fainted? || user.effects[PBEffects::Stockpile]==0 + def pbEffectAfterAllHits(user, target) + return if user.fainted? || user.effects[PBEffects::Stockpile] == 0 return if target.damageState.unaffected - @battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!",user.pbThis)) + @battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis)) return if @battle.pbAllFainted?(target.idxOwnSide) showAnim = true - if user.effects[PBEffects::StockpileDef]>0 && - user.pbCanLowerStatStage?(:DEFENSE,user,self) - if user.pbLowerStatStage(:DEFENSE,user.effects[PBEffects::StockpileDef],user,showAnim) + if user.effects[PBEffects::StockpileDef] > 0 && + user.pbCanLowerStatStage?(:DEFENSE, user, self) + if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim) showAnim = false end end - if user.effects[PBEffects::StockpileSpDef]>0 && - user.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user,self) - user.pbLowerStatStage(:SPECIAL_DEFENSE,user.effects[PBEffects::StockpileSpDef],user,showAnim) + if user.effects[PBEffects::StockpileSpDef] > 0 && + user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self) + user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim) end user.effects[PBEffects::Stockpile] = 0 user.effects[PBEffects::StockpileDef] = 0 @@ -584,14 +584,14 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move def healingMove?; return true; end def canSnatch?; return true; end - def pbMoveFailed?(user,targets) - if user.effects[PBEffects::Stockpile]==0 + def pbMoveFailed?(user, targets) + if user.effects[PBEffects::Stockpile] == 0 @battle.pbDisplay(_INTL("But it failed to swallow a thing!")) return true end if !user.canHeal? && - user.effects[PBEffects::StockpileDef]==0 && - user.effects[PBEffects::StockpileSpDef]==0 + user.effects[PBEffects::StockpileDef] == 0 && + user.effects[PBEffects::StockpileSpDef] == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -600,25 +600,25 @@ class Battle::Move::HealUserDependingOnUserStockpile < Battle::Move def pbEffectGeneral(user) hpGain = 0 - case [user.effects[PBEffects::Stockpile],1].max - when 1 then hpGain = user.totalhp/4 - when 2 then hpGain = user.totalhp/2 + case [user.effects[PBEffects::Stockpile], 1].max + when 1 then hpGain = user.totalhp / 4 + when 2 then hpGain = user.totalhp / 2 when 3 then hpGain = user.totalhp end - if user.pbRecoverHP(hpGain)>0 - @battle.pbDisplay(_INTL("{1}'s HP was restored.",user.pbThis)) + if user.pbRecoverHP(hpGain) > 0 + @battle.pbDisplay(_INTL("{1}'s HP was restored.", user.pbThis)) end - @battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!",user.pbThis)) + @battle.pbDisplay(_INTL("{1}'s stockpiled effect wore off!", user.pbThis)) showAnim = true - if user.effects[PBEffects::StockpileDef]>0 && - user.pbCanLowerStatStage?(:DEFENSE,user,self) - if user.pbLowerStatStage(:DEFENSE,user.effects[PBEffects::StockpileDef],user,showAnim) + if user.effects[PBEffects::StockpileDef] > 0 && + user.pbCanLowerStatStage?(:DEFENSE, user, self) + if user.pbLowerStatStage(:DEFENSE, user.effects[PBEffects::StockpileDef], user, showAnim) showAnim = false end end - if user.effects[PBEffects::StockpileSpDef]>0 && - user.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user,self) - user.pbLowerStatStage(:SPECIAL_DEFENSE,user.effects[PBEffects::StockpileSpDef],user,showAnim) + if user.effects[PBEffects::StockpileSpDef] > 0 && + user.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user, self) + user.pbLowerStatStage(:SPECIAL_DEFENSE, user.effects[PBEffects::StockpileSpDef], user, showAnim) end user.effects[PBEffects::Stockpile] = 0 user.effects[PBEffects::StockpileDef] = 0 @@ -632,7 +632,7 @@ end # swamp on the opposing side. #=============================================================================== class Battle::Move::GrassPledge < Battle::Move::PledgeMove - def initialize(battle,move) + def initialize(battle, move) super # [Function code to combo with, effect, override type, override animation] @combos = [["FirePledge", :SeaOfFire, :FIRE, :FIREPLEDGE], @@ -646,7 +646,7 @@ end # user's side or a sea of fire on the opposing side. #=============================================================================== class Battle::Move::FirePledge < Battle::Move::PledgeMove - def initialize(battle,move) + def initialize(battle, move) super # [Function code to combo with, effect, override type, override animation] @combos = [["WaterPledge", :Rainbow, :WATER, :WATERPLEDGE], @@ -660,7 +660,7 @@ end # opposing side or a rainbow on the user's side. #=============================================================================== class Battle::Move::WaterPledge < Battle::Move::PledgeMove - def initialize(battle,move) + def initialize(battle, move) super # [Function code to combo with, effect, override type, override animation] @combos = [["GrassPledge", :Swamp, :GRASS, :GRASSPLEDGE], @@ -674,7 +674,7 @@ end class Battle::Move::UseLastMoveUsed < Battle::Move def callsAnotherMove?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @moveBlacklist = [ # Struggle, Belch @@ -738,12 +738,12 @@ class Battle::Move::UseLastMoveUsed < Battle::Move end end - def pbChangeUsageCounters(user,specialUsage) + def pbChangeUsageCounters(user, specialUsage) super @copied_move = @battle.lastMoveUsed end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !@copied_move || @moveBlacklist.include?(GameData::Move.get(@copied_move).function_code) @battle.pbDisplay(_INTL("But it failed!")) @@ -773,11 +773,11 @@ class Battle::Move::UseLastMoveUsedByTarget < Battle::Move return false end - def pbEffectAgainstTarget(user,target) - user.pbUseMoveSimple(target.lastRegularMoveUsed,target.index) + def pbEffectAgainstTarget(user, target) + user.pbUseMoveSimple(target.lastRegularMoveUsed, target.index) end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) # No animation end end @@ -790,7 +790,7 @@ class Battle::Move::UseMoveTargetIsAboutToUse < Battle::Move def ignoresSubstitute?(user); return true; end def callsAnotherMove?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @moveBlacklist = [ "UserTakesTargetItem", # Covet, Thief @@ -818,7 +818,7 @@ class Battle::Move::UseMoveTargetIsAboutToUse < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) user.effects[PBEffects::MeFirst] = true user.pbUseMoveSimple(@battle.choices[target.index][2].id) user.effects[PBEffects::MeFirst] = false @@ -834,7 +834,7 @@ end class Battle::Move::UseMoveDependingOnEnvironment < Battle::Move def callsAnotherMove?; return true; end - def pbOnStartUse(user,targets) + def pbOnStartUse(user, targets) # NOTE: It's possible in theory to not have the move Nature Power wants to # turn into, but what self-respecting game wouldn't at least have Tri # Attack in it? @@ -882,7 +882,7 @@ class Battle::Move::UseMoveDependingOnEnvironment < Battle::Move end end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) @battle.pbDisplay(_INTL("{1} turned into {2}!", @name, GameData::Move.get(@npMove).name)) user.pbUseMoveSimple(@npMove, target.index) end @@ -894,7 +894,7 @@ end class Battle::Move::UseRandomMove < Battle::Move def callsAnotherMove?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @moveBlacklist = [ "FlinchTargetFailsIfUserNotAsleep", # Snore @@ -977,7 +977,7 @@ class Battle::Move::UseRandomMove < Battle::Move ] end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @metronomeMove = nil move_keys = GameData::Move.keys # NOTE: You could be really unlucky and roll blacklisted moves 1000 times in @@ -1009,7 +1009,7 @@ end class Battle::Move::UseRandomMoveFromUserParty < Battle::Move def callsAnotherMove?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @moveBlacklist = [ # Struggle, Belch @@ -1092,11 +1092,11 @@ class Battle::Move::UseRandomMoveFromUserParty < Battle::Move end end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @assistMoves = [] # NOTE: This includes the Pokémon of ally trainers in multi battles. - @battle.pbParty(user.index).each_with_index do |pkmn,i| - next if !pkmn || i==user.pokemonIndex + @battle.pbParty(user.index).each_with_index do |pkmn, i| + next if !pkmn || i == user.pokemonIndex next if Settings::MECHANICS_GENERATION >= 6 && pkmn.egg? pkmn.moves.each do |move| next if @moveBlacklist.include?(move.function_code) @@ -1104,7 +1104,7 @@ class Battle::Move::UseRandomMoveFromUserParty < Battle::Move @assistMoves.push(move.id) end end - if @assistMoves.length==0 + if @assistMoves.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1124,7 +1124,7 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move def usableWhenAsleep?; return true; end def callsAnotherMove?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @moveBlacklist = [ "MultiTurnAttackPreventSleeping", # Uproar @@ -1165,14 +1165,14 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move ] end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) @sleepTalkMoves = [] - user.eachMoveWithIndex do |m,i| + user.eachMoveWithIndex do |m, i| next if @moveBlacklist.include?(m.function) - next if !@battle.pbCanChooseMove?(user.index,i,false,true) + next if !@battle.pbCanChooseMove?(user.index, i, false, true) @sleepTalkMoves.push(i) end - if !user.asleep? || @sleepTalkMoves.length==0 + if !user.asleep? || @sleepTalkMoves.length == 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -1181,7 +1181,7 @@ class Battle::Move::UseRandomUserMoveIfAsleep < Battle::Move def pbEffectGeneral(user) choice = @sleepTalkMoves[@battle.pbRandom(@sleepTalkMoves.length)] - user.pbUseMoveSimple(user.moves[choice].id,user.pbDirectOpposing.index) + user.pbUseMoveSimple(user.moves[choice].id, user.pbDirectOpposing.index) end end @@ -1192,7 +1192,7 @@ end class Battle::Move::BounceBackProblemCausingStatusMoves < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::MagicCoat] = true - @battle.pbDisplay(_INTL("{1} shrouded itself with Magic Coat!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} shrouded itself with Magic Coat!", user.pbThis)) end end @@ -1203,10 +1203,10 @@ class Battle::Move::StealAndUseBeneficialStatusMove < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::Snatch] = 1 @battle.allBattlers.each do |b| - next if b.effects[PBEffects::Snatch]user.level + if @battle.wildBattle? && target.level > user.level @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end if @battle.trainerBattle? canSwitch = false - @battle.eachInTeamFromBattlerIndex(target.index) do |_pkmn,i| - next if !@battle.pbCanSwitchLax?(target.index,i) + @battle.eachInTeamFromBattlerIndex(target.index) do |_pkmn, i| + next if !@battle.pbCanSwitchLax?(target.index, i) canSwitch = true break end @@ -205,10 +205,10 @@ class Battle::Move::SwitchOutTargetStatusMove < Battle::Move next if b.fainted? || b.damageState.unaffected next if b.effects[PBEffects::Ingrain] next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker - newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random - next if newPkmn<0 + newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random + next if newPkmn < 0 @battle.pbRecallAndReplace(b.index, newPkmn, true) - @battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis)) + @battle.pbDisplay(_INTL("{1} was dragged out!", b.pbThis)) @battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round @battle.pbOnBattlerEnteringBattle(b.index) switched_battlers.push(b.index) @@ -224,9 +224,9 @@ end # For damaging moves. (Circle Throw, Dragon Tail) #=============================================================================== class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move - def pbEffectAgainstTarget(user,target) - if @battle.wildBattle? && target.level<=user.level && @battle.canRun && - (target.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(user)) + def pbEffectAgainstTarget(user, target) + if @battle.wildBattle? && target.level <= user.level && @battle.canRun && + (target.effects[PBEffects::Substitute] == 0 || ignoresSubstitute?(user)) @battle.decision = 3 end end @@ -238,10 +238,10 @@ class Battle::Move::SwitchOutTargetDamagingMove < Battle::Move next if b.fainted? || b.damageState.unaffected || b.damageState.substitute next if b.effects[PBEffects::Ingrain] next if b.hasActiveAbility?(:SUCTIONCUPS) && !@battle.moldBreaker - newPkmn = @battle.pbGetReplacementPokemonIndex(b.index,true) # Random - next if newPkmn<0 + newPkmn = @battle.pbGetReplacementPokemonIndex(b.index, true) # Random + next if newPkmn < 0 @battle.pbRecallAndReplace(b.index, newPkmn, true) - @battle.pbDisplay(_INTL("{1} was dragged out!",b.pbThis)) + @battle.pbDisplay(_INTL("{1} was dragged out!", b.pbThis)) @battle.pbClearChoice(b.index) # Replacement Pokémon does nothing this round @battle.pbOnBattlerEnteringBattle(b.index) switched_battlers.push(b.index) @@ -255,36 +255,36 @@ end # at end of each round. #=============================================================================== class Battle::Move::BindTarget < Battle::Move - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if target.fainted? || target.damageState.substitute - return if target.effects[PBEffects::Trapping]>0 + return if target.effects[PBEffects::Trapping] > 0 # Set trapping effect duration and info if user.hasActiveItem?(:GRIPCLAW) target.effects[PBEffects::Trapping] = (Settings::MECHANICS_GENERATION >= 5) ? 8 : 6 else - target.effects[PBEffects::Trapping] = 5+@battle.pbRandom(2) + target.effects[PBEffects::Trapping] = 5 + @battle.pbRandom(2) end target.effects[PBEffects::TrappingMove] = @id target.effects[PBEffects::TrappingUser] = user.index # Message - msg = _INTL("{1} was trapped in the vortex!",target.pbThis) + msg = _INTL("{1} was trapped in the vortex!", target.pbThis) case @id when :BIND - msg = _INTL("{1} was squeezed by {2}!",target.pbThis,user.pbThis(true)) + msg = _INTL("{1} was squeezed by {2}!", target.pbThis, user.pbThis(true)) when :CLAMP - msg = _INTL("{1} clamped {2}!",user.pbThis,target.pbThis(true)) + msg = _INTL("{1} clamped {2}!", user.pbThis, target.pbThis(true)) when :FIRESPIN - msg = _INTL("{1} was trapped in the fiery vortex!",target.pbThis) + msg = _INTL("{1} was trapped in the fiery vortex!", target.pbThis) when :INFESTATION - msg = _INTL("{1} has been afflicted with an infestation by {2}!",target.pbThis,user.pbThis(true)) + msg = _INTL("{1} has been afflicted with an infestation by {2}!", target.pbThis, user.pbThis(true)) when :MAGMASTORM - msg = _INTL("{1} became trapped by Magma Storm!",target.pbThis) + msg = _INTL("{1} became trapped by Magma Storm!", target.pbThis) when :SANDTOMB - msg = _INTL("{1} became trapped by Sand Tomb!",target.pbThis) + msg = _INTL("{1} became trapped by Sand Tomb!", target.pbThis) when :WHIRLPOOL - msg = _INTL("{1} became trapped in the vortex!",target.pbThis) + msg = _INTL("{1} became trapped in the vortex!", target.pbThis) when :WRAP - msg = _INTL("{1} was wrapped by {2}!",target.pbThis,user.pbThis(true)) + msg = _INTL("{1} was wrapped by {2}!", target.pbThis, user.pbThis(true)) end @battle.pbDisplay(msg) end @@ -298,7 +298,7 @@ end class Battle::Move::BindTargetDoublePowerIfTargetUnderwater < Battle::Move::BindTarget def hitsDivingTargets?; return true; end - def pbModifyDamage(damageMult,user,target) + def pbModifyDamage(damageMult, user, target) damageMult *= 2 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableUnderwater") return damageMult end @@ -313,7 +313,7 @@ class Battle::Move::TrapTargetInBattle < Battle::Move def pbFailsAgainstTarget?(user, target, show_message) return false if damagingMove? - if target.effects[PBEffects::MeanLook]>=0 + if target.effects[PBEffects::MeanLook] >= 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -324,18 +324,18 @@ class Battle::Move::TrapTargetInBattle < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) return if damagingMove? target.effects[PBEffects::MeanLook] = user.index - @battle.pbDisplay(_INTL("{1} can no longer escape!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} can no longer escape!", target.pbThis)) end - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.fainted? || target.damageState.substitute - return if target.effects[PBEffects::MeanLook]>=0 + return if target.effects[PBEffects::MeanLook] >= 0 return if Settings::MORE_TYPE_EFFECTS && target.pbHasType?(:GHOST) target.effects[PBEffects::MeanLook] = user.index - @battle.pbDisplay(_INTL("{1} can no longer escape!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} can no longer escape!", target.pbThis)) end end @@ -383,8 +383,8 @@ end # No Pokémon can switch out or flee until the end of the next round. (Fairy Lock) #=============================================================================== class Battle::Move::TrapAllBattlersInBattleForOneTurn < Battle::Move - def pbMoveFailed?(user,targets) - if @battle.field.effects[PBEffects::FairyLock]>0 + def pbMoveFailed?(user, targets) + if @battle.field.effects[PBEffects::FairyLock] > 0 @battle.pbDisplay(_INTL("But it failed!")) return true end @@ -403,12 +403,12 @@ end # (Handled in Battle's pbAttackPhase): Makes this attack happen before switching. #=============================================================================== class Battle::Move::PursueSwitchingFoe < Battle::Move - def pbAccuracyCheck(user,target) + def pbAccuracyCheck(user, target) return true if @battle.switching return super end - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if @battle.switching return baseDmg end @@ -421,21 +421,21 @@ end class Battle::Move::UsedAfterUserTakesPhysicalDamage < Battle::Move def pbDisplayChargeMessage(user) user.effects[PBEffects::ShellTrap] = true - @battle.pbCommonAnimation("ShellTrap",user) - @battle.pbDisplay(_INTL("{1} set a shell trap!",user.pbThis)) + @battle.pbCommonAnimation("ShellTrap", user) + @battle.pbDisplay(_INTL("{1} set a shell trap!", user.pbThis)) end def pbDisplayUseMessage(user) super if user.tookPhysicalHit end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !user.effects[PBEffects::ShellTrap] @battle.pbDisplay(_INTL("But it failed!")) return true end if !user.tookPhysicalHit - @battle.pbDisplay(_INTL("{1}'s shell trap didn't work!",user.pbThis)) + @battle.pbDisplay(_INTL("{1}'s shell trap didn't work!", user.pbThis)) return true end return false @@ -447,7 +447,7 @@ end # If an ally is about to use the same move, make it go next, ignoring priority. #=============================================================================== class Battle::Move::UsedAfterAllyRoundWithDoublePower < Battle::Move - def pbBaseDamage(baseDmg,user,target) + def pbBaseDamage(baseDmg, user, target) baseDmg *= 2 if user.pbOwnSide.effects[PBEffects::Round] return baseDmg end @@ -455,8 +455,8 @@ class Battle::Move::UsedAfterAllyRoundWithDoublePower < Battle::Move def pbEffectGeneral(user) user.pbOwnSide.effects[PBEffects::Round] = true user.allAllies.each do |b| - next if @battle.choices[b.index][0]!=:UseMove || b.movedThisRound? - next if @battle.choices[b.index][2].function!=@function + next if @battle.choices[b.index][0] != :UseMove || b.movedThisRound? + next if @battle.choices[b.index][2].function != @function b.effects[PBEffects::MoveNext] = true b.effects[PBEffects::Quash] = 0 break @@ -487,10 +487,10 @@ class Battle::Move::TargetActsNext < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::MoveNext] = true target.effects[PBEffects::Quash] = 0 - @battle.pbDisplay(_INTL("{1} took the kind offer!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} took the kind offer!", target.pbThis)) end end @@ -509,30 +509,30 @@ class Battle::Move::TargetActsLast < Battle::Move # Target is already maximally Quashed and will move last anyway highestQuash = 0 @battle.allBattlers.each do |b| - next if b.effects[PBEffects::Quash]<=highestQuash + next if b.effects[PBEffects::Quash] <= highestQuash highestQuash = b.effects[PBEffects::Quash] end - if highestQuash>0 && target.effects[PBEffects::Quash]==highestQuash + if highestQuash > 0 && target.effects[PBEffects::Quash] == highestQuash @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end # Target was already going to move last - if highestQuash==0 && @battle.pbPriority.last.index==target.index + if highestQuash == 0 && @battle.pbPriority.last.index == target.index @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) highestQuash = 0 @battle.allBattlers.each do |b| - next if b.effects[PBEffects::Quash]<=highestQuash + next if b.effects[PBEffects::Quash] <= highestQuash highestQuash = b.effects[PBEffects::Quash] end - target.effects[PBEffects::Quash] = highestQuash+1 + target.effects[PBEffects::Quash] = highestQuash + 1 target.effects[PBEffects::MoveNext] = false - @battle.pbDisplay(_INTL("{1}'s move was postponed!",target.pbThis)) + @battle.pbDisplay(_INTL("{1}'s move was postponed!", target.pbThis)) end end @@ -542,7 +542,7 @@ end class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move def ignoresSubstitute?(user); return true; end - def initialize(battle,move) + def initialize(battle, move) super @moveBlacklist = [ "MultiTurnAttackBideThenReturnDoubleDamage", # Bide @@ -596,9 +596,9 @@ class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move return true end targetMove = @battle.choices[target.index][2] - if targetMove && (targetMove.function=="FailsIfUserDamagedThisTurn" || # Focus Punch - targetMove.function=="UsedAfterUserTakesPhysicalDamage" || # Shell Trap - targetMove.function=="BurnAttackerBeforeUserActs") # Beak Blast + if targetMove && (targetMove.function == "FailsIfUserDamagedThisTurn" || # Focus Punch + targetMove.function == "UsedAfterUserTakesPhysicalDamage" || # Shell Trap + targetMove.function == "BurnAttackerBeforeUserActs") # Beak Blast @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -607,17 +607,17 @@ class Battle::Move::TargetUsesItsLastUsedMoveAgain < Battle::Move return true end idxMove = -1 - target.eachMoveWithIndex do |m,i| - idxMove = i if m.id==target.lastRegularMoveUsed + target.eachMoveWithIndex do |m, i| + idxMove = i if m.id == target.lastRegularMoveUsed end - if target.moves[idxMove].pp==0 && target.moves[idxMove].total_pp>0 + if target.moves[idxMove].pp == 0 && target.moves[idxMove].total_pp > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Instruct] = true end end @@ -628,17 +628,17 @@ end #=============================================================================== class Battle::Move::StartSlowerBattlersActFirst < Battle::Move def pbEffectGeneral(user) - if @battle.field.effects[PBEffects::TrickRoom]>0 + if @battle.field.effects[PBEffects::TrickRoom] > 0 @battle.field.effects[PBEffects::TrickRoom] = 0 - @battle.pbDisplay(_INTL("{1} reverted the dimensions!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} reverted the dimensions!", user.pbThis)) else @battle.field.effects[PBEffects::TrickRoom] = 5 - @battle.pbDisplay(_INTL("{1} twisted the dimensions!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} twisted the dimensions!", user.pbThis)) end end - def pbShowAnimation(id,user,targets,hitNum = 0,showAnimation = true) - return if @battle.field.effects[PBEffects::TrickRoom]>0 # No animation + def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) + return if @battle.field.effects[PBEffects::TrickRoom] > 0 # No animation super end end @@ -710,15 +710,15 @@ class Battle::Move::DisableTargetLastMoveUsed < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.effects[PBEffects::Disable]>0 || !target.lastRegularMoveUsed + if target.effects[PBEffects::Disable] > 0 || !target.lastRegularMoveUsed @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end return true if pbMoveFailedAromaVeil?(user, target, show_message) canDisable = false target.eachMove do |m| - next if m.id!=target.lastRegularMoveUsed - next if m.pp==0 && m.total_pp>0 + next if m.id != target.lastRegularMoveUsed + next if m.pp == 0 && m.total_pp > 0 canDisable = true break end @@ -729,10 +729,10 @@ class Battle::Move::DisableTargetLastMoveUsed < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Disable] = 5 target.effects[PBEffects::DisableMove] = target.lastRegularMoveUsed - @battle.pbDisplay(_INTL("{1}'s {2} was disabled!",target.pbThis, + @battle.pbDisplay(_INTL("{1}'s {2} was disabled!", target.pbThis, GameData::Move.get(target.lastRegularMoveUsed).name)) target.pbItemStatusCureCheck end @@ -754,9 +754,9 @@ class Battle::Move::DisableTargetUsingSameMoveConsecutively < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Torment] = true - @battle.pbDisplay(_INTL("{1} was subjected to torment!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} was subjected to torment!", target.pbThis)) target.pbItemStatusCureCheck end end @@ -768,7 +768,7 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move def ignoresSubstitute?(user); return true; end def canMagicCoat?; return true; end - def initialize(battle,move) + def initialize(battle, move) super @moveBlacklist = [ "DisableTargetUsingDifferentMove", # Encore @@ -796,7 +796,7 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move end def pbFailsAgainstTarget?(user, target, show_message) - if target.effects[PBEffects::Encore]>0 + if target.effects[PBEffects::Encore] > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -812,8 +812,8 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move return true if pbMoveFailedAromaVeil?(user, target, show_message) canEncore = false target.eachMove do |m| - next if m.id!=target.lastRegularMoveUsed - next if m.pp==0 && m.total_pp>0 + next if m.id != target.lastRegularMoveUsed + next if m.pp == 0 && m.total_pp > 0 canEncore = true break end @@ -824,10 +824,10 @@ class Battle::Move::DisableTargetUsingDifferentMove < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Encore] = 4 target.effects[PBEffects::EncoreMove] = target.lastRegularMoveUsed - @battle.pbDisplay(_INTL("{1} received an encore!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} received an encore!", target.pbThis)) target.pbItemStatusCureCheck end end @@ -840,7 +840,7 @@ class Battle::Move::DisableTargetStatusMoves < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.effects[PBEffects::Taunt]>0 + if target.effects[PBEffects::Taunt] > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -862,9 +862,9 @@ class Battle::Move::DisableTargetStatusMoves < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::Taunt] = 4 - @battle.pbDisplay(_INTL("{1} fell for the taunt!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} fell for the taunt!", target.pbThis)) target.pbItemStatusCureCheck end end @@ -876,7 +876,7 @@ class Battle::Move::DisableTargetHealingMoves < Battle::Move def canMagicCoat?; return true; end def pbFailsAgainstTarget?(user, target, show_message) - if target.effects[PBEffects::HealBlock]>0 + if target.effects[PBEffects::HealBlock] > 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -884,9 +884,9 @@ class Battle::Move::DisableTargetHealingMoves < Battle::Move return false end - def pbEffectAgainstTarget(user,target) + def pbEffectAgainstTarget(user, target) target.effects[PBEffects::HealBlock] = 5 - @battle.pbDisplay(_INTL("{1} was prevented from healing!",target.pbThis)) + @battle.pbDisplay(_INTL("{1} was prevented from healing!", target.pbThis)) target.pbItemStatusCureCheck end end @@ -895,10 +895,10 @@ end # Target cannot use sound-based moves for 2 more rounds. (Throat Chop) #=============================================================================== class Battle::Move::DisableTargetSoundMoves < Battle::Move - def pbAdditionalEffect(user,target) + def pbAdditionalEffect(user, target) return if target.fainted? || target.damageState.substitute @battle.pbDisplay(_INTL("The effects of {1} prevent {2} from using certain moves!", - @name,target.pbThis(true))) if target.effects[PBEffects::ThroatChop]==0 + @name, target.pbThis(true))) if target.effects[PBEffects::ThroatChop] == 0 target.effects[PBEffects::ThroatChop] = 3 end end @@ -909,7 +909,7 @@ end class Battle::Move::DisableTargetMovesKnownByUser < Battle::Move def canSnatch?; return true; end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if user.effects[PBEffects::Imprison] @battle.pbDisplay(_INTL("But it failed!")) return true @@ -919,6 +919,6 @@ class Battle::Move::DisableTargetMovesKnownByUser < Battle::Move def pbEffectGeneral(user) user.effects[PBEffects::Imprison] = true - @battle.pbDisplay(_INTL("{1} sealed any moves its target shares with it!",user.pbThis)) + @battle.pbDisplay(_INTL("{1} sealed any moves its target shares with it!", user.pbThis)) end end diff --git a/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb b/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb index b95ffb8f7..97eac2766 100644 --- a/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb +++ b/Data/Scripts/011_Battle/004_Scene/001_Battle_Scene.rb @@ -84,9 +84,9 @@ class Battle::Scene def pbGraphicsUpdate # Update lineup animations - if @animations.length>0 + if @animations.length > 0 shouldCompact = false - @animations.each_with_index do |a,i| + @animations.each_with_index do |a, i| a.update if a.animDone? a.dispose @@ -100,7 +100,7 @@ class Battle::Scene @sprites["battle_bg"].update if @sprites["battle_bg"].respond_to?("update") Graphics.update @frameCounter += 1 - @frameCounter = @frameCounter%(Graphics.frame_rate*12/20) + @frameCounter = @frameCounter % (Graphics.frame_rate * 12 / 20) end def pbInputUpdate @@ -113,7 +113,7 @@ class Battle::Scene def pbFrameUpdate(cw = nil) cw.update if cw - @battle.battlers.each_with_index do |b,i| + @battle.battlers.each_with_index do |b, i| next if !b @sprites["dataBox_#{i}"].update(@frameCounter) if @sprites["dataBox_#{i}"] @sprites["pokemon_#{i}"].update(@frameCounter) if @sprites["pokemon_#{i}"] @@ -122,7 +122,7 @@ class Battle::Scene end def pbRefresh - @battle.battlers.each_with_index do |b,i| + @battle.battlers.each_with_index do |b, i| next if !b @sprites["dataBox_#{i}"].refresh if @sprites["dataBox_#{i}"] end @@ -147,7 +147,7 @@ class Battle::Scene #============================================================================= # Returns whether the party line-ups are currently coming on-screen def inPartyAnimation? - return @animations.length>0 + return @animations.length > 0 end #============================================================================= @@ -157,11 +157,11 @@ class Battle::Scene # NOTE: If you are not using fancy graphics for the command/fight menus, you # will need to make "messageBox" also visible if the windowtype if # COMMAND_BOX/FIGHT_BOX respectively. - @sprites["messageBox"].visible = (windowType==MESSAGE_BOX) - @sprites["messageWindow"].visible = (windowType==MESSAGE_BOX) - @sprites["commandWindow"].visible = (windowType==COMMAND_BOX) - @sprites["fightWindow"].visible = (windowType==FIGHT_BOX) - @sprites["targetWindow"].visible = (windowType==TARGET_BOX) + @sprites["messageBox"].visible = (windowType == MESSAGE_BOX) + @sprites["messageWindow"].visible = (windowType == MESSAGE_BOX) + @sprites["commandWindow"].visible = (windowType == COMMAND_BOX) + @sprites["fightWindow"].visible = (windowType == FIGHT_BOX) + @sprites["targetWindow"].visible = (windowType == TARGET_BOX) end # This is for the end of brief messages, which have been lingering on-screen @@ -185,7 +185,7 @@ class Battle::Scene # NOTE: A regular message is displayed for 1 second after it fully appears (or # less if Back/Use is pressed). Disappears automatically after that time. - def pbDisplayMessage(msg,brief = false) + def pbDisplayMessage(msg, brief = false) pbWaitMessage pbShowWindow(MESSAGE_BOX) cw = @sprites["messageWindow"] @@ -235,7 +235,7 @@ class Battle::Scene pbWaitMessage pbShowWindow(MESSAGE_BOX) cw = @sprites["messageWindow"] - cw.text = _INTL("{1}\1",msg) + cw.text = _INTL("{1}\1", msg) PBDebug.log(msg) yielded = false timer = 0.0 @@ -269,19 +269,19 @@ class Battle::Scene end def pbDisplayConfirmMessage(msg) - return pbShowCommands(msg,[_INTL("Yes"),_INTL("No")],1)==0 + return pbShowCommands(msg, [_INTL("Yes"), _INTL("No")], 1) == 0 end - def pbShowCommands(msg,commands,defaultValue) + def pbShowCommands(msg, commands, defaultValue) pbWaitMessage pbShowWindow(MESSAGE_BOX) dw = @sprites["messageWindow"] dw.text = msg cw = Window_CommandPokemon.new(commands) cw.height = Graphics.height - dw.height if cw.height > Graphics.height - dw.height - cw.x = Graphics.width-cw.width - cw.y = Graphics.height-cw.height-dw.height - cw.z = dw.z+1 + cw.x = Graphics.width - cw.width + cw.y = Graphics.height - cw.height - dw.height + cw.z = dw.z + 1 cw.index = 0 cw.viewport = @viewport PBDebug.log(msg) @@ -289,7 +289,7 @@ class Battle::Scene cw.visible = (!dw.busy?) pbUpdate(cw) dw.update - if Input.trigger?(Input::BACK) && defaultValue>=0 + if Input.trigger?(Input::BACK) && defaultValue >= 0 if dw.busy? pbPlayDecisionSE if dw.pausing? dw.resume @@ -314,8 +314,8 @@ class Battle::Scene #============================================================================= # Sprites #============================================================================= - def pbAddSprite(id,x,y,filename,viewport) - sprite = @sprites[id] || IconSprite.new(x,y,viewport) + def pbAddSprite(id, x, y, filename, viewport) + sprite = @sprites[id] || IconSprite.new(x, y, viewport) if filename sprite.setBitmap(filename) rescue nil end @@ -323,7 +323,7 @@ class Battle::Scene return sprite end - def pbAddPlane(id,filename,viewport) + def pbAddPlane(id, filename, viewport) sprite = AnimatedPlane.new(viewport) if filename sprite.setBitmap(filename) @@ -337,12 +337,12 @@ class Battle::Scene end # Used by Ally Switch. - def pbSwapBattlerSprites(idxA,idxB) + def pbSwapBattlerSprites(idxA, idxB) @sprites["pokemon_#{idxA}"], @sprites["pokemon_#{idxB}"] = @sprites["pokemon_#{idxB}"], @sprites["pokemon_#{idxA}"] @sprites["shadow_#{idxA}"], @sprites["shadow_#{idxB}"] = @sprites["shadow_#{idxB}"], @sprites["shadow_#{idxA}"] @lastCmd[idxA], @lastCmd[idxB] = @lastCmd[idxB], @lastCmd[idxA] @lastMove[idxA], @lastMove[idxB] = @lastMove[idxB], @lastMove[idxA] - [idxA,idxB].each do |i| + [idxA, idxB].each do |i| @sprites["pokemon_#{i}"].index = i @sprites["pokemon_#{i}"].pbSetPosition @sprites["shadow_#{i}"].index = i @@ -379,22 +379,22 @@ class Battle::Scene #============================================================================= # #============================================================================= - def pbSelectBattler(idxBattler,selectMode = 1) - numWindows = @battle.sideSizes.max*2 + def pbSelectBattler(idxBattler, selectMode = 1) + numWindows = @battle.sideSizes.max * 2 for i in 0...numWindows - sel = (idxBattler.is_a?(Array)) ? !idxBattler[i].nil? : i==idxBattler + sel = (idxBattler.is_a?(Array)) ? !idxBattler[i].nil? : i == idxBattler selVal = (sel) ? selectMode : 0 @sprites["dataBox_#{i}"].selected = selVal if @sprites["dataBox_#{i}"] @sprites["pokemon_#{i}"].selected = selVal if @sprites["pokemon_#{i}"] end end - def pbChangePokemon(idxBattler,pkmn) + def pbChangePokemon(idxBattler, pkmn) idxBattler = idxBattler.index if idxBattler.respond_to?("index") pkmnSprite = @sprites["pokemon_#{idxBattler}"] shadowSprite = @sprites["shadow_#{idxBattler}"] back = !@battle.opposes?(idxBattler) - pkmnSprite.setPokemonBitmap(pkmn,back) + pkmnSprite.setPokemonBitmap(pkmn, back) shadowSprite.setPokemonBitmap(pkmn) # Set visibility of battler's shadow shadowSprite.visible = pkmn.species_data.shows_shadow? if shadowSprite && !back diff --git a/Data/Scripts/011_Battle/004_Scene/002_Scene_Initialize.rb b/Data/Scripts/011_Battle/004_Scene/002_Scene_Initialize.rb index 4779632cb..b09348bc9 100644 --- a/Data/Scripts/011_Battle/004_Scene/002_Scene_Initialize.rb +++ b/Data/Scripts/011_Battle/004_Scene/002_Scene_Initialize.rb @@ -14,10 +14,10 @@ class Battle::Scene # Called whenever the battle begins. def pbStartBattle(battle) @battle = battle - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 - @lastCmd = Array.new(@battle.battlers.length,0) - @lastMove = Array.new(@battle.battlers.length,0) + @lastCmd = Array.new(@battle.battlers.length, 0) + @lastMove = Array.new(@battle.battlers.length, 0) pbInitSprites pbBattleIntroAnimation end @@ -27,12 +27,12 @@ class Battle::Scene # The background image and each side's base graphic pbCreateBackdropSprites # Create message box graphic - messageBox = pbAddSprite("messageBox",0,Graphics.height-96, - "Graphics/Pictures/Battle/overlay_message",@viewport) + messageBox = pbAddSprite("messageBox", 0, Graphics.height - 96, + "Graphics/Pictures/Battle/overlay_message", @viewport) messageBox.z = 195 # Create message window (displays the message) msgWindow = Window_AdvancedTextPokemon.newWithSize("", - 16,Graphics.height-96+2,Graphics.width-32,96,@viewport) + 16, Graphics.height - 96 + 2, Graphics.width - 32, 96, @viewport) msgWindow.z = 200 msgWindow.opacity = 0 msgWindow.baseColor = MESSAGE_BASE_COLOR @@ -40,52 +40,52 @@ class Battle::Scene msgWindow.letterbyletter = true @sprites["messageWindow"] = msgWindow # Create command window - @sprites["commandWindow"] = CommandMenu.new(@viewport,200) + @sprites["commandWindow"] = CommandMenu.new(@viewport, 200) # Create fight window - @sprites["fightWindow"] = FightMenu.new(@viewport,200) + @sprites["fightWindow"] = FightMenu.new(@viewport, 200) # Create targeting window - @sprites["targetWindow"] = TargetMenu.new(@viewport,200,@battle.sideSizes) + @sprites["targetWindow"] = TargetMenu.new(@viewport, 200, @battle.sideSizes) pbShowWindow(MESSAGE_BOX) # The party lineup graphics (bar and balls) for both sides for side in 0...2 - partyBar = pbAddSprite("partyBar_#{side}",0,0, - "Graphics/Pictures/Battle/overlay_lineup",@viewport) + partyBar = pbAddSprite("partyBar_#{side}", 0, 0, + "Graphics/Pictures/Battle/overlay_lineup", @viewport) partyBar.z = 120 - partyBar.mirror = true if side==0 # Player's lineup bar only + partyBar.mirror = true if side == 0 # Player's lineup bar only partyBar.visible = false for i in 0...NUM_BALLS - ball = pbAddSprite("partyBall_#{side}_#{i}",0,0,nil,@viewport) + ball = pbAddSprite("partyBall_#{side}_#{i}", 0, 0, nil, @viewport) ball.z = 121 ball.visible = false end # Ability splash bars if USE_ABILITY_SPLASH - @sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side,@viewport) + @sprites["abilityBar_#{side}"] = AbilitySplashBar.new(side, @viewport) end end # Player's and partner trainer's back sprite - @battle.player.each_with_index do |p,i| - pbCreateTrainerBackSprite(i,p.trainer_type,@battle.player.length) + @battle.player.each_with_index do |p, i| + pbCreateTrainerBackSprite(i, p.trainer_type, @battle.player.length) end # Opposing trainer(s) sprites if @battle.trainerBattle? - @battle.opponent.each_with_index do |p,i| - pbCreateTrainerFrontSprite(i,p.trainer_type,@battle.opponent.length) + @battle.opponent.each_with_index do |p, i| + pbCreateTrainerFrontSprite(i, p.trainer_type, @battle.opponent.length) end end # Data boxes and Pokémon sprites - @battle.battlers.each_with_index do |b,i| + @battle.battlers.each_with_index do |b, i| next if !b - @sprites["dataBox_#{i}"] = PokemonDataBox.new(b,@battle.pbSideSize(i),@viewport) + @sprites["dataBox_#{i}"] = PokemonDataBox.new(b, @battle.pbSideSize(i), @viewport) pbCreatePokemonSprite(i) end # Wild battle, so set up the Pokémon sprite(s) accordingly if @battle.wildBattle? - @battle.pbParty(1).each_with_index do |pkmn,i| - index = i*2+1 - pbChangePokemon(index,pkmn) + @battle.pbParty(1).each_with_index do |pkmn, i| + index = i * 2 + 1 + pbChangePokemon(index, pkmn) pkmnSprite = @sprites["pokemon_#{index}"] - pkmnSprite.tone = Tone.new(-80,-80,-80) + pkmnSprite.tone = Tone.new(-80, -80, -80) pkmnSprite.visible = true end end @@ -99,92 +99,92 @@ class Battle::Scene # Put everything together into backdrop, bases and message bar filenames backdropFilename = @battle.backdrop baseFilename = @battle.backdrop - baseFilename = sprintf("%s_%s",baseFilename,@battle.backdropBase) if @battle.backdropBase + baseFilename = sprintf("%s_%s", baseFilename, @battle.backdropBase) if @battle.backdropBase messageFilename = @battle.backdrop if time - trialName = sprintf("%s_%s",backdropFilename,time) - if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_bg")) + trialName = sprintf("%s_%s", backdropFilename, time) + if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_bg")) backdropFilename = trialName end - trialName = sprintf("%s_%s",baseFilename,time) - if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0")) + trialName = sprintf("%s_%s", baseFilename, time) + if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_base0")) baseFilename = trialName end - trialName = sprintf("%s_%s",messageFilename,time) - if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_message")) + trialName = sprintf("%s_%s", messageFilename, time) + if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_message")) messageFilename = trialName end end - if !pbResolveBitmap(sprintf("Graphics/Battlebacks/"+baseFilename+"_base0")) && + if !pbResolveBitmap(sprintf("Graphics/Battlebacks/" + baseFilename + "_base0")) && @battle.backdropBase baseFilename = @battle.backdropBase if time - trialName = sprintf("%s_%s",baseFilename,time) - if pbResolveBitmap(sprintf("Graphics/Battlebacks/"+trialName+"_base0")) + trialName = sprintf("%s_%s", baseFilename, time) + if pbResolveBitmap(sprintf("Graphics/Battlebacks/" + trialName + "_base0")) baseFilename = trialName end end end # Finalise filenames - battleBG = "Graphics/Battlebacks/"+backdropFilename+"_bg" - playerBase = "Graphics/Battlebacks/"+baseFilename+"_base0" - enemyBase = "Graphics/Battlebacks/"+baseFilename+"_base1" - messageBG = "Graphics/Battlebacks/"+messageFilename+"_message" + battleBG = "Graphics/Battlebacks/" + backdropFilename + "_bg" + playerBase = "Graphics/Battlebacks/" + baseFilename + "_base0" + enemyBase = "Graphics/Battlebacks/" + baseFilename + "_base1" + messageBG = "Graphics/Battlebacks/" + messageFilename + "_message" # Apply graphics - bg = pbAddSprite("battle_bg",0,0,battleBG,@viewport) + bg = pbAddSprite("battle_bg", 0, 0, battleBG, @viewport) bg.z = 0 - bg = pbAddSprite("battle_bg2",-Graphics.width,0,battleBG,@viewport) + bg = pbAddSprite("battle_bg2", -Graphics.width, 0, battleBG, @viewport) bg.z = 0 bg.mirror = true for side in 0...2 baseX, baseY = Battle::Scene.pbBattlerPosition(side) - base = pbAddSprite("base_#{side}",baseX,baseY, - (side==0) ? playerBase : enemyBase,@viewport) - base.z = 1 + base = pbAddSprite("base_#{side}", baseX, baseY, + (side == 0) ? playerBase : enemyBase, @viewport) + base.z = 1 if base.bitmap - base.ox = base.bitmap.width/2 - base.oy = (side==0) ? base.bitmap.height : base.bitmap.height/2 + base.ox = base.bitmap.width / 2 + base.oy = (side == 0) ? base.bitmap.height : base.bitmap.height / 2 end end - cmdBarBG = pbAddSprite("cmdBar_bg",0,Graphics.height-96,messageBG,@viewport) + cmdBarBG = pbAddSprite("cmdBar_bg", 0, Graphics.height - 96, messageBG, @viewport) cmdBarBG.z = 180 end - def pbCreateTrainerBackSprite(idxTrainer,trainerType,numTrainers = 1) - if idxTrainer==0 # Player's sprite + def pbCreateTrainerBackSprite(idxTrainer, trainerType, numTrainers = 1) + if idxTrainer == 0 # Player's sprite trainerFile = GameData::TrainerType.player_back_sprite_filename(trainerType) else # Partner trainer's sprite trainerFile = GameData::TrainerType.back_sprite_filename(trainerType) end - spriteX, spriteY = Battle::Scene.pbTrainerPosition(0,idxTrainer,numTrainers) - trainer = pbAddSprite("player_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport) + spriteX, spriteY = Battle::Scene.pbTrainerPosition(0, idxTrainer, numTrainers) + trainer = pbAddSprite("player_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport) return if !trainer.bitmap # Alter position of sprite - trainer.z = 80+idxTrainer - if trainer.bitmap.width>trainer.bitmap.height*2 + trainer.z = 80 + idxTrainer + if trainer.bitmap.width > trainer.bitmap.height * 2 trainer.src_rect.x = 0 - trainer.src_rect.width = trainer.bitmap.width/5 + trainer.src_rect.width = trainer.bitmap.width / 5 end - trainer.ox = trainer.src_rect.width/2 + trainer.ox = trainer.src_rect.width / 2 trainer.oy = trainer.bitmap.height end - def pbCreateTrainerFrontSprite(idxTrainer,trainerType,numTrainers = 1) + def pbCreateTrainerFrontSprite(idxTrainer, trainerType, numTrainers = 1) trainerFile = GameData::TrainerType.front_sprite_filename(trainerType) - spriteX, spriteY = Battle::Scene.pbTrainerPosition(1,idxTrainer,numTrainers) - trainer = pbAddSprite("trainer_#{idxTrainer+1}",spriteX,spriteY,trainerFile,@viewport) + spriteX, spriteY = Battle::Scene.pbTrainerPosition(1, idxTrainer, numTrainers) + trainer = pbAddSprite("trainer_#{idxTrainer + 1}", spriteX, spriteY, trainerFile, @viewport) return if !trainer.bitmap # Alter position of sprite - trainer.z = 7+idxTrainer - trainer.ox = trainer.src_rect.width/2 + trainer.z = 7 + idxTrainer + trainer.ox = trainer.src_rect.width / 2 trainer.oy = trainer.bitmap.height end def pbCreatePokemonSprite(idxBattler) sideSize = @battle.pbSideSize(idxBattler) - batSprite = BattlerSprite.new(@viewport,sideSize,idxBattler,@animations) + batSprite = BattlerSprite.new(@viewport, sideSize, idxBattler, @animations) @sprites["pokemon_#{idxBattler}"] = batSprite - shaSprite = BattlerShadowSprite.new(@viewport,sideSize,idxBattler) + shaSprite = BattlerShadowSprite.new(@viewport, sideSize, idxBattler) shaSprite.visible = false @sprites["shadow_#{idxBattler}"] = shaSprite end diff --git a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb index ce2232d6c..e9e4c98a5 100644 --- a/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb +++ b/Data/Scripts/011_Battle/004_Scene/003_Scene_ChooseCommands.rb @@ -3,18 +3,18 @@ class Battle::Scene # The player chooses a main command for a Pokémon # Return values: -1=Cancel, 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call #============================================================================= - def pbCommandMenu(idxBattler,firstAction) + def pbCommandMenu(idxBattler, firstAction) shadowTrainer = (GameData::Type.exists?(:SHADOW) && @battle.trainerBattle?) cmds = [ - _INTL("What will\n{1} do?",@battle.battlers[idxBattler].name), + _INTL("What will\n{1} do?", @battle.battlers[idxBattler].name), _INTL("Fight"), _INTL("Bag"), _INTL("Pokémon"), (shadowTrainer) ? _INTL("Call") : (firstAction) ? _INTL("Run") : _INTL("Cancel") ] - ret = pbCommandMenuEx(idxBattler,cmds,(shadowTrainer) ? 2 : (firstAction) ? 0 : 1) - ret = 4 if ret==3 && shadowTrainer # Convert "Run" to "Call" - ret = -1 if ret==3 && !firstAction # Convert "Run" to "Cancel" + ret = pbCommandMenuEx(idxBattler, cmds, (shadowTrainer) ? 2 : (firstAction) ? 0 : 1) + ret = 4 if ret == 3 && shadowTrainer # Convert "Run" to "Call" + ret = -1 if ret == 3 && !firstAction # Convert "Run" to "Cancel" return ret end @@ -23,11 +23,11 @@ class Battle::Scene # 2 = regular battle with "Call" (for Shadow Pokémon battles) # 3 = Safari Zone # 4 = Bug Catching Contest - def pbCommandMenuEx(idxBattler,texts,mode = 0) + def pbCommandMenuEx(idxBattler, texts, mode = 0) pbShowWindow(COMMAND_BOX) cw = @sprites["commandWindow"] cw.setTexts(texts) - cw.setIndexAndMode(@lastCmd[idxBattler],mode) + cw.setIndexAndMode(@lastCmd[idxBattler], mode) pbSelectBattler(idxBattler) ret = -1 loop do @@ -35,22 +35,22 @@ class Battle::Scene pbUpdate(cw) # Update selected command if Input.trigger?(Input::LEFT) - cw.index -= 1 if (cw.index&1)==1 + cw.index -= 1 if (cw.index & 1) == 1 elsif Input.trigger?(Input::RIGHT) - cw.index += 1 if (cw.index&1)==0 + cw.index += 1 if (cw.index & 1) == 0 elsif Input.trigger?(Input::UP) - cw.index -= 2 if (cw.index&2)==2 + cw.index -= 2 if (cw.index & 2) == 2 elsif Input.trigger?(Input::DOWN) - cw.index += 2 if (cw.index&2)==0 + cw.index += 2 if (cw.index & 2) == 0 end - pbPlayCursorSE if cw.index!=oldIndex + pbPlayCursorSE if cw.index != oldIndex # Actions if Input.trigger?(Input::USE) # Confirm choice pbPlayDecisionSE ret = cw.index @lastCmd[idxBattler] = ret break - elsif Input.trigger?(Input::BACK) && mode==1 # Cancel + elsif Input.trigger?(Input::BACK) && mode == 1 # Cancel pbPlayCancelSE break elsif Input.trigger?(Input::F9) && $DEBUG # Debug menu @@ -65,7 +65,7 @@ class Battle::Scene #============================================================================= # The player chooses a move for a Pokémon to use #============================================================================= - def pbFightMenu(idxBattler,megaEvoPossible = false) + def pbFightMenu(idxBattler, megaEvoPossible = false) battler = @battle.battlers[idxBattler] cw = @sprites["fightWindow"] cw.battler = battler @@ -74,7 +74,7 @@ class Battle::Scene moveIndex = @lastMove[idxBattler] end cw.shiftMode = (@battle.pbCanShift?(idxBattler)) ? 1 : 0 - cw.setIndexAndMode(moveIndex,(megaEvoPossible) ? 1 : 0) + cw.setIndexAndMode(moveIndex, (megaEvoPossible) ? 1 : 0) needFullRefresh = true needRefresh = false loop do @@ -87,7 +87,7 @@ class Battle::Scene if needRefresh if megaEvoPossible newMode = (@battle.pbRegisteredMegaEvolution?(idxBattler)) ? 2 : 1 - cw.mode = newMode if newMode!=cw.mode + cw.mode = newMode if newMode != cw.mode end needRefresh = false end @@ -96,19 +96,19 @@ class Battle::Scene pbUpdate(cw) # Update selected command if Input.trigger?(Input::LEFT) - cw.index -= 1 if (cw.index&1)==1 + cw.index -= 1 if (cw.index & 1) == 1 elsif Input.trigger?(Input::RIGHT) - if battler.moves[cw.index+1] && battler.moves[cw.index+1].id - cw.index += 1 if (cw.index&1)==0 + if battler.moves[cw.index + 1] && battler.moves[cw.index + 1].id + cw.index += 1 if (cw.index & 1) == 0 end elsif Input.trigger?(Input::UP) - cw.index -= 2 if (cw.index&2)==2 + cw.index -= 2 if (cw.index & 2) == 2 elsif Input.trigger?(Input::DOWN) - if battler.moves[cw.index+2] && battler.moves[cw.index+2].id - cw.index += 2 if (cw.index&2)==0 + if battler.moves[cw.index + 2] && battler.moves[cw.index + 2].id + cw.index += 2 if (cw.index & 2) == 0 end end - pbPlayCursorSE if cw.index!=oldIndex + pbPlayCursorSE if cw.index != oldIndex # Actions if Input.trigger?(Input::USE) # Confirm choice pbPlayDecisionSE @@ -126,7 +126,7 @@ class Battle::Scene needRefresh = true end elsif Input.trigger?(Input::SPECIAL) # Shift - if cw.shiftMode>0 + if cw.shiftMode > 0 pbPlayDecisionSE break if yield -3 needRefresh = true @@ -140,7 +140,7 @@ class Battle::Scene # Opens the party screen to choose a Pokémon to switch in (or just view its # summary screens) #============================================================================= - def pbPartyScreen(idxBattler,canCancel = false) + def pbPartyScreen(idxBattler, canCancel = false) # Fade out and hide all sprites visibleSprites = pbFadeOutAndHide(@sprites) # Get player's party @@ -149,14 +149,14 @@ class Battle::Scene modParty = @battle.pbPlayerDisplayParty(idxBattler) # Start party screen scene = PokemonParty_Scene.new - switchScreen = PokemonPartyScreen.new(scene,modParty) - switchScreen.pbStartScene(_INTL("Choose a Pokémon."),@battle.pbNumPositions(0,0)) + switchScreen = PokemonPartyScreen.new(scene, modParty) + switchScreen.pbStartScene(_INTL("Choose a Pokémon."), @battle.pbNumPositions(0, 0)) # Loop while in party screen loop do # Select a Pokémon scene.pbSetHelpText(_INTL("Choose a Pokémon.")) idxParty = switchScreen.pbChoosePokemon - if idxParty<0 + if idxParty < 0 next if !canCancel break end @@ -167,29 +167,29 @@ class Battle::Scene commands[cmdSwitch = commands.length] = _INTL("Switch In") if modParty[idxParty].able? commands[cmdSummary = commands.length] = _INTL("Summary") commands[commands.length] = _INTL("Cancel") - command = scene.pbShowCommands(_INTL("Do what with {1}?",modParty[idxParty].name),commands) - if cmdSwitch>=0 && command==cmdSwitch # Switch In + command = scene.pbShowCommands(_INTL("Do what with {1}?", modParty[idxParty].name), commands) + if cmdSwitch >= 0 && command == cmdSwitch # Switch In idxPartyRet = -1 - partyPos.each_with_index do |pos,i| - next if pos!=idxParty+partyStart + partyPos.each_with_index do |pos, i| + next if pos != idxParty + partyStart idxPartyRet = i break end break if yield idxPartyRet, switchScreen - elsif cmdSummary>=0 && command==cmdSummary # Summary - scene.pbSummary(idxParty,true) + elsif cmdSummary >= 0 && command == cmdSummary # Summary + scene.pbSummary(idxParty, true) end end # Close party screen switchScreen.pbEndScene # Fade back into battle screen - pbFadeInAndShow(@sprites,visibleSprites) + pbFadeInAndShow(@sprites, visibleSprites) end #============================================================================= # 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 @@ -216,10 +216,10 @@ class Battle::Scene useType = item.battle_use cmdUse = -1 commands = [] - commands[cmdUse = commands.length] = _INTL("Use") if useType && useType!=0 + commands[cmdUse = commands.length] = _INTL("Use") if useType && useType != 0 commands[commands.length] = _INTL("Cancel") - command = itemScene.pbShowCommands(_INTL("{1} is selected.",itemName),commands) - next unless cmdUse>=0 && command==cmdUse # Use + command = itemScene.pbShowCommands(_INTL("{1} is selected.", itemName), commands) + next unless cmdUse >= 0 && command == cmdUse # Use # Use types: # 0 = not usable in battle # 1 = use on Pokémon (lots of items, Blue Flute) @@ -233,11 +233,11 @@ class Battle::Scene # are the only available Pokémon/battler to use the item on case useType when 1 # Use on Pokémon - if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1 + if @battle.pbTeamLengthFromBattlerIndex(idxBattler) == 1 break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene end when 3 # Use on battler - if @battle.pbPlayerBattlerCount==1 + if @battle.pbPlayerBattlerCount == 1 break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene end end @@ -250,38 +250,38 @@ class Battle::Scene modParty = @battle.pbPlayerDisplayParty(idxBattler) # Start party screen pkmnScene = PokemonParty_Scene.new - pkmnScreen = PokemonPartyScreen.new(pkmnScene,modParty) - pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.pbNumPositions(0,0)) + pkmnScreen = PokemonPartyScreen.new(pkmnScene, modParty) + pkmnScreen.pbStartScene(_INTL("Use on which Pokémon?"), @battle.pbNumPositions(0, 0)) idxParty = -1 # Loop while in party screen loop do # Select a Pokémon pkmnScene.pbSetHelpText(_INTL("Use on which Pokémon?")) idxParty = pkmnScreen.pbChoosePokemon - break if idxParty<0 + break if idxParty < 0 idxPartyRet = -1 - partyPos.each_with_index do |pos,i| - next if pos!=idxParty+partyStart + partyPos.each_with_index do |pos, i| + next if pos != idxParty + partyStart idxPartyRet = i break end - next if idxPartyRet<0 + next if idxPartyRet < 0 pkmn = party[idxPartyRet] next if !pkmn || pkmn.egg? idxMove = -1 - if useType==2 # Use on Pokémon's move - idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL("Restore which move?")) - next if idxMove<0 + if useType == 2 # Use on Pokémon's move + idxMove = pkmnScreen.pbChooseMove(pkmn, _INTL("Restore which move?")) + next if idxMove < 0 end break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene end pkmnScene.pbEndScene - break if idxParty>=0 + break if idxParty >= 0 # Cancelled choosing a Pokémon; show the Bag screen again itemScene.pbFadeInScene when 4 # Use on opposing battler (Poké Balls) idxTarget = -1 - if @battle.pbOpposingBattlerCount(idxBattler)==1 + if @battle.pbOpposingBattlerCount(idxBattler) == 1 @battle.allOtherSideBattlers(idxBattler).each { |b| idxTarget = b.index } break if yield item.id, useType, idxTarget, -1, itemScene else @@ -292,8 +292,8 @@ class Battle::Scene tempVisibleSprites = visibleSprites.clone tempVisibleSprites["commandWindow"] = false tempVisibleSprites["targetWindow"] = true - idxTarget = pbChooseTarget(idxBattler,GameData::Target.get(:Foe),tempVisibleSprites) - if idxTarget>=0 + idxTarget = pbChooseTarget(idxBattler, GameData::Target.get(:Foe), tempVisibleSprites) + if idxTarget >= 0 break if yield item.id, useType, idxTarget, -1, self end # Target invalid/cancelled choosing a target; show the Bag screen again @@ -312,7 +312,7 @@ class Battle::Scene # Close Bag screen itemScene.pbEndScene # Fade back into battle screen (if not already showing it) - pbFadeInAndShow(@sprites,visibleSprites) if !wasTargeting + pbFadeInAndShow(@sprites, visibleSprites) if !wasTargeting end #============================================================================= @@ -322,7 +322,7 @@ class Battle::Scene # target. # nil means can't select that position, "" means can select that position but # there is no battler there, otherwise is a battler's name. - def pbCreateTargetTexts(idxBattler,target_data) + def pbCreateTargetTexts(idxBattler, target_data) texts = Array.new(@battle.battlers.length) do |i| next nil if !@battle.battlers[i] showName = false @@ -331,15 +331,15 @@ class Battle::Scene # other targets are handled by the "else" part. case target_data.id when :None, :User, :RandomNearFoe - showName = (i==idxBattler) + showName = (i == idxBattler) when :UserSide - showName = !@battle.opposes?(i,idxBattler) + showName = !@battle.opposes?(i, idxBattler) when :FoeSide - showName = @battle.opposes?(i,idxBattler) + showName = @battle.opposes?(i, idxBattler) when :BothSides showName = true else - showName = @battle.pbMoveCanTarget?(i,idxBattler,target_data) + showName = @battle.pbMoveCanTarget?(i, idxBattler, target_data) end next nil if !showName next (@battle.battlers[i].fainted?) ? "" : @battle.battlers[i].name @@ -349,22 +349,22 @@ class Battle::Scene # Returns the initial position of the cursor when choosing a target for a move # in a non-single battle. - def pbFirstTarget(idxBattler,target_data) + def pbFirstTarget(idxBattler, target_data) case target_data.id when :NearAlly @battle.allSameSideBattlers(idxBattler).each do |b| - next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler) + next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler) next if b.fainted? return b.index end @battle.allSameSideBattlers(idxBattler).each do |b| - next if b.index==idxBattler || !@battle.nearBattlers?(b,idxBattler) + next if b.index == idxBattler || !@battle.nearBattlers?(b, idxBattler) return b.index end when :NearFoe, :NearOther indices = @battle.pbGetOpposingIndicesInOrder(idxBattler) - indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) && !@battle.battlers[i].fainted? } - indices.each { |i| return i if @battle.nearBattlers?(i,idxBattler) } + indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) && !@battle.battlers[i].fainted? } + indices.each { |i| return i if @battle.nearBattlers?(i, idxBattler) } when :Foe, :Other indices = @battle.pbGetOpposingIndicesInOrder(idxBattler) indices.each { |i| return i if !@battle.battlers[i].fainted? } @@ -373,37 +373,37 @@ class Battle::Scene return idxBattler # Target the user initially end - def pbChooseTarget(idxBattler,target_data,visibleSprites = nil) + def pbChooseTarget(idxBattler, target_data, visibleSprites = nil) pbShowWindow(TARGET_BOX) cw = @sprites["targetWindow"] # Create an array of battler names (only valid targets are named) - texts = pbCreateTargetTexts(idxBattler,target_data) + texts = pbCreateTargetTexts(idxBattler, target_data) # Determine mode based on target_data mode = (target_data.num_targets == 1) ? 0 : 1 - cw.setDetails(texts,mode) - cw.index = pbFirstTarget(idxBattler,target_data) - pbSelectBattler((mode==0) ? cw.index : texts,2) # Select initial battler/data box - pbFadeInAndShow(@sprites,visibleSprites) if visibleSprites + cw.setDetails(texts, mode) + cw.index = pbFirstTarget(idxBattler, target_data) + pbSelectBattler((mode == 0) ? cw.index : texts, 2) # Select initial battler/data box + pbFadeInAndShow(@sprites, visibleSprites) if visibleSprites ret = -1 loop do oldIndex = cw.index pbUpdate(cw) # Update selected command - if mode==0 # Choosing just one target, can change index + if mode == 0 # Choosing just one target, can change index if Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) - inc = ((cw.index%2)==0) ? -2 : 2 + inc = ((cw.index % 2) == 0) ? -2 : 2 inc *= -1 if Input.trigger?(Input::RIGHT) - indexLength = @battle.sideSizes[cw.index%2]*2 + indexLength = @battle.sideSizes[cw.index % 2] * 2 newIndex = cw.index loop do newIndex += inc - break if newIndex<0 || newIndex>=indexLength + break if newIndex < 0 || newIndex >= indexLength next if texts[newIndex].nil? cw.index = newIndex break end - elsif (Input.trigger?(Input::UP) && (cw.index%2)==0) || - (Input.trigger?(Input::DOWN) && (cw.index%2)==1) + elsif (Input.trigger?(Input::UP) && (cw.index % 2) == 0) || + (Input.trigger?(Input::DOWN) && (cw.index % 2) == 1) tryIndex = @battle.pbGetOpposingIndicesInOrder(cw.index) tryIndex.each do |idxBattlerTry| next if texts[idxBattlerTry].nil? @@ -411,9 +411,9 @@ class Battle::Scene break end end - if cw.index!=oldIndex + if cw.index != oldIndex pbPlayCursorSE - pbSelectBattler(cw.index,2) # Select the new battler/data box + pbSelectBattler(cw.index, 2) # Select the new battler/data box end end if Input.trigger?(Input::USE) # Confirm @@ -436,12 +436,12 @@ class Battle::Scene # Called whenever a Pokémon should forget a move. It should return -1 if the # selection is canceled, or 0 to 3 to indicate the move to forget. It should # not allow HM moves to be forgotten. - def pbForgetMove(pkmn,moveToLearn) + def pbForgetMove(pkmn, moveToLearn) ret = -1 pbFadeOutIn { scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene) - ret = screen.pbStartForgetScreen([pkmn],0,moveToLearn) + ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn) } return ret end @@ -449,7 +449,7 @@ class Battle::Scene #============================================================================= # Opens the nicknaming screen for a newly caught Pokémon #============================================================================= - def pbNameEntry(helpText,pkmn) + def pbNameEntry(helpText, pkmn) return pbEnterPokemonName(helpText, 0, Pokemon::MAX_NAME_SIZE, "", pkmn) end diff --git a/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb b/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb index 2725c8d87..ddeb57c87 100644 --- a/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb +++ b/Data/Scripts/011_Battle/004_Scene/004_Scene_PlayAnimations.rb @@ -4,7 +4,7 @@ class Battle::Scene #============================================================================= def pbBattleIntroAnimation # Make everything appear - introAnim = Animation::Intro.new(@sprites,@viewport,@battle) + introAnim = Animation::Intro.new(@sprites, @viewport, @battle) loop do introAnim.update pbUpdate @@ -19,8 +19,8 @@ class Battle::Scene # entrance animation. Be sure to set it up like a Pokémon entrance # animation, i.e. add them to @animations so that they can play out # while party lineups appear and messages show. - pbShowPartyLineup(0,true) - pbShowPartyLineup(1,true) + pbShowPartyLineup(0, true) + pbShowPartyLineup(1, true) return end # Wild battle: play wild Pokémon's intro animations (including cry), show @@ -28,14 +28,14 @@ class Battle::Scene # shiny animation(s) # Set up data box animation for i in 0...@battle.sideSizes[1] - idxBattler = 2*i+1 + idxBattler = 2 * i + 1 next if !@battle.battlers[idxBattler] - dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,idxBattler) + dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, idxBattler) @animations.push(dataBoxAnim) end # Set up wild Pokémon returning to normal colour and playing intro # animations (including cry) - @animations.push(Animation::Intro2.new(@sprites,@viewport,@battle.sideSizes[1])) + @animations.push(Animation::Intro2.new(@sprites, @viewport, @battle.sideSizes[1])) # Play all the animations while inPartyAnimation? pbUpdate @@ -43,7 +43,7 @@ class Battle::Scene # Show shiny animation for wild Pokémon if @battle.showAnims for i in 0...@battle.sideSizes[1] - idxBattler = 2*i+1 + idxBattler = 2 * i + 1 next if !@battle.battlers[idxBattler] || !@battle.battlers[idxBattler].shiny? if Settings::SUPER_SHINY && @battle.battlers[idxBattler].super_shiny? pbCommonAnimation("SuperShiny", @battle.battlers[idxBattler]) @@ -57,9 +57,9 @@ class Battle::Scene #============================================================================= # Animates a party lineup appearing for the given side #============================================================================= - def pbShowPartyLineup(side,fullAnim = false) - @animations.push(Animation::LineupAppear.new(@sprites,@viewport, - side,@battle.pbParty(side),@battle.pbPartyStarts(side),fullAnim)) + def pbShowPartyLineup(side, fullAnim = false) + @animations.push(Animation::LineupAppear.new(@sprites, @viewport, + side, @battle.pbParty(side), @battle.pbPartyStarts(side), fullAnim)) if !fullAnim while inPartyAnimation? pbUpdate @@ -74,7 +74,7 @@ class Battle::Scene #============================================================================= def pbShowOpponent(idxTrainer) # Set up trainer appearing animation - appearAnim = Animation::TrainerAppear.new(@sprites,@viewport,idxTrainer) + appearAnim = Animation::TrainerAppear.new(@sprites, @viewport, idxTrainer) @animations.push(appearAnim) # Play the animation while inPartyAnimation? @@ -88,8 +88,8 @@ class Battle::Scene # animation for it if relevant. # sendOuts is an array; each element is itself an array: [idxBattler,pkmn] #============================================================================= - def pbSendOutBattlers(sendOuts,startBattle = false) - return if sendOuts.length==0 + def pbSendOutBattlers(sendOuts, startBattle = false) + return if sendOuts.length == 0 # If party balls are still appearing, wait for them to finish showing up, as # the FadeAnimation will make them disappear. while inPartyAnimation? @@ -99,29 +99,29 @@ class Battle::Scene # Make all trainers and party lineups disappear (player-side trainers may # animate throwing a Poké Ball) if @battle.opposes?(sendOuts[0][0]) - fadeAnim = Animation::TrainerFade.new(@sprites,@viewport,startBattle) + fadeAnim = Animation::TrainerFade.new(@sprites, @viewport, startBattle) else - fadeAnim = Animation::PlayerFade.new(@sprites,@viewport,startBattle) + fadeAnim = Animation::PlayerFade.new(@sprites, @viewport, startBattle) end # For each battler being sent out, set the battler's sprite and create two # animations (the Poké Ball moving and battler appearing from it, and its # data box appearing) sendOutAnims = [] - sendOuts.each_with_index do |b,i| + sendOuts.each_with_index do |b, i| pkmn = @battle.battlers[b[0]].effects[PBEffects::Illusion] || b[1] - pbChangePokemon(b[0],pkmn) + pbChangePokemon(b[0], pkmn) pbRefresh if @battle.opposes?(b[0]) - sendOutAnim = Animation::PokeballTrainerSendOut.new(@sprites,@viewport, - @battle.pbGetOwnerIndexFromBattlerIndex(b[0])+1, - @battle.battlers[b[0]],startBattle,i) + sendOutAnim = Animation::PokeballTrainerSendOut.new(@sprites, @viewport, + @battle.pbGetOwnerIndexFromBattlerIndex(b[0]) + 1, + @battle.battlers[b[0]], startBattle, i) else - sendOutAnim = Animation::PokeballPlayerSendOut.new(@sprites,@viewport, - @battle.pbGetOwnerIndexFromBattlerIndex(b[0])+1, - @battle.battlers[b[0]],startBattle,i) + sendOutAnim = Animation::PokeballPlayerSendOut.new(@sprites, @viewport, + @battle.pbGetOwnerIndexFromBattlerIndex(b[0]) + 1, + @battle.battlers[b[0]], startBattle, i) end - dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,b[0]) - sendOutAnims.push([sendOutAnim,dataBoxAnim,false]) + dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, b[0]) + sendOutAnims.push([sendOutAnim, dataBoxAnim, false]) end # Play all animations loop do @@ -159,7 +159,7 @@ class Battle::Scene def pbRecall(idxBattler) @briefMessage = false # Recall animation - recallAnim = Animation::BattlerRecall.new(@sprites,@viewport,idxBattler) + recallAnim = Animation::BattlerRecall.new(@sprites, @viewport, idxBattler) loop do recallAnim.update if recallAnim pbUpdate @@ -167,7 +167,7 @@ class Battle::Scene end recallAnim.dispose # Data box disappear animation - dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,idxBattler) + dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, idxBattler) loop do dataBoxAnim.update pbUpdate @@ -181,10 +181,10 @@ class Battle::Scene #============================================================================= def pbShowAbilitySplash(battler) return if !USE_ABILITY_SPLASH - side = battler.index%2 + side = battler.index % 2 pbHideAbilitySplash(battler) if @sprites["abilityBar_#{side}"].visible @sprites["abilityBar_#{side}"].battler = battler - abilitySplashAnim = Animation::AbilitySplashAppear.new(@sprites,@viewport,side) + abilitySplashAnim = Animation::AbilitySplashAppear.new(@sprites, @viewport, side) loop do abilitySplashAnim.update pbUpdate @@ -195,9 +195,9 @@ class Battle::Scene def pbHideAbilitySplash(battler) return if !USE_ABILITY_SPLASH - side = battler.index%2 + side = battler.index % 2 return if !@sprites["abilityBar_#{side}"].visible - abilitySplashAnim = Animation::AbilitySplashDisappear.new(@sprites,@viewport,side) + abilitySplashAnim = Animation::AbilitySplashDisappear.new(@sprites, @viewport, side) loop do abilitySplashAnim.update pbUpdate @@ -216,23 +216,23 @@ class Battle::Scene #============================================================================= # Shows a HP-changing common animation and animates a data box's HP bar. # Called by def pbReduceHP, def pbRecoverHP. - def pbHPChanged(battler,oldHP,showAnim = false) + def pbHPChanged(battler, oldHP, showAnim = false) @briefMessage = false - if battler.hp>oldHP - pbCommonAnimation("HealthUp",battler) if showAnim && @battle.showAnims - elsif battler.hp oldHP + pbCommonAnimation("HealthUp", battler) if showAnim && @battle.showAnims + elsif battler.hp < oldHP + pbCommonAnimation("HealthDown", battler) if showAnim && @battle.showAnims end - @sprites["dataBox_#{battler.index}"].animateHP(oldHP,battler.hp,battler.totalhp) + @sprites["dataBox_#{battler.index}"].animateHP(oldHP, battler.hp, battler.totalhp) while @sprites["dataBox_#{battler.index}"].animatingHP pbUpdate end end - def pbDamageAnimation(battler,effectiveness = 0) + def pbDamageAnimation(battler, effectiveness = 0) @briefMessage = false # Damage animation - damageAnim = Animation::BattlerDamage.new(@sprites,@viewport,battler.index,effectiveness) + damageAnim = Animation::BattlerDamage.new(@sprites, @viewport, battler.index, effectiveness) loop do damageAnim.update pbUpdate @@ -249,9 +249,9 @@ class Battle::Scene # Set up animations damageAnims = [] targets.each do |t| - anim = Animation::BattlerDamage.new(@sprites,@viewport,t[0].index,t[2]) + anim = Animation::BattlerDamage.new(@sprites, @viewport, t[0].index, t[2]) damageAnims.push(anim) - @sprites["dataBox_#{t[0].index}"].animateHP(t[1],t[0].hp,t[0].totalhp) + @sprites["dataBox_#{t[0].index}"].animateHP(t[1], t[0].hp, t[0].totalhp) end # Update loop loop do @@ -278,13 +278,13 @@ class Battle::Scene #============================================================================= # Animates a data box's Exp bar #============================================================================= - def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2) + def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2) return if !battler || endExp == startExp - startExpLevel = tempExp1-startExp - endExpLevel = tempExp2-startExp - expRange = endExp-startExp + startExpLevel = tempExp1 - startExp + endExpLevel = tempExp2 - startExp + expRange = endExp - startExp dataBox = @sprites["dataBox_#{battler.index}"] - dataBox.animateExp(startExpLevel,endExpLevel,expRange) + dataBox.animateExp(startExpLevel, endExpLevel, expRange) while dataBox.animatingExp pbUpdate end @@ -293,14 +293,14 @@ class Battle::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, - pkmn.spatk-oldSpAtk,pkmn.spdef-oldSpDef,pkmn.speed-oldSpeed)) + pkmn.totalhp - oldTotalHP, pkmn.attack - oldAttack, pkmn.defense - oldDefense, + pkmn.spatk - oldSpAtk, pkmn.spdef - oldSpDef, pkmn.speed - 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,pkmn.attack,pkmn.defense,pkmn.spatk,pkmn.spdef,pkmn.speed)) + pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed)) end #============================================================================= @@ -309,8 +309,8 @@ class Battle::Scene def pbFaintBattler(battler) @briefMessage = false # Pokémon plays cry and drops down, data box disappears - faintAnim = Animation::BattlerFaint.new(@sprites,@viewport,battler.index,@battle) - dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,battler.index) + faintAnim = Animation::BattlerFaint.new(@sprites, @viewport, battler.index, @battle) + dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, battler.index) loop do faintAnim.update dataBoxAnim.update @@ -324,10 +324,10 @@ class Battle::Scene #============================================================================= # Animates throwing a Poké Ball at a Pokémon in an attempt to catch it #============================================================================= - def pbThrow(ball,shakes,critical,targetBattler,showPlayer = false) + def pbThrow(ball, shakes, critical, targetBattler, showPlayer = false) @briefMessage = false - captureAnim = Animation::PokeballThrowCapture.new(@sprites,@viewport, - ball,shakes,critical,@battle.battlers[targetBattler],showPlayer) + captureAnim = Animation::PokeballThrowCapture.new(@sprites, @viewport, + ball, shakes, critical, @battle.battlers[targetBattler], showPlayer) loop do captureAnim.update pbUpdate @@ -343,7 +343,7 @@ class Battle::Scene i = 0 loop do pbUpdate - break if i>=Graphics.frame_rate*3.5 # 3.5 seconds + break if i >= Graphics.frame_rate * 3.5 # 3.5 seconds i += 1 end pbMEStop @@ -355,20 +355,20 @@ class Battle::Scene ball = @sprites["captureBall"] return if !ball # Data box disappear animation - dataBoxAnim = Animation::DataBoxDisappear.new(@sprites,@viewport,idxBattler) + dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, idxBattler) loop do dataBoxAnim.update - ball.opacity -= 12*20/Graphics.frame_rate if ball.opacity>0 + ball.opacity -= 12 * 20 / Graphics.frame_rate if ball.opacity > 0 pbUpdate - break if dataBoxAnim.animDone? && ball.opacity<=0 + break if dataBoxAnim.animDone? && ball.opacity <= 0 end dataBoxAnim.dispose end - def pbThrowAndDeflect(ball,idxBattler) + def pbThrowAndDeflect(ball, idxBattler) @briefMessage = false - throwAnim = Animation::PokeballThrowDeflect.new(@sprites,@viewport, - ball,@battle.battlers[idxBattler]) + throwAnim = Animation::PokeballThrowDeflect.new(@sprites, @viewport, + ball, @battle.battlers[idxBattler]) loop do throwAnim.update pbUpdate @@ -403,17 +403,17 @@ class Battle::Scene #============================================================================= # Returns the animation ID to use for a given move/user. Returns nil if that # move has no animations defined for it. - def pbFindMoveAnimDetails(move2anim,moveID,idxUser,hitNum = 0) + def pbFindMoveAnimDetails(move2anim, moveID, idxUser, hitNum = 0) real_move_id = GameData::Move.get(moveID).id noFlip = false - if (idxUser&1)==0 # On player's side + if (idxUser & 1) == 0 # On player's side anim = move2anim[0][real_move_id] else # On opposing side anim = move2anim[1][real_move_id] noFlip = true if anim anim = move2anim[0][real_move_id] if !anim end - return [anim+hitNum,noFlip] if anim + return [anim + hitNum, noFlip] if anim return nil end @@ -483,8 +483,8 @@ class Battle::Scene # Plays a move/common animation #============================================================================= # Plays a move animation. - def pbAnimation(moveID,user,targets,hitNum = 0) - animID = pbFindMoveAnimation(moveID,user.index,hitNum) + def pbAnimation(moveID, user, targets, hitNum = 0) + animID = pbFindMoveAnimation(moveID, user.index, hitNum) return if !animID anim = animID[0] target = (targets && targets.is_a?(Array)) ? targets[0] : targets @@ -492,27 +492,27 @@ class Battle::Scene return if !animations pbSaveShadows { if animID[1] # On opposing side and using OppMove animation - pbAnimationCore(animations[anim],target,user,true) + pbAnimationCore(animations[anim], target, user, true) else # On player's side, and/or using Move animation - pbAnimationCore(animations[anim],user,target) + pbAnimationCore(animations[anim], user, target) end } end # Plays a common animation. - def pbCommonAnimation(animName,user = nil,target = nil) + def pbCommonAnimation(animName, user = nil, target = nil) return if nil_or_empty?(animName) target = target[0] if target && target.is_a?(Array) animations = pbLoadBattleAnimations return if !animations animations.each do |a| - next if !a || a.name!="Common:"+animName - pbAnimationCore(a,user,(target!=nil) ? target : user) + next if !a || a.name != "Common:" + animName + pbAnimationCore(a, user, (target != nil) ? target : user) return end end - def pbAnimationCore(animation,user,target,oppMove = false) + def pbAnimationCore(animation, user, target, oppMove = false) return if !animation @briefMessage = false userSprite = (user) ? @sprites["pokemon_#{user.index}"] : nil @@ -523,7 +523,7 @@ class Battle::Scene oldTargetX = (targetSprite) ? targetSprite.x : oldUserX oldTargetY = (targetSprite) ? targetSprite.y : oldUserY # Create the animation player - animPlayer = PBAnimationPlayerX.new(animation,user,target,self,oppMove) + animPlayer = PBAnimationPlayerX.new(animation, user, target, self, oppMove) # Apply a transformation to the animation based on where the user and target # actually are. Get the centres of each sprite. userHeight = (userSprite && userSprite.bitmap && !userSprite.bitmap.disposed?) ? userSprite.bitmap.height : 128 diff --git a/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb b/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb index b67cc8d94..219a821c8 100644 --- a/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb +++ b/Data/Scripts/011_Battle/004_Scene/005_Battle_Scene_Menus.rb @@ -20,7 +20,7 @@ class Battle::Scene::MenuBase @y = 0 @z = 0 @visible = false - @color = Color.new(0,0,0,0) + @color = Color.new(0, 0, 0, 0) @index = 0 @mode = 0 @disposed = false @@ -61,27 +61,27 @@ class Battle::Scene::MenuBase oldValue = @index @index = value @cmdWindow.index = @index if @cmdWindow - refresh if @index!=oldValue + refresh if @index != oldValue end def mode=(value) oldValue = @mode @mode = value - refresh if @mode!=oldValue + refresh if @mode != oldValue end - def addSprite(key,sprite) + def addSprite(key, sprite) @sprites[key] = sprite @visibility[key] = true end - def setIndexAndMode(index,mode) + def setIndexAndMode(index, mode) oldIndex = @index oldMode = @mode @index = index @mode = mode @cmdWindow.index = @index if @cmdWindow - refresh if @index!=oldIndex || @mode!=oldMode + refresh if @index != oldIndex || @mode != oldMode end def refresh; end @@ -106,52 +106,52 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase USE_GRAPHICS = true # Lists of which button graphics to use in different situations/types of battle. MODES = [ - [0,2,1,3], # 0 = Regular battle - [0,2,1,9], # 1 = Regular battle with "Cancel" instead of "Run" - [0,2,1,4], # 2 = Regular battle with "Call" instead of "Run" - [5,7,6,3], # 3 = Safari Zone - [0,8,1,3] # 4 = Bug Catching Contest + [0, 2, 1, 3], # 0 = Regular battle + [0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run" + [0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run" + [5, 7, 6, 3], # 3 = Safari Zone + [0, 8, 1, 3] # 4 = Bug Catching Contest ] - def initialize(viewport,z) + def initialize(viewport, z) super(viewport) self.x = 0 - self.y = Graphics.height-96 + self.y = Graphics.height - 96 # Create message box (shows "What will X do?") @msgBox = Window_UnformattedTextPokemon.newWithSize("", - self.x+16,self.y+2,220,Graphics.height-self.y,viewport) + self.x + 16, self.y + 2, 220, Graphics.height - self.y, viewport) @msgBox.baseColor = TEXT_BASE_COLOR @msgBox.shadowColor = TEXT_SHADOW_COLOR @msgBox.windowskin = nil - addSprite("msgBox",@msgBox) + addSprite("msgBox", @msgBox) if USE_GRAPHICS # Create background graphic - background = IconSprite.new(self.x,self.y,viewport) + background = IconSprite.new(self.x, self.y, viewport) background.setBitmap("Graphics/Pictures/Battle/overlay_command") - addSprite("background",background) + addSprite("background", background) # Create bitmaps @buttonBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_command")) # Create action buttons @buttons = Array.new(4) do |i| # 4 command options, therefore 4 buttons button = SpriteWrapper.new(viewport) button.bitmap = @buttonBitmap.bitmap - button.x = self.x+Graphics.width-260 - button.x += (((i%2)==0) ? 0 : @buttonBitmap.width/2-4) - button.y = self.y+6 - button.y += (((i/2)==0) ? 0 : BUTTON_HEIGHT-4) - button.src_rect.width = @buttonBitmap.width/2 + button.x = self.x + Graphics.width - 260 + button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4) + button.y = self.y + 6 + button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4) + button.src_rect.width = @buttonBitmap.width / 2 button.src_rect.height = BUTTON_HEIGHT - addSprite("button_#{i}",button) + addSprite("button_#{i}", button) next button end else # Create command window (shows Fight/Bag/Pokémon/Run) @cmdWindow = Window_CommandPokemon.newWithSize([], - self.x+Graphics.width-240,self.y,240,Graphics.height-self.y,viewport) + self.x + Graphics.width - 240, self.y, 240, Graphics.height - self.y, viewport) @cmdWindow.columns = 2 @cmdWindow.columnSpacing = 4 @cmdWindow.ignore_input = true - addSprite("cmdWindow",@cmdWindow) + addSprite("cmdWindow", @cmdWindow) end self.z = z refresh @@ -173,7 +173,7 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase return if USE_GRAPHICS commands = [] for i in 1..4 - commands.push(value[i]) if value[i] && value[i]!=nil + commands.push(value[i]) if value[i] && value[i] != nil end @cmdWindow.commands = commands end @@ -182,9 +182,9 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase return if !USE_GRAPHICS for i in 0...@buttons.length button = @buttons[i] - button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0 - button.src_rect.y = MODES[@mode][i]*BUTTON_HEIGHT - button.z = self.z + ((i==@index) ? 3 : 2) + button.src_rect.x = (i == @index) ? @buttonBitmap.width / 2 : 0 + button.src_rect.y = MODES[@mode][i] * BUTTON_HEIGHT + button.z = self.z + ((i == @index) ? 3 : 2) end end @@ -216,16 +216,16 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase TYPE_ICON_HEIGHT = 28 # Text colours of PP of selected move PP_COLORS = [ - Color.new(248,72,72),Color.new(136,48,48), # Red, zero PP - Color.new(248,136,32),Color.new(144,72,24), # Orange, 1/4 of total PP or less - Color.new(248,192,0),Color.new(144,104,0), # Yellow, 1/2 of total PP or less - TEXT_BASE_COLOR,TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP + Color.new(248, 72, 72), Color.new(136, 48, 48), # Red, zero PP + Color.new(248, 136, 32), Color.new(144, 72, 24), # Orange, 1/4 of total PP or less + Color.new(248, 192, 0), Color.new(144, 104, 0), # Yellow, 1/2 of total PP or less + TEXT_BASE_COLOR, TEXT_SHADOW_COLOR # Black, more than 1/2 of total PP ] - def initialize(viewport,z) + def initialize(viewport, z) super(viewport) self.x = 0 - self.y = Graphics.height-96 + self.y = Graphics.height - 96 @battler = nil @shiftMode = 0 # NOTE: @mode is for the display of the Mega Evolution button. @@ -237,70 +237,70 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase @megaEvoBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_mega")) @shiftBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_shift")) # Create background graphic - background = IconSprite.new(0,Graphics.height-96,viewport) + background = IconSprite.new(0, Graphics.height - 96, viewport) background.setBitmap("Graphics/Pictures/Battle/overlay_fight") - addSprite("background",background) + addSprite("background", background) # Create move buttons @buttons = Array.new(Pokemon::MAX_MOVES) do |i| button = SpriteWrapper.new(viewport) button.bitmap = @buttonBitmap.bitmap - button.x = self.x+4 - button.x += (((i%2)==0) ? 0 : @buttonBitmap.width/2-4) - button.y = self.y+6 - button.y += (((i/2)==0) ? 0 : BUTTON_HEIGHT-4) - button.src_rect.width = @buttonBitmap.width/2 + button.x = self.x + 4 + button.x += (i.even? ? 0 : @buttonBitmap.width / 2 - 4) + button.y = self.y + 6 + button.y += (((i / 2) == 0) ? 0 : BUTTON_HEIGHT - 4) + button.src_rect.width = @buttonBitmap.width / 2 button.src_rect.height = BUTTON_HEIGHT - addSprite("button_#{i}",button) + addSprite("button_#{i}", button) next button end # Create overlay for buttons (shows move names) - @overlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport) + @overlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport) @overlay.x = self.x @overlay.y = self.y pbSetNarrowFont(@overlay.bitmap) - addSprite("overlay",@overlay) + addSprite("overlay", @overlay) # Create overlay for selected move's info (shows move's PP) - @infoOverlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport) + @infoOverlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport) @infoOverlay.x = self.x @infoOverlay.y = self.y pbSetNarrowFont(@infoOverlay.bitmap) - addSprite("infoOverlay",@infoOverlay) + addSprite("infoOverlay", @infoOverlay) # Create type icon @typeIcon = SpriteWrapper.new(viewport) @typeIcon.bitmap = @typeBitmap.bitmap - @typeIcon.x = self.x+416 - @typeIcon.y = self.y+20 + @typeIcon.x = self.x + 416 + @typeIcon.y = self.y + 20 @typeIcon.src_rect.height = TYPE_ICON_HEIGHT - addSprite("typeIcon",@typeIcon) + addSprite("typeIcon", @typeIcon) # Create Mega Evolution button @megaButton = SpriteWrapper.new(viewport) @megaButton.bitmap = @megaEvoBitmap.bitmap - @megaButton.x = self.x+120 - @megaButton.y = self.y-@megaEvoBitmap.height/2 - @megaButton.src_rect.height = @megaEvoBitmap.height/2 - addSprite("megaButton",@megaButton) + @megaButton.x = self.x + 120 + @megaButton.y = self.y - @megaEvoBitmap.height / 2 + @megaButton.src_rect.height = @megaEvoBitmap.height / 2 + addSprite("megaButton", @megaButton) # Create Shift button @shiftButton = SpriteWrapper.new(viewport) @shiftButton.bitmap = @shiftBitmap.bitmap - @shiftButton.x = self.x+4 - @shiftButton.y = self.y-@shiftBitmap.height - addSprite("shiftButton",@shiftButton) + @shiftButton.x = self.x + 4 + @shiftButton.y = self.y - @shiftBitmap.height + addSprite("shiftButton", @shiftButton) else # Create message box (shows type and PP of selected move) @msgBox = Window_AdvancedTextPokemon.newWithSize("", - self.x+320,self.y,Graphics.width-320,Graphics.height-self.y,viewport) + self.x + 320, self.y, Graphics.width - 320, Graphics.height - self.y, viewport) @msgBox.baseColor = TEXT_BASE_COLOR @msgBox.shadowColor = TEXT_SHADOW_COLOR pbSetNarrowFont(@msgBox.contents) - addSprite("msgBox",@msgBox) + addSprite("msgBox", @msgBox) # Create command window (shows moves) @cmdWindow = Window_CommandPokemon.newWithSize([], - self.x,self.y,320,Graphics.height-self.y,viewport) + self.x, self.y, 320, Graphics.height - self.y, viewport) @cmdWindow.columns = 2 @cmdWindow.columnSpacing = 4 @cmdWindow.ignore_input = true pbSetNarrowFont(@cmdWindow.contents) - addSprite("cmdWindow",@cmdWindow) + addSprite("cmdWindow", @cmdWindow) end self.z = z end @@ -331,7 +331,7 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase def shiftMode=(value) oldValue = @shiftMode @shiftMode = value - refreshShiftButton if @shiftMode!=oldValue + refreshShiftButton if @shiftMode != oldValue end def refreshButtonNames @@ -348,10 +348,10 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase # Draw move names onto overlay @overlay.bitmap.clear textPos = [] - @buttons.each_with_index do |button,i| + @buttons.each_with_index do |button, i| next if !@visibility["button_#{i}"] - x = button.x-self.x+button.src_rect.width/2 - y = button.y-self.y+2 + x = button.x - self.x + button.src_rect.width / 2 + y = button.y - self.y + 2 moveNameBase = TEXT_BASE_COLOR if GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON && moves[i].display_type(@battler) # NOTE: This takes a color from a particular pixel in the button @@ -359,26 +359,26 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase # The pixel is at coordinates 10,34 in the button box. If you # change the graphic, you may want to change the below line of # code to ensure the font is an appropriate color. - moveNameBase = button.bitmap.get_pixel(10,button.src_rect.y+34) + moveNameBase = button.bitmap.get_pixel(10, button.src_rect.y + 34) end - textPos.push([moves[i].name,x,y,2,moveNameBase,TEXT_SHADOW_COLOR]) + textPos.push([moves[i].name, x, y, 2, moveNameBase, TEXT_SHADOW_COLOR]) end - pbDrawTextPositions(@overlay.bitmap,textPos) + pbDrawTextPositions(@overlay.bitmap, textPos) end def refreshSelection moves = (@battler) ? @battler.moves : [] if USE_GRAPHICS # Choose appropriate button graphics and z positions - @buttons.each_with_index do |button,i| + @buttons.each_with_index do |button, i| if !moves[i] @visibility["button_#{i}"] = false next end @visibility["button_#{i}"] = true - button.src_rect.x = (i==@index) ? @buttonBitmap.width/2 : 0 + button.src_rect.x = (i == @index) ? @buttonBitmap.width / 2 : 0 button.src_rect.y = GameData::Type.get(moves[i].display_type(@battler)).icon_position * BUTTON_HEIGHT - button.z = self.z + ((i==@index) ? 4 : 3) + button.z = self.z + ((i == @index) ? 4 : 3) end end refreshMoveData(moves[@index]) @@ -388,11 +388,11 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase # Write PP and type of the selected move if !USE_GRAPHICS moveType = GameData::Type.get(move.display_type(@battler)).name - if move.total_pp<=0 - @msgBox.text = _INTL("PP: ---
TYPE/{1}",moveType) + if move.total_pp <= 0 + @msgBox.text = _INTL("PP: ---
TYPE/{1}", moveType) else @msgBox.text = _ISPRINTF("PP: {1: 2d}/{2: 2d}
TYPE/{3:s}", - move.pp,move.total_pp,moveType) + move.pp, move.total_pp, moveType) end return end @@ -406,12 +406,12 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase type_number = GameData::Type.get(move.display_type(@battler)).icon_position @typeIcon.src_rect.y = type_number * TYPE_ICON_HEIGHT # PP text - if move.total_pp>0 - ppFraction = [(4.0*move.pp/move.total_pp).ceil,3].min + if move.total_pp > 0 + ppFraction = [(4.0 * move.pp / move.total_pp).ceil, 3].min textPos = [] - textPos.push([_INTL("PP: {1}/{2}",move.pp,move.total_pp), - 448,44,2,PP_COLORS[ppFraction*2],PP_COLORS[ppFraction*2+1]]) - pbDrawTextPositions(@infoOverlay.bitmap,textPos) + textPos.push([_INTL("PP: {1}/{2}", move.pp, move.total_pp), + 448, 44, 2, PP_COLORS[ppFraction * 2], PP_COLORS[ppFraction * 2 + 1]]) + pbDrawTextPositions(@infoOverlay.bitmap, textPos) end end @@ -450,57 +450,57 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase # Lists of which button graphics to use in different situations/types of battle. MODES = [ - [0,2,1,3], # 0 = Regular battle - [0,2,1,9], # 1 = Regular battle with "Cancel" instead of "Run" - [0,2,1,4], # 2 = Regular battle with "Call" instead of "Run" - [5,7,6,3], # 3 = Safari Zone - [0,8,1,3] # 4 = Bug Catching Contest + [0, 2, 1, 3], # 0 = Regular battle + [0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run" + [0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run" + [5, 7, 6, 3], # 3 = Safari Zone + [0, 8, 1, 3] # 4 = Bug Catching Contest ] CMD_BUTTON_WIDTH_SMALL = 170 - TEXT_BASE_COLOR = Color.new(240,248,224) - TEXT_SHADOW_COLOR = Color.new(64,64,64) + TEXT_BASE_COLOR = Color.new(240, 248, 224) + TEXT_SHADOW_COLOR = Color.new(64, 64, 64) - def initialize(viewport,z,sideSizes) + def initialize(viewport, z, sideSizes) super(viewport) @sideSizes = sideSizes - maxIndex = (@sideSizes[0]>@sideSizes[1]) ? (@sideSizes[0]-1)*2 : @sideSizes[1]*2-1 - @smallButtons = (@sideSizes.max>2) + maxIndex = (@sideSizes[0] > @sideSizes[1]) ? (@sideSizes[0] - 1) * 2 : @sideSizes[1] * 2 - 1 + @smallButtons = (@sideSizes.max > 2) self.x = 0 - self.y = Graphics.height-96 + self.y = Graphics.height - 96 @texts = [] # NOTE: @mode is for which buttons are shown as selected. # 0=select 1 button (@index), 1=select all buttons with text # Create bitmaps @buttonBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/cursor_target")) # Create target buttons - @buttons = Array.new(maxIndex+1) do |i| - numButtons = @sideSizes[i%2] - next if numButtons<=i/2 + @buttons = Array.new(maxIndex + 1) do |i| + numButtons = @sideSizes[i % 2] + next if numButtons <= i / 2 # NOTE: Battler indexes go from left to right from the perspective of # that side's trainer, so inc is different for each side for the # same value of i/2. - inc = ((i%2)==0) ? i/2 : numButtons-1-i/2 + inc = ((i % 2) == 0) ? i / 2 : numButtons - 1 - i / 2 button = SpriteWrapper.new(viewport) button.bitmap = @buttonBitmap.bitmap - button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width/2 + button.src_rect.width = (@smallButtons) ? CMD_BUTTON_WIDTH_SMALL : @buttonBitmap.width / 2 button.src_rect.height = BUTTON_HEIGHT if @smallButtons - button.x = self.x+170-[0,82,166][numButtons-1] + button.x = self.x + 170 - [0, 82, 166][numButtons - 1] else - button.x = self.x+138-[0,116][numButtons-1] + button.x = self.x + 138 - [0, 116][numButtons - 1] end - button.x += (button.src_rect.width-4)*inc - button.y = self.y+6 - button.y += (BUTTON_HEIGHT-4)*((i+1)%2) - addSprite("button_#{i}",button) + button.x += (button.src_rect.width - 4) * inc + button.y = self.y + 6 + button.y += (BUTTON_HEIGHT - 4) * ((i + 1) % 2) + addSprite("button_#{i}", button) next button end # Create overlay (shows target names) - @overlay = BitmapSprite.new(Graphics.width,Graphics.height-self.y,viewport) + @overlay = BitmapSprite.new(Graphics.width, Graphics.height - self.y, viewport) @overlay.x = self.x @overlay.y = self.y pbSetNarrowFont(@overlay.bitmap) - addSprite("overlay",@overlay) + addSprite("overlay", @overlay) self.z = z refresh end @@ -515,7 +515,7 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase @overlay.z += 5 if @overlay end - def setDetails(texts,mode) + def setDetails(texts, mode) @texts = texts @mode = mode refresh @@ -523,30 +523,30 @@ class Battle::Scene::TargetMenu < Battle::Scene::MenuBase def refreshButtons # Choose appropriate button graphics and z positions - @buttons.each_with_index do |button,i| + @buttons.each_with_index do |button, i| next if !button sel = false buttonType = 0 if @texts[i] - sel ||= (@mode==0 && i==@index) - sel ||= (@mode==1) - buttonType = ((i%2)==0) ? 1 : 2 + sel ||= (@mode == 0 && i == @index) + sel ||= (@mode == 1) + buttonType = ((i % 2) == 0) ? 1 : 2 end - buttonType = 2*buttonType + ((@smallButtons) ? 1 : 0) - button.src_rect.x = (sel) ? @buttonBitmap.width/2 : 0 - button.src_rect.y = buttonType*BUTTON_HEIGHT + buttonType = 2 * buttonType + ((@smallButtons) ? 1 : 0) + button.src_rect.x = (sel) ? @buttonBitmap.width / 2 : 0 + button.src_rect.y = buttonType * BUTTON_HEIGHT button.z = self.z + ((sel) ? 3 : 2) end # Draw target names onto overlay @overlay.bitmap.clear textpos = [] - @buttons.each_with_index do |button,i| + @buttons.each_with_index do |button, i| next if !button || nil_or_empty?(@texts[i]) - x = button.x-self.x+button.src_rect.width/2 - y = button.y-self.y+2 - textpos.push([@texts[i],x,y,2,TEXT_BASE_COLOR,TEXT_SHADOW_COLOR]) + x = button.x - self.x + button.src_rect.width / 2 + y = button.y - self.y + 2 + textpos.push([@texts[i], x, y, 2, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]) end - pbDrawTextPositions(@overlay.bitmap,textpos) + pbDrawTextPositions(@overlay.bitmap, textpos) end def refresh diff --git a/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb b/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb index 265ec56fa..587135c5b 100644 --- a/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb +++ b/Data/Scripts/011_Battle/004_Scene/006_Battle_Scene_Objects.rb @@ -12,14 +12,14 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper # Maximum time in seconds to make a change to the HP bar. HP_BAR_CHANGE_TIME = 1.0 STATUS_ICON_HEIGHT = 16 - NAME_BASE_COLOR = Color.new(72,72,72) - NAME_SHADOW_COLOR = Color.new(184,184,184) - MALE_BASE_COLOR = Color.new(48,96,216) + NAME_BASE_COLOR = Color.new(72, 72, 72) + NAME_SHADOW_COLOR = Color.new(184, 184, 184) + MALE_BASE_COLOR = Color.new(48, 96, 216) MALE_SHADOW_COLOR = NAME_SHADOW_COLOR - FEMALE_BASE_COLOR = Color.new(248,88,40) + FEMALE_BASE_COLOR = Color.new(248, 88, 40) FEMALE_SHADOW_COLOR = NAME_SHADOW_COLOR - def initialize(battler,sideSize,viewport = nil) + def initialize(battler, sideSize, viewport = nil) super(viewport) @battler = battler @sprites = {} @@ -39,18 +39,18 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper end def initializeDataBoxGraphic(sideSize) - onPlayerSide = ((@battler.index%2)==0) + onPlayerSide = ((@battler.index % 2) == 0) # Get the data box graphic and set whether the HP numbers/Exp bar are shown - if sideSize==1 # One Pokémon on side, use the regular dara box BG + if sideSize == 1 # One Pokémon on side, use the regular dara box BG bgFilename = ["Graphics/Pictures/Battle/databox_normal", - "Graphics/Pictures/Battle/databox_normal_foe"][@battler.index%2] + "Graphics/Pictures/Battle/databox_normal_foe"][@battler.index % 2] if onPlayerSide @showHP = true @showExp = true end else # Multiple Pokémon on side, use the thin dara box BG bgFilename = ["Graphics/Pictures/Battle/databox_thin", - "Graphics/Pictures/Battle/databox_thin_foe"][@battler.index%2] + "Graphics/Pictures/Battle/databox_thin_foe"][@battler.index % 2] end @databoxBitmap.dispose if @databoxBitmap @databoxBitmap = AnimatedBitmap.new(bgFilename) @@ -80,23 +80,23 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper @hpBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_hp")) @expBarBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/overlay_exp")) # Create sprite to draw HP numbers on - @hpNumbers = BitmapSprite.new(124,16,viewport) + @hpNumbers = BitmapSprite.new(124, 16, viewport) pbSetSmallFont(@hpNumbers.bitmap) @sprites["hpNumbers"] = @hpNumbers # Create sprite wrapper that displays HP bar @hpBar = SpriteWrapper.new(viewport) @hpBar.bitmap = @hpBarBitmap.bitmap - @hpBar.src_rect.height = @hpBarBitmap.height/3 + @hpBar.src_rect.height = @hpBarBitmap.height / 3 @sprites["hpBar"] = @hpBar # Create sprite wrapper that displays Exp bar @expBar = SpriteWrapper.new(viewport) @expBar.bitmap = @expBarBitmap.bitmap @sprites["expBar"] = @expBar # Create sprite wrapper that displays everything except the above - @contents = BitmapWrapper.new(@databoxBitmap.width,@databoxBitmap.height) + @contents = BitmapWrapper.new(@databoxBitmap.width, @databoxBitmap.height) self.bitmap = @contents self.visible = false - self.z = 150+((@battler.index)/2)*5 + self.z = 150 + ((@battler.index) / 2) * 5 pbSetSystemFont(self.bitmap) end @@ -112,23 +112,23 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper def x=(value) super - @hpBar.x = value+@spriteBaseX+102 - @expBar.x = value+@spriteBaseX+6 - @hpNumbers.x = value+@spriteBaseX+80 + @hpBar.x = value + @spriteBaseX + 102 + @expBar.x = value + @spriteBaseX + 6 + @hpNumbers.x = value + @spriteBaseX + 80 end def y=(value) super - @hpBar.y = value+40 - @expBar.y = value+74 - @hpNumbers.y = value+52 + @hpBar.y = value + 40 + @expBar.y = value + 74 + @hpNumbers.y = value + 52 end def z=(value) super - @hpBar.z = value+1 - @expBar.z = value+1 - @hpNumbers.z = value+2 + @hpBar.z = value + 1 + @expBar.z = value + 1 + @hpNumbers.z = value + 2 end def opacity=(value) @@ -164,43 +164,43 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper def exp_fraction return 0.0 if @rangeExp == 0 - return (@animatingExp) ? @currentExp.to_f/@rangeExp : @battler.pokemon.exp_fraction + return (@animatingExp) ? @currentExp.to_f / @rangeExp : @battler.pokemon.exp_fraction end - def animateHP(oldHP,newHP,rangeHP) + def animateHP(oldHP, newHP, rangeHP) @currentHP = oldHP @endHP = newHP @rangeHP = rangeHP # NOTE: A change in HP takes the same amount of time to animate, no matter # how big a change it is. - @hpIncPerFrame = (newHP-oldHP).abs/(HP_BAR_CHANGE_TIME*Graphics.frame_rate) + @hpIncPerFrame = (newHP - oldHP).abs / (HP_BAR_CHANGE_TIME * Graphics.frame_rate) # minInc is the smallest amount that HP is allowed to change per frame. # This avoids a tiny change in HP still taking HP_BAR_CHANGE_TIME seconds. - minInc = (rangeHP*4)/(@hpBarBitmap.width*HP_BAR_CHANGE_TIME*Graphics.frame_rate) - @hpIncPerFrame = minInc if @hpIncPerFrame116 - textPos.push([@battler.name,@spriteBaseX+8-nameOffset,0,false,NAME_BASE_COLOR,NAME_SHADOW_COLOR]) + nameOffset = nameWidth - 116 if nameWidth > 116 + textPos.push([@battler.name, @spriteBaseX + 8 - nameOffset, 0, false, NAME_BASE_COLOR, NAME_SHADOW_COLOR]) # Draw Pokémon's gender symbol case @battler.displayGender when 0 # Male - textPos.push([_INTL("♂"),@spriteBaseX+126,0,false,MALE_BASE_COLOR,MALE_SHADOW_COLOR]) + textPos.push([_INTL("♂"), @spriteBaseX + 126, 0, false, MALE_BASE_COLOR, MALE_SHADOW_COLOR]) when 1 # Female - textPos.push([_INTL("♀"),@spriteBaseX+126,0,false,FEMALE_BASE_COLOR,FEMALE_SHADOW_COLOR]) + textPos.push([_INTL("♀"), @spriteBaseX + 126, 0, false, FEMALE_BASE_COLOR, FEMALE_SHADOW_COLOR]) end - pbDrawTextPositions(self.bitmap,textPos) + pbDrawTextPositions(self.bitmap, textPos) # Draw Pokémon's level - imagePos.push(["Graphics/Pictures/Battle/overlay_lv",@spriteBaseX+140,16]) - pbDrawNumber(@battler.level,self.bitmap,@spriteBaseX+162,16) + imagePos.push(["Graphics/Pictures/Battle/overlay_lv", @spriteBaseX + 140, 16]) + pbDrawNumber(@battler.level, self.bitmap, @spriteBaseX + 162, 16) # Draw shiny icon if @battler.shiny? shinyX = (@battler.opposes?(0)) ? 206 : -6 # Foe's/player's - imagePos.push(["Graphics/Pictures/shiny",@spriteBaseX+shinyX,36]) + imagePos.push(["Graphics/Pictures/shiny", @spriteBaseX + shinyX, 36]) end # Draw Mega Evolution/Primal Reversion icon if @battler.mega? - imagePos.push(["Graphics/Pictures/Battle/icon_mega",@spriteBaseX+8,34]) + imagePos.push(["Graphics/Pictures/Battle/icon_mega", @spriteBaseX + 8, 34]) elsif @battler.primal? primalX = (@battler.opposes?) ? 208 : -28 # Foe's/player's if @battler.isSpecies?(:KYOGRE) - imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre",@spriteBaseX+primalX,4]) + imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre", @spriteBaseX + primalX, 4]) elsif @battler.isSpecies?(:GROUDON) - imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon",@spriteBaseX+primalX,4]) + imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon", @spriteBaseX + primalX, 4]) end end # Draw owned icon (foe Pokémon only) if @battler.owned? && @battler.opposes?(0) - imagePos.push(["Graphics/Pictures/Battle/icon_own",@spriteBaseX+8,36]) + imagePos.push(["Graphics/Pictures/Battle/icon_own", @spriteBaseX + 8, 36]) end # Draw status icon if @battler.status != :NONE @@ -255,10 +255,10 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper else s = GameData::Status.get(@battler.status).icon_position end - imagePos.push(["Graphics/Pictures/Battle/icon_statuses",@spriteBaseX+24,36, + imagePos.push(["Graphics/Pictures/Battle/icon_statuses", @spriteBaseX + 24, 36, 0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT]) if s >= 0 end - pbDrawImagePositions(self.bitmap,imagePos) + pbDrawImagePositions(self.bitmap, imagePos) refreshHP refreshExp end @@ -268,24 +268,24 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper return if !@battler.pokemon # Show HP numbers if @showHP - pbDrawNumber(self.hp,@hpNumbers.bitmap,54,2,1) - pbDrawNumber(-1,@hpNumbers.bitmap,54,2) # / char - pbDrawNumber(@battler.totalhp,@hpNumbers.bitmap,70,2) + pbDrawNumber(self.hp, @hpNumbers.bitmap, 54, 2, 1) + pbDrawNumber(-1, @hpNumbers.bitmap, 54, 2) # / char + pbDrawNumber(@battler.totalhp, @hpNumbers.bitmap, 70, 2) end # Resize HP bar w = 0 - if self.hp>0 - w = @hpBarBitmap.width.to_f*self.hp/@battler.totalhp - w = 1 if w<1 + if self.hp > 0 + w = @hpBarBitmap.width.to_f * self.hp / @battler.totalhp + w = 1 if w < 1 # NOTE: The line below snaps the bar's width to the nearest 2 pixels, to # fit in with the rest of the graphics which are doubled in size. - w = ((w/2.0).round)*2 + w = ((w / 2.0).round) * 2 end @hpBar.src_rect.width = w hpColor = 0 # Green bar - hpColor = 1 if self.hp<=@battler.totalhp/2 # Yellow bar - hpColor = 2 if self.hp<=@battler.totalhp/4 # Red bar - @hpBar.src_rect.y = hpColor*@hpBarBitmap.height/3 + hpColor = 1 if self.hp <= @battler.totalhp / 2 # Yellow bar + hpColor = 2 if self.hp <= @battler.totalhp / 4 # Red bar + @hpBar.src_rect.y = hpColor * @hpBarBitmap.height / 3 end def refreshExp @@ -293,22 +293,22 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper w = exp_fraction * @expBarBitmap.width # NOTE: The line below snaps the bar's width to the nearest 2 pixels, to # fit in with the rest of the graphics which are doubled in size. - w = ((w/2).round)*2 + w = ((w / 2).round) * 2 @expBar.src_rect.width = w end def updateHPAnimation return if !@animatingHP - if @currentHP<@endHP # Gaining HP + if @currentHP < @endHP # Gaining HP @currentHP += @hpIncPerFrame - @currentHP = @endHP if @currentHP>=@endHP - elsif @currentHP>@endHP # Losing HP + @currentHP = @endHP if @currentHP >= @endHP + elsif @currentHP > @endHP # Losing HP @currentHP -= @hpIncPerFrame - @currentHP = @endHP if @currentHP<=@endHP + @currentHP = @endHP if @currentHP <= @endHP end # Refresh the HP bar/numbers refreshHP - @animatingHP = false if @currentHP==@endHP + @animatingHP = false if @currentHP == @endHP end def updateExpAnimation @@ -318,29 +318,29 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper @animatingExp = false return end - if @currentExp<@endExp # Gaining Exp + if @currentExp < @endExp # Gaining Exp @currentExp += @expIncPerFrame - @currentExp = @endExp if @currentExp>=@endExp - elsif @currentExp>@endExp # Losing Exp + @currentExp = @endExp if @currentExp >= @endExp + elsif @currentExp > @endExp # Losing Exp @currentExp -= @expIncPerFrame - @currentExp = @endExp if @currentExp<=@endExp + @currentExp = @endExp if @currentExp <= @endExp end # Refresh the Exp bar refreshExp - return if @currentExp!=@endExp # Exp bar still has more to animate + return if @currentExp != @endExp # Exp bar still has more to animate # Exp bar is completely filled, level up with a flash and sound effect - if @currentExp>=@rangeExp - if @expFlash==0 + if @currentExp >= @rangeExp + if @expFlash == 0 pbSEStop - @expFlash = Graphics.frame_rate/5 + @expFlash = Graphics.frame_rate / 5 pbSEPlay("Pkmn exp full") - self.flash(Color.new(64,200,248,192),@expFlash) + self.flash(Color.new(64, 200, 248, 192), @expFlash) for i in @sprites - i[1].flash(Color.new(64,200,248,192),@expFlash) if !i[1].disposed? + i[1].flash(Color.new(64, 200, 248, 192), @expFlash) if !i[1].disposed? end else @expFlash -= 1 - @animatingExp = false if @expFlash==0 + @animatingExp = false if @expFlash == 0 end else pbSEStop @@ -349,16 +349,16 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper end end - QUARTER_ANIM_PERIOD = Graphics.frame_rate*3/20 + QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20 def updatePositions(frameCounter) self.x = @spriteX self.y = @spriteY # Data box bobbing while Pokémon is selected - if @selected==1 || @selected==2 # Choosing commands/targeted or damaged - case (frameCounter/QUARTER_ANIM_PERIOD).floor - when 1 then self.y = @spriteY-2 - when 3 then self.y = @spriteY+2 + if @selected == 1 || @selected == 2 # Choosing commands/targeted or damaged + case (frameCounter / QUARTER_ANIM_PERIOD).floor + when 1 then self.y = @spriteY - 2 + when 3 then self.y = @spriteY + 2 end end end @@ -383,10 +383,10 @@ end class Battle::Scene::AbilitySplashBar < SpriteWrapper attr_reader :battler - TEXT_BASE_COLOR = Color.new(0,0,0) - TEXT_SHADOW_COLOR = Color.new(248,248,248) + TEXT_BASE_COLOR = Color.new(0, 0, 0) + TEXT_SHADOW_COLOR = Color.new(248, 248, 248) - def initialize(side,viewport = nil) + def initialize(side, viewport = nil) super(viewport) @side = side @battler = nil @@ -394,15 +394,15 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper @bgBitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Battle/ability_bar")) @bgSprite = SpriteWrapper.new(viewport) @bgSprite.bitmap = @bgBitmap.bitmap - @bgSprite.src_rect.y = (side==0) ? 0 : @bgBitmap.height/2 - @bgSprite.src_rect.height = @bgBitmap.height/2 + @bgSprite.src_rect.y = (side == 0) ? 0 : @bgBitmap.height / 2 + @bgSprite.src_rect.height = @bgBitmap.height / 2 # Create bitmap that displays the text - @contents = BitmapWrapper.new(@bgBitmap.width,@bgBitmap.height/2) + @contents = BitmapWrapper.new(@bgBitmap.width, @bgBitmap.height / 2) self.bitmap = @contents pbSetSystemFont(self.bitmap) # Position the bar - self.x = (side==0) ? -Graphics.width/2 : Graphics.width - self.y = (side==0) ? 180 : 80 + self.x = (side == 0) ? -Graphics.width / 2 : Graphics.width + self.y = (side == 0) ? 180 : 80 self.z = 120 self.visible = false end @@ -426,7 +426,7 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper def z=(value) super - @bgSprite.z = value-1 + @bgSprite.z = value - 1 end def opacity=(value) @@ -453,14 +453,14 @@ class Battle::Scene::AbilitySplashBar < SpriteWrapper self.bitmap.clear return if !@battler textPos = [] - textX = (@side==0) ? 10 : self.bitmap.width-8 + textX = (@side == 0) ? 10 : self.bitmap.width - 8 # Draw Pokémon's name - textPos.push([_INTL("{1}'s",@battler.name),textX,-4,@side==1, - TEXT_BASE_COLOR,TEXT_SHADOW_COLOR,true]) + textPos.push([_INTL("{1}'s", @battler.name), textX, -4, @side == 1, + TEXT_BASE_COLOR, TEXT_SHADOW_COLOR, true]) # Draw Pokémon's ability - textPos.push([@battler.abilityName,textX,26,@side==1, - TEXT_BASE_COLOR,TEXT_SHADOW_COLOR,true]) - pbDrawTextPositions(self.bitmap,textPos) + textPos.push([@battler.abilityName, textX, 26, @side == 1, + TEXT_BASE_COLOR, TEXT_SHADOW_COLOR, true]) + pbDrawTextPositions(self.bitmap, textPos) end def update @@ -480,7 +480,7 @@ class Battle::Scene::BattlerSprite < RPG::Sprite attr_accessor :selected attr_reader :sideSize - def initialize(viewport,sideSize,index,battleAnimations) + def initialize(viewport, sideSize, index, battleAnimations) super(viewport) @pkmn = nil @sideSize = sideSize @@ -511,12 +511,12 @@ class Battle::Scene::BattlerSprite < RPG::Sprite def x=(value) @spriteX = value - super(value+@spriteXExtra) + super(value + @spriteXExtra) end def y=(value) @spriteY = value - super(value+@spriteYExtra) + super(value + @spriteYExtra) end def width; return (self.bitmap) ? self.bitmap.width : 0; end @@ -530,27 +530,27 @@ class Battle::Scene::BattlerSprite < RPG::Sprite # Set sprite's origin to bottom middle def pbSetOrigin return if !@_iconBitmap - self.ox = @_iconBitmap.width/2 + self.ox = @_iconBitmap.width / 2 self.oy = @_iconBitmap.height end def pbSetPosition return if !@_iconBitmap pbSetOrigin - if (@index%2)==0 - self.z = 50+5*@index/2 + if (@index % 2) == 0 + self.z = 50 + 5 * @index / 2 else - self.z = 50-5*(@index+1)/2 + self.z = 50 - 5 * (@index + 1) / 2 end # Set original position - p = Battle::Scene.pbBattlerPosition(@index,@sideSize) + p = Battle::Scene.pbBattlerPosition(@index, @sideSize) @spriteX = p[0] @spriteY = p[1] # Apply metrics @pkmn.species_data.apply_metrics_to_sprite(self, @index) end - def setPokemonBitmap(pkmn,back = false) + def setPokemonBitmap(pkmn, back = false) @pkmn = pkmn @_iconBitmap.dispose if @_iconBitmap @_iconBitmap = GameData::Species.sprite_bitmap_from_pokemon(@pkmn, back) @@ -566,8 +566,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite @pkmn.play_cry if @pkmn end - QUARTER_ANIM_PERIOD = Graphics.frame_rate*3/20 - SIXTH_ANIM_PERIOD = Graphics.frame_rate*2/20 + QUARTER_ANIM_PERIOD = Graphics.frame_rate * 3 / 20 + SIXTH_ANIM_PERIOD = Graphics.frame_rate * 2 / 20 def update(frameCounter = 0) return if !@_iconBitmap @@ -577,8 +577,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite self.bitmap = @_iconBitmap.bitmap # Pokémon sprite bobbing while Pokémon is selected @spriteYExtra = 0 - if @selected==1 # When choosing commands for this Pokémon - case (frameCounter/QUARTER_ANIM_PERIOD).floor + if @selected == 1 # When choosing commands for this Pokémon + case (frameCounter / QUARTER_ANIM_PERIOD).floor when 1 then @spriteYExtra = 2 when 3 then @spriteYExtra = -2 end @@ -587,8 +587,8 @@ class Battle::Scene::BattlerSprite < RPG::Sprite self.y = self.y self.visible = @spriteVisible # Pokémon sprite blinking when targeted - if @selected==2 && @spriteVisible - case (frameCounter/SIXTH_ANIM_PERIOD).floor + if @selected == 2 && @spriteVisible + case (frameCounter / SIXTH_ANIM_PERIOD).floor when 2, 5 then self.visible = false else self.visible = true end @@ -607,7 +607,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite attr_accessor :index attr_accessor :selected - def initialize(viewport,sideSize,index) + def initialize(viewport, sideSize, index) super(viewport) @pkmn = nil @sideSize = sideSize @@ -629,8 +629,8 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite # Set sprite's origin to centre def pbSetOrigin return if !@_iconBitmap - self.ox = @_iconBitmap.width/2 - self.oy = @_iconBitmap.height/2 + self.ox = @_iconBitmap.width / 2 + self.oy = @_iconBitmap.height / 2 end def pbSetPosition @@ -638,7 +638,7 @@ class Battle::Scene::BattlerShadowSprite < RPG::Sprite pbSetOrigin self.z = 3 # Set original position - p = Battle::Scene.pbBattlerPosition(@index,@sideSize) + p = Battle::Scene.pbBattlerPosition(@index, @sideSize) self.x = p[0] self.y = p[1] # Apply metrics diff --git a/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb b/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb index 6cecd12c8..7eff14012 100644 --- a/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb +++ b/Data/Scripts/011_Battle/004_Scene/007_Battle_Scene_BaseAnimation.rb @@ -1,5 +1,5 @@ class Battle::Scene::Animation - def initialize(sprites,viewport) + def initialize(sprites, viewport) @sprites = sprites @viewport = viewport @pictureEx = [] # For all the PictureEx @@ -14,10 +14,10 @@ class Battle::Scene::Animation end def createProcesses; end - def empty?; return @pictureEx.length==0; end + def empty?; return @pictureEx.length == 0; end def animDone?; return @animDone; end - def addSprite(s,origin = PictureOrigin::TopLeft) + def addSprite(s, origin = PictureOrigin::TopLeft) num = @pictureEx.length picture = PictureEx.new(s.z) picture.x = s.x @@ -25,20 +25,20 @@ class Battle::Scene::Animation picture.visible = s.visible picture.color = s.color.clone picture.tone = s.tone.clone - picture.setOrigin(0,origin) + picture.setOrigin(0, origin) @pictureEx[num] = picture @pictureSprites[num] = s return picture end - def addNewSprite(x,y,name,origin = PictureOrigin::TopLeft) + def addNewSprite(x, y, name, origin = PictureOrigin::TopLeft) num = @pictureEx.length picture = PictureEx.new(num) - picture.setXY(0,x,y) - picture.setName(0,name) - picture.setOrigin(0,origin) + picture.setXY(0, x, y) + picture.setName(0, name) + picture.setOrigin(0, origin) @pictureEx[num] = picture - s = IconSprite.new(x,y,@viewport) + s = IconSprite.new(x, y, @viewport) s.setBitmap(name) @pictureSprites[num] = s @tempSprites.push(s) @@ -49,11 +49,11 @@ class Battle::Scene::Animation return if @animDone @tempSprites.each { |s| s.update if s } finished = true - @pictureEx.each_with_index do |p,i| + @pictureEx.each_with_index do |p, i| next if !p.running? finished = false p.update - setPictureIconSprite(@pictureSprites[i],p) + setPictureIconSprite(@pictureSprites[i], p) end @animDone = true if finished end @@ -96,110 +96,110 @@ module Battle::Scene::Animation::BallAnimationMixin return ball end - def ballTracksHand(ball,traSprite,safariThrow = false) + def ballTracksHand(ball, traSprite, safariThrow = false) # Back sprite isn't animated, no hand-tracking needed - if traSprite.bitmap.width=@ballSprite.bitmap.height + if @ballSprite && @ballSprite.bitmap.width >= @ballSprite.bitmap.height # 2* because each frame is twice as tall as it is wide - numFrames = 2*@ballSprite.bitmap.width/@ballSprite.bitmap.height + numFrames = 2 * @ballSprite.bitmap.width / @ballSprite.bitmap.height end - if numFrames>1 + if numFrames > 1 curFrame = 0 for i in 1..duration - thisFrame = numFrames*numTumbles*i/duration - if thisFrame>curFrame + thisFrame = numFrames * numTumbles * i / duration + if thisFrame > curFrame curFrame = thisFrame - ball.setSrc(delay+i-1,(curFrame%numFrames)*@ballSprite.bitmap.height/2,0) + ball.setSrc(delay + i - 1, (curFrame % numFrames) * @ballSprite.bitmap.height / 2, 0) end end - ball.setSrc(delay+duration,0,0) + ball.setSrc(delay + duration, 0, 0) end # Rotate ball - ball.moveAngle(delay,duration,360*3) - ball.setAngle(delay+duration,0) + ball.moveAngle(delay, duration, 360 * 3) + ball.setAngle(delay + duration, 0) end def ballSetOpen(ball, delay, poke_ball) @@ -228,24 +228,24 @@ module Battle::Scene::Animation::BallAnimationMixin ballSetOpen(ball, delay, poke_ball) end - def battlerAppear(battler,delay,battlerX,battlerY,batSprite,color) - battler.setVisible(delay,true) - battler.setOpacity(delay,255) - battler.moveXY(delay,5,battlerX,battlerY) - battler.moveZoom(delay,5,100,[batSprite,:pbPlayIntroAnimation]) + def battlerAppear(battler, delay, battlerX, battlerY, batSprite, color) + battler.setVisible(delay, true) + battler.setOpacity(delay, 255) + battler.moveXY(delay, 5, battlerX, battlerY) + battler.moveZoom(delay, 5, 100, [batSprite, :pbPlayIntroAnimation]) # NOTE: As soon as the battler sprite finishes zooming, and just as it # starts changing its tone to normal, it plays its intro animation. color.alpha = 0 - battler.moveColor(delay+5,10,color) + battler.moveColor(delay + 5, 10, color) end - def battlerAbsorb(battler,delay,battlerX,battlerY,color) + def battlerAbsorb(battler, delay, battlerX, battlerY, color) color.alpha = 255 - battler.moveColor(delay,10,color) + battler.moveColor(delay, 10, color) delay = battler.totalDuration - battler.moveXY(delay,5,battlerX,battlerY) - battler.moveZoom(delay,5,0) - battler.setVisible(delay+5,false) + battler.moveXY(delay, 5, battlerX, battlerY) + battler.moveZoom(delay, 5, 0) + battler.setVisible(delay + 5, false) end # The regular Poké Ball burst animation. diff --git a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb index fb36c64f0..b2d24dedd 100644 --- a/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb +++ b/Data/Scripts/011_Battle/004_Scene/008_Battle_Scene_Animations.rb @@ -2,58 +2,58 @@ # Shows the battle scene fading in while elements slide around into place #=============================================================================== class Battle::Scene::Animation::Intro < Battle::Scene::Animation - def initialize(sprites,viewport,battle) + def initialize(sprites, viewport, battle) @battle = battle - super(sprites,viewport) + super(sprites, viewport) end def createProcesses appearTime = 20 # This is in 1/20 seconds # Background if @sprites["battle_bg2"] - makeSlideSprite("battle_bg",0.5,appearTime) - makeSlideSprite("battle_bg2",0.5,appearTime) + makeSlideSprite("battle_bg", 0.5, appearTime) + makeSlideSprite("battle_bg2", 0.5, appearTime) end # Bases - makeSlideSprite("base_0",1,appearTime,PictureOrigin::Bottom) - makeSlideSprite("base_1",-1,appearTime,PictureOrigin::Center) + 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| - makeSlideSprite("player_#{i+1}",1,appearTime,PictureOrigin::Bottom) + @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| - makeSlideSprite("trainer_#{i+1}",-1,appearTime,PictureOrigin::Bottom) + @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| - idxBattler = 2*i+1 - makeSlideSprite("pokemon_#{idxBattler}",-1,appearTime,PictureOrigin::Bottom) + @battle.pbParty(1).each_with_index do |_pkmn, i| + idxBattler = 2 * i + 1 + makeSlideSprite("pokemon_#{idxBattler}", -1, appearTime, PictureOrigin::Bottom) end end # Shadows for i in 0...@battle.battlers.length - makeSlideSprite("shadow_#{i}",((i%2)==0) ? 1 : -1,appearTime,PictureOrigin::Center) + makeSlideSprite("shadow_#{i}", ((i % 2) == 0) ? 1 : -1, appearTime, PictureOrigin::Center) end # Fading blackness over whole screen - blackScreen = addNewSprite(0,0,"Graphics/Battle animations/black_screen") - blackScreen.setZ(0,999) - blackScreen.moveOpacity(0,8,0) + blackScreen = addNewSprite(0, 0, "Graphics/Battle animations/black_screen") + blackScreen.setZ(0, 999) + blackScreen.moveOpacity(0, 8, 0) # Fading blackness over command bar - blackBar = addNewSprite(@sprites["cmdBar_bg"].x,@sprites["cmdBar_bg"].y, + blackBar = addNewSprite(@sprites["cmdBar_bg"].x, @sprites["cmdBar_bg"].y, "Graphics/Battle animations/black_bar") - blackBar.setZ(0,998) - blackBar.moveOpacity(appearTime*3/4,appearTime/4,0) + blackBar.setZ(0, 998) + blackBar.moveOpacity(appearTime * 3 / 4, appearTime / 4, 0) end - def makeSlideSprite(spriteName,deltaMult,appearTime,origin = nil) + def makeSlideSprite(spriteName, deltaMult, appearTime, origin = nil) # If deltaMult is positive, the sprite starts off to the right and moves # left (for sprites on the player's side and the background). return if !@sprites[spriteName] - s = addSprite(@sprites[spriteName],origin) - s.setDelta(0,(Graphics.width*deltaMult).floor,0) - s.moveDelta(0,appearTime,(-Graphics.width*deltaMult).floor,0) + s = addSprite(@sprites[spriteName], origin) + s.setDelta(0, (Graphics.width * deltaMult).floor, 0) + s.moveDelta(0, appearTime, (-Graphics.width * deltaMult).floor, 0) end end @@ -64,18 +64,18 @@ end # animations #=============================================================================== class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation - def initialize(sprites,viewport,sideSize) + def initialize(sprites, viewport, sideSize) @sideSize = sideSize - super(sprites,viewport) + super(sprites, viewport) end def createProcesses for i in 0...@sideSize - idxBattler = 2*i+1 + idxBattler = 2 * i + 1 next if !@sprites["pokemon_#{idxBattler}"] - battler = addSprite(@sprites["pokemon_#{idxBattler}"],PictureOrigin::Bottom) - battler.moveTone(0,4,Tone.new(0,0,0,0)) - battler.setCallback(10*i,[@sprites["pokemon_#{idxBattler}"],:pbPlayIntroAnimation]) + battler = addSprite(@sprites["pokemon_#{idxBattler}"], PictureOrigin::Bottom) + battler.moveTone(0, 4, Tone.new(0, 0, 0, 0)) + battler.setCallback(10 * i, [@sprites["pokemon_#{idxBattler}"], :pbPlayIntroAnimation]) end end end @@ -88,13 +88,13 @@ end class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation BAR_DISPLAY_WIDTH = 248 - def initialize(sprites,viewport,side,party,partyStarts,fullAnim) + def initialize(sprites, viewport, side, party, partyStarts, fullAnim) @side = side @party = party @partyStarts = partyStarts @fullAnim = fullAnim # True at start of battle, false when switching resetGraphics(sprites) - super(sprites,viewport) + super(sprites, viewport) end def resetGraphics(sprites) @@ -110,9 +110,9 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation barY = 114 ballX = barX - 44 - 30 # 30 is width of ball icon ballY = barY - 30 - barX -= bar.bitmap.width + barX -= bar.bitmap.width end - ballXdiff = 32*(1-2*@side) + ballXdiff = 32 * (1 - 2 * @side) bar.x = barX bar.y = barY bar.opacity = 255 @@ -129,41 +129,41 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation def getPartyIndexFromBallIndex(idxBall) # Player's lineup (just show balls for player's party) - if @side==0 - return idxBall if @partyStarts.length<2 - return idxBall if idxBall<@partyStarts[1] + if @side == 0 + return idxBall if @partyStarts.length < 2 + return idxBall if idxBall < @partyStarts[1] return -1 end # Opposing lineup # NOTE: This doesn't work well for 4+ opposing trainers. - ballsPerTrainer = Battle::Scene::NUM_BALLS/@partyStarts.length # 6/3/2 - startsIndex = idxBall/ballsPerTrainer - teamIndex = idxBall%ballsPerTrainer - ret = @partyStarts[startsIndex]+teamIndex - if startsIndex<@partyStarts.length-1 + ballsPerTrainer = Battle::Scene::NUM_BALLS / @partyStarts.length # 6/3/2 + startsIndex = idxBall / ballsPerTrainer + teamIndex = idxBall % ballsPerTrainer + ret = @partyStarts[startsIndex] + teamIndex + if startsIndex < @partyStarts.length - 1 # There is a later trainer, don't spill over into its team - return -1 if ret>=@partyStarts[startsIndex+1] + return -1 if ret >= @partyStarts[startsIndex + 1] end return ret end def createProcesses bar = addSprite(@sprites["partyBar_#{@side}"]) - bar.setVisible(0,true) - dir = (@side==0) ? 1 : -1 - bar.setDelta(0,dir*Graphics.width/2,0) - bar.moveDelta(0,8,-dir*Graphics.width/2,0) + bar.setVisible(0, true) + dir = (@side == 0) ? 1 : -1 + bar.setDelta(0, dir * Graphics.width / 2, 0) + bar.moveDelta(0, 8, -dir * Graphics.width / 2, 0) delay = bar.totalDuration for i in 0...Battle::Scene::NUM_BALLS - createBall(i,(@fullAnim) ? delay+i*2 : 0,dir) + createBall(i, (@fullAnim) ? delay + i * 2 : 0, dir) end end - def createBall(idxBall,delay,dir) + def createBall(idxBall, delay, dir) # Choose ball's graphic idxParty = getPartyIndexFromBallIndex(idxBall) - graphicFilename = "Graphics/Pictures/Battle/icon_ball_empty" - if idxParty>=0 && idxParty<@party.length && @party[idxParty] + graphicFilename = "Graphics/Pictures/Battle/icon_ball_empty" + if idxParty >= 0 && idxParty < @party.length && @party[idxParty] if !@party[idxParty].able? graphicFilename = "Graphics/Pictures/Battle/icon_ball_faint" elsif @party[idxParty].status != :NONE @@ -174,10 +174,10 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation end # Set up ball sprite ball = addSprite(@sprites["partyBall_#{@side}_#{idxBall}"]) - ball.setVisible(delay,true) - ball.setName(delay,graphicFilename) - ball.setDelta(delay,dir*Graphics.width/2,0) - ball.moveDelta(delay,8,-dir*Graphics.width/2,0) + ball.setVisible(delay, true) + ball.setName(delay, graphicFilename) + ball.setDelta(delay, dir * Graphics.width / 2, 0) + ball.moveDelta(delay, 8, -dir * Graphics.width / 2, 0) end end @@ -187,18 +187,18 @@ end # Makes a Pokémon's data box appear #=============================================================================== class Battle::Scene::Animation::DataBoxAppear < Battle::Scene::Animation - def initialize(sprites,viewport,idxBox) + def initialize(sprites, viewport, idxBox) @idxBox = idxBox - super(sprites,viewport) + super(sprites, viewport) end def createProcesses return if !@sprites["dataBox_#{@idxBox}"] box = addSprite(@sprites["dataBox_#{@idxBox}"]) - box.setVisible(0,true) - dir = ((@idxBox%2)==0) ? 1 : -1 - box.setDelta(0,dir*Graphics.width/2,0) - box.moveDelta(0,8,-dir*Graphics.width/2,0) + box.setVisible(0, true) + dir = ((@idxBox % 2) == 0) ? 1 : -1 + box.setDelta(0, dir * Graphics.width / 2, 0) + box.moveDelta(0, 8, -dir * Graphics.width / 2, 0) end end @@ -208,17 +208,17 @@ end # Makes a Pokémon's data box disappear #=============================================================================== class Battle::Scene::Animation::DataBoxDisappear < Battle::Scene::Animation - def initialize(sprites,viewport,idxBox) + def initialize(sprites, viewport, idxBox) @idxBox = idxBox - super(sprites,viewport) + super(sprites, viewport) end def createProcesses return if !@sprites["dataBox_#{@idxBox}"] || !@sprites["dataBox_#{@idxBox}"].visible box = addSprite(@sprites["dataBox_#{@idxBox}"]) - dir = ((@idxBox%2)==0) ? 1 : -1 - box.moveDelta(0,8,dir*Graphics.width/2,0) - box.setVisible(8,false) + dir = ((@idxBox % 2) == 0) ? 1 : -1 + box.moveDelta(0, 8, dir * Graphics.width / 2, 0) + box.setVisible(8, false) end end @@ -228,17 +228,17 @@ end # Makes a Pokémon's ability bar appear #=============================================================================== class Battle::Scene::Animation::AbilitySplashAppear < Battle::Scene::Animation - def initialize(sprites,viewport,side) + def initialize(sprites, viewport, side) @side = side - super(sprites,viewport) + super(sprites, viewport) end def createProcesses return if !@sprites["abilityBar_#{@side}"] bar = addSprite(@sprites["abilityBar_#{@side}"]) - bar.setVisible(0,true) - dir = (@side==0) ? 1 : -1 - bar.moveDelta(0,8,dir*Graphics.width/2,0) + bar.setVisible(0, true) + dir = (@side == 0) ? 1 : -1 + bar.moveDelta(0, 8, dir * Graphics.width / 2, 0) end end @@ -248,17 +248,17 @@ end # Makes a Pokémon's ability bar disappear #=============================================================================== class Battle::Scene::Animation::AbilitySplashDisappear < Battle::Scene::Animation - def initialize(sprites,viewport,side) + def initialize(sprites, viewport, side) @side = side - super(sprites,viewport) + super(sprites, viewport) end def createProcesses return if !@sprites["abilityBar_#{@side}"] bar = addSprite(@sprites["abilityBar_#{@side}"]) - dir = (@side==0) ? -1 : 1 - bar.moveDelta(0,8,dir*Graphics.width/2,0) - bar.setVisible(8,false) + dir = (@side == 0) ? -1 : 1 + bar.moveDelta(0, 8, dir * Graphics.width / 2, 0) + bar.setVisible(8, false) end end @@ -270,28 +270,28 @@ end # Used at the end of battle. #=============================================================================== class Battle::Scene::Animation::TrainerAppear < Battle::Scene::Animation - def initialize(sprites,viewport,idxTrainer) + def initialize(sprites, viewport, idxTrainer) @idxTrainer = idxTrainer - super(sprites,viewport) + super(sprites, viewport) end def createProcesses delay = 0 # Make old trainer sprite move off-screen first if necessary - if @idxTrainer>0 && @sprites["trainer_#{@idxTrainer}"].visible - oldTrainer = addSprite(@sprites["trainer_#{@idxTrainer}"],PictureOrigin::Bottom) - oldTrainer.moveDelta(delay,8,Graphics.width/4,0) - oldTrainer.setVisible(delay+8,false) + if @idxTrainer > 0 && @sprites["trainer_#{@idxTrainer}"].visible + oldTrainer = addSprite(@sprites["trainer_#{@idxTrainer}"], PictureOrigin::Bottom) + oldTrainer.moveDelta(delay, 8, Graphics.width / 4, 0) + oldTrainer.setVisible(delay + 8, false) delay = oldTrainer.totalDuration end # Make new trainer sprite move on-screen - if @sprites["trainer_#{@idxTrainer+1}"] + if @sprites["trainer_#{@idxTrainer + 1}"] trainerX, trainerY = Battle::Scene.pbTrainerPosition(1) - trainerX += 64+Graphics.width/4 - newTrainer = addSprite(@sprites["trainer_#{@idxTrainer+1}"],PictureOrigin::Bottom) - newTrainer.setVisible(delay,true) - newTrainer.setXY(delay,trainerX,trainerY) - newTrainer.moveDelta(delay,8,-Graphics.width/4,0) + trainerX += 64 + Graphics.width / 4 + newTrainer = addSprite(@sprites["trainer_#{@idxTrainer + 1}"], PictureOrigin::Bottom) + newTrainer.setVisible(delay, true) + newTrainer.setXY(delay, trainerX, trainerY) + newTrainer.moveDelta(delay, 8, -Graphics.width / 4, 0) end end end @@ -304,9 +304,9 @@ end # Doesn't show the ball thrown or the Pokémon. #=============================================================================== class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation - def initialize(sprites,viewport,fullAnim = false) + def initialize(sprites, viewport, fullAnim = false) @fullAnim = fullAnim # True at start of battle, false when switching - super(sprites,viewport) + super(sprites, viewport) end def createProcesses @@ -314,38 +314,38 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation # Move trainer sprite(s) off-screen spriteNameBase = "player" i = 1 - while @sprites[spriteNameBase+"_#{i}"] - pl = @sprites[spriteNameBase+"_#{i}"] + while @sprites[spriteNameBase + "_#{i}"] + pl = @sprites[spriteNameBase + "_#{i}"] i += 1 - next if !pl.visible || pl.x<0 - trainer = addSprite(pl,PictureOrigin::Bottom) - trainer.moveDelta(0,16,-Graphics.width/2,0) + next if !pl.visible || pl.x < 0 + trainer = addSprite(pl, PictureOrigin::Bottom) + trainer.moveDelta(0, 16, -Graphics.width / 2, 0) # Animate trainer sprite(s) if they have multiple frames - if pl.bitmap && !pl.bitmap.disposed? && pl.bitmap.width>=pl.bitmap.height*2 + if pl.bitmap && !pl.bitmap.disposed? && pl.bitmap.width >= pl.bitmap.height * 2 size = pl.src_rect.width # Width per frame - trainer.setSrc(0,size,0) - trainer.setSrc(5,size*2,0) - trainer.setSrc(7,size*3,0) - trainer.setSrc(9,size*4,0) + trainer.setSrc(0, size, 0) + trainer.setSrc(5, size * 2, 0) + trainer.setSrc(7, size * 3, 0) + trainer.setSrc(9, size * 4, 0) end - trainer.setVisible(16,false) + trainer.setVisible(16, false) end # Move and fade party bar/balls delay = 3 if @sprites["partyBar_0"] && @sprites["partyBar_0"].visible partyBar = addSprite(@sprites["partyBar_0"]) - partyBar.moveDelta(delay,16,-Graphics.width/4,0) if @fullAnim - partyBar.moveOpacity(delay,12,0) - partyBar.setVisible(delay+12,false) - partyBar.setOpacity(delay+12,255) + partyBar.moveDelta(delay, 16, -Graphics.width / 4, 0) if @fullAnim + partyBar.moveOpacity(delay, 12, 0) + partyBar.setVisible(delay + 12, false) + partyBar.setOpacity(delay + 12, 255) end for i in 0...Battle::Scene::NUM_BALLS next if !@sprites["partyBall_0_#{i}"] || !@sprites["partyBall_0_#{i}"].visible partyBall = addSprite(@sprites["partyBall_0_#{i}"]) - partyBall.moveDelta(delay+2*i,16,-Graphics.width,0) if @fullAnim - partyBall.moveOpacity(delay,12,0) - partyBall.setVisible(delay+12,false) - partyBall.setOpacity(delay+12,255) + partyBall.moveDelta(delay + 2 * i, 16, -Graphics.width, 0) if @fullAnim + partyBall.moveOpacity(delay, 12, 0) + partyBall.setVisible(delay + 12, false) + partyBall.setOpacity(delay + 12, 255) end end end @@ -357,9 +357,9 @@ end # Doesn't show the ball thrown or the Pokémon. #=============================================================================== class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation - def initialize(sprites,viewport,fullAnim = false) + def initialize(sprites, viewport, fullAnim = false) @fullAnim = fullAnim # True at start of battle, false when switching - super(sprites,viewport) + super(sprites, viewport) end def createProcesses @@ -367,30 +367,30 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation # Move trainer sprite(s) off-screen spriteNameBase = "trainer" i = 1 - while @sprites[spriteNameBase+"_#{i}"] - trSprite = @sprites[spriteNameBase+"_#{i}"] + while @sprites[spriteNameBase + "_#{i}"] + trSprite = @sprites[spriteNameBase + "_#{i}"] i += 1 - next if !trSprite.visible || trSprite.x>Graphics.width - trainer = addSprite(trSprite,PictureOrigin::Bottom) - trainer.moveDelta(0,16,Graphics.width/2,0) - trainer.setVisible(16,false) + next if !trSprite.visible || trSprite.x > Graphics.width + trainer = addSprite(trSprite, PictureOrigin::Bottom) + trainer.moveDelta(0, 16, Graphics.width / 2, 0) + trainer.setVisible(16, false) end # Move and fade party bar/balls delay = 3 if @sprites["partyBar_1"] && @sprites["partyBar_1"].visible partyBar = addSprite(@sprites["partyBar_1"]) - partyBar.moveDelta(delay,16,Graphics.width/4,0) if @fullAnim - partyBar.moveOpacity(delay,12,0) - partyBar.setVisible(delay+12,false) - partyBar.setOpacity(delay+12,255) + partyBar.moveDelta(delay, 16, Graphics.width / 4, 0) if @fullAnim + partyBar.moveOpacity(delay, 12, 0) + partyBar.setVisible(delay + 12, false) + partyBar.setOpacity(delay + 12, 255) end for i in 0...Battle::Scene::NUM_BALLS next if !@sprites["partyBall_1_#{i}"] || !@sprites["partyBall_1_#{i}"].visible partyBall = addSprite(@sprites["partyBall_1_#{i}"]) - partyBall.moveDelta(delay+2*i,16,Graphics.width,0) if @fullAnim - partyBall.moveOpacity(delay,12,0) - partyBall.setVisible(delay+12,false) - partyBall.setOpacity(delay+12,255) + partyBall.moveDelta(delay + 2 * i, 16, Graphics.width, 0) if @fullAnim + partyBall.moveOpacity(delay, 12, 0) + partyBall.setVisible(delay + 12, false) + partyBall.setOpacity(delay + 12, 255) end end end @@ -404,7 +404,7 @@ end class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation include Battle::Scene::Animation::BallAnimationMixin - def initialize(sprites,viewport,idxTrainer,battler,startBattle,idxOrder = 0) + def initialize(sprites, viewport, idxTrainer, battler, startBattle, idxOrder = 0) @idxTrainer = idxTrainer @battler = battler @showingTrainer = startBattle @@ -413,7 +413,7 @@ class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation sprites["pokemon_#{battler.index}"].visible = false @shadowVisible = sprites["shadow_#{battler.index}"].visible sprites["shadow_#{battler.index}"].visible = false - super(sprites,viewport) + super(sprites, viewport) end def createProcesses @@ -426,7 +426,7 @@ class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation col = getBattlerColorFromPokeBall(poke_ball) col.alpha = 255 # Calculate start and end coordinates for battler sprite movement - ballPos = Battle::Scene.pbBattlerPosition(@battler.index,batSprite.sideSize) + ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize) battlerStartX = ballPos[0] # Is also where the Ball needs to end battlerStartY = ballPos[1] # Is also where the Ball needs to end + 18 battlerEndX = batSprite.x @@ -435,40 +435,40 @@ class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation ballStartX = -6 ballStartY = 202 ballMidX = 0 # Unused in trajectory calculation - ballMidY = battlerStartY-144 + ballMidY = battlerStartY - 144 # Set up Poké Ball sprite - ball = addBallSprite(ballStartX,ballStartY,poke_ball) - ball.setZ(0,25) - ball.setVisible(0,false) + ball = addBallSprite(ballStartX, ballStartY, poke_ball) + ball.setZ(0, 25) + ball.setVisible(0, false) # Poké Ball tracking the player's hand animation (if trainer is visible) - if @showingTrainer && traSprite && traSprite.x>0 - ball.setZ(0,traSprite.z-1) - ballStartX, ballStartY = ballTracksHand(ball,traSprite) + if @showingTrainer && traSprite && traSprite.x > 0 + ball.setZ(0, traSprite.z - 1) + ballStartX, ballStartY = ballTracksHand(ball, traSprite) end delay = ball.totalDuration # 0 or 7 # Poké Ball trajectory animation - createBallTrajectory(ball,delay,12, - ballStartX,ballStartY,ballMidX,ballMidY,battlerStartX,battlerStartY-18) - ball.setZ(9,batSprite.z-1) - delay = ball.totalDuration+4 - delay += 10*@idxOrder # Stagger appearances if multiple Pokémon are sent out at once - ballOpenUp(ball,delay-2,poke_ball) - ballBurst(delay,battlerStartX,battlerStartY-18,poke_ball) - ball.moveOpacity(delay+2,2,0) + createBallTrajectory(ball, delay, 12, + ballStartX, ballStartY, ballMidX, ballMidY, battlerStartX, battlerStartY - 18) + ball.setZ(9, batSprite.z - 1) + delay = ball.totalDuration + 4 + delay += 10 * @idxOrder # Stagger appearances if multiple Pokémon are sent out at once + ballOpenUp(ball, delay - 2, poke_ball) + ballBurst(delay, battlerStartX, battlerStartY - 18, poke_ball) + ball.moveOpacity(delay + 2, 2, 0) # Set up battler sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) - battler.setXY(0,battlerStartX,battlerStartY) - battler.setZoom(0,0) - battler.setColor(0,col) + battler = addSprite(batSprite, PictureOrigin::Bottom) + battler.setXY(0, battlerStartX, battlerStartY) + battler.setZoom(0, 0) + battler.setColor(0, col) # Battler animation - battlerAppear(battler,delay,battlerEndX,battlerEndY,batSprite,col) + battlerAppear(battler, delay, battlerEndX, battlerEndY, batSprite, col) if @shadowVisible # Set up shadow sprite - shadow = addSprite(shaSprite,PictureOrigin::Center) - shadow.setOpacity(0,0) + shadow = addSprite(shaSprite, PictureOrigin::Center) + shadow.setOpacity(0, 0) # Shadow animation - shadow.setVisible(delay,@shadowVisible) - shadow.moveOpacity(delay+5,10,255) + shadow.setVisible(delay, @shadowVisible) + shadow.moveOpacity(delay + 5, 10, 255) end end end @@ -483,7 +483,7 @@ end class Battle::Scene::Animation::PokeballTrainerSendOut < Battle::Scene::Animation include Battle::Scene::Animation::BallAnimationMixin - def initialize(sprites,viewport,idxTrainer,battler,startBattle,idxOrder) + def initialize(sprites, viewport, idxTrainer, battler, startBattle, idxOrder) @idxTrainer = idxTrainer @battler = battler @showingTrainer = startBattle @@ -491,7 +491,7 @@ class Battle::Scene::Animation::PokeballTrainerSendOut < Battle::Scene::Animatio sprites["pokemon_#{battler.index}"].visible = false @shadowVisible = sprites["shadow_#{battler.index}"].visible sprites["shadow_#{battler.index}"].visible = false - super(sprites,viewport) + super(sprites, viewport) end def createProcesses @@ -503,44 +503,44 @@ class Battle::Scene::Animation::PokeballTrainerSendOut < Battle::Scene::Animatio col = getBattlerColorFromPokeBall(poke_ball) col.alpha = 255 # Calculate start and end coordinates for battler sprite movement - ballPos = Battle::Scene.pbBattlerPosition(@battler.index,batSprite.sideSize) + ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize) battlerStartX = ballPos[0] battlerStartY = ballPos[1] battlerEndX = batSprite.x battlerEndY = batSprite.y # Set up Poké Ball sprite - ball = addBallSprite(0,0,poke_ball) - ball.setZ(0,batSprite.z-1) + ball = addBallSprite(0, 0, poke_ball) + ball.setZ(0, batSprite.z - 1) # Poké Ball animation - createBallTrajectory(ball,battlerStartX,battlerStartY) - delay = ball.totalDuration+6 + createBallTrajectory(ball, battlerStartX, battlerStartY) + delay = ball.totalDuration + 6 delay += 10 if @showingTrainer # Give time for trainer to slide off screen - delay += 10*@idxOrder # Stagger appearances if multiple Pokémon are sent out at once - ballOpenUp(ball,delay-2,poke_ball) - ballBurst(delay,battlerStartX,battlerStartY-18,poke_ball) - ball.moveOpacity(delay+2,2,0) + delay += 10 * @idxOrder # Stagger appearances if multiple Pokémon are sent out at once + ballOpenUp(ball, delay - 2, poke_ball) + ballBurst(delay, battlerStartX, battlerStartY - 18, poke_ball) + ball.moveOpacity(delay + 2, 2, 0) # Set up battler sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) - battler.setXY(0,battlerStartX,battlerStartY) - battler.setZoom(0,0) - battler.setColor(0,col) + battler = addSprite(batSprite, PictureOrigin::Bottom) + battler.setXY(0, battlerStartX, battlerStartY) + battler.setZoom(0, 0) + battler.setColor(0, col) # Battler animation - battlerAppear(battler,delay,battlerEndX,battlerEndY,batSprite,col) + battlerAppear(battler, delay, battlerEndX, battlerEndY, batSprite, col) if @shadowVisible # Set up shadow sprite - shadow = addSprite(shaSprite,PictureOrigin::Center) - shadow.setOpacity(0,0) + shadow = addSprite(shaSprite, PictureOrigin::Center) + shadow.setOpacity(0, 0) # Shadow animation - shadow.setVisible(delay,@shadowVisible) - shadow.moveOpacity(delay+5,10,255) + shadow.setVisible(delay, @shadowVisible) + shadow.moveOpacity(delay + 5, 10, 255) end end - def createBallTrajectory(ball,destX,destY) + def createBallTrajectory(ball, destX, destY) # NOTE: In HGSS, there isn't a Poké Ball arc under any circumstance (neither # when throwing out the first Pokémon nor when switching/replacing a # fainted Pokémon). This is probably worth changing. - ball.setXY(0,destX,destY-4) + ball.setXY(0, destX, destY - 4) end end @@ -552,9 +552,9 @@ end class Battle::Scene::Animation::BattlerRecall < Battle::Scene::Animation include Battle::Scene::Animation::BallAnimationMixin - def initialize(sprites,viewport,idxBattler) + def initialize(sprites, viewport, idxBattler) @idxBattler = idxBattler - super(sprites,viewport) + super(sprites, viewport) end def createProcesses @@ -566,29 +566,29 @@ class Battle::Scene::Animation::BattlerRecall < Battle::Scene::Animation col = getBattlerColorFromPokeBall(poke_ball) col.alpha = 0 # Calculate end coordinates for battler sprite movement - ballPos = Battle::Scene.pbBattlerPosition(@idxBattler,batSprite.sideSize) + ballPos = Battle::Scene.pbBattlerPosition(@idxBattler, batSprite.sideSize) battlerEndX = ballPos[0] battlerEndY = ballPos[1] # Set up battler sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) - battler.setVisible(0,true) - battler.setColor(0,col) + battler = addSprite(batSprite, PictureOrigin::Bottom) + battler.setVisible(0, true) + battler.setColor(0, col) # Set up Poké Ball sprite - ball = addBallSprite(battlerEndX,battlerEndY,poke_ball) - ball.setZ(0,batSprite.z+1) + ball = addBallSprite(battlerEndX, battlerEndY, poke_ball) + ball.setZ(0, batSprite.z + 1) # Poké Ball animation - ballOpenUp(ball,0,poke_ball) + ballOpenUp(ball, 0, poke_ball) delay = ball.totalDuration - ballBurstRecall(delay,battlerEndX,battlerEndY,poke_ball) - ball.moveOpacity(10,2,0) + ballBurstRecall(delay, battlerEndX, battlerEndY, poke_ball) + ball.moveOpacity(10, 2, 0) # Battler animation - battlerAbsorb(battler,delay,battlerEndX,battlerEndY,col) + battlerAbsorb(battler, delay, battlerEndX, battlerEndY, col) if shaSprite.visible # Set up shadow sprite - shadow = addSprite(shaSprite,PictureOrigin::Center) + shadow = addSprite(shaSprite, PictureOrigin::Center) # Shadow animation - shadow.moveOpacity(0,10,0) - shadow.setVisible(delay,false) + shadow.moveOpacity(0, 10, 0) + shadow.setVisible(delay, false) end end end @@ -599,18 +599,18 @@ end # Shows a Pokémon flashing after taking damage #=============================================================================== class Battle::Scene::Animation::BattlerDamage < Battle::Scene::Animation - def initialize(sprites,viewport,idxBattler,effectiveness) + def initialize(sprites, viewport, idxBattler, effectiveness) @idxBattler = idxBattler @effectiveness = effectiveness - super(sprites,viewport) + super(sprites, viewport) end def createProcesses batSprite = @sprites["pokemon_#{@idxBattler}"] shaSprite = @sprites["shadow_#{@idxBattler}"] # Set up battler/shadow sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) - shadow = addSprite(shaSprite,PictureOrigin::Center) + battler = addSprite(batSprite, PictureOrigin::Bottom) + shadow = addSprite(shaSprite, PictureOrigin::Center) # Animation delay = 0 case @effectiveness @@ -619,15 +619,15 @@ class Battle::Scene::Animation::BattlerDamage < Battle::Scene::Animation when 2 then battler.setSE(delay, "Battle damage super") end 4.times do # 4 flashes, each lasting 0.2 (4/20) seconds - battler.setVisible(delay,false) - shadow.setVisible(delay,false) - battler.setVisible(delay+2,true) if batSprite.visible - shadow.setVisible(delay+2,true) if shaSprite.visible + battler.setVisible(delay, false) + shadow.setVisible(delay, false) + battler.setVisible(delay + 2, true) if batSprite.visible + shadow.setVisible(delay + 2, true) if shaSprite.visible delay += 4 end # Restore original battler/shadow sprites visibilities - battler.setVisible(delay,batSprite.visible) - shadow.setVisible(delay,shaSprite.visible) + battler.setVisible(delay, batSprite.visible) + shadow.setVisible(delay, shaSprite.visible) end end @@ -637,25 +637,25 @@ end # Shows a Pokémon fainting #=============================================================================== class Battle::Scene::Animation::BattlerFaint < Battle::Scene::Animation - def initialize(sprites,viewport,idxBattler,battle) + def initialize(sprites, viewport, idxBattler, battle) @idxBattler = idxBattler @battle = battle - super(sprites,viewport) + super(sprites, viewport) end def createProcesses batSprite = @sprites["pokemon_#{@idxBattler}"] shaSprite = @sprites["shadow_#{@idxBattler}"] # Set up battler/shadow sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) - shadow = addSprite(shaSprite,PictureOrigin::Center) + battler = addSprite(batSprite, PictureOrigin::Bottom) + shadow = addSprite(shaSprite, PictureOrigin::Center) # Get approx duration depending on sprite's position/size. Min 20 frames. - battlerTop = batSprite.y-batSprite.height + battlerTop = batSprite.y - batSprite.height cropY = Battle::Scene.pbBattlerPosition(@idxBattler, @battle.pbSideSize(@idxBattler))[1] cropY += 8 - duration = (cropY-battlerTop)/8 - duration = 10 if duration<10 # Min 0.5 seconds + duration = (cropY - battlerTop) / 8 + duration = 10 if duration < 10 # Min 0.5 seconds # Animation # Play cry delay = 10 @@ -672,13 +672,13 @@ class Battle::Scene::Animation::BattlerFaint < Battle::Scene::Animation end delay += 2 # Sprite drops down - shadow.setVisible(delay,false) - battler.setSE(delay,"Pkmn faint") - battler.moveOpacity(delay,duration,0) - battler.moveDelta(delay,duration,0,cropY-battlerTop) - battler.setCropBottom(delay,cropY) - battler.setVisible(delay+duration,false) - battler.setOpacity(delay+duration,255) + shadow.setVisible(delay, false) + battler.setSE(delay, "Pkmn faint") + battler.moveOpacity(delay, duration, 0) + battler.moveDelta(delay, duration, 0, cropY - battlerTop) + battler.setCropBottom(delay, cropY) + battler.setVisible(delay + duration, false) + battler.setOpacity(delay + duration, 255) end end @@ -690,8 +690,8 @@ end class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation include Battle::Scene::Animation::BallAnimationMixin - def initialize(sprites,viewport, - poke_ball,numShakes,critCapture,battler,showingTrainer) + def initialize(sprites, viewport, + poke_ball, numShakes, critCapture, battler, showingTrainer) @poke_ball = poke_ball @success = numShakes >= 4 @numShakes = (critCapture && numShakes > 0) ? 1 : numShakes @@ -700,7 +700,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation @showingTrainer = showingTrainer # Only true if a Safari Zone battle @shadowVisible = sprites["shadow_#{battler.index}"].visible @trainer = battler.battle.pbPlayer - super(sprites,viewport) + super(sprites, viewport) end def createProcesses @@ -708,7 +708,7 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation batSprite = @sprites["pokemon_#{@battler.index}"] shaSprite = @sprites["shadow_#{@battler.index}"] traSprite = @sprites["player_1"] - ballPos = Battle::Scene.pbBattlerPosition(@battler.index,batSprite.sideSize) + ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize) battlerStartX = batSprite.x battlerStartY = batSprite.y ballStartX = -6 @@ -717,117 +717,117 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation ballMidY = 78 ballEndX = ballPos[0] ballEndY = 112 - ballGroundY = ballPos[1]-4 + ballGroundY = ballPos[1] - 4 # Set up Poké Ball sprite - ball = addBallSprite(ballStartX,ballStartY,@poke_ball) - ball.setZ(0,batSprite.z+1) + ball = addBallSprite(ballStartX, ballStartY, @poke_ball) + ball.setZ(0, batSprite.z + 1) @ballSpriteIndex = (@success) ? @tempSprites.length - 1 : -1 # Set up trainer sprite (only visible in Safari Zone battles) if @showingTrainer && traSprite - if traSprite.bitmap.width>=traSprite.bitmap.height*2 - trainer = addSprite(traSprite,PictureOrigin::Bottom) + if traSprite.bitmap.width >= traSprite.bitmap.height * 2 + trainer = addSprite(traSprite, PictureOrigin::Bottom) # Trainer animation - ballStartX, ballStartY = trainerThrowingFrames(ball,trainer,traSprite) + ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite) end end delay = ball.totalDuration # 0 or 7 # Poké Ball arc animation - ball.setSE(delay,"Battle throw") - createBallTrajectory(ball,delay,16, - ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY) - ball.setZ(9,batSprite.z+1) - ball.setSE(delay+16,"Battle ball hit") + ball.setSE(delay, "Battle throw") + createBallTrajectory(ball, delay, 16, + ballStartX, ballStartY, ballMidX, ballMidY, ballEndX, ballEndY) + ball.setZ(9, batSprite.z + 1) + ball.setSE(delay + 16, "Battle ball hit") # Poké Ball opens up - delay = ball.totalDuration+6 - ballOpenUp(ball,delay,@poke_ball,true,false) + delay = ball.totalDuration + 6 + ballOpenUp(ball, delay, @poke_ball, true, false) # Set up battler sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) + battler = addSprite(batSprite, PictureOrigin::Bottom) # Poké Ball absorbs battler delay = ball.totalDuration - ballBurstCapture(delay,ballEndX,ballEndY,@poke_ball) - delay = ball.totalDuration+4 + ballBurstCapture(delay, ballEndX, ballEndY, @poke_ball) + delay = ball.totalDuration + 4 # NOTE: The Pokémon does not change color while being absorbed into a Poké # Ball during a capture attempt. This may be an oversight in HGSS. - battler.setSE(delay,"Battle jump to ball") - battler.moveXY(delay,5,ballEndX,ballEndY) - battler.moveZoom(delay,5,0) - battler.setVisible(delay+5,false) + battler.setSE(delay, "Battle jump to ball") + battler.moveXY(delay, 5, ballEndX, ballEndY) + battler.moveZoom(delay, 5, 0) + battler.setVisible(delay + 5, false) if @shadowVisible # Set up shadow sprite - shadow = addSprite(shaSprite,PictureOrigin::Center) + shadow = addSprite(shaSprite, PictureOrigin::Center) # Shadow animation - shadow.moveOpacity(delay,5,0) - shadow.moveZoom(delay,5,0) - shadow.setVisible(delay+5,false) + shadow.moveOpacity(delay, 5, 0) + shadow.moveZoom(delay, 5, 0) + shadow.setVisible(delay + 5, false) end # Poké Ball closes delay = battler.totalDuration - ballSetClosed(ball,delay,@poke_ball) - ball.moveTone(delay,3,Tone.new(96,64,-160,160)) - ball.moveTone(delay+5,3,Tone.new(0,0,0,0)) + ballSetClosed(ball, delay, @poke_ball) + ball.moveTone(delay, 3, Tone.new(96, 64, -160, 160)) + ball.moveTone(delay + 5, 3, Tone.new(0, 0, 0, 0)) # Poké Ball critical capture animation - delay = ball.totalDuration+3 + delay = ball.totalDuration + 3 if @critCapture - ball.setSE(delay,"Battle ball shake") - ball.moveXY(delay,1,ballEndX+4,ballEndY) - ball.moveXY(delay+1,2,ballEndX-4,ballEndY) - ball.moveXY(delay+3,2,ballEndX+4,ballEndY) - ball.setSE(delay+4,"Battle ball shake") - ball.moveXY(delay+5,2,ballEndX-4,ballEndY) - ball.moveXY(delay+7,1,ballEndX,ballEndY) - delay = ball.totalDuration+3 + ball.setSE(delay, "Battle ball shake") + ball.moveXY(delay, 1, ballEndX + 4, ballEndY) + ball.moveXY(delay + 1, 2, ballEndX - 4, ballEndY) + ball.moveXY(delay + 3, 2, ballEndX + 4, ballEndY) + ball.setSE(delay + 4, "Battle ball shake") + ball.moveXY(delay + 5, 2, ballEndX - 4, ballEndY) + ball.moveXY(delay + 7, 1, ballEndX, ballEndY) + delay = ball.totalDuration + 3 end # Poké Ball drops to the ground for i in 0...4 - t = [4,4,3,2][i] # Time taken to rise or fall for each bounce - d = [1,2,4,8][i] # Fraction of the starting height each bounce rises to - delay -= t if i==0 - if i>0 - ball.setZoomXY(delay,100+5*(5-i),100-5*(5-i)) # Squish - ball.moveZoom(delay,2,100) # Unsquish - ball.moveXY(delay,t,ballEndX,ballGroundY-(ballGroundY-ballEndY)/d) + t = [4, 4, 3, 2][i] # Time taken to rise or fall for each bounce + d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to + delay -= t if i == 0 + if i > 0 + ball.setZoomXY(delay, 100 + 5 * (5 - i), 100 - 5 * (5 - i)) # Squish + ball.moveZoom(delay, 2, 100) # Unsquish + ball.moveXY(delay, t, ballEndX, ballGroundY - (ballGroundY - ballEndY) / d) end - ball.moveXY(delay+t,t,ballEndX,ballGroundY) - ball.setSE(delay+2*t,"Battle ball drop",100-i*7) + ball.moveXY(delay + t, t, ballEndX, ballGroundY) + ball.setSE(delay + 2 * t, "Battle ball drop", 100 - i * 7) delay = ball.totalDuration end - battler.setXY(ball.totalDuration,ballEndX,ballGroundY) + battler.setXY(ball.totalDuration, ballEndX, ballGroundY) # Poké Ball shakes - delay = ball.totalDuration+12 - for i in 0...[@numShakes,3].min - ball.setSE(delay,"Battle ball shake") - ball.moveXY(delay,2,ballEndX-2*(4-i),ballGroundY) - ball.moveAngle(delay,2,5*(4-i)) # positive means counterclockwise - ball.moveXY(delay+2,4,ballEndX+2*(4-i),ballGroundY) - ball.moveAngle(delay+2,4,-5*(4-i)) # negative means clockwise - ball.moveXY(delay+6,2,ballEndX,ballGroundY) - ball.moveAngle(delay+6,2,0) - delay = ball.totalDuration+8 + delay = ball.totalDuration + 12 + for i in 0...[@numShakes, 3].min + ball.setSE(delay, "Battle ball shake") + ball.moveXY(delay, 2, ballEndX - 2 * (4 - i), ballGroundY) + ball.moveAngle(delay, 2, 5 * (4 - i)) # positive means counterclockwise + ball.moveXY(delay + 2, 4, ballEndX + 2 * (4 - i), ballGroundY) + ball.moveAngle(delay + 2, 4, -5 * (4 - i)) # negative means clockwise + ball.moveXY(delay + 6, 2, ballEndX, ballGroundY) + ball.moveAngle(delay + 6, 2, 0) + delay = ball.totalDuration + 8 end if @success # Pokémon was caught - ballCaptureSuccess(ball,delay,ballEndX,ballGroundY) + ballCaptureSuccess(ball, delay, ballEndX, ballGroundY) else # Poké Ball opens - ball.setZ(delay,batSprite.z-1) - ballOpenUp(ball,delay,@poke_ball,false) - ballBurst(delay,ballEndX,ballGroundY,@poke_ball) - ball.moveOpacity(delay+2,2,0) + ball.setZ(delay, batSprite.z - 1) + ballOpenUp(ball, delay, @poke_ball, false) + ballBurst(delay, ballEndX, ballGroundY, @poke_ball) + ball.moveOpacity(delay + 2, 2, 0) # Battler emerges col = getBattlerColorFromPokeBall(@poke_ball) col.alpha = 255 - battler.setColor(delay,col) - battlerAppear(battler,delay,battlerStartX,battlerStartY,batSprite,col) + battler.setColor(delay, col) + battlerAppear(battler, delay, battlerStartX, battlerStartY, batSprite, col) if @shadowVisible - shadow.setVisible(delay+5,true) - shadow.setZoom(delay+5,100) - shadow.moveOpacity(delay+5,10,255) + shadow.setVisible(delay + 5, true) + shadow.setZoom(delay + 5, 100) + shadow.moveOpacity(delay + 5, 10, 255) end end end def dispose - if @ballSpriteIndex>=0 + if @ballSpriteIndex >= 0 # Capture was successful, the Poké Ball sprite should stay around after # this animation has finished. @sprites["captureBall"] = @tempSprites[@ballSpriteIndex] @@ -845,16 +845,16 @@ end class Battle::Scene::Animation::PokeballThrowDeflect < Battle::Scene::Animation include Battle::Scene::Animation::BallAnimationMixin - def initialize(sprites,viewport,poke_ball,battler) + def initialize(sprites, viewport, poke_ball, battler) @poke_ball = poke_ball @battler = battler - super(sprites,viewport) + super(sprites, viewport) end def createProcesses # Calculate start and end coordinates for battler sprite movement batSprite = @sprites["pokemon_#{@battler.index}"] - ballPos = Battle::Scene.pbBattlerPosition(@battler.index,batSprite.sideSize) + ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize) ballStartX = -6 ballStartY = 246 ballMidX = 190 # Unused in arc calculation @@ -862,16 +862,16 @@ class Battle::Scene::Animation::PokeballThrowDeflect < Battle::Scene::Animation ballEndX = ballPos[0] ballEndY = 112 # Set up Poké Ball sprite - ball = addBallSprite(ballStartX,ballStartY,@poke_ball) - ball.setZ(0,90) + ball = addBallSprite(ballStartX, ballStartY, @poke_ball) + ball.setZ(0, 90) # Poké Ball arc animation - ball.setSE(0,"Battle throw") - createBallTrajectory(ball,0,16, - ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY) + ball.setSE(0, "Battle throw") + createBallTrajectory(ball, 0, 16, + ballStartX, ballStartY, ballMidX, ballMidY, ballEndX, ballEndY) # Poké Ball knocked back delay = ball.totalDuration - ball.setSE(delay,"Battle ball drop") - ball.moveXY(delay,8,-32,Graphics.height-96+32) # Back to player's corner - createBallTumbling(ball,delay,8) + ball.setSE(delay, "Battle ball drop") + ball.moveXY(delay, 8, -32, Graphics.height - 96 + 32) # Back to player's corner + createBallTumbling(ball, delay, 8) end end diff --git a/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb b/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb index b76513a6a..d5ba88691 100644 --- a/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb +++ b/Data/Scripts/011_Battle/004_Scene/009_Battle_DebugScene.rb @@ -4,15 +4,15 @@ class Battle::DebugSceneNoLogging def initialize @battle = nil - @lastCmd = [0,0,0,0] - @lastMove = [0,0,0,0] + @lastCmd = [0, 0, 0, 0] + @lastMove = [0, 0, 0, 0] end # Called whenever the battle begins. def pbStartBattle(battle) @battle = battle - @lastCmd = [0,0,0,0] - @lastMove = [0,0,0,0] + @lastCmd = [0, 0, 0, 0] + @lastMove = [0, 0, 0, 0] end def pbBlitz(keys) @@ -23,61 +23,61 @@ class Battle::DebugSceneNoLogging def pbBeginCommandPhase; end def pbBeginAttackPhase; end def pbShowOpponent(idxTrainer); end - def pbDamageAnimation(battler,effectiveness = 0); end - def pbCommonAnimation(animName,user = nil,target = nil); end - def pbAnimation(moveID,user,targets,hitNum = 0); end + def pbDamageAnimation(battler, effectiveness = 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 def pbTrainerBattleSuccess; end - def pbBattleArenaJudgment(b1,b2,r1,r2); end - def pbBattleArenaBattlers(b1,b2); end + def pbBattleArenaJudgment(b1, b2, r1, r2); end + def pbBattleArenaBattlers(b1, b2); end def pbRefresh; end - def pbDisplayMessage(msg,brief = false); end + def pbDisplayMessage(msg, brief = false); end def pbDisplayPausedMessage(msg); end def pbDisplayConfirmMessage(msg); return true; end - def pbShowCommands(msg,commands,defaultValue); return 0; end + def pbShowCommands(msg, commands, defaultValue); return 0; end - def pbSendOutBattlers(sendOuts,startBattle = false); end + def pbSendOutBattlers(sendOuts, startBattle = false); end def pbRecall(idxBattler); end - def pbItemMenu(idxBattler,firstAction); return -1; end + def pbItemMenu(idxBattler, firstAction); return -1; end def pbResetMoveIndex(idxBattler); end - def pbHPChanged(battler,oldHP,showAnim = false); end + def pbHPChanged(battler, oldHP, showAnim = false); end def pbFaintBattler(battler); end - def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2); end + def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2); end def pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense, oldSpAtk, oldSpDef, oldSpeed); end - def pbForgetMove(pkmn,moveToLearn); return 0; end # Always forget first move + def pbForgetMove(pkmn, moveToLearn); return 0; end # Always forget first move - def pbCommandMenu(idxBattler,firstAction) - return 1 if rand(15)==0 # Bag - return 4 if rand(10)==0 # Call - return 0 # Fight + def pbCommandMenu(idxBattler, firstAction) + return 1 if rand(15) == 0 # Bag + return 4 if rand(10) == 0 # Call + return 0 # Fight end - def pbFightMenu(idxBattler,megaEvoPossible = false) + def pbFightMenu(idxBattler, megaEvoPossible = false) battler = @battle.battlers[idxBattler] 50.times do break if yield rand(battler.move.length) end end - def pbChooseTarget(idxBattler,target_data,visibleSprites = nil) + def pbChooseTarget(idxBattler, target_data, visibleSprites = nil) targets = @battle.allOtherSideBattlers(idxBattler).map { |b| b.index } - return -1 if targets.length==0 + return -1 if targets.length == 0 return targets.sample end - def pbPartyScreen(idxBattler,canCancel = false) + def pbPartyScreen(idxBattler, canCancel = false) replacements = [] - @battle.eachInTeamFromBattlerIndex(idxBattler) do |_b,idxParty| - replacements.push(idxParty) if !@battle.pbFindBattler(idxParty,idxBattler) + @battle.eachInTeamFromBattlerIndex(idxBattler) do |_b, idxParty| + replacements.push(idxParty) if !@battle.pbFindBattler(idxParty, idxBattler) end - return if replacements.length==0 + return if replacements.length == 0 50.times do - break if yield replacements[rand(replacements.length)],self + break if yield replacements[rand(replacements.length)], self end end end diff --git a/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb b/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb index 26ee37f77..4a2c395ab 100644 --- a/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb +++ b/Data/Scripts/011_Battle/005_AI/001_Battle_AI.rb @@ -31,17 +31,17 @@ class Battle::AI sum += c[1] n += 1 end - return 0 if n<2 + return 0 if n < 2 mean = sum.to_f / n varianceTimesN = 0 choices.each do |c| - next if c[1]<=0 - deviation = c[1].to_f-mean - varianceTimesN += deviation*deviation + next if c[1] <= 0 + deviation = c[1].to_f - mean + varianceTimesN += deviation * deviation end # Using population standard deviation # [(n-1) makes it a sample std dev, would be 0 with only 1 sample] - return Math.sqrt(varianceTimesN/n) + return Math.sqrt(varianceTimesN / n) end #============================================================================= diff --git a/Data/Scripts/011_Battle/005_AI/002_AI_Item.rb b/Data/Scripts/011_Battle/005_AI/002_AI_Item.rb index b824b1fa5..211e99462 100644 --- a/Data/Scripts/011_Battle/005_AI/002_AI_Item.rb +++ b/Data/Scripts/011_Battle/005_AI/002_AI_Item.rb @@ -12,7 +12,7 @@ class Battle::AI idxTarget = @battle.battlers[idxTarget].pokemonIndex # Party Pokémon end # Register use of item - @battle.pbRegisterItem(idxBattler,item,idxTarget) + @battle.pbRegisterItem(idxBattler, item, idxTarget) PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will use item #{GameData::Item.get(item).name}") return true end @@ -22,7 +22,7 @@ class Battle::AI def pbEnemyItemToUse(idxBattler) return nil if !@battle.internalBattle items = @battle.pbGetOwnerItems(idxBattler) - return nil if !items || items.length==0 + return nil if !items || items.length == 0 # Determine target of item (always the Pokémon choosing the action) idxTarget = idxBattler # Battler using the item battler = @battle.battlers[idxTarget] @@ -40,7 +40,7 @@ class Battle::AI :LEMONADE => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 70 : 80, :MOOMOOMILK => 100, :ORANBERRY => 10, - :SITRUSBERRY => battler.totalhp/4, + :SITRUSBERRY => battler.totalhp / 4, :ENERGYPOWDER => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 60 : 50, :ENERGYROOT => (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 120 : 200 } @@ -103,9 +103,9 @@ class Battle::AI usableXItems = [] items.each do |i| next if !i - next if !@battle.pbCanUseItemOnPokemon?(i,pkmn,battler,@battle.scene,false) - next if !ItemHandlers.triggerCanUseInBattle(i,pkmn,battler,nil, - false,self,@battle.scene,false) + next if !@battle.pbCanUseItemOnPokemon?(i, pkmn, battler, @battle.scene, false) + next if !ItemHandlers.triggerCanUseInBattle(i, pkmn, battler, nil, + false, self, @battle.scene, false) # Log HP healing items if losthp > 0 power = hpItems[i] @@ -140,28 +140,28 @@ class Battle::AI end end # Prioritise using a HP restoration item - if usableHPItems.length>0 && (battler.hp<=battler.totalhp/4 || - (battler.hp<=battler.totalhp/2 && pbAIRandom(100)<30)) - usableHPItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] } + if usableHPItems.length > 0 && (battler.hp <= battler.totalhp / 4 || + (battler.hp <= battler.totalhp / 2 && pbAIRandom(100) < 30)) + usableHPItems.sort! { |a, b| (a[1] == b[1]) ? a[2] <=> b[2] : a[1] <=> b[1] } prevItem = nil usableHPItems.each do |i| - return i[0], idxTarget if i[2]>=losthp + return i[0], idxTarget if i[2] >= losthp prevItem = i end return prevItem[0], idxTarget end # Next prioritise using a status-curing item - if usableStatusItems.length>0 && pbAIRandom(100)<40 - usableStatusItems.sort! { |a,b| a[1]<=>b[1] } + if usableStatusItems.length > 0 && pbAIRandom(100) < 40 + usableStatusItems.sort! { |a, b| a[1] <=> b[1] } return usableStatusItems[0][0], idxTarget end # Next try using an X item - if usableXItems.length>0 && pbAIRandom(100)<30 - usableXItems.sort! { |a,b| (a[1]==b[1]) ? a[2]<=>b[2] : a[1]<=>b[1] } + if usableXItems.length > 0 && pbAIRandom(100) < 30 + usableXItems.sort! { |a, b| (a[1] == b[1]) ? a[2] <=> b[2] : a[1] <=> b[1] } prevItem = nil usableXItems.each do |i| - break if prevItem && i[1]>prevItem[1] - return i[0], idxTarget if i[1]+i[2]>=6 + break if prevItem && i[1] > prevItem[1] + return i[0], idxTarget if i[1] + i[2] >= 6 prevItem = i end return prevItem[0], idxTarget diff --git a/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb b/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb index 369ef4e3a..8a855e667 100644 --- a/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb +++ b/Data/Scripts/011_Battle/005_AI/003_AI_Switch.rb @@ -3,10 +3,10 @@ class Battle::AI # Decide whether the opponent should switch Pokémon #============================================================================= def pbEnemyShouldWithdraw?(idxBattler) - return pbEnemyShouldWithdrawEx?(idxBattler,false) + return pbEnemyShouldWithdrawEx?(idxBattler, false) end - def pbEnemyShouldWithdrawEx?(idxBattler,forceSwitch) + def pbEnemyShouldWithdrawEx?(idxBattler, forceSwitch) return false if @battle.wildBattle? shouldSwitch = forceSwitch batonPass = -1 @@ -15,13 +15,13 @@ class Battle::AI battler = @battle.battlers[idxBattler] # If Pokémon is within 6 levels of the foe, and foe's last move was # super-effective and powerful - if !shouldSwitch && battler.turnCount>0 && skill>=PBTrainerAI.highSkill + if !shouldSwitch && battler.turnCount > 0 && skill >= PBTrainerAI.highSkill target = battler.pbDirectOpposing(true) if !target.fainted? && target.lastMoveUsed && - (target.level-battler.level).abs<=6 + (target.level - battler.level).abs <= 6 moveData = GameData::Move.get(target.lastMoveUsed) moveType = moveData.type - typeMod = pbCalcTypeMod(moveType,target,battler) + typeMod = pbCalcTypeMod(moveType, target, battler) if Effectiveness.super_effective?(typeMod) && moveData.base_damage > 50 switchChance = (moveData.base_damage > 70) ? 30 : 20 shouldSwitch = (pbAIRandom(100) < switchChance) @@ -30,14 +30,14 @@ class Battle::AI end # Pokémon can't do anything (must have been in battle for at least 5 rounds) if !@battle.pbCanChooseAnyMove?(idxBattler) && - battler.turnCount && battler.turnCount>=5 + battler.turnCount && battler.turnCount >= 5 shouldSwitch = true end # Pokémon is Perish Songed and has Baton Pass - if skill>=PBTrainerAI.highSkill && battler.effects[PBEffects::PerishSong]==1 - battler.eachMoveWithIndex do |m,i| - next if m.function!="SwitchOutUserPassOnEffects" # Baton Pass - next if !@battle.pbCanChooseMove?(idxBattler,i,false) + if skill >= PBTrainerAI.highSkill && battler.effects[PBEffects::PerishSong] == 1 + battler.eachMoveWithIndex do |m, i| + next if m.function != "SwitchOutUserPassOnEffects" # Baton Pass + next if !@battle.pbCanChooseMove?(idxBattler, i, false) batonPass = i break end @@ -45,96 +45,96 @@ class Battle::AI # Pokémon will faint because of bad poisoning at the end of this round, but # would survive at least one more round if it were regular poisoning instead if battler.status == :POISON && battler.statusCount > 0 && - skill>=PBTrainerAI.highSkill - toxicHP = battler.totalhp/16 - nextToxicHP = toxicHP*(battler.effects[PBEffects::Toxic]+1) - if battler.hp<=nextToxicHP && battler.hp>toxicHP*2 - shouldSwitch = true if pbAIRandom(100)<80 + skill >= PBTrainerAI.highSkill + toxicHP = battler.totalhp / 16 + nextToxicHP = toxicHP * (battler.effects[PBEffects::Toxic] + 1) + if battler.hp <= nextToxicHP && battler.hp > toxicHP * 2 + shouldSwitch = true if pbAIRandom(100) < 80 end end # Pokémon is Encored into an unfavourable move - if battler.effects[PBEffects::Encore]>0 && skill>=PBTrainerAI.mediumSkill + if battler.effects[PBEffects::Encore] > 0 && skill >= PBTrainerAI.mediumSkill idxEncoredMove = battler.pbEncoredMoveIndex - if idxEncoredMove>=0 + if idxEncoredMove >= 0 scoreSum = 0 scoreCount = 0 battler.allOpposing.each do |b| - scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove],battler,b,skill) + scoreSum += pbGetMoveScore(battler.moves[idxEncoredMove], battler, b, skill) scoreCount += 1 end - if scoreCount>0 && scoreSum/scoreCount<=20 - shouldSwitch = true if pbAIRandom(100)<80 + if scoreCount > 0 && scoreSum / scoreCount <= 20 + shouldSwitch = true if pbAIRandom(100) < 80 end end end # If there is a single foe and it is resting after Hyper Beam or is # Truanting (i.e. free turn) - if @battle.pbSideSize(battler.index+1)==1 && - !battler.pbDirectOpposing.fainted? && skill>=PBTrainerAI.highSkill + if @battle.pbSideSize(battler.index + 1) == 1 && + !battler.pbDirectOpposing.fainted? && skill >= PBTrainerAI.highSkill opp = battler.pbDirectOpposing - if opp.effects[PBEffects::HyperBeam]>0 || + if opp.effects[PBEffects::HyperBeam] > 0 || (opp.hasActiveAbility?(:TRUANT) && opp.effects[PBEffects::Truant]) - shouldSwitch = false if pbAIRandom(100)<80 + shouldSwitch = false if pbAIRandom(100) < 80 end end # Sudden Death rule - I'm not sure what this means - if @battle.rules["suddendeath"] && battler.turnCount>0 - if battler.hp<=battler.totalhp/4 && pbAIRandom(100)<30 + if @battle.rules["suddendeath"] && battler.turnCount > 0 + if battler.hp <= battler.totalhp / 4 && pbAIRandom(100) < 30 shouldSwitch = true - elsif battler.hp<=battler.totalhp/2 && pbAIRandom(100)<80 + elsif battler.hp <= battler.totalhp / 2 && pbAIRandom(100) < 80 shouldSwitch = true end end # Pokémon is about to faint because of Perish Song - if battler.effects[PBEffects::PerishSong]==1 + if battler.effects[PBEffects::PerishSong] == 1 shouldSwitch = true end if shouldSwitch list = [] idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) - @battle.pbParty(idxBattler).each_with_index do |pkmn,i| + @battle.pbParty(idxBattler).each_with_index do |pkmn, i| next if i == idxPartyEnd - 1 # Don't choose to switch in ace - next if !@battle.pbCanSwitch?(idxBattler,i) + next if !@battle.pbCanSwitch?(idxBattler, i) # If perish count is 1, it may be worth it to switch # even with Spikes, since Perish Song's effect will end - if battler.effects[PBEffects::PerishSong]!=1 + if battler.effects[PBEffects::PerishSong] != 1 # Will contain effects that recommend against switching spikes = battler.pbOwnSide.effects[PBEffects::Spikes] # Don't switch to this if too little HP - if spikes>0 - spikesDmg = [8,6,4][spikes-1] - if pkmn.hp<=pkmn.totalhp/spikesDmg + if spikes > 0 + spikesDmg = [8, 6, 4][spikes - 1] + if pkmn.hp <= pkmn.totalhp / spikesDmg next if !pkmn.hasType?(:FLYING) && !pkmn.hasActiveAbility?(:LEVITATE) end end end # moveType is the type of the target's last used move - if moveType && Effectiveness.ineffective?(pbCalcTypeMod(moveType,battler,battler)) + if moveType && Effectiveness.ineffective?(pbCalcTypeMod(moveType, battler, battler)) weight = 65 - typeMod = pbCalcTypeModPokemon(pkmn,battler.pbDirectOpposing(true)) + typeMod = pbCalcTypeModPokemon(pkmn, battler.pbDirectOpposing(true)) if Effectiveness.super_effective?(typeMod) # Greater weight if new Pokemon's type is effective against target weight = 85 end - list.unshift(i) if pbAIRandom(100)0 - if batonPass>=0 && @battle.pbRegisterMove(idxBattler,batonPass,false) + if list.length > 0 + if batonPass >= 0 && @battle.pbRegisterMove(idxBattler, batonPass, false) PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will use Baton Pass to avoid Perish Song") return true end - if @battle.pbRegisterSwitch(idxBattler,list[0]) + if @battle.pbRegisterSwitch(idxBattler, list[0]) PBDebug.log("[AI] #{battler.pbThis} (#{idxBattler}) will switch with " + "#{@battle.pbParty(idxBattler)[list[0]].name}") return true @@ -147,19 +147,19 @@ class Battle::AI #============================================================================= # Choose a replacement Pokémon #============================================================================= - def pbDefaultChooseNewEnemy(idxBattler,party) + def pbDefaultChooseNewEnemy(idxBattler, party) enemies = [] idxPartyStart, idxPartyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) - party.each_with_index do |_p,i| + party.each_with_index do |_p, i| next if i == idxPartyEnd - 1 && enemies.length > 0 # Ignore ace if possible - enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i) + enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler, i) end - return -1 if enemies.length==0 - return pbChooseBestNewEnemy(idxBattler,party,enemies) + return -1 if enemies.length == 0 + return pbChooseBestNewEnemy(idxBattler, party, enemies) end - def pbChooseBestNewEnemy(idxBattler,party,enemies) - return -1 if !enemies || enemies.length==0 + def pbChooseBestNewEnemy(idxBattler, party, enemies) + return -1 if !enemies || enemies.length == 0 best = -1 bestSum = 0 enemies.each do |i| @@ -172,7 +172,7 @@ class Battle::AI sum += Effectiveness.calculate(m.type, bTypes[0], bTypes[1], bTypes[2]) end end - if best==-1 || sum>bestSum + if best == -1 || sum > bestSum best = i bestSum = sum end diff --git a/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb b/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb index 0efa45d50..77204db7d 100644 --- a/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb +++ b/Data/Scripts/011_Battle/005_AI/004_AI_Move.rb @@ -14,12 +14,12 @@ class Battle::AI # NOTE: A move is only added to the choices array if it has a non-zero # score. choices = [] - user.eachMoveWithIndex do |_m,i| - next if !@battle.pbCanChooseMove?(idxBattler,i,false) + user.eachMoveWithIndex do |_m, i| + next if !@battle.pbCanChooseMove?(idxBattler, i, false) if wildBattler - pbRegisterMoveWild(user,i,choices) + pbRegisterMoveWild(user, i, choices) else - pbRegisterMoveTrainer(user,i,choices,skill) + pbRegisterMoveTrainer(user, i, choices, skill) end end # Figure out useful information about the choices @@ -27,54 +27,54 @@ class Battle::AI maxScore = 0 choices.each do |c| totalScore += c[1] - maxScore = c[1] if maxScore=0 - logMsg += ", " if i= 0 + logMsg += ", " if i < choices.length - 1 end PBDebug.log(logMsg) end # Find any preferred moves and just choose from them - if !wildBattler && skill>=PBTrainerAI.highSkill && maxScore>100 + if !wildBattler && skill >= PBTrainerAI.highSkill && maxScore > 100 stDev = pbStdDev(choices) - if stDev>=40 && pbAIRandom(100)<90 + if stDev >= 40 && pbAIRandom(100) < 90 preferredMoves = [] choices.each do |c| - next if c[1]<200 && c[1]0 + if preferredMoves.length > 0 m = preferredMoves[pbAIRandom(preferredMoves.length)] PBDebug.log("[AI] #{user.pbThis} (#{user.index}) prefers #{user.moves[m[0]].name}") - @battle.pbRegisterMove(idxBattler,m[0],false) - @battle.pbRegisterTarget(idxBattler,m[2]) if m[2]>=0 + @battle.pbRegisterMove(idxBattler, m[0], false) + @battle.pbRegisterTarget(idxBattler, m[2]) if m[2] >= 0 return end end end # Decide whether all choices are bad, and if so, try switching instead - if !wildBattler && skill>=PBTrainerAI.highSkill + if !wildBattler && skill >= PBTrainerAI.highSkill badMoves = false - if (maxScore<=20 && user.turnCount>2) || - (maxScore<=40 && user.turnCount>5) - badMoves = true if pbAIRandom(100)<80 + if (maxScore <= 20 && user.turnCount > 2) || + (maxScore <= 40 && user.turnCount > 5) + badMoves = true if pbAIRandom(100) < 80 end - if !badMoves && totalScore<100 && user.turnCount>1 + if !badMoves && totalScore < 100 && user.turnCount > 1 badMoves = true choices.each do |c| next if !user.moves[c[0]].damagingMove? badMoves = false break end - badMoves = false if badMoves && pbAIRandom(100)<10 + badMoves = false if badMoves && pbAIRandom(100) < 10 end - if badMoves && pbEnemyShouldWithdrawEx?(idxBattler,true) + if badMoves && pbEnemyShouldWithdrawEx?(idxBattler, true) if $INTERNAL PBDebug.log("[AI] #{user.pbThis} (#{user.index}) will switch due to terrible moves") end @@ -82,13 +82,13 @@ class Battle::AI end end # If there are no calculated choices, pick one at random - if choices.length==0 + if choices.length == 0 PBDebug.log("[AI] #{user.pbThis} (#{user.index}) doesn't want to use any moves; picking one at random") - user.eachMoveWithIndex do |_m,i| - next if !@battle.pbCanChooseMove?(idxBattler,i,false) - choices.push([i,100,-1]) # Move index, score, target + user.eachMoveWithIndex do |_m, i| + next if !@battle.pbCanChooseMove?(idxBattler, i, false) + choices.push([i, 100, -1]) # Move index, score, target end - if choices.length==0 # No moves are physically possible to use; use Struggle + if choices.length == 0 # No moves are physically possible to use; use Struggle @battle.pbAutoChooseMove(user.index) end end @@ -96,9 +96,9 @@ class Battle::AI randNum = pbAIRandom(totalScore) choices.each do |c| randNum -= c[1] - next if randNum>=0 - @battle.pbRegisterMove(idxBattler,c[0],false) - @battle.pbRegisterTarget(idxBattler,c[2]) if c[2]>=0 + next if randNum >= 0 + @battle.pbRegisterMove(idxBattler, c[0], false) + @battle.pbRegisterTarget(idxBattler, c[2]) if c[2] >= 0 break end # Log the result @@ -111,40 +111,40 @@ class Battle::AI # Get scores for the given move against each possible target #============================================================================= # Wild Pokémon choose their moves randomly. - def pbRegisterMoveWild(_user,idxMove,choices) - choices.push([idxMove,100,-1]) # Move index, score, target + def pbRegisterMoveWild(_user, idxMove, choices) + choices.push([idxMove, 100, -1]) # Move index, score, target end # Trainer Pokémon calculate how much they want to use each of their moves. - def pbRegisterMoveTrainer(user,idxMove,choices,skill) + def pbRegisterMoveTrainer(user, idxMove, choices, skill) move = user.moves[idxMove] target_data = move.pbTarget(user) if target_data.num_targets > 1 # If move affects multiple battlers and you don't choose a particular one totalScore = 0 @battle.allBattlers.each do |b| - next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data) - score = pbGetMoveScore(move,user,b,skill) + next if !@battle.pbMoveCanTarget?(user.index, b.index, target_data) + score = pbGetMoveScore(move, user, b, skill) totalScore += ((user.opposes?(b)) ? score : -score) end - choices.push([idxMove,totalScore,-1]) if totalScore>0 + choices.push([idxMove, totalScore, -1]) if totalScore > 0 elsif target_data.num_targets == 0 # If move has no targets, affects the user, a side or the whole field - score = pbGetMoveScore(move,user,user,skill) - choices.push([idxMove,score,-1]) if score>0 + score = pbGetMoveScore(move, user, user, skill) + choices.push([idxMove, score, -1]) if score > 0 else # If move affects one battler and you have to choose which one scoresAndTargets = [] @battle.allBattlers.each do |b| - next if !@battle.pbMoveCanTarget?(user.index,b.index,target_data) + next if !@battle.pbMoveCanTarget?(user.index, b.index, target_data) next if target_data.targets_foe && !user.opposes?(b) - score = pbGetMoveScore(move,user,b,skill) - scoresAndTargets.push([score,b.index]) if score>0 + score = pbGetMoveScore(move, user, b, skill) + scoresAndTargets.push([score, b.index]) if score > 0 end - if scoresAndTargets.length>0 + if scoresAndTargets.length > 0 # Get the one best target for the move - scoresAndTargets.sort! { |a,b| b[0]<=>a[0] } - choices.push([idxMove,scoresAndTargets[0][0],scoresAndTargets[0][1]]) + scoresAndTargets.sort! { |a, b| b[0] <=> a[0] } + choices.push([idxMove, scoresAndTargets[0][0], scoresAndTargets[0][1]]) end end end @@ -152,31 +152,31 @@ class Battle::AI #============================================================================= # Get a score for the given move being used against the given target #============================================================================= - def pbGetMoveScore(move,user,target,skill = 100) - skill = PBTrainerAI.minimumSkill if skill=PBTrainerAI.mediumSkill + return 0 if score <= 0 + if skill >= PBTrainerAI.mediumSkill # Prefer damaging moves if AI has no more Pokémon or AI is less clever - if @battle.pbAbleNonActiveCount(user.idxOwnSide)==0 - if !(skill>=PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide)>0) + if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 + if !(skill >= PBTrainerAI.highSkill && @battle.pbAbleNonActiveCount(target.idxOwnSide) > 0) if move.statusMove? score /= 1.5 - elsif target.hp<=target.totalhp/2 + elsif target.hp <= target.totalhp / 2 score *= 1.5 end end end # Don't prefer attacking the target if they'd be semi-invulnerable - if skill>=PBTrainerAI.highSkill && move.accuracy>0 && - (target.semiInvulnerable? || target.effects[PBEffects::SkyDrop]>=0) + if skill >= PBTrainerAI.highSkill && move.accuracy > 0 && + (target.semiInvulnerable? || target.effects[PBEffects::SkyDrop] >= 0) miss = true miss = false if user.hasActiveAbility?(:NOGUARD) || target.hasActiveAbility?(:NOGUARD) - if miss && pbRoughStat(user,:SPEED,skill)>pbRoughStat(target,:SPEED,skill) + if miss && pbRoughStat(user, :SPEED, skill) > pbRoughStat(target, :SPEED, skill) # Knows what can get past semi-invulnerability - if target.effects[PBEffects::SkyDrop]>=0 + if target.effects[PBEffects::SkyDrop] >= 0 miss = false if move.hitsFlyingTargets? else if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", @@ -193,13 +193,13 @@ class Battle::AI score -= 80 if miss end # Pick a good move for the Choice items - if user.hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) || + if user.hasActiveItem?([:CHOICEBAND, :CHOICESPECS, :CHOICESCARF]) || user.hasActiveAbility?(:GORILLATACTICS) - if move.baseDamage>=60 + if move.baseDamage >= 60 score += 60 elsif move.damagingMove? score += 30 - elsif move.function=="UserTargetSwapItems" + elsif move.function == "UserTargetSwapItems" score += 70 # Trick else score -= 60 @@ -236,17 +236,17 @@ class Battle::AI end # Adjust score based on how much damage it can deal if move.damagingMove? - score = pbGetMoveScoreDamage(score,move,user,target,skill) + score = pbGetMoveScoreDamage(score, move, user, target, skill) else # Status moves # Don't prefer attacks which don't deal damage score -= 10 # Account for accuracy of move - accuracy = pbRoughAccuracy(move,user,target,skill) - score *= accuracy/100.0 - score = 0 if score<=10 && skill>=PBTrainerAI.highSkill + accuracy = pbRoughAccuracy(move, user, target, skill) + score *= accuracy / 100.0 + score = 0 if score <= 10 && skill >= PBTrainerAI.highSkill end score = score.to_i - score = 0 if score<0 + score = 0 if score < 0 return score end @@ -254,25 +254,25 @@ class Battle::AI # Add to a move's score based on how much damage it will deal (as a percentage # of the target's current HP) #============================================================================= - def pbGetMoveScoreDamage(score,move,user,target,skill) + def pbGetMoveScoreDamage(score, move, user, target, skill) # Don't prefer moves that are ineffective because of abilities or effects - return 0 if score<=0 || pbCheckMoveImmunity(score,move,user,target,skill) + return 0 if score <= 0 || pbCheckMoveImmunity(score, move, user, target, skill) # Calculate how much damage the move will do (roughly) - baseDmg = pbMoveBaseDamage(move,user,target,skill) - realDamage = pbRoughDamage(move,user,target,skill,baseDmg) + baseDmg = pbMoveBaseDamage(move, user, target, skill) + realDamage = pbRoughDamage(move, user, target, skill, baseDmg) # Account for accuracy of move - accuracy = pbRoughAccuracy(move,user,target,skill) - realDamage *= accuracy/100.0 + accuracy = pbRoughAccuracy(move, user, target, skill) + realDamage *= accuracy / 100.0 # Two-turn attacks waste 2 turns to deal one lot of damage - if move.chargingTurnMove? || move.function=="AttackAndSkipNextTurn" # Hyper Beam - realDamage *= 2/3 # Not halved because semi-invulnerable during use or hits first turn + if move.chargingTurnMove? || move.function == "AttackAndSkipNextTurn" # Hyper Beam + realDamage *= 2 / 3 # Not halved because semi-invulnerable during use or hits first turn end # Prefer flinching external effects (note that move effects which cause # flinching are dealt with in the function code part of score calculation) - if skill>=PBTrainerAI.mediumSkill && !move.flinchingMove? + if skill >= PBTrainerAI.mediumSkill && !move.flinchingMove? if !target.hasActiveAbility?(:INNERFOCUS) && !target.hasActiveAbility?(:SHIELDDUST) && - target.effects[PBEffects::Substitute]==0 + target.effects[PBEffects::Substitute] == 0 canFlinch = false if user.hasActiveItem?([:KINGSROCK, :RAZORFANG]) canFlinch = true @@ -283,14 +283,14 @@ class Battle::AI end end # Convert damage to percentage of target's remaining HP - damagePercentage = realDamage*100.0/target.hp + damagePercentage = realDamage * 100.0 / target.hp # Don't prefer weak attacks # damagePercentage /= 2 if damagePercentage<20 # Prefer damaging attack if level difference is significantly high - damagePercentage *= 1.2 if user.level-10>target.level + damagePercentage *= 1.2 if user.level - 10 > target.level # Adjust score - damagePercentage = 120 if damagePercentage>120 # Treat all lethal moves the same - damagePercentage += 40 if damagePercentage>100 # Prefer moves likely to be lethal + damagePercentage = 120 if damagePercentage > 120 # Treat all lethal moves the same + damagePercentage += 40 if damagePercentage > 100 # Prefer moves likely to be lethal score += damagePercentage.to_i return score end diff --git a/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb b/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb index 03a36523d..ccf54f86d 100644 --- a/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb +++ b/Data/Scripts/011_Battle/005_AI/005_AI_Move_EffectScores.rb @@ -2,47 +2,47 @@ class Battle::AI #============================================================================= # Get a score for the given move based on its effect #============================================================================= - def pbGetMoveScoreFunctionCode(score,move,user,target,skill = 100) + def pbGetMoveScoreFunctionCode(score, move, user, target, skill = 100) case move.function #--------------------------------------------------------------------------- when "None" # No extra effect #--------------------------------------------------------------------------- when "DoesNothingUnusableInGravity" score -= 95 - score = 0 if skill>=PBTrainerAI.highSkill + score = 0 if skill >= PBTrainerAI.highSkill #--------------------------------------------------------------------------- when "Struggle" # Struggle #--------------------------------------------------------------------------- when "SleepTarget", "SleepTargetChangeUserMeloettaForm" - if target.pbCanSleep?(user,false) + if target.pbCanSleep?(user, false) score += 30 - if skill>=PBTrainerAI.mediumSkill - score -= 30 if target.effects[PBEffects::Yawn]>0 + if skill >= PBTrainerAI.mediumSkill + score -= 30 if target.effects[PBEffects::Yawn] > 0 end - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score -= 30 if target.hasActiveAbility?(:MARVELSCALE) end - if skill>=PBTrainerAI.bestSkill + if skill >= PBTrainerAI.bestSkill if target.pbHasMoveFunction?("FlinchTargetFailsIfUserNotAsleep", "UseRandomUserMoveIfAsleep") # Snore, Sleep Talk score -= 50 end end else - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill score -= 90 if move.statusMove? end end #--------------------------------------------------------------------------- when "SleepTargetNextTurn" - if target.effects[PBEffects::Yawn]>0 || !target.pbCanSleep?(user,false) - score -= 90 if skill>=PBTrainerAI.mediumSkill + if target.effects[PBEffects::Yawn] > 0 || !target.pbCanSleep?(user, false) + score -= 90 if skill >= PBTrainerAI.mediumSkill else score += 30 - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score -= 30 if target.hasActiveAbility?(:MARVELSCALE) end - if skill>=PBTrainerAI.bestSkill + if skill >= PBTrainerAI.bestSkill if target.pbHasMoveFunction?("FlinchTargetFailsIfUserNotAsleep", "UseRandomUserMoveIfAsleep") # Snore, Sleep Talk score -= 50 @@ -51,20 +51,20 @@ class Battle::AI end #--------------------------------------------------------------------------- when "PoisonTarget", "BadPoisonTarget", "HitTwoTimesPoisonTarget" - if target.pbCanPoison?(user,false) + if target.pbCanPoison?(user, false) score += 30 - if skill>=PBTrainerAI.mediumSkill - score += 30 if target.hp<=target.totalhp/4 - score += 50 if target.hp<=target.totalhp/8 - score -= 40 if target.effects[PBEffects::Yawn]>0 + if skill >= PBTrainerAI.mediumSkill + score += 30 if target.hp <= target.totalhp / 4 + score += 50 if target.hp <= target.totalhp / 8 + score -= 40 if target.effects[PBEffects::Yawn] > 0 end - if skill>=PBTrainerAI.highSkill - score += 10 if pbRoughStat(target,:DEFENSE,skill)>100 - score += 10 if pbRoughStat(target,:SPECIAL_DEFENSE,skill)>100 - score -= 40 if target.hasActiveAbility?([:GUTS,:MARVELSCALE,:TOXICBOOST]) + if skill >= PBTrainerAI.highSkill + score += 10 if pbRoughStat(target, :DEFENSE, skill) > 100 + score += 10 if pbRoughStat(target, :SPECIAL_DEFENSE, skill) > 100 + score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :TOXICBOOST]) end else - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill score -= 90 if move.statusMove? end end @@ -72,95 +72,95 @@ class Battle::AI when "ParalyzeTarget", "ParalyzeTargetIfNotTypeImmune", "ParalyzeTargetTrampleMinimize", "ParalyzeTargetAlwaysHitsInRainHitsTargetInSky", "ParalyzeFlinchTarget", "TwoTurnAttackParalyzeTarget" - if target.pbCanParalyze?(user,false) && - !(skill>=PBTrainerAI.mediumSkill && + if target.pbCanParalyze?(user, false) && + !(skill >= PBTrainerAI.mediumSkill && move.id == :THUNDERWAVE && - Effectiveness.ineffective?(pbCalcTypeMod(move.type,user,target))) + Effectiveness.ineffective?(pbCalcTypeMod(move.type, user, target))) score += 30 - if skill>=PBTrainerAI.mediumSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - if aspeed= PBTrainerAI.mediumSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + if aspeed < ospeed score += 30 - elsif aspeed>ospeed + elsif aspeed > ospeed score -= 40 end end - if skill>=PBTrainerAI.highSkill - score -= 40 if target.hasActiveAbility?([:GUTS,:MARVELSCALE,:QUICKFEET]) + if skill >= PBTrainerAI.highSkill + score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET]) end else - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill score -= 90 if move.statusMove? end end #--------------------------------------------------------------------------- when "BurnTarget", "BurnFlinchTarget", "TwoTurnAttackBurnTarget" - if target.pbCanBurn?(user,false) + if target.pbCanBurn?(user, false) score += 30 - if skill>=PBTrainerAI.highSkill - score -= 40 if target.hasActiveAbility?([:GUTS,:MARVELSCALE,:QUICKFEET,:FLAREBOOST]) + if skill >= PBTrainerAI.highSkill + score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET, :FLAREBOOST]) end else - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill score -= 90 if move.statusMove? end end #--------------------------------------------------------------------------- when "FreezeTarget", "FreezeTargetAlwaysHitsInHail", "FreezeFlinchTarget" - if target.pbCanFreeze?(user,false) + if target.pbCanFreeze?(user, false) score += 30 - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score -= 20 if target.hasActiveAbility?(:MARVELSCALE) end else - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill score -= 90 if move.statusMove? end end #--------------------------------------------------------------------------- when "FlinchTarget" score += 30 - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score += 30 if !target.hasActiveAbility?(:INNERFOCUS) && - target.effects[PBEffects::Substitute]==0 + target.effects[PBEffects::Substitute] == 0 end #--------------------------------------------------------------------------- when "FlinchTargetTrampleMinimize" - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score += 30 if !target.hasActiveAbility?(:INNERFOCUS) && - target.effects[PBEffects::Substitute]==0 + target.effects[PBEffects::Substitute] == 0 end score += 30 if target.effects[PBEffects::Minimize] #--------------------------------------------------------------------------- when "FlinchTargetFailsIfUserNotAsleep" if user.asleep? score += 100 # Because it can only be used while asleep - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score += 30 if !target.hasActiveAbility?(:INNERFOCUS) && - target.effects[PBEffects::Substitute]==0 + target.effects[PBEffects::Substitute] == 0 end else score -= 90 # Because it will fail here - score = 0 if skill>=PBTrainerAI.bestSkill + score = 0 if skill >= PBTrainerAI.bestSkill end #--------------------------------------------------------------------------- when "FlinchTargetFailsIfNotUserFirstTurn" - if user.turnCount==0 - if skill>=PBTrainerAI.highSkill + if user.turnCount == 0 + if skill >= PBTrainerAI.highSkill score += 30 if !target.hasActiveAbility?(:INNERFOCUS) && - target.effects[PBEffects::Substitute]==0 + target.effects[PBEffects::Substitute] == 0 end else score -= 90 # Because it will fail here - score = 0 if skill>=PBTrainerAI.bestSkill + score = 0 if skill >= PBTrainerAI.bestSkill end #--------------------------------------------------------------------------- when "ConfuseTarget", "ConfuseTargetAlwaysHitsInRainHitsTargetInSky" - if target.pbCanConfuse?(user,false) + if target.pbCanConfuse?(user, false) score += 30 else - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill score -= 90 if move.statusMove? end end @@ -169,19 +169,19 @@ class Battle::AI canattract = true agender = user.gender ogender = target.gender - if agender==2 || ogender==2 || agender==ogender + if agender == 2 || ogender == 2 || agender == ogender score -= 90 canattract = false - elsif target.effects[PBEffects::Attract]>=0 + elsif target.effects[PBEffects::Attract] >= 0 score -= 80 canattract = false - elsif skill>=PBTrainerAI.bestSkill && target.hasActiveAbility?(:OBLIVIOUS) + elsif skill >= PBTrainerAI.bestSkill && target.hasActiveAbility?(:OBLIVIOUS) score -= 80 canattract = false end - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if canattract && target.hasActiveItem?(:DESTINYKNOT) && - user.pbCanAttract?(target,false) + user.pbCanAttract?(target, false) score -= 30 end end @@ -193,11 +193,11 @@ class Battle::AI case user.status when :POISON score += 40 - if skill>=PBTrainerAI.mediumSkill - if user.hp= PBTrainerAI.mediumSkill + if user.hp < user.totalhp / 8 score += 60 - elsif skill>=PBTrainerAI.highSkill && - user.hp<(user.effects[PBEffects::Toxic]+1)*user.totalhp/16 + elsif skill >= PBTrainerAI.highSkill && + user.hp < (user.effects[PBEffects::Toxic] + 1) * user.totalhp / 16 score += 60 end end @@ -212,14 +212,14 @@ class Battle::AI @battle.pbParty(user.index).each do |pkmn| statuses += 1 if pkmn && pkmn.status != :NONE end - if statuses==0 + if statuses == 0 score -= 80 else - score += 20*statuses + score += 20 * statuses end #--------------------------------------------------------------------------- when "StartUserSideImmunityToInflictedStatus" - if user.pbOwnSide.effects[PBEffects::Safeguard]>0 + if user.pbOwnSide.effects[PBEffects::Safeguard] > 0 score -= 80 elsif user.status != :NONE score -= 40 @@ -239,8 +239,8 @@ class Battle::AI if user.statStageAtMax?(:ATTACK) score -= 90 else - score -= user.stages[:ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -249,14 +249,14 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 20 if user.stages[:ATTACK]<0 - if skill>=PBTrainerAI.mediumSkill + score += 20 if user.stages[:ATTACK] < 0 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -272,10 +272,10 @@ class Battle::AI if user.statStageAtMax?(:DEFENSE) score -= 90 else - score -= user.stages[:DEFENSE]*20 + score -= user.stages[:DEFENSE] * 20 end else - score += 20 if user.stages[:DEFENSE]<0 + score += 20 if user.stages[:DEFENSE] < 0 end #--------------------------------------------------------------------------- when "RaiseUserSpeed1" @@ -283,15 +283,15 @@ class Battle::AI if user.statStageAtMax?(:SPEED) score -= 90 else - score -= user.stages[:SPEED]*10 - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 30 if aspeedospeed + score -= user.stages[:SPEED] * 10 + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 30 if aspeed < ospeed && aspeed * 2 > ospeed end end else - score += 20 if user.stages[:SPEED]<0 + score += 20 if user.stages[:SPEED] < 0 end #--------------------------------------------------------------------------- when "RaiseUserSpAtk1" @@ -299,8 +299,8 @@ class Battle::AI if user.statStageAtMax?(:SPECIAL_ATTACK) score -= 90 else - score -= user.stages[:SPECIAL_ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:SPECIAL_ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -309,14 +309,14 @@ class Battle::AI end if hasSpecicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 20 if user.stages[:SPECIAL_ATTACK]<0 - if skill>=PBTrainerAI.mediumSkill + score += 20 if user.stages[:SPECIAL_ATTACK] < 0 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -339,10 +339,10 @@ class Battle::AI if user.statStageAtMax?(:SPECIAL_DEFENSE) score -= 90 else - score -= user.stages[:SPECIAL_DEFENSE]*20 + score -= user.stages[:SPECIAL_DEFENSE] * 20 end else - score += 20 if user.stages[:SPECIAL_DEFENSE]<0 + score += 20 if user.stages[:SPECIAL_DEFENSE] < 0 end #--------------------------------------------------------------------------- when "RaiseUserEvasion1" @@ -350,21 +350,21 @@ class Battle::AI if user.statStageAtMax?(:EVASION) score -= 90 else - score -= user.stages[:EVASION]*10 + score -= user.stages[:EVASION] * 10 end else - score += 20 if user.stages[:EVASION]<0 + score += 20 if user.stages[:EVASION] < 0 end #--------------------------------------------------------------------------- when "RaiseUserCriticalHitRate2" if move.statusMove? - if user.effects[PBEffects::FocusEnergy]>=2 + if user.effects[PBEffects::FocusEnergy] >= 2 score -= 80 else score += 30 end else - score += 30 if user.effects[PBEffects::FocusEnergy]<2 + score += 30 if user.effects[PBEffects::FocusEnergy] < 2 end #--------------------------------------------------------------------------- when "RaiseUserAtkDef1" @@ -372,9 +372,9 @@ class Battle::AI user.statStageAtMax?(:DEFENSE) score -= 90 else - score -= user.stages[:ATTACK]*10 - score -= user.stages[:DEFENSE]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:DEFENSE] * 10 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -383,7 +383,7 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end @@ -395,10 +395,10 @@ class Battle::AI user.statStageAtMax?(:ACCURACY) score -= 90 else - score -= user.stages[:ATTACK]*10 - score -= user.stages[:DEFENSE]*10 - score -= user.stages[:ACCURACY]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:DEFENSE] * 10 + score -= user.stages[:ACCURACY] * 10 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -407,21 +407,21 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end #--------------------------------------------------------------------------- when "RaiseUserAtkSpd1" - score += 40 if user.turnCount==0 # Dragon Dance tends to be popular + score += 40 if user.turnCount == 0 # Dragon Dance tends to be popular if user.statStageAtMax?(:ATTACK) && user.statStageAtMax?(:SPEED) score -= 90 else - score -= user.stages[:ATTACK]*10 - score -= user.stages[:SPEED]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:SPEED] * 10 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -430,14 +430,14 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 20 if aspeedospeed + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 20 if aspeed < ospeed && aspeed * 2 > ospeed end end #--------------------------------------------------------------------------- @@ -446,9 +446,9 @@ class Battle::AI user.statStageAtMax?(:SPECIAL_ATTACK) score -= 90 else - score -= user.stages[:ATTACK]*10 - score -= user.stages[:SPECIAL_ATTACK]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:SPECIAL_ATTACK] * 10 + if skill >= PBTrainerAI.mediumSkill hasDamagingAttack = false user.eachMove do |m| next if !m.damagingMove? @@ -457,11 +457,11 @@ class Battle::AI end if hasDamagingAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end - if move.function=="RaiseUserAtkSpAtk1Or2InSun" # Growth + if move.function == "RaiseUserAtkSpAtk1Or2InSun" # Growth score += 20 if [:Sun, :HarshSun].include?(user.effectiveWeather) end end @@ -471,9 +471,9 @@ class Battle::AI user.statStageAtMax?(:ACCURACY) score -= 90 else - score -= user.stages[:ATTACK]*10 - score -= user.stages[:ACCURACY]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:ACCURACY] * 10 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -482,7 +482,7 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end @@ -493,8 +493,8 @@ class Battle::AI user.statStageAtMax?(:SPECIAL_DEFENSE) score -= 90 else - score -= user.stages[:DEFENSE]*10 - score -= user.stages[:SPECIAL_DEFENSE]*10 + score -= user.stages[:DEFENSE] * 10 + score -= user.stages[:SPECIAL_DEFENSE] * 10 end #--------------------------------------------------------------------------- when "RaiseUserSpAtkSpDefSpd1" @@ -503,10 +503,10 @@ class Battle::AI user.statStageAtMax?(:SPECIAL_DEFENSE) score -= 90 else - score -= user.stages[:SPECIAL_ATTACK]*10 - score -= user.stages[:SPECIAL_DEFENSE]*10 - score -= user.stages[:SPEED]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:SPECIAL_ATTACK] * 10 + score -= user.stages[:SPECIAL_DEFENSE] * 10 + score -= user.stages[:SPEED] * 10 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -515,14 +515,14 @@ class Battle::AI end if hasSpecicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - if aspeedospeed + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + if aspeed < ospeed && aspeed * 2 > ospeed score += 20 end end @@ -533,10 +533,10 @@ class Battle::AI user.statStageAtMax?(:SPECIAL_DEFENSE) score -= 90 else - score += 40 if user.turnCount==0 # Calm Mind tends to be popular - score -= user.stages[:SPECIAL_ATTACK]*10 - score -= user.stages[:SPECIAL_DEFENSE]*10 - if skill>=PBTrainerAI.mediumSkill + score += 40 if user.turnCount == 0 # Calm Mind tends to be popular + score -= user.stages[:SPECIAL_ATTACK] * 10 + score -= user.stages[:SPECIAL_DEFENSE] * 10 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -545,7 +545,7 @@ class Battle::AI end if hasSpecicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end @@ -553,7 +553,7 @@ class Battle::AI #--------------------------------------------------------------------------- when "RaiseUserMainStats1" GameData::Stat.each_main_battle { |s| score += 10 if user.stages[s.id] < 0 } - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill hasDamagingAttack = false user.eachMove do |m| next if !m.damagingMove? @@ -568,9 +568,9 @@ class Battle::AI if user.statStageAtMax?(:ATTACK) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score += 40 if user.turnCount == 0 + score -= user.stages[:ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -579,15 +579,15 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 10 if user.turnCount==0 - score += 20 if user.stages[:ATTACK]<0 - if skill>=PBTrainerAI.mediumSkill + score += 10 if user.turnCount == 0 + score += 20 if user.stages[:ATTACK] < 0 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -603,12 +603,12 @@ class Battle::AI if user.statStageAtMax?(:DEFENSE) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:DEFENSE]*20 + score += 40 if user.turnCount == 0 + score -= user.stages[:DEFENSE] * 20 end else - score += 10 if user.turnCount==0 - score += 20 if user.stages[:DEFENSE]<0 + score += 10 if user.turnCount == 0 + score += 20 if user.stages[:DEFENSE] < 0 end #--------------------------------------------------------------------------- when "RaiseUserSpeed2", "RaiseUserSpeed2LowerUserWeight", "RaiseUserSpeed3" @@ -616,17 +616,17 @@ class Battle::AI if user.statStageAtMax?(:SPEED) score -= 90 else - score += 20 if user.turnCount==0 - score -= user.stages[:SPEED]*10 - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 30 if aspeedospeed + score += 20 if user.turnCount == 0 + score -= user.stages[:SPEED] * 10 + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 30 if aspeed < ospeed && aspeed * 2 > ospeed end end else - score += 10 if user.turnCount==0 - score += 20 if user.stages[:SPEED]<0 + score += 10 if user.turnCount == 0 + score += 20 if user.stages[:SPEED] < 0 end #--------------------------------------------------------------------------- when "RaiseUserSpAtk2" @@ -634,9 +634,9 @@ class Battle::AI if user.statStageAtMax?(:SPECIAL_ATTACK) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:SPECIAL_ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score += 40 if user.turnCount == 0 + score -= user.stages[:SPECIAL_ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -645,15 +645,15 @@ class Battle::AI end if hasSpecicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 10 if user.turnCount==0 - score += 20 if user.stages[:SPECIAL_ATTACK]<0 - if skill>=PBTrainerAI.mediumSkill + score += 10 if user.turnCount == 0 + score += 20 if user.stages[:SPECIAL_ATTACK] < 0 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -669,12 +669,12 @@ class Battle::AI if user.statStageAtMax?(:SPECIAL_DEFENSE) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:SPECIAL_DEFENSE]*20 + score += 40 if user.turnCount == 0 + score -= user.stages[:SPECIAL_DEFENSE] * 20 end else - score += 10 if user.turnCount==0 - score += 20 if user.stages[:SPECIAL_DEFENSE]<0 + score += 10 if user.turnCount == 0 + score += 20 if user.stages[:SPECIAL_DEFENSE] < 0 end #--------------------------------------------------------------------------- when "RaiseUserAccuracy1", "RaiseUserAccuracy2", "RaiseUserAccuracy3" @@ -682,12 +682,12 @@ class Battle::AI if user.statStageAtMax?(:ACCURACY) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:ACCURACY]*20 + score += 40 if user.turnCount == 0 + score -= user.stages[:ACCURACY] * 20 end else - score += 10 if user.turnCount==0 - score += 20 if user.stages[:ACCURACY]<0 + score += 10 if user.turnCount == 0 + score += 20 if user.stages[:ACCURACY] < 0 end #--------------------------------------------------------------------------- when "RaiseUserEvasion2", "RaiseUserEvasion2MinimizeUser", "RaiseUserEvasion3" @@ -695,21 +695,21 @@ class Battle::AI if user.statStageAtMax?(:EVASION) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:EVASION]*10 + score += 40 if user.turnCount == 0 + score -= user.stages[:EVASION] * 10 end else - score += 10 if user.turnCount==0 - score += 20 if user.stages[:EVASION]<0 + score += 10 if user.turnCount == 0 + score += 20 if user.stages[:EVASION] < 0 end #--------------------------------------------------------------------------- when "LowerUserDefSpDef1RaiseUserAtkSpAtkSpd2" - score -= user.stages[:ATTACK]*20 - score -= user.stages[:SPEED]*20 - score -= user.stages[:SPECIAL_ATTACK]*20 - score += user.stages[:DEFENSE]*10 - score += user.stages[:SPECIAL_DEFENSE]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 20 + score -= user.stages[:SPEED] * 20 + score -= user.stages[:SPECIAL_ATTACK] * 20 + score += user.stages[:DEFENSE] * 10 + score += user.stages[:SPECIAL_DEFENSE] * 10 + if skill >= PBTrainerAI.mediumSkill hasDamagingAttack = false user.eachMove do |m| next if !m.damagingMove? @@ -724,9 +724,9 @@ class Battle::AI user.statStageAtMax?(:SPEED) score -= 90 else - score -= user.stages[:ATTACK]*10 - score -= user.stages[:SPEED]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:SPEED] * 10 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -735,14 +735,14 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 30 if aspeedospeed + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 30 if aspeed < ospeed && aspeed * 2 > ospeed end end #--------------------------------------------------------------------------- @@ -755,8 +755,8 @@ class Battle::AI canChangeStat = true end if canChangeStat - avgStat = avgStat/2 if avgStat<0 # More chance of getting even better - score += avgStat*10 + avgStat = avgStat / 2 if avgStat < 0 # More chance of getting even better + score += avgStat * 10 else score -= 90 end @@ -766,12 +766,12 @@ class Battle::AI if user.statStageAtMax?(:DEFENSE) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:DEFENSE]*30 + score += 40 if user.turnCount == 0 + score -= user.stages[:DEFENSE] * 30 end else - score += 10 if user.turnCount==0 - score += 30 if user.stages[:DEFENSE]<0 + score += 10 if user.turnCount == 0 + score += 30 if user.stages[:DEFENSE] < 0 end #--------------------------------------------------------------------------- when "RaiseUserSpAtk3" @@ -779,9 +779,9 @@ class Battle::AI if user.statStageAtMax?(:SPECIAL_ATTACK) score -= 90 else - score += 40 if user.turnCount==0 - score -= user.stages[:SPECIAL_ATTACK]*30 - if skill>=PBTrainerAI.mediumSkill + score += 40 if user.turnCount == 0 + score -= user.stages[:SPECIAL_ATTACK] * 30 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -790,15 +790,15 @@ class Battle::AI end if hasSpecicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 10 if user.turnCount==0 - score += 30 if user.stages[:SPECIAL_ATTACK]<0 - if skill>=PBTrainerAI.mediumSkill + score += 10 if user.turnCount == 0 + score += 30 if user.stages[:SPECIAL_ATTACK] < 0 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -811,11 +811,11 @@ class Battle::AI #--------------------------------------------------------------------------- when "MaxUserAttackLoseHalfOfTotalHP" if user.statStageAtMax?(:ATTACK) || - user.hp<=user.totalhp/2 + user.hp <= user.totalhp / 2 score -= 100 else - score += (6-user.stages[:ATTACK])*10 - if skill>=PBTrainerAI.mediumSkill + score += (6 - user.stages[:ATTACK]) * 10 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false user.eachMove do |m| next if !m.physicalMove?(m.type) @@ -824,58 +824,58 @@ class Battle::AI end if hasPhysicalAttack score += 40 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end #--------------------------------------------------------------------------- when "LowerUserAtkDef1" - avg = user.stages[:ATTACK]*10 - avg += user.stages[:DEFENSE]*10 - score += avg/2 + avg = user.stages[:ATTACK] * 10 + avg += user.stages[:DEFENSE] * 10 + score += avg / 2 #--------------------------------------------------------------------------- when "LowerUserDefSpDef1" - avg = user.stages[:DEFENSE]*10 - avg += user.stages[:SPECIAL_DEFENSE]*10 - score += avg/2 + avg = user.stages[:DEFENSE] * 10 + avg += user.stages[:SPECIAL_DEFENSE] * 10 + score += avg / 2 #--------------------------------------------------------------------------- when "LowerUserDefSpDefSpd1" - avg = user.stages[:DEFENSE]*10 - avg += user.stages[:SPEED]*10 - avg += user.stages[:SPECIAL_DEFENSE]*10 - score += (avg/3).floor + avg = user.stages[:DEFENSE] * 10 + avg += user.stages[:SPEED] * 10 + avg += user.stages[:SPECIAL_DEFENSE] * 10 + score += (avg / 3).floor #--------------------------------------------------------------------------- when "LowerUserSpeed1", "LowerUserSpeed2" - score += user.stages[:SPEED]*10 + score += user.stages[:SPEED] * 10 #--------------------------------------------------------------------------- when "LowerUserSpAtk1", "LowerUserSpAtk2" - score += user.stages[:SPECIAL_ATTACK]*10 + score += user.stages[:SPECIAL_ATTACK] * 10 #--------------------------------------------------------------------------- when "LowerUserSpDef1", "LowerUserSpDef2" score += user.stages[:SPECIAL_DEFENSE] * 10 #--------------------------------------------------------------------------- when "RaiseTargetSpAtk1ConfuseTarget" - if !target.pbCanConfuse?(user,false) + if !target.pbCanConfuse?(user, false) score -= 90 else - score += 30 if target.stages[:SPECIAL_ATTACK]<0 + score += 30 if target.stages[:SPECIAL_ATTACK] < 0 end #--------------------------------------------------------------------------- when "RaiseTargetAttack2ConfuseTarget" - if !target.pbCanConfuse?(user,false) + if !target.pbCanConfuse?(user, false) score -= 90 else - score += 30 if target.stages[:ATTACK]<0 + score += 30 if target.stages[:ATTACK] < 0 end #--------------------------------------------------------------------------- when "LowerTargetAttack1" if move.statusMove? - if !target.pbCanLowerStatStage?(:ATTACK,user) + if !target.pbCanLowerStatStage?(:ATTACK, user) score -= 90 else - score += target.stages[:ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score += target.stages[:ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false target.eachMove do |m| next if !m.physicalMove?(m.type) @@ -884,14 +884,14 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 20 if target.stages[:ATTACK]>0 - if skill>=PBTrainerAI.mediumSkill + score += 20 if target.stages[:ATTACK] > 0 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false target.eachMove do |m| next if !m.physicalMove?(m.type) @@ -904,38 +904,38 @@ class Battle::AI #--------------------------------------------------------------------------- when "LowerTargetDefense1" if move.statusMove? - if !target.pbCanLowerStatStage?(:DEFENSE,user) + if !target.pbCanLowerStatStage?(:DEFENSE, user) score -= 90 else - score += target.stages[:DEFENSE]*20 + score += target.stages[:DEFENSE] * 20 end else - score += 20 if target.stages[:DEFENSE]>0 + score += 20 if target.stages[:DEFENSE] > 0 end #--------------------------------------------------------------------------- when "LowerTargetSpeed1", "LowerTargetSpeed1WeakerInGrassyTerrain" if move.statusMove? - if !target.pbCanLowerStatStage?(:SPEED,user) + if !target.pbCanLowerStatStage?(:SPEED, user) score -= 90 else - score += target.stages[:SPEED]*10 - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 30 if aspeedospeed + score += target.stages[:SPEED] * 10 + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 30 if aspeed < ospeed && aspeed * 2 > ospeed end end else - score += 20 if user.stages[:SPEED]>0 + score += 20 if user.stages[:SPEED] > 0 end #--------------------------------------------------------------------------- when "LowerTargetSpAtk1" if move.statusMove? - if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK,user) + if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user) score -= 90 else - score += user.stages[:SPECIAL_ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score += user.stages[:SPECIAL_ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false target.eachMove do |m| next if !m.specialMove?(m.type) @@ -944,14 +944,14 @@ class Battle::AI end if hasSpecicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 20 if user.stages[:SPECIAL_ATTACK]>0 - if skill>=PBTrainerAI.mediumSkill + score += 20 if user.stages[:SPECIAL_ATTACK] > 0 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false target.eachMove do |m| next if !m.specialMove?(m.type) @@ -964,69 +964,69 @@ class Battle::AI #--------------------------------------------------------------------------- when "LowerTargetSpDef1" if move.statusMove? - if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user) + if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user) score -= 90 else - score += target.stages[:SPECIAL_DEFENSE]*20 + score += target.stages[:SPECIAL_DEFENSE] * 20 end else - score += 20 if target.stages[:SPECIAL_DEFENSE]>0 + score += 20 if target.stages[:SPECIAL_DEFENSE] > 0 end #--------------------------------------------------------------------------- when "LowerTargetAccuracy1", "LowerTargetAccuracy2", "LowerTargetAccuracy3" if move.statusMove? - if !target.pbCanLowerStatStage?(:ACCURACY,user) + if !target.pbCanLowerStatStage?(:ACCURACY, user) score -= 90 else - score += target.stages[:ACCURACY]*10 + score += target.stages[:ACCURACY] * 10 end else - score += 20 if target.stages[:ACCURACY]>0 + score += 20 if target.stages[:ACCURACY] > 0 end #--------------------------------------------------------------------------- when "LowerTargetEvasion1", "LowerTargetEvasion2", "LowerTargetEvasion3" if move.statusMove? - if !target.pbCanLowerStatStage?(:EVASION,user) + if !target.pbCanLowerStatStage?(:EVASION, user) score -= 90 else - score += target.stages[:EVASION]*10 + score += target.stages[:EVASION] * 10 end else - score += 20 if target.stages[:EVASION]>0 + score += 20 if target.stages[:EVASION] > 0 end #--------------------------------------------------------------------------- when "LowerTargetEvasion1RemoveSideEffects" if move.statusMove? - if !target.pbCanLowerStatStage?(:EVASION,user) + if !target.pbCanLowerStatStage?(:EVASION, user) score -= 90 else - score += target.stages[:EVASION]*10 + score += target.stages[:EVASION] * 10 end else - score += 20 if target.stages[:EVASION]>0 + score += 20 if target.stages[:EVASION] > 0 end - score += 30 if target.pbOwnSide.effects[PBEffects::AuroraVeil]>0 || - target.pbOwnSide.effects[PBEffects::Reflect]>0 || - target.pbOwnSide.effects[PBEffects::LightScreen]>0 || - target.pbOwnSide.effects[PBEffects::Mist]>0 || - target.pbOwnSide.effects[PBEffects::Safeguard]>0 - score -= 30 if target.pbOwnSide.effects[PBEffects::Spikes]>0 || - target.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 || + score += 30 if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 || + target.pbOwnSide.effects[PBEffects::Reflect] > 0 || + target.pbOwnSide.effects[PBEffects::LightScreen] > 0 || + target.pbOwnSide.effects[PBEffects::Mist] > 0 || + target.pbOwnSide.effects[PBEffects::Safeguard] > 0 + score -= 30 if target.pbOwnSide.effects[PBEffects::Spikes] > 0 || + target.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0 || target.pbOwnSide.effects[PBEffects::StealthRock] #--------------------------------------------------------------------------- when "LowerTargetAtkDef" - avg = target.stages[:ATTACK]*10 - avg += target.stages[:DEFENSE]*10 - score += avg/2 + avg = target.stages[:ATTACK] * 10 + avg += target.stages[:DEFENSE] * 10 + score += avg / 2 #--------------------------------------------------------------------------- when "LowerTargetAttack2", "LowerTargetAttack3" if move.statusMove? - if !target.pbCanLowerStatStage?(:ATTACK,user) + if !target.pbCanLowerStatStage?(:ATTACK, user) score -= 90 else - score += 40 if user.turnCount==0 - score += target.stages[:ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score += 40 if user.turnCount == 0 + score += target.stages[:ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false target.eachMove do |m| next if !m.physicalMove?(m.type) @@ -1035,15 +1035,15 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 10 if user.turnCount==0 - score += 20 if target.stages[:ATTACK]>0 - if skill>=PBTrainerAI.mediumSkill + score += 10 if user.turnCount == 0 + score += 20 if target.stages[:ATTACK] > 0 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false target.eachMove do |m| next if !m.physicalMove?(m.type) @@ -1056,46 +1056,46 @@ class Battle::AI #--------------------------------------------------------------------------- when "LowerTargetDefense2", "LowerTargetDefense3" if move.statusMove? - if !target.pbCanLowerStatStage?(:DEFENSE,user) + if !target.pbCanLowerStatStage?(:DEFENSE, user) score -= 90 else - score += 40 if user.turnCount==0 - score += target.stages[:DEFENSE]*20 + score += 40 if user.turnCount == 0 + score += target.stages[:DEFENSE] * 20 end else - score += 10 if user.turnCount==0 - score += 20 if target.stages[:DEFENSE]>0 + score += 10 if user.turnCount == 0 + score += 20 if target.stages[:DEFENSE] > 0 end #--------------------------------------------------------------------------- when "LowerTargetSpeed2", "LowerTargetSpeed3" if move.statusMove? - if !target.pbCanLowerStatStage?(:SPEED,user) + if !target.pbCanLowerStatStage?(:SPEED, user) score -= 90 else - score += 20 if user.turnCount==0 - score += target.stages[:SPEED]*20 - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 30 if aspeedospeed + score += 20 if user.turnCount == 0 + score += target.stages[:SPEED] * 20 + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 30 if aspeed < ospeed && aspeed * 2 > ospeed end end else - score += 10 if user.turnCount==0 - score += 30 if target.stages[:SPEED]>0 + score += 10 if user.turnCount == 0 + score += 30 if target.stages[:SPEED] > 0 end #--------------------------------------------------------------------------- when "LowerTargetSpAtk2IfCanAttract" - if user.gender==2 || target.gender==2 || user.gender==target.gender || + if user.gender == 2 || target.gender == 2 || user.gender == target.gender || target.hasActiveAbility?(:OBLIVIOUS) score -= 90 elsif move.statusMove? - if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK,user) + if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user) score -= 90 else - score += 40 if user.turnCount==0 - score += target.stages[:SPECIAL_ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score += 40 if user.turnCount == 0 + score += target.stages[:SPECIAL_ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false target.eachMove do |m| next if !m.specialMove?(m.type) @@ -1104,15 +1104,15 @@ class Battle::AI end if hasSpecicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end else - score += 10 if user.turnCount==0 - score += 20 if target.stages[:SPECIAL_ATTACK]>0 - if skill>=PBTrainerAI.mediumSkill + score += 10 if user.turnCount == 0 + score += 20 if target.stages[:SPECIAL_ATTACK] > 0 + if skill >= PBTrainerAI.mediumSkill hasSpecicalAttack = false target.eachMove do |m| next if !m.specialMove?(m.type) @@ -1125,37 +1125,37 @@ class Battle::AI #--------------------------------------------------------------------------- when "LowerTargetSpDef2", "LowerTargetSpDef3" if move.statusMove? - if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE,user) + if !target.pbCanLowerStatStage?(:SPECIAL_DEFENSE, user) score -= 90 else - score += 40 if user.turnCount==0 - score += target.stages[:SPECIAL_DEFENSE]*20 + score += 40 if user.turnCount == 0 + score += target.stages[:SPECIAL_DEFENSE] * 20 end else - score += 10 if user.turnCount==0 - score += 20 if target.stages[:SPECIAL_DEFENSE]>0 + score += 10 if user.turnCount == 0 + score += 20 if target.stages[:SPECIAL_DEFENSE] > 0 end #--------------------------------------------------------------------------- when "ResetTargetStatStages" - if target.effects[PBEffects::Substitute]>0 + if target.effects[PBEffects::Substitute] > 0 score -= 90 else avg = 0 anyChange = false GameData::Stat.each_battle do |s| - next if target.stages[s.id]==0 + next if target.stages[s.id] == 0 avg += target.stages[s.id] anyChange = true end if anyChange - score += avg*10 + score += avg * 10 else score -= 90 end end #--------------------------------------------------------------------------- when "ResetAllBattlersStatStages" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill stages = 0 @battle.allBattlers.each do |b| totalStages = 0 @@ -1166,61 +1166,61 @@ class Battle::AI stages -= totalStages end end - score += stages*10 + score += stages * 10 end #--------------------------------------------------------------------------- when "UserTargetSwapAtkSpAtkStages" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill aatk = user.stages[:ATTACK] aspa = user.stages[:SPECIAL_ATTACK] oatk = target.stages[:ATTACK] ospa = target.stages[:SPECIAL_ATTACK] - if aatk>=oatk && aspa>=ospa + if aatk >= oatk && aspa >= ospa score -= 80 else - score += (oatk-aatk)*10 - score += (ospa-aspa)*10 + score += (oatk - aatk) * 10 + score += (ospa - aspa) * 10 end else score -= 50 end #--------------------------------------------------------------------------- when "UserTargetSwapDefSpDefStages" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill adef = user.stages[:DEFENSE] aspd = user.stages[:SPECIAL_DEFENSE] odef = target.stages[:DEFENSE] ospd = target.stages[:SPECIAL_DEFENSE] - if adef>=odef && aspd>=ospd + if adef >= odef && aspd >= ospd score -= 80 else - score += (odef-adef)*10 - score += (ospd-aspd)*10 + score += (odef - adef) * 10 + score += (ospd - aspd) * 10 end else score -= 50 end #--------------------------------------------------------------------------- when "UserTargetSwapStatStages" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill userStages = 0 targetStages = 0 GameData::Stat.each_battle do |s| userStages += user.stages[s.id] targetStages += target.stages[s.id] end - score += (targetStages-userStages)*10 + score += (targetStages - userStages) * 10 else score -= 50 end #--------------------------------------------------------------------------- when "UserCopyTargetStatStages" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill equal = true GameData::Stat.each_battle do |s| stagediff = target.stages[s.id] - user.stages[s.id] - score += stagediff*10 - equal = false if stagediff!=0 + score += stagediff * 10 + equal = false if stagediff != 0 end score -= 80 if equal else @@ -1228,16 +1228,16 @@ class Battle::AI end #--------------------------------------------------------------------------- when "StartUserSideImmunityToStatStageLowering" - score -= 80 if user.pbOwnSide.effects[PBEffects::Mist]>0 + score -= 80 if user.pbOwnSide.effects[PBEffects::Mist] > 0 #--------------------------------------------------------------------------- when "UserSwapBaseAtkDef" - if skill>=PBTrainerAI.mediumSkill - aatk = pbRoughStat(user,:ATTACK,skill) - adef = pbRoughStat(user,:DEFENSE,skill) - if aatk==adef || + if skill >= PBTrainerAI.mediumSkill + aatk = pbRoughStat(user, :ATTACK, skill) + adef = pbRoughStat(user, :DEFENSE, skill) + if aatk == adef || user.effects[PBEffects::PowerTrick] # No flip-flopping score -= 90 - elsif adef>aatk # Prefer a higher Attack + elsif adef > aatk # Prefer a higher Attack score += 30 else score -= 30 @@ -1247,14 +1247,14 @@ class Battle::AI end #--------------------------------------------------------------------------- when "UserTargetAverageBaseAtkSpAtk" - if skill>=PBTrainerAI.mediumSkill - aatk = pbRoughStat(user,:ATTACK,skill) - aspatk = pbRoughStat(user,:SPECIAL_ATTACK,skill) - oatk = pbRoughStat(target,:ATTACK,skill) - ospatk = pbRoughStat(target,:SPECIAL_ATTACK,skill) - if aatk= PBTrainerAI.mediumSkill + aatk = pbRoughStat(user, :ATTACK, skill) + aspatk = pbRoughStat(user, :SPECIAL_ATTACK, skill) + oatk = pbRoughStat(target, :ATTACK, skill) + ospatk = pbRoughStat(target, :SPECIAL_ATTACK, skill) + if aatk < oatk && aspatk < ospatk score += 50 - elsif aatk+aspatk=PBTrainerAI.mediumSkill - adef = pbRoughStat(user,:DEFENSE,skill) - aspdef = pbRoughStat(user,:SPECIAL_DEFENSE,skill) - odef = pbRoughStat(target,:DEFENSE,skill) - ospdef = pbRoughStat(target,:SPECIAL_DEFENSE,skill) - if adef= PBTrainerAI.mediumSkill + adef = pbRoughStat(user, :DEFENSE, skill) + aspdef = pbRoughStat(user, :SPECIAL_DEFENSE, skill) + odef = pbRoughStat(target, :DEFENSE, skill) + ospdef = pbRoughStat(target, :SPECIAL_DEFENSE, skill) + if adef < odef && aspdef < ospdef score += 50 - elsif adef+aspdef0 + if target.effects[PBEffects::Substitute] > 0 score -= 90 - elsif user.hp>=(user.hp+target.hp)/2 + elsif user.hp >= (user.hp + target.hp) / 2 score -= 90 else score += 40 end #--------------------------------------------------------------------------- when "StartUserSideDoubleSpeed" - score -= 90 if user.pbOwnSide.effects[PBEffects::Tailwind]>0 + score -= 90 if user.pbOwnSide.effects[PBEffects::Tailwind] > 0 #--------------------------------------------------------------------------- when "ReplaceMoveThisBattleWithTargetLastMoveUsed" moveBlacklist = [ @@ -1339,8 +1339,8 @@ class Battle::AI score -= 90 else has_possible_type = false - user.eachMoveWithIndex do |m,i| - break if Settings::MECHANICS_GENERATION >= 6 && i>0 + user.eachMoveWithIndex do |m, i| + break if Settings::MECHANICS_GENERATION >= 6 && i > 0 next if GameData::Type.get(m.type).pseudo_type next if user.pbHasType?(m.type) has_possible_type = true @@ -1358,7 +1358,7 @@ class Battle::AI else aType = nil target.eachMove do |m| - next if m.id!=target.lastMoveUsed + next if m.id != target.lastMoveUsed aType = m.pbCalcType(user) break end @@ -1379,7 +1379,7 @@ class Battle::AI when "SetUserTypesBasedOnEnvironment" if !user.canChangeType? score -= 90 - elsif skill>=PBTrainerAI.mediumSkill + elsif skill >= PBTrainerAI.mediumSkill new_type = nil case @battle.field.terrain when :Electric @@ -1421,7 +1421,7 @@ class Battle::AI end #--------------------------------------------------------------------------- when "SetTargetTypesToWater" - if target.effects[PBEffects::Substitute]>0 || !target.canChangeType? + if target.effects[PBEffects::Substitute] > 0 || !target.canChangeType? score -= 90 elsif !target.pbHasOtherType?(:WATER) score -= 90 @@ -1436,18 +1436,18 @@ class Battle::AI end #--------------------------------------------------------------------------- when "SetTargetAbilityToSimple" - if target.effects[PBEffects::Substitute]>0 + if target.effects[PBEffects::Substitute] > 0 score -= 90 - elsif skill>=PBTrainerAI.mediumSkill + elsif skill >= PBTrainerAI.mediumSkill if target.unstoppableAbility? || [:TRUANT, :SIMPLE].include?(target.ability) score -= 90 end end #--------------------------------------------------------------------------- when "SetTargetAbilityToInsomnia" - if target.effects[PBEffects::Substitute]>0 + if target.effects[PBEffects::Substitute] > 0 score -= 90 - elsif skill>=PBTrainerAI.mediumSkill + elsif skill >= PBTrainerAI.mediumSkill if target.unstoppableAbility? || [:TRUANT, :INSOMNIA].include?(target.ability_id) score -= 90 end @@ -1455,15 +1455,15 @@ class Battle::AI #--------------------------------------------------------------------------- when "SetUserAbilityToTargetAbility" score -= 40 # don't prefer this move - if skill>=PBTrainerAI.mediumSkill - if !target.ability || user.ability==target.ability || + if skill >= PBTrainerAI.mediumSkill + if !target.ability || user.ability == target.ability || [:MULTITYPE, :RKSSYSTEM].include?(user.ability_id) || [:FLOWERGIFT, :FORECAST, :ILLUSION, :IMPOSTER, :MULTITYPE, :RKSSYSTEM, :TRACE, :WONDERGUARD, :ZENMODE].include?(target.ability_id) score -= 90 end end - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if target.ability == :TRUANT && user.opposes?(target) score -= 90 elsif target.ability == :SLOWSTART && user.opposes?(target) @@ -1473,16 +1473,16 @@ class Battle::AI #--------------------------------------------------------------------------- when "SetTargetAbilityToUserAbility" score -= 40 # don't prefer this move - if target.effects[PBEffects::Substitute]>0 + if target.effects[PBEffects::Substitute] > 0 score -= 90 - elsif skill>=PBTrainerAI.mediumSkill - if !user.ability || user.ability==target.ability || + elsif skill >= PBTrainerAI.mediumSkill + if !user.ability || user.ability == target.ability || [:MULTITYPE, :RKSSYSTEM, :TRUANT].include?(target.ability_id) || [:FLOWERGIFT, :FORECAST, :ILLUSION, :IMPOSTER, :MULTITYPE, :RKSSYSTEM, :TRACE, :ZENMODE].include?(user.ability_id) score -= 90 end - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if user.ability == :TRUANT && user.opposes?(target) score += 90 elsif user.ability == :SLOWSTART && user.opposes?(target) @@ -1493,15 +1493,15 @@ class Battle::AI #--------------------------------------------------------------------------- when "UserTargetSwapAbilities" score -= 40 # don't prefer this move - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if (!user.ability && !target.ability) || - user.ability==target.ability || + user.ability == target.ability || [:ILLUSION, :MULTITYPE, :RKSSYSTEM, :WONDERGUARD].include?(user.ability_id) || [:ILLUSION, :MULTITYPE, :RKSSYSTEM, :WONDERGUARD].include?(target.ability_id) score -= 90 end end - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if target.ability == :TRUANT && user.opposes?(target) score -= 90 elsif target.ability == :SLOWSTART && user.opposes?(target) @@ -1510,10 +1510,10 @@ class Battle::AI end #--------------------------------------------------------------------------- when "NegateTargetAbility" - if target.effects[PBEffects::Substitute]>0 || + if target.effects[PBEffects::Substitute] > 0 || target.effects[PBEffects::GastroAcid] score -= 90 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 if [:MULTITYPE, :RKSSYSTEM, :SLOWSTART, :TRUANT].include?(target.ability_id) end #--------------------------------------------------------------------------- @@ -1521,66 +1521,66 @@ class Battle::AI score -= 70 #--------------------------------------------------------------------------- when "FixedDamage20" - if target.hp<=20 + if target.hp <= 20 score += 80 - elsif target.level>=25 + elsif target.level >= 25 score -= 60 # Not useful against high-level Pokemon end #--------------------------------------------------------------------------- when "FixedDamage40" - score += 80 if target.hp<=40 + score += 80 if target.hp <= 40 #--------------------------------------------------------------------------- when "FixedDamageHalfTargetHP" score -= 50 - score += target.hp*100/target.totalhp + score += target.hp * 100 / target.totalhp #--------------------------------------------------------------------------- when "FixedDamageUserLevel" - score += 80 if target.hp<=user.level + score += 80 if target.hp <= user.level #--------------------------------------------------------------------------- when "LowerTargetHPToUserHP" - if user.hp>=target.hp + if user.hp >= target.hp score -= 90 - elsif user.hpuser.level + score -= 90 if target.level > user.level #--------------------------------------------------------------------------- when "CounterPhysicalDamage" - if target.effects[PBEffects::HyperBeam]>0 + if target.effects[PBEffects::HyperBeam] > 0 score -= 90 else - attack = pbRoughStat(user,:ATTACK,skill) - spatk = pbRoughStat(user,:SPECIAL_ATTACK,skill) - if attack*1.5=PBTrainerAI.mediumSkill && target.lastMoveUsed + elsif skill >= PBTrainerAI.mediumSkill && target.lastMoveUsed moveData = GameData::Move.get(target.lastMoveUsed) score += 60 if moveData.physical? end end #--------------------------------------------------------------------------- when "CounterSpecialDamage" - if target.effects[PBEffects::HyperBeam]>0 + if target.effects[PBEffects::HyperBeam] > 0 score -= 90 else - attack = pbRoughStat(user,:ATTACK,skill) - spatk = pbRoughStat(user,:SPECIAL_ATTACK,skill) - if attack>spatk*1.5 + attack = pbRoughStat(user, :ATTACK, skill) + spatk = pbRoughStat(user, :SPECIAL_ATTACK, skill) + if attack > spatk * 1.5 score -= 60 - elsif skill>=PBTrainerAI.mediumSkill && target.lastMoveUsed + elsif skill >= PBTrainerAI.mediumSkill && target.lastMoveUsed moveData = GameData::Move.get(target.lastMoveUsed) score += 60 if moveData.special? end end #--------------------------------------------------------------------------- when "CounterDamagePlusHalf" - score -= 90 if target.effects[PBEffects::HyperBeam]>0 + score -= 90 if target.effects[PBEffects::HyperBeam] > 0 #--------------------------------------------------------------------------- when "DamageTargetAlly" target.allAllies.each do |b| @@ -1595,9 +1595,9 @@ class Battle::AI when "DoublePowerIfTargetInSky" #--------------------------------------------------------------------------- when "FlinchTargetDoublePowerIfTargetInSky" - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score += 30 if !target.hasActiveAbility?(:INNERFOCUS) && - target.effects[PBEffects::Substitute]==0 + target.effects[PBEffects::Substitute] == 0 end #--------------------------------------------------------------------------- when "DoublePowerAfterFusionFlare" @@ -1620,15 +1620,15 @@ class Battle::AI when "DoublePowerIfTargetHPLessThanHalf" #--------------------------------------------------------------------------- when "DoublePowerIfUserLostHPThisTurn" - attspeed = pbRoughStat(user,:SPEED,skill) - oppspeed = pbRoughStat(target,:SPEED,skill) - score += 30 if oppspeed>attspeed + attspeed = pbRoughStat(user, :SPEED, skill) + oppspeed = pbRoughStat(target, :SPEED, skill) + score += 30 if oppspeed > attspeed #--------------------------------------------------------------------------- when "DoublePowerIfTargetLostHPThisTurn" - score += 20 if @battle.pbOpposingBattlerCount(user)>1 + score += 20 if @battle.pbOpposingBattlerCount(user) > 1 #--------------------------------------------------------------------------- when "UsedAfterAllyRoundWithDoublePower" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill user.allAllies.each do |b| next if !b.pbHasMove?(move.id) score += 20 @@ -1636,9 +1636,9 @@ class Battle::AI end #--------------------------------------------------------------------------- when "DoublePowerIfTargetActed" - attspeed = pbRoughStat(user,:SPEED,skill) - oppspeed = pbRoughStat(target,:SPEED,skill) - score += 30 if oppspeed>attspeed + attspeed = pbRoughStat(user, :SPEED, skill) + oppspeed = pbRoughStat(target, :SPEED, skill) + score += 30 if oppspeed > attspeed #--------------------------------------------------------------------------- when "DoublePowerIfAllyFaintedLastTurn" #--------------------------------------------------------------------------- @@ -1708,26 +1708,26 @@ class Battle::AI when "AlwaysCriticalHit" #--------------------------------------------------------------------------- when "StartPreventCriticalHitsAgainstUserSide" - score -= 90 if user.pbOwnSide.effects[PBEffects::LuckyChant]>0 + score -= 90 if user.pbOwnSide.effects[PBEffects::LuckyChant] > 0 #--------------------------------------------------------------------------- when "StartWeakenPhysicalDamageAgainstUserSide" - score -= 90 if user.pbOwnSide.effects[PBEffects::Reflect]>0 + score -= 90 if user.pbOwnSide.effects[PBEffects::Reflect] > 0 #--------------------------------------------------------------------------- when "StartWeakenSpecialDamageAgainstUserSide" - score -= 90 if user.pbOwnSide.effects[PBEffects::LightScreen]>0 + score -= 90 if user.pbOwnSide.effects[PBEffects::LightScreen] > 0 #--------------------------------------------------------------------------- when "EffectDependsOnEnvironment" #--------------------------------------------------------------------------- when "EnsureNextMoveAlwaysHits" - score -= 90 if target.effects[PBEffects::Substitute]>0 - score -= 90 if user.effects[PBEffects::LockOn]>0 + score -= 90 if target.effects[PBEffects::Substitute] > 0 + score -= 90 if user.effects[PBEffects::LockOn] > 0 #--------------------------------------------------------------------------- when "StartNegateTargetEvasionStatStageAndGhostImmunity" if target.effects[PBEffects::Foresight] score -= 90 elsif target.pbHasType?(:GHOST) score += 70 - elsif target.stages[:EVASION]<=0 + elsif target.stages[:EVASION] <= 0 score -= 60 end #--------------------------------------------------------------------------- @@ -1736,21 +1736,21 @@ class Battle::AI score -= 90 elsif target.pbHasType?(:DARK) score += 70 - elsif target.stages[:EVASION]<=0 + elsif target.stages[:EVASION] <= 0 score -= 60 end #--------------------------------------------------------------------------- when "IgnoreTargetDefSpDefEvaStatStages" #--------------------------------------------------------------------------- when "ProtectUser" - if user.effects[PBEffects::ProtectRate]>1 || - target.effects[PBEffects::HyperBeam]>0 + if user.effects[PBEffects::ProtectRate] > 1 || + target.effects[PBEffects::HyperBeam] > 0 score -= 90 else - if skill>=PBTrainerAI.mediumSkill - score -= user.effects[PBEffects::ProtectRate]*40 + if skill >= PBTrainerAI.mediumSkill + score -= user.effects[PBEffects::ProtectRate] * 40 end - score += 50 if user.turnCount==0 + score += 50 if user.turnCount == 0 score += 30 if target.effects[PBEffects::TwoTurnAttack] end #--------------------------------------------------------------------------- @@ -1762,7 +1762,7 @@ class Battle::AI #--------------------------------------------------------------------------- when "UseLastMoveUsedByTarget" score -= 40 - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score -= 100 if !target.lastRegularMoveUsed || !GameData::Move.get(target.lastRegularMoveUsed).flags.any? { |f| f[/^CanMirrorMove$/i] } end @@ -1795,20 +1795,20 @@ class Battle::AI score -= 90 if user.effects[PBEffects::Imprison] #--------------------------------------------------------------------------- when "DisableTargetLastMoveUsed" - score -= 90 if target.effects[PBEffects::Disable]>0 + score -= 90 if target.effects[PBEffects::Disable] > 0 #--------------------------------------------------------------------------- when "DisableTargetStatusMoves" - score -= 90 if target.effects[PBEffects::Taunt]>0 + score -= 90 if target.effects[PBEffects::Taunt] > 0 #--------------------------------------------------------------------------- when "DisableTargetHealingMoves" - score -= 90 if target.effects[PBEffects::HealBlock]>0 + score -= 90 if target.effects[PBEffects::HealBlock] > 0 #--------------------------------------------------------------------------- when "DisableTargetUsingDifferentMove" - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - if target.effects[PBEffects::Encore]>0 + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + if target.effects[PBEffects::Encore] > 0 score -= 90 - elsif aspeed>ospeed + elsif aspeed > ospeed if !target.lastRegularMoveUsed score -= 90 else @@ -1841,10 +1841,10 @@ class Battle::AI when "TwoTurnAttack" #--------------------------------------------------------------------------- when "TwoTurnAttackFlinchTarget" - score += 20 if user.effects[PBEffects::FocusEnergy]>0 - if skill>=PBTrainerAI.highSkill + score += 20 if user.effects[PBEffects::FocusEnergy] > 0 + if skill >= PBTrainerAI.highSkill score += 20 if !target.hasActiveAbility?(:INNERFOCUS) && - target.effects[PBEffects::Substitute]==0 + target.effects[PBEffects::Substitute] == 0 end #--------------------------------------------------------------------------- when "TwoTurnAttackInvulnerableInSky" @@ -1860,10 +1860,10 @@ class Battle::AI when "TwoTurnAttackInvulnerableInSkyTargetCannotAct" #--------------------------------------------------------------------------- when "BindTarget" - score += 40 if target.effects[PBEffects::Trapping]==0 + score += 40 if target.effects[PBEffects::Trapping] == 0 #--------------------------------------------------------------------------- when "BindTargetDoublePowerIfTargetUnderwater" - score += 40 if target.effects[PBEffects::Trapping]==0 + score += 40 if target.effects[PBEffects::Trapping] == 0 #--------------------------------------------------------------------------- when "MultiTurnAttackPreventSleeping" #--------------------------------------------------------------------------- @@ -1872,25 +1872,25 @@ class Battle::AI when "MultiTurnAttackPowersUpEachTurn" #--------------------------------------------------------------------------- when "MultiTurnAttackBideThenReturnDoubleDamage" - if user.hp<=user.totalhp/4 + if user.hp <= user.totalhp / 4 score -= 90 - elsif user.hp<=user.totalhp/2 + elsif user.hp <= user.totalhp / 2 score -= 50 end #--------------------------------------------------------------------------- when "HealUserHalfOfTotalHP", "HealUserHalfOfTotalHPLoseFlyingTypeThisTurn" - if user.hp==user.totalhp || (skill>=PBTrainerAI.mediumSkill && !user.canHeal?) + if user.hp == user.totalhp || (skill >= PBTrainerAI.mediumSkill && !user.canHeal?) score -= 90 else score += 50 - score -= user.hp*100/user.totalhp + score -= user.hp * 100 / user.totalhp end #--------------------------------------------------------------------------- when "HealUserPositionNextTurn" - score -= 90 if @battle.positions[user.index].effects[PBEffects::Wish]>0 + score -= 90 if @battle.positions[user.index].effects[PBEffects::Wish] > 0 #--------------------------------------------------------------------------- when "HealUserDependingOnWeather" - if user.hp==user.totalhp || (skill>=PBTrainerAI.mediumSkill && !user.canHeal?) + if user.hp == user.totalhp || (skill >= PBTrainerAI.mediumSkill && !user.canHeal?) score -= 90 else case user.effectiveWeather @@ -1901,15 +1901,15 @@ class Battle::AI score -= 30 end score += 50 - score -= user.hp*100/user.totalhp + score -= user.hp * 100 / user.totalhp end #--------------------------------------------------------------------------- when "HealUserFullyAndFallAsleep" - if user.hp==user.totalhp || !user.pbCanSleep?(user,false,nil,true) + if user.hp == user.totalhp || !user.pbCanSleep?(user, false, nil, true) score -= 90 else score += 70 - score -= user.hp*140/user.totalhp + score -= user.hp * 140 / user.totalhp score += 30 if user.status != :NONE end #--------------------------------------------------------------------------- @@ -1920,36 +1920,36 @@ class Battle::AI score -= 90 if user.effects[PBEffects::Ingrain] #--------------------------------------------------------------------------- when "StartLeechSeedTarget" - if target.effects[PBEffects::LeechSeed]>=0 + if target.effects[PBEffects::LeechSeed] >= 0 score -= 90 - elsif skill>=PBTrainerAI.mediumSkill && target.pbHasType?(:GRASS) + elsif skill >= PBTrainerAI.mediumSkill && target.pbHasType?(:GRASS) score -= 90 else - score += 60 if user.turnCount==0 + score += 60 if user.turnCount == 0 end #--------------------------------------------------------------------------- when "HealUserByHalfOfDamageDone" - if skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) + if skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) score -= 70 else - score += 20 if user.hp<=user.totalhp/2 + score += 20 if user.hp <= user.totalhp / 2 end #--------------------------------------------------------------------------- when "HealUserByHalfOfDamageDoneIfTargetAsleep" if !target.asleep? score -= 100 - elsif skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) + elsif skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) score -= 70 else - score += 20 if user.hp<=user.totalhp/2 + score += 20 if user.hp <= user.totalhp / 2 end #--------------------------------------------------------------------------- when "HealTargetHalfOfTotalHP" if user.opposes?(target) score -= 100 else - score += 20 if target.hp=PBTrainerAI.mediumSkill && reserves==0 && foes>0 + elsif skill >= PBTrainerAI.mediumSkill && reserves == 0 && foes > 0 score -= 100 # don't want to lose - elsif skill>=PBTrainerAI.highSkill && reserves==0 && foes==0 + elsif skill >= PBTrainerAI.highSkill && reserves == 0 && foes == 0 score += 80 # want to draw else - score -= user.hp*100/user.totalhp + score -= user.hp * 100 / user.totalhp end #--------------------------------------------------------------------------- when "UserFaintsFixedDamageUserHP" #--------------------------------------------------------------------------- when "UserFaintsLowerTargetAtkSpAtk2" - if !target.pbCanLowerStatStage?(:ATTACK,user) && - !target.pbCanLowerStatStage?(:SPECIAL_ATTACK,user) + if !target.pbCanLowerStatStage?(:ATTACK, user) && + !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user) score -= 100 - elsif @battle.pbAbleNonActiveCount(user.idxOwnSide)==0 + elsif @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 score -= 100 else - score += target.stages[:ATTACK]*10 - score += target.stages[:SPECIAL_ATTACK]*10 - score -= user.hp*100/user.totalhp + score += target.stages[:ATTACK] * 10 + score += target.stages[:SPECIAL_ATTACK] * 10 + score -= user.hp * 100 / user.totalhp end #--------------------------------------------------------------------------- when "UserFaintsHealAndCureReplacement", "UserFaintsHealAndCureReplacementRestorePP" score -= 70 #--------------------------------------------------------------------------- when "StartPerishCountsForAllBattlers" - if @battle.pbAbleNonActiveCount(user.idxOwnSide)==0 + if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 score -= 90 else - score -= 90 if target.effects[PBEffects::PerishSong]>0 + score -= 90 if target.effects[PBEffects::PerishSong] > 0 end #--------------------------------------------------------------------------- when "ReduceAttackerMovePPTo0IfUserFaints" score += 50 - score -= user.hp*100/user.totalhp - score += 30 if user.hp<=user.totalhp/10 + score -= user.hp * 100 / user.totalhp + score += 30 if user.hp <= user.totalhp / 10 #--------------------------------------------------------------------------- when "AttackerFaintsIfUserFaints" score += 50 - score -= user.hp*100/user.totalhp - score += 30 if user.hp<=user.totalhp/10 + score -= user.hp * 100 / user.totalhp + score += 30 if user.hp <= user.totalhp / 10 #--------------------------------------------------------------------------- when "UserEnduresFaintingThisTurn" - score -= 25 if user.hp>user.totalhp/2 - if skill>=PBTrainerAI.mediumSkill - score -= 90 if user.effects[PBEffects::ProtectRate]>1 - score -= 90 if target.effects[PBEffects::HyperBeam]>0 + score -= 25 if user.hp > user.totalhp / 2 + if skill >= PBTrainerAI.mediumSkill + score -= 90 if user.effects[PBEffects::ProtectRate] > 1 + score -= 90 if target.effects[PBEffects::HyperBeam] > 0 else - score -= user.effects[PBEffects::ProtectRate]*40 + score -= user.effects[PBEffects::ProtectRate] * 40 end #--------------------------------------------------------------------------- when "CannotMakeTargetFaint" - if target.hp==1 + if target.hp == 1 score -= 90 - elsif target.hp<=target.totalhp/8 + elsif target.hp <= target.totalhp / 8 score -= 60 - elsif target.hp<=target.totalhp/4 + elsif target.hp <= target.totalhp / 4 score -= 30 end #--------------------------------------------------------------------------- @@ -2025,13 +2025,13 @@ class Battle::AI @battle.pbTeamAbleNonActiveCount(user.index) > 1 # Don't switch in ace score -= 100 else - score += 40 if user.effects[PBEffects::Confusion]>0 + score += 40 if user.effects[PBEffects::Confusion] > 0 total = 0 GameData::Stat.each_battle { |s| total += user.stages[s.id] } - if total<=0 || user.turnCount==0 + if total <= 0 || user.turnCount == 0 score += 60 else - score -= total*10 + score -= total * 10 # special case: user has no damaging moves hasDamagingMove = false user.eachMove do |m| @@ -2051,26 +2051,26 @@ class Battle::AI #--------------------------------------------------------------------------- when "SwitchOutTargetStatusMove" if target.effects[PBEffects::Ingrain] || - (skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:SUCTIONCUPS)) + (skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:SUCTIONCUPS)) score -= 90 else ch = 0 - @battle.pbParty(target.index).each_with_index do |pkmn,i| - ch += 1 if @battle.pbCanSwitchLax?(target.index,i) + @battle.pbParty(target.index).each_with_index do |pkmn, i| + ch += 1 if @battle.pbCanSwitchLax?(target.index, i) end - score -= 90 if ch==0 + score -= 90 if ch == 0 end - if score>20 - score += 50 if target.pbOwnSide.effects[PBEffects::Spikes]>0 - score += 50 if target.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 + if score > 20 + score += 50 if target.pbOwnSide.effects[PBEffects::Spikes] > 0 + score += 50 if target.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0 score += 50 if target.pbOwnSide.effects[PBEffects::StealthRock] end #--------------------------------------------------------------------------- when "SwitchOutTargetDamagingMove" if !target.effects[PBEffects::Ingrain] && - !(skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:SUCTIONCUPS)) - score += 40 if target.pbOwnSide.effects[PBEffects::Spikes]>0 - score += 40 if target.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 + !(skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:SUCTIONCUPS)) + score += 40 if target.pbOwnSide.effects[PBEffects::Spikes] > 0 + score += 40 if target.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0 score += 40 if target.pbOwnSide.effects[PBEffects::StealthRock] end #--------------------------------------------------------------------------- @@ -2078,13 +2078,13 @@ class Battle::AI if !@battle.pbCanChooseNonActive?(user.index) score -= 100 else - score -= 40 if user.effects[PBEffects::Confusion]>0 + score -= 40 if user.effects[PBEffects::Confusion] > 0 total = 0 GameData::Stat.each_battle { |s| total += user.stages[s.id] } - if total<=0 || user.turnCount==0 + if total <= 0 || user.turnCount == 0 score -= 60 else - score += total*10 + score += total * 10 # special case: user has no damaging moves hasDamagingMove = false user.eachMove do |m| @@ -2097,15 +2097,15 @@ class Battle::AI end #--------------------------------------------------------------------------- when "TrapTargetInBattle" - score -= 90 if target.effects[PBEffects::MeanLook]>=0 + score -= 90 if target.effects[PBEffects::MeanLook] >= 0 #--------------------------------------------------------------------------- when "RemoveTargetItem" - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score += 20 if target.item end #--------------------------------------------------------------------------- when "UserTakesTargetItem" - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if !user.item && target.item score += 40 else @@ -2118,10 +2118,10 @@ class Battle::AI when "UserTargetSwapItems" if !user.item && !target.item score -= 90 - elsif skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:STICKYHOLD) + elsif skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:STICKYHOLD) score -= 90 - elsif user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL, - :CHOICEBAND,:CHOICESCARF,:CHOICESPECS]) + elsif user.hasActiveItem?([:FLAMEORB, :TOXICORB, :STICKYBARB, :IRONBALL, + :CHOICEBAND, :CHOICESCARF, :CHOICESPECS]) score += 50 elsif !user.item && target.item score -= 30 if user.lastMoveUsed && @@ -2132,8 +2132,8 @@ class Battle::AI if !user.item || target.item score -= 90 else - if user.hasActiveItem?([:FLAMEORB,:TOXICORB,:STICKYBARB,:IRONBALL, - :CHOICEBAND,:CHOICESCARF,:CHOICESPECS]) + if user.hasActiveItem?([:FLAMEORB, :TOXICORB, :STICKYBARB, :IRONBALL, + :CHOICEBAND, :CHOICESCARF, :CHOICESPECS]) score += 50 else score -= 80 @@ -2141,8 +2141,8 @@ class Battle::AI end #--------------------------------------------------------------------------- when "UserConsumeTargetBerry", "DestroyTargetBerryOrGem" - if target.effects[PBEffects::Substitute]==0 - if skill>=PBTrainerAI.highSkill && target.item && target.item.is_berry? + if target.effects[PBEffects::Substitute] == 0 + if skill >= PBTrainerAI.highSkill && target.item && target.item.is_berry? score += 30 end end @@ -2161,10 +2161,10 @@ class Battle::AI end #--------------------------------------------------------------------------- when "StartTargetCannotUseItem" - score -= 90 if target.effects[PBEffects::Embargo]>0 + score -= 90 if target.effects[PBEffects::Embargo] > 0 #--------------------------------------------------------------------------- when "StartNegateHeldItems" - if @battle.field.effects[PBEffects::MagicRoom]>0 + if @battle.field.effects[PBEffects::MagicRoom] > 0 score -= 90 else score += 30 if !user.item && target.item @@ -2181,28 +2181,28 @@ class Battle::AI #--------------------------------------------------------------------------- when "RecoilThirdOfDamageDealtParalyzeTarget" score -= 30 - if target.pbCanParalyze?(user,false) + if target.pbCanParalyze?(user, false) score += 30 - if skill>=PBTrainerAI.mediumSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - if aspeed= PBTrainerAI.mediumSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + if aspeed < ospeed score += 30 - elsif aspeed>ospeed + elsif aspeed > ospeed score -= 40 end end - if skill>=PBTrainerAI.highSkill - score -= 40 if target.hasActiveAbility?([:GUTS,:MARVELSCALE,:QUICKFEET]) + if skill >= PBTrainerAI.highSkill + score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET]) end end #--------------------------------------------------------------------------- when "RecoilThirdOfDamageDealtBurnTarget" score -= 30 - if target.pbCanBurn?(user,false) + if target.pbCanBurn?(user, false) score += 30 - if skill>=PBTrainerAI.highSkill - score -= 40 if target.hasActiveAbility?([:GUTS,:MARVELSCALE,:QUICKFEET,:FLAREBOOST]) + if skill >= PBTrainerAI.highSkill + score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :QUICKFEET, :FLAREBOOST]) end end #--------------------------------------------------------------------------- @@ -2249,28 +2249,28 @@ class Battle::AI end #--------------------------------------------------------------------------- when "AddSpikesToFoeSide" - if user.pbOpposingSide.effects[PBEffects::Spikes]>=3 + if user.pbOpposingSide.effects[PBEffects::Spikes] >= 3 score -= 90 else if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) } # Opponent can't switch in any Pokemon score -= 90 else - score += 10*@battle.pbAbleNonActiveCount(user.idxOpposingSide) - score += [40,26,13][user.pbOpposingSide.effects[PBEffects::Spikes]] + score += 10 * @battle.pbAbleNonActiveCount(user.idxOpposingSide) + score += [40, 26, 13][user.pbOpposingSide.effects[PBEffects::Spikes]] end end #--------------------------------------------------------------------------- when "AddToxicSpikesToFoeSide" - if user.pbOpposingSide.effects[PBEffects::ToxicSpikes]>=2 + if user.pbOpposingSide.effects[PBEffects::ToxicSpikes] >= 2 score -= 90 else if user.allOpposing.none? { |b| @battle.pbCanChooseNonActive?(b.index) } # Opponent can't switch in any Pokemon score -= 90 else - score += 8*@battle.pbAbleNonActiveCount(user.idxOpposingSide) - score += [26,13][user.pbOpposingSide.effects[PBEffects::ToxicSpikes]] + score += 8 * @battle.pbAbleNonActiveCount(user.idxOpposingSide) + score += [26, 13][user.pbOpposingSide.effects[PBEffects::ToxicSpikes]] end end #--------------------------------------------------------------------------- @@ -2282,7 +2282,7 @@ class Battle::AI # Opponent can't switch in any Pokemon score -= 90 else - score += 10*@battle.pbAbleNonActiveCount(user.idxOpposingSide) + score += 10 * @battle.pbAbleNonActiveCount(user.idxOpposingSide) end end #--------------------------------------------------------------------------- @@ -2295,17 +2295,17 @@ class Battle::AI when "AddMoneyGainedFromBattle" #--------------------------------------------------------------------------- when "RemoveScreens" - score += 20 if user.pbOpposingSide.effects[PBEffects::AuroraVeil]>0 - score += 20 if user.pbOpposingSide.effects[PBEffects::Reflect]>0 - score += 20 if user.pbOpposingSide.effects[PBEffects::LightScreen]>0 + score += 20 if user.pbOpposingSide.effects[PBEffects::AuroraVeil] > 0 + score += 20 if user.pbOpposingSide.effects[PBEffects::Reflect] > 0 + score += 20 if user.pbOpposingSide.effects[PBEffects::LightScreen] > 0 #--------------------------------------------------------------------------- when "CrashDamageIfFailsUnusableInGravity" - score += 10*(user.stages[:ACCURACY]-target.stages[:EVASION]) + score += 10 * (user.stages[:ACCURACY] - target.stages[:EVASION]) #--------------------------------------------------------------------------- when "UserMakeSubstitute" - if user.effects[PBEffects::Substitute]>0 + if user.effects[PBEffects::Substitute] > 0 score -= 90 - elsif user.hp<=user.totalhp/4 + elsif user.hp <= user.totalhp / 4 score -= 90 end #--------------------------------------------------------------------------- @@ -2313,8 +2313,8 @@ class Battle::AI if user.pbHasType?(:GHOST) if target.effects[PBEffects::Curse] score -= 90 - elsif user.hp<=user.totalhp/2 - if @battle.pbAbleNonActiveCount(user.idxOwnSide)==0 + elsif user.hp <= user.totalhp / 2 + if @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 score -= 90 else score -= 50 @@ -2322,10 +2322,10 @@ class Battle::AI end end else - avg = user.stages[:SPEED]*10 - avg -= user.stages[:ATTACK]*10 - avg -= user.stages[:DEFENSE]*10 - score += avg/3 + avg = user.stages[:SPEED] * 10 + avg -= user.stages[:ATTACK] * 10 + avg -= user.stages[:DEFENSE] * 10 + score += avg / 3 end #--------------------------------------------------------------------------- when "LowerPPOfTargetLastMoveBy4" @@ -2333,38 +2333,38 @@ class Battle::AI #--------------------------------------------------------------------------- when "StartDamageTargetEachTurnIfTargetAsleep" if target.effects[PBEffects::Nightmare] || - target.effects[PBEffects::Substitute]>0 + target.effects[PBEffects::Substitute] > 0 score -= 90 elsif !target.asleep? score -= 90 else - score -= 90 if target.statusCount<=1 - score += 50 if target.statusCount>3 + score -= 90 if target.statusCount <= 1 + score += 50 if target.statusCount > 3 end #--------------------------------------------------------------------------- when "RemoveUserBindingAndEntryHazards" - score += 30 if user.effects[PBEffects::Trapping]>0 - score += 30 if user.effects[PBEffects::LeechSeed]>=0 - if @battle.pbAbleNonActiveCount(user.idxOwnSide)>0 - score += 80 if user.pbOwnSide.effects[PBEffects::Spikes]>0 - score += 80 if user.pbOwnSide.effects[PBEffects::ToxicSpikes]>0 + score += 30 if user.effects[PBEffects::Trapping] > 0 + score += 30 if user.effects[PBEffects::LeechSeed] >= 0 + if @battle.pbAbleNonActiveCount(user.idxOwnSide) > 0 + score += 80 if user.pbOwnSide.effects[PBEffects::Spikes] > 0 + score += 80 if user.pbOwnSide.effects[PBEffects::ToxicSpikes] > 0 score += 80 if user.pbOwnSide.effects[PBEffects::StealthRock] end #--------------------------------------------------------------------------- when "AttackTwoTurnsLater" - if @battle.positions[target.index].effects[PBEffects::FutureSightCounter]>0 + if @battle.positions[target.index].effects[PBEffects::FutureSightCounter] > 0 score -= 100 - elsif @battle.pbAbleNonActiveCount(user.idxOwnSide)==0 + elsif @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 # Future Sight tends to be wasteful if down to last Pokemon score -= 70 end #--------------------------------------------------------------------------- when "UserAddStockpileRaiseDefSpDef1" avg = 0 - avg -= user.stages[:DEFENSE]*10 - avg -= user.stages[:SPECIAL_DEFENSE]*10 - score += avg/2 - if user.effects[PBEffects::Stockpile]>=3 + avg -= user.stages[:DEFENSE] * 10 + avg -= user.stages[:SPECIAL_DEFENSE] * 10 + score += avg / 2 + if user.effects[PBEffects::Stockpile] >= 3 score -= 80 else # More preferable if user also has Spit Up/Swallow @@ -2373,23 +2373,23 @@ class Battle::AI end #--------------------------------------------------------------------------- when "PowerDependsOnUserStockpile" - score -= 100 if user.effects[PBEffects::Stockpile]==0 + score -= 100 if user.effects[PBEffects::Stockpile] == 0 #--------------------------------------------------------------------------- when "HealUserDependingOnUserStockpile" - if user.effects[PBEffects::Stockpile]==0 + if user.effects[PBEffects::Stockpile] == 0 score -= 90 - elsif user.hp==user.totalhp + elsif user.hp == user.totalhp score -= 90 else - mult = [0,25,50,100][user.effects[PBEffects::Stockpile]] + mult = [0, 25, 50, 100][user.effects[PBEffects::Stockpile]] score += mult - score -= user.hp*mult*2/user.totalhp + score -= user.hp * mult * 2 / user.totalhp end #--------------------------------------------------------------------------- when "FailsIfUserDamagedThisTurn" - score += 50 if target.effects[PBEffects::HyperBeam]>0 - score -= 35 if target.hp<=target.totalhp/2 # If target is weak, no - score -= 70 if target.hp<=target.totalhp/4 # need to risk this move + score += 50 if target.effects[PBEffects::HyperBeam] > 0 + score -= 35 if target.hp <= target.totalhp / 2 # If target is weak, no + score -= 70 if target.hp <= target.totalhp / 4 # need to risk this move #--------------------------------------------------------------------------- when "FailsIfTargetActed" #--------------------------------------------------------------------------- @@ -2397,19 +2397,19 @@ class Battle::AI score -= 90 if user.allAllies.length == 0 #--------------------------------------------------------------------------- when "StartGravity" - if @battle.field.effects[PBEffects::Gravity]>0 + if @battle.field.effects[PBEffects::Gravity] > 0 score -= 90 - elsif skill>=PBTrainerAI.mediumSkill + elsif skill >= PBTrainerAI.mediumSkill score -= 30 - score -= 20 if user.effects[PBEffects::SkyDrop]>=0 - score -= 20 if user.effects[PBEffects::MagnetRise]>0 - score -= 20 if user.effects[PBEffects::Telekinesis]>0 + score -= 20 if user.effects[PBEffects::SkyDrop] >= 0 + score -= 20 if user.effects[PBEffects::MagnetRise] > 0 + score -= 20 if user.effects[PBEffects::Telekinesis] > 0 score -= 20 if user.pbHasType?(:FLYING) score -= 20 if user.hasActiveAbility?(:LEVITATE) score -= 20 if user.hasActiveItem?(:AIRBALLOON) - score += 20 if target.effects[PBEffects::SkyDrop]>=0 - score += 20 if target.effects[PBEffects::MagnetRise]>0 - score += 20 if target.effects[PBEffects::Telekinesis]>0 + score += 20 if target.effects[PBEffects::SkyDrop] >= 0 + score += 20 if target.effects[PBEffects::MagnetRise] > 0 + score += 20 if target.effects[PBEffects::Telekinesis] > 0 score += 20 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", "TwoTurnAttackInvulnerableInSkyParalyzeTarget", "TwoTurnAttackInvulnerableInSkyTargetCannotAct") @@ -2419,14 +2419,14 @@ class Battle::AI end #--------------------------------------------------------------------------- when "StartUserAirborne" - if user.effects[PBEffects::MagnetRise]>0 || + if user.effects[PBEffects::MagnetRise] > 0 || user.effects[PBEffects::Ingrain] || user.effects[PBEffects::SmackDown] score -= 90 end #--------------------------------------------------------------------------- when "StartTargetAirborneAndAlwaysHitByMoves" - if target.effects[PBEffects::Telekinesis]>0 || + if target.effects[PBEffects::Telekinesis] > 0 || target.effects[PBEffects::Ingrain] || target.effects[PBEffects::SmackDown] score -= 90 @@ -2435,9 +2435,9 @@ class Battle::AI when "HitsTargetInSky" #--------------------------------------------------------------------------- when "HitsTargetInSkyGroundsTarget" - if skill>=PBTrainerAI.mediumSkill - score += 20 if target.effects[PBEffects::MagnetRise]>0 - score += 20 if target.effects[PBEffects::Telekinesis]>0 + if skill >= PBTrainerAI.mediumSkill + score += 20 if target.effects[PBEffects::MagnetRise] > 0 + score += 20 if target.effects[PBEffects::Telekinesis] > 0 score += 20 if target.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSky", "TwoTurnAttackInvulnerableInSkyParalyzeTarget") score += 20 if target.pbHasType?(:FLYING) @@ -2469,8 +2469,8 @@ class Battle::AI #--------------------------------------------------------------------------- when "AllBattlersLoseHalfHPUserSkipsNextTurn" score += 20 # Shadow moves are more preferable - score += 20 if target.hp>=target.totalhp/2 - score -= 20 if user.hp= target.totalhp / 2 + score -= 20 if user.hp < user.hp / 2 #--------------------------------------------------------------------------- when "UserLosesHalfHP" score += 20 # Shadow moves are more preferable @@ -2487,27 +2487,27 @@ class Battle::AI #--------------------------------------------------------------------------- when "RemoveAllScreens" score += 20 # Shadow moves are more preferable - if target.pbOwnSide.effects[PBEffects::AuroraVeil]>0 || - target.pbOwnSide.effects[PBEffects::Reflect]>0 || - target.pbOwnSide.effects[PBEffects::LightScreen]>0 || - target.pbOwnSide.effects[PBEffects::Safeguard]>0 + if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 || + target.pbOwnSide.effects[PBEffects::Reflect] > 0 || + target.pbOwnSide.effects[PBEffects::LightScreen] > 0 || + target.pbOwnSide.effects[PBEffects::Safeguard] > 0 score += 30 - score -= 90 if user.pbOwnSide.effects[PBEffects::AuroraVeil]>0 || - user.pbOwnSide.effects[PBEffects::Reflect]>0 || - user.pbOwnSide.effects[PBEffects::LightScreen]>0 || - user.pbOwnSide.effects[PBEffects::Safeguard]>0 + score -= 90 if user.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 || + user.pbOwnSide.effects[PBEffects::Reflect] > 0 || + user.pbOwnSide.effects[PBEffects::LightScreen] > 0 || + user.pbOwnSide.effects[PBEffects::Safeguard] > 0 else score -= 110 end #--------------------------------------------------------------------------- when "DoesNothingFailsIfNoAlly", "DoesNothingCongratulations" score -= 95 - score = 0 if skill>=PBTrainerAI.highSkill + score = 0 if skill >= PBTrainerAI.highSkill #--------------------------------------------------------------------------- when "FreezeTargetSuperEffectiveAgainstWater" - if target.pbCanFreeze?(user,false) + if target.pbCanFreeze?(user, false) score += 30 - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill score -= 20 if target.hasActiveAbility?(:MARVELSCALE) end end @@ -2518,12 +2518,12 @@ class Battle::AI user.allAllies.each do |b| next if b.statStageAtMax?(:DEFENSE) && b.statStageAtMax?(:SPECIAL_DEFENSE) hasEffect = true - score -= b.stages[:DEFENSE]*10 - score -= b.stages[:SPECIAL_DEFENSE]*10 + score -= b.stages[:DEFENSE] * 10 + score -= b.stages[:SPECIAL_DEFENSE] * 10 end if hasEffect - score -= user.stages[:DEFENSE]*10 - score -= user.stages[:SPECIAL_DEFENSE]*10 + score -= user.stages[:DEFENSE] * 10 + score -= user.stages[:SPECIAL_DEFENSE] * 10 else score -= 90 end @@ -2532,15 +2532,15 @@ class Battle::AI if target.statStageAtMax?(:SPECIAL_DEFENSE) score -= 90 else - score -= target.stages[:SPECIAL_DEFENSE]*10 + score -= target.stages[:SPECIAL_DEFENSE] * 10 end #--------------------------------------------------------------------------- when "LowerTargetAttack1BypassSubstitute" - if !target.pbCanLowerStatStage?(:ATTACK,user) + if !target.pbCanLowerStatStage?(:ATTACK, user) score -= 90 else - score += target.stages[:ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + score += target.stages[:ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false target.eachMove do |m| next if !m.physicalMove?(m.type) @@ -2549,30 +2549,30 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end #--------------------------------------------------------------------------- when "LowerTargetAtkSpAtk1" - avg = target.stages[:ATTACK]*10 - avg += target.stages[:SPECIAL_ATTACK]*10 - score += avg/2 + avg = target.stages[:ATTACK] * 10 + avg += target.stages[:SPECIAL_ATTACK] * 10 + score += avg / 2 #--------------------------------------------------------------------------- when "HoopaRemoveProtectionsBypassSubstituteLowerUserDef1" - if !user.isSpecies?(:HOOPA) || user.form!=1 + if !user.isSpecies?(:HOOPA) || user.form != 1 score -= 100 else - score += 20 if target.stages[:DEFENSE]>0 + score += 20 if target.stages[:DEFENSE] > 0 end #--------------------------------------------------------------------------- when "LowerTargetSpAtk2", "LowerTargetSpAtk3" - if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK,user) + if !target.pbCanLowerStatStage?(:SPECIAL_ATTACK, user) score -= 90 else - score += 40 if user.turnCount==0 - score += target.stages[:SPECIAL_ATTACK]*20 + score += 40 if user.turnCount == 0 + score += target.stages[:SPECIAL_ATTACK] * 20 end #--------------------------------------------------------------------------- when "RaiseGroundedGrassBattlersAtkSpAtk1" @@ -2584,12 +2584,12 @@ class Battle::AI if user.opposes?(b) score -= 20 else - score -= user.stages[:ATTACK]*10 - score -= user.stages[:SPECIAL_ATTACK]*10 + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:SPECIAL_ATTACK] * 10 end end end - score -= 95 if count==0 + score -= 95 if count == 0 #--------------------------------------------------------------------------- when "RaiseGrassBattlersDef1" count = 0 @@ -2599,14 +2599,14 @@ class Battle::AI if user.opposes?(b) score -= 20 else - score -= user.stages[:DEFENSE]*10 + score -= user.stages[:DEFENSE] * 10 end end end - score -= 95 if count==0 + score -= 95 if count == 0 #--------------------------------------------------------------------------- when "LowerPoisonedTargetAtkSpAtkSpd1" - count=0 + count = 0 @battle.allBattlers.each do |b| if b.poisoned? && (!b.statStageAtMin?(:ATTACK) || @@ -2614,18 +2614,18 @@ class Battle::AI !b.statStageAtMin?(:SPEED)) count += 1 if user.opposes?(b) - score += user.stages[:ATTACK]*10 - score += user.stages[:SPECIAL_ATTACK]*10 - score += user.stages[:SPEED]*10 + score += user.stages[:ATTACK] * 10 + score += user.stages[:SPECIAL_ATTACK] * 10 + score += user.stages[:SPEED] * 10 else score -= 20 end end end - score -= 95 if count==0 + score -= 95 if count == 0 #--------------------------------------------------------------------------- when "InvertTargetStatStages" - if target.effects[PBEffects::Substitute]>0 + if target.effects[PBEffects::Substitute] > 0 score -= 90 else numpos = 0 @@ -2634,8 +2634,8 @@ class Battle::AI numpos += target.stages[s.id] if target.stages[s.id] > 0 numneg += target.stages[s.id] if target.stages[s.id] < 0 end - if numpos!=0 || numneg!=0 - score += (numpos-numneg)*10 + if numpos != 0 || numneg != 0 + score += (numpos - numneg) * 10 else score -= 95 end @@ -2650,42 +2650,42 @@ class Battle::AI when "EffectivenessIncludesFlyingType" #--------------------------------------------------------------------------- when "TargetMovesBecomeElectric" - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score -= 90 if aspeed>ospeed + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score -= 90 if aspeed > ospeed #--------------------------------------------------------------------------- when "NormalMovesBecomeElectric" #--------------------------------------------------------------------------- when "RemoveProtectionsBypassSubstitute" #--------------------------------------------------------------------------- when "TargetNextFireMoveDamagesTarget" - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - if aspeed>ospeed + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + if aspeed > ospeed score -= 90 else score += 30 if target.pbHasMoveType?(:FIRE) end #--------------------------------------------------------------------------- when "ProtectUserSideFromDamagingMovesIfUserFirstTurn" - if user.turnCount==0 + if user.turnCount == 0 score += 30 else score -= 90 # Because it will fail here - score = 0 if skill>=PBTrainerAI.bestSkill + score = 0 if skill >= PBTrainerAI.bestSkill end #--------------------------------------------------------------------------- when "ProtectUserSideFromStatusMoves" #--------------------------------------------------------------------------- when "ProtectUserFromDamagingMovesKingsShield", "ProtectUserFromTargetingMovesSpikyShield" - if user.effects[PBEffects::ProtectRate]>1 || - target.effects[PBEffects::HyperBeam]>0 + if user.effects[PBEffects::ProtectRate] > 1 || + target.effects[PBEffects::HyperBeam] > 0 score -= 90 else - if skill>=PBTrainerAI.mediumSkill - score -= user.effects[PBEffects::ProtectRate]*40 + if skill >= PBTrainerAI.mediumSkill + score -= user.effects[PBEffects::ProtectRate] * 40 end - score += 50 if user.turnCount==0 + score += 50 if user.turnCount == 0 score += 30 if target.effects[PBEffects::TwoTurnAttack] end #--------------------------------------------------------------------------- @@ -2695,10 +2695,10 @@ class Battle::AI user.statStageAtMax?(:SPEED) score -= 90 else - score -= user.stages[:SPECIAL_ATTACK]*10 # Only *10 instead of *20 - score -= user.stages[:SPECIAL_DEFENSE]*10 # because two-turn attack - score -= user.stages[:SPEED]*10 - if skill>=PBTrainerAI.mediumSkill + score -= user.stages[:SPECIAL_ATTACK] * 10 # Only *10 instead of *20 + score -= user.stages[:SPECIAL_DEFENSE] * 10 # because two-turn attack + score -= user.stages[:SPEED] * 10 + if skill >= PBTrainerAI.mediumSkill hasSpecialAttack = false user.eachMove do |m| next if !m.specialMove?(m.type) @@ -2707,33 +2707,33 @@ class Battle::AI end if hasSpecialAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 30 if aspeedospeed + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 30 if aspeed < ospeed && aspeed * 2 > ospeed end end #--------------------------------------------------------------------------- when "HealUserByThreeQuartersOfDamageDone" - if skill>=PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) + if skill >= PBTrainerAI.highSkill && target.hasActiveAbility?(:LIQUIDOOZE) score -= 80 else - score += 40 if user.hp<=user.totalhp/2 + score += 40 if user.hp <= user.totalhp / 2 end #--------------------------------------------------------------------------- when "RaiseTargetAttack1" #--------------------------------------------------------------------------- when "RaiseTargetAttack1IfKOTarget" - score += 20 if !user.statStageAtMax?(:ATTACK) && target.hp<=target.totalhp/4 + score += 20 if !user.statStageAtMax?(:ATTACK) && target.hp <= target.totalhp / 4 #--------------------------------------------------------------------------- when "LowerTargetAtkSpAtk1SwitchOutUser" - avg = target.stages[:ATTACK]*10 - avg += target.stages[:SPECIAL_ATTACK]*10 - score += avg/2 + avg = target.stages[:ATTACK] * 10 + avg += target.stages[:SPECIAL_ATTACK] * 10 + score += avg / 2 #--------------------------------------------------------------------------- when "TrapAllBattlersInBattleForOneTurn" #--------------------------------------------------------------------------- @@ -2753,28 +2753,28 @@ class Battle::AI score -= 90 if !user.belched? #--------------------------------------------------------------------------- when "PoisonTargetLowerTargetSpeed1" - if !target.pbCanPoison?(user,false) && !target.pbCanLowerStatStage?(:SPEED,user) + if !target.pbCanPoison?(user, false) && !target.pbCanLowerStatStage?(:SPEED, user) score -= 90 else - if target.pbCanPoison?(user,false) + if target.pbCanPoison?(user, false) score += 30 - if skill>=PBTrainerAI.mediumSkill - score += 30 if target.hp<=target.totalhp/4 - score += 50 if target.hp<=target.totalhp/8 - score -= 40 if target.effects[PBEffects::Yawn]>0 + if skill >= PBTrainerAI.mediumSkill + score += 30 if target.hp <= target.totalhp / 4 + score += 50 if target.hp <= target.totalhp / 8 + score -= 40 if target.effects[PBEffects::Yawn] > 0 end - if skill>=PBTrainerAI.highSkill - score += 10 if pbRoughStat(target,:DEFENSE,skill)>100 - score += 10 if pbRoughStat(target,:SPECIAL_DEFENSE,skill)>100 - score -= 40 if target.hasActiveAbility?([:GUTS,:MARVELSCALE,:TOXICBOOST]) + if skill >= PBTrainerAI.highSkill + score += 10 if pbRoughStat(target, :DEFENSE, skill) > 100 + score += 10 if pbRoughStat(target, :SPECIAL_DEFENSE, skill) > 100 + score -= 40 if target.hasActiveAbility?([:GUTS, :MARVELSCALE, :TOXICBOOST]) end end - if target.pbCanLowerStatStage?(:SPEED,user) - score += target.stages[:SPEED]*10 - if skill>=PBTrainerAI.highSkill - aspeed = pbRoughStat(user,:SPEED,skill) - ospeed = pbRoughStat(target,:SPEED,skill) - score += 30 if aspeedospeed + if target.pbCanLowerStatStage?(:SPEED, user) + score += target.stages[:SPEED] * 10 + if skill >= PBTrainerAI.highSkill + aspeed = pbRoughStat(user, :SPEED, skill) + ospeed = pbRoughStat(target, :SPEED, skill) + score += 30 if aspeed < ospeed && aspeed * 2 > ospeed end end end @@ -2789,10 +2789,10 @@ class Battle::AI when "CureTargetStatusHealUserHalfOfTotalHP" if target.status == :NONE score -= 90 - elsif user.hp==user.totalhp && target.opposes?(user) + elsif user.hp == user.totalhp && target.opposes?(user) score -= 90 else - score += (user.totalhp-user.hp)*50/user.totalhp + score += (user.totalhp - user.hp) * 50 / user.totalhp score -= 30 if target.opposes?(user) end #--------------------------------------------------------------------------- @@ -2802,12 +2802,12 @@ class Battle::AI user.allAllies.each do |b| next if b.statStageAtMax?(:ATTACK) && b.statStageAtMax?(:SPECIAL_ATTACK) hasEffect = true - score -= b.stages[:ATTACK]*10 - score -= b.stages[:SPECIAL_ATTACK]*10 + score -= b.stages[:ATTACK] * 10 + score -= b.stages[:SPECIAL_ATTACK] * 10 end if hasEffect - score -= user.stages[:ATTACK]*10 - score -= user.stages[:SPECIAL_ATTACK]*10 + score -= user.stages[:ATTACK] * 10 + score -= user.stages[:SPECIAL_ATTACK] * 10 else score -= 90 end @@ -2818,10 +2818,10 @@ class Battle::AI next if target.stages[s.id] <= 0 numStages += target.stages[s.id] end - score += numStages*20 + score += numStages * 20 #--------------------------------------------------------------------------- when "EnsureNextCriticalHit" - if user.effects[PBEffects::LaserFocus]>0 + if user.effects[PBEffects::LaserFocus] > 0 score -= 90 else score += 40 @@ -2831,15 +2831,15 @@ class Battle::AI score += user.stages[:ATTACK] * 10 #--------------------------------------------------------------------------- when "LowerUserDefense1", "LowerUserDefense2" - score += user.stages[:DEFENSE]*10 + score += user.stages[:DEFENSE] * 10 #--------------------------------------------------------------------------- when "HealUserByTargetAttackLowerTargetAttack1" if target.statStageAtMin?(:ATTACK) score -= 90 else - if target.pbCanLowerStatStage?(:ATTACK,user) - score += target.stages[:ATTACK]*20 - if skill>=PBTrainerAI.mediumSkill + if target.pbCanLowerStatStage?(:ATTACK, user) + score += target.stages[:ATTACK] * 20 + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false target.eachMove do |m| next if !m.physicalMove?(m.type) @@ -2848,17 +2848,17 @@ class Battle::AI end if hasPhysicalAttack score += 20 - elsif skill>=PBTrainerAI.highSkill + elsif skill >= PBTrainerAI.highSkill score -= 90 end end end - score += (user.totalhp-user.hp)*50/user.totalhp + score += (user.totalhp - user.hp) * 50 / user.totalhp end #--------------------------------------------------------------------------- when "UserTargetSwapBaseSpeed" - if skill>=PBTrainerAI.mediumSkill - if user.speed>target.speed + if skill >= PBTrainerAI.mediumSkill + if user.speed > target.speed score += 50 else score -= 70 @@ -2873,10 +2873,10 @@ class Battle::AI when "CategoryDependsOnHigherDamageIgnoreTargetAbility" #--------------------------------------------------------------------------- when "NegateTargetAbilityIfTargetActed" - if skill>=PBTrainerAI.mediumSkill - userSpeed = pbRoughStat(user,:SPEED,skill) - targetSpeed = pbRoughStat(target,:SPEED,skill) - if userSpeed= PBTrainerAI.mediumSkill + userSpeed = pbRoughStat(user, :SPEED, skill) + targetSpeed = pbRoughStat(target, :SPEED, skill) + if userSpeed < targetSpeed score += 30 end else @@ -2886,21 +2886,21 @@ class Battle::AI when "DoublePowerIfUserLastMoveFailed" #--------------------------------------------------------------------------- when "StartWeakenDamageAgainstUserSideIfHail" - if user.pbOwnSide.effects[PBEffects::AuroraVeil]>0 || user.effectiveWeather != :Hail + if user.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 || user.effectiveWeather != :Hail score -= 90 else score += 40 end #--------------------------------------------------------------------------- when "ProtectUserBanefulBunker" - if user.effects[PBEffects::ProtectRate]>1 || - target.effects[PBEffects::HyperBeam]>0 + if user.effects[PBEffects::ProtectRate] > 1 || + target.effects[PBEffects::HyperBeam] > 0 score -= 90 else - if skill>=PBTrainerAI.mediumSkill - score -= user.effects[PBEffects::ProtectRate]*40 + if skill >= PBTrainerAI.mediumSkill + score -= user.effects[PBEffects::ProtectRate] * 40 end - score += 50 if user.turnCount==0 + score += 50 if user.turnCount == 0 score += 30 if target.effects[PBEffects::TwoTurnAttack] score += 20 # Because of possible poisoning end @@ -2911,7 +2911,7 @@ class Battle::AI score -= 90 if user.allAllies.length == 0 #--------------------------------------------------------------------------- when "TargetUsesItsLastUsedMoveAgain" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if !target.lastRegularMoveUsed || !target.pbHasMove?(target.lastRegularMoveUsed) || target.usingMultiTurnAttack? @@ -2924,7 +2924,7 @@ class Battle::AI end #--------------------------------------------------------------------------- when "DisableTargetSoundMoves" - if target.effects[PBEffects::ThroatChop]==0 && skill>=PBTrainerAI.highSkill + if target.effects[PBEffects::ThroatChop] == 0 && skill >= PBTrainerAI.highSkill hasSoundMove = false user.eachMove do |m| next if !m.soundMove? @@ -2935,32 +2935,32 @@ class Battle::AI end #--------------------------------------------------------------------------- when "HealUserDependingOnSandstorm" - if user.hp==user.totalhp || (skill>=PBTrainerAI.mediumSkill && !user.canHeal?) + if user.hp == user.totalhp || (skill >= PBTrainerAI.mediumSkill && !user.canHeal?) score -= 90 else score += 50 - score -= user.hp*100/user.totalhp + score -= user.hp * 100 / user.totalhp score += 30 if user.effectiveWeather == :Sandstorm end #--------------------------------------------------------------------------- when "HealTargetDependingOnGrassyTerrain" - if user.hp==user.totalhp || (skill>=PBTrainerAI.mediumSkill && !user.canHeal?) + if user.hp == user.totalhp || (skill >= PBTrainerAI.mediumSkill && !user.canHeal?) score -= 90 else score += 50 - score -= user.hp*100/user.totalhp - if skill>=PBTrainerAI.mediumSkill + score -= user.hp * 100 / user.totalhp + if skill >= PBTrainerAI.mediumSkill score += 30 if @battle.field.terrain == :Grassy end end #--------------------------------------------------------------------------- when "HealAllyOrDamageFoe" if !target.opposes?(user) - if target.hp==target.totalhp || (skill>=PBTrainerAI.mediumSkill && !target.canHeal?) + if target.hp == target.totalhp || (skill >= PBTrainerAI.mediumSkill && !target.canHeal?) score -= 90 else score += 50 - score -= target.hp*100/target.totalhp + score -= target.hp * 100 / target.totalhp end end #--------------------------------------------------------------------------- @@ -2969,16 +2969,16 @@ class Battle::AI foes = @battle.pbAbleNonActiveCount(user.idxOpposingSide) if @battle.pbCheckGlobalAbility(:DAMP) score -= 100 - elsif skill>=PBTrainerAI.mediumSkill && reserves==0 && foes>0 + elsif skill >= PBTrainerAI.mediumSkill && reserves == 0 && foes > 0 score -= 100 # don't want to lose - elsif skill>=PBTrainerAI.highSkill && reserves==0 && foes==0 + elsif skill >= PBTrainerAI.highSkill && reserves == 0 && foes == 0 score += 80 # want to draw else - score -= (user.totalhp-user.hp)*75/user.totalhp + score -= (user.totalhp - user.hp) * 75 / user.totalhp end #--------------------------------------------------------------------------- when "UsedAfterUserTakesPhysicalDamage" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill hasPhysicalAttack = false target.eachMove do |m| next if !m.physicalMove?(m.type) @@ -3174,7 +3174,7 @@ class Battle::AI #--------------------------------------------------------------------------- when "HitThreeTimesAlwaysCriticalHit" if skill >= PBTrainerAI.highSkill - stat = (move.physicalMove?)? :DEFENSE : :SPECIAL_DEFENSE + stat = (move.physicalMove?) ? :DEFENSE : :SPECIAL_DEFENSE score += 50 if targets.stages[stat] > 1 end #--------------------------------------------------------------------------- diff --git a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb index 51110a2c6..76b7ba3fc 100644 --- a/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb +++ b/Data/Scripts/011_Battle/005_AI/006_AI_Move_Utilities.rb @@ -2,7 +2,7 @@ class Battle::AI #============================================================================= # #============================================================================= - def pbTargetsMultiple?(move,user) + def pbTargetsMultiple?(move, user) target_data = move.pbTarget(user) return false if target_data.num_targets <= 1 num_targets = 0 @@ -26,8 +26,8 @@ class Battle::AI #============================================================================= # Move's type effectiveness #============================================================================= - def pbCalcTypeModSingle(moveType,defType,user,target) - ret = Effectiveness.calculate_one(moveType,defType) + def pbCalcTypeModSingle(moveType, defType, user, target) + ret = Effectiveness.calculate_one(moveType, defType) # Ring Target if target.hasActiveItem?(:RINGTARGET) ret = Effectiveness::NORMAL_EFFECTIVE_ONE if Effectiveness.ineffective_type?(moveType, defType) @@ -54,7 +54,7 @@ class Battle::AI return ret end - def pbCalcTypeMod(moveType,user,target) + def pbCalcTypeMod(moveType, user, target) return Effectiveness::NORMAL_EFFECTIVE if !moveType return Effectiveness::NORMAL_EFFECTIVE if moveType == :GROUND && target.pbHasType?(:FLYING) && @@ -70,8 +70,8 @@ class Battle::AI typeMods[0] = Effectiveness::SUPER_EFFECTIVE_ONE end else - tTypes.each_with_index do |type,i| - typeMods[i] = pbCalcTypeModSingle(moveType,type,user,target) + tTypes.each_with_index do |type, i| + typeMods[i] = pbCalcTypeModSingle(moveType, type, user, target) end end # Multiply all effectivenesses together @@ -82,41 +82,41 @@ class Battle::AI # For switching. Determines the effectiveness of a potential switch-in against # an opposing battler. - def pbCalcTypeModPokemon(battlerThis,_battlerOther) + def pbCalcTypeModPokemon(battlerThis, _battlerOther) mod1 = Effectiveness.calculate(battlerThis.types[0], target.types[0], target.types[1]) mod2 = Effectiveness::NORMAL_EFFECTIVE if battlerThis.types.length > 1 mod2 = Effectiveness.calculate(battlerThis.types[1], target.types[0], target.types[1]) mod2 = mod2.to_f / Effectivenesss::NORMAL_EFFECTIVE end - return mod1*mod2 + return mod1 * mod2 end #============================================================================= # Immunity to a move because of the target's ability, item or other effects #============================================================================= - def pbCheckMoveImmunity(score,move,user,target,skill) - type = pbRoughType(move,user,skill) - typeMod = pbCalcTypeMod(type,user,target) + def pbCheckMoveImmunity(score, move, user, target, skill) + type = pbRoughType(move, user, skill) + typeMod = pbCalcTypeMod(type, user, target) # Type effectiveness - return true if Effectiveness.ineffective?(typeMod) || score<=0 + return true if Effectiveness.ineffective?(typeMod) || score <= 0 # Immunity due to ability/item/other effects - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill case type when :GROUND return true if target.airborne? && !move.hitsFlyingTargets? when :FIRE return true if target.hasActiveAbility?(:FLASHFIRE) when :WATER - return true if target.hasActiveAbility?([:DRYSKIN,:STORMDRAIN,:WATERABSORB]) + return true if target.hasActiveAbility?([:DRYSKIN, :STORMDRAIN, :WATERABSORB]) when :GRASS return true if target.hasActiveAbility?(:SAPSIPPER) when :ELECTRIC - return true if target.hasActiveAbility?([:LIGHTNINGROD,:MOTORDRIVE,:VOLTABSORB]) + return true if target.hasActiveAbility?([:LIGHTNINGROD, :MOTORDRIVE, :VOLTABSORB]) end return true if Effectiveness.not_very_effective?(typeMod) && target.hasActiveAbility?(:WONDERGUARD) - return true if move.damagingMove? && user.index!=target.index && !target.opposes?(user) && + return true if move.damagingMove? && user.index != target.index && !target.opposes?(user) && target.hasActiveAbility?(:TELEPATHY) return true if move.statusMove? && move.canMagicCoat? && target.hasActiveAbility?(:MAGICBOUNCE) && target.opposes?(user) @@ -127,11 +127,11 @@ class Battle::AI return true if target.hasActiveAbility?(:OVERCOAT) return true if target.hasActiveItem?(:SAFETYGOGGLES) end - return true if target.effects[PBEffects::Substitute]>0 && move.statusMove? && - !move.ignoresSubstitute?(user) && user.index!=target.index + return true if target.effects[PBEffects::Substitute] > 0 && move.statusMove? && + !move.ignoresSubstitute?(user) && user.index != target.index return true if Settings::MECHANICS_GENERATION >= 7 && user.hasActiveAbility?(:PRANKSTER) && target.pbHasType?(:DARK) && target.opposes?(user) - return true if move.priority>0 && @battle.field.terrain == :Psychic && + return true if move.priority > 0 && @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) end return false @@ -140,19 +140,19 @@ class Battle::AI #============================================================================= # Get approximate properties for a battler #============================================================================= - def pbRoughType(move,user,skill) + def pbRoughType(move, user, skill) ret = move.type - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill ret = move.pbCalcType(user) end return ret end - def pbRoughStat(battler,stat,skill) - return battler.pbSpeed if skill>=PBTrainerAI.highSkill && stat==:SPEED - stageMul = [2,2,2,2,2,2, 2, 3,4,5,6,7,8] - stageDiv = [8,7,6,5,4,3, 2, 2,2,2,2,2,2] - stage = battler.stages[stat]+6 + def pbRoughStat(battler, stat, skill) + return battler.pbSpeed if skill >= PBTrainerAI.highSkill && stat == :SPEED + stageMul = [2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 8] + stageDiv = [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2] + stage = battler.stages[stat] + 6 value = 0 case stat when :ATTACK then value = battler.attack @@ -161,24 +161,24 @@ class Battle::AI when :SPECIAL_DEFENSE then value = battler.spdef when :SPEED then value = battler.speed end - return (value.to_f*stageMul[stage]/stageDiv[stage]).floor + return (value.to_f * stageMul[stage] / stageDiv[stage]).floor end #============================================================================= # Get a better move's base damage value #============================================================================= - def pbMoveBaseDamage(move,user,target,skill) + def pbMoveBaseDamage(move, user, target, skill) baseDmg = move.baseDamage - baseDmg = 60 if baseDmg==1 - return baseDmg if skill=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] + baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] # Sonic Boom, Dragon Rage, Super Fang, Night Shade, Endeavor when "FixedDamage20", "FixedDamage40", "FixedDamageHalfTargetHP", "FixedDamageUserLevel", "LowerTargetHPToUserHP" - baseDmg = move.pbFixedDamage(user,target) + baseDmg = move.pbFixedDamage(user, target) when "FixedDamageUserLevelRandom" # Psywave baseDmg = user.level when "OHKO", "OHKOIce", "OHKOHitsUndergroundTarget" @@ -187,7 +187,7 @@ class Battle::AI baseDmg = 60 when "DoublePowerIfTargetUnderwater", "DoublePowerIfTargetUnderground", "BindTargetDoublePowerIfTargetUnderwater" - baseDmg = move.pbModifyDamage(baseDmg,user,target) + baseDmg = move.pbModifyDamage(baseDmg, user, target) # Gust, Twister, Venoshock, Smelling Salts, Wake-Up Slap, Facade, Hex, Brine, # Retaliate, Weather Ball, Return, Frustration, Eruption, Crush Grip, # Stored Power, Punishment, Hidden Power, Fury Cutter, Echoed Voice, @@ -217,13 +217,13 @@ class Battle::AI "PowerHigherWithTargetWeight", "ThrowUserItemAtTarget", "PowerDependsOnUserStockpile" - baseDmg = move.pbBaseDamage(baseDmg,user,target) + baseDmg = move.pbBaseDamage(baseDmg, user, target) when "DoublePowerIfUserHasNoItem" # Acrobatics baseDmg *= 2 if !user.item || user.hasActiveItem?(:FLYINGGEM) when "PowerHigherWithTargetFasterThanUser" # Gyro Ball - targetSpeed = pbRoughStat(target,:SPEED,skill) - userSpeed = pbRoughStat(user,:SPEED,skill) - baseDmg = [[(25*targetSpeed/userSpeed).floor,150].min,1].max + targetSpeed = pbRoughStat(target, :SPEED, skill) + userSpeed = pbRoughStat(user, :SPEED, skill) + baseDmg = [[(25 * targetSpeed / userSpeed).floor, 150].min, 1].max when "RandomlyDamageOrHealTarget" # Present baseDmg = 50 when "RandomPowerDoublePowerIfTargetUnderground" # Magnitude @@ -232,8 +232,8 @@ class Battle::AI when "TypeAndPowerDependOnUserBerry" # Natural Gift baseDmg = move.pbNaturalGiftBaseDamage(user.item_id) when "PowerHigherWithUserHeavierThanTarget" # Heavy Slam - baseDmg = move.pbBaseDamage(baseDmg,user,target) - baseDmg *= 2 if Settings::MECHANICS_GENERATION >= 7 && skill>=PBTrainerAI.mediumSkill && + baseDmg = move.pbBaseDamage(baseDmg, user, target) + baseDmg *= 2 if Settings::MECHANICS_GENERATION >= 7 && skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] when "AlwaysCriticalHit", "HitTwoTimes", "HitTwoTimesPoisonTarget" # Frost Breath, Double Kick, Twineedle baseDmg *= 2 @@ -255,12 +255,12 @@ class Battle::AI end when "HitOncePerUserTeamMember" # 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 == :NONE end baseDmg *= mult when "TwoTurnAttackOneTurnInSun" # Solar Beam - baseDmg = move.pbBaseDamageMultiplier(baseDmg,user,target) + baseDmg = move.pbBaseDamageMultiplier(baseDmg, user, target) when "MultiTurnAttackPowersUpEachTurn" # Rollout baseDmg *= 2 if user.effects[PBEffects::DefenseCurl] when "MultiTurnAttackBideThenReturnDoubleDamage" # Bide @@ -269,23 +269,23 @@ class Battle::AI baseDmg = user.hp when "EffectivenessIncludesFlyingType" # Flying Press if GameData::Type.exists?(:FLYING) - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill targetTypes = target.pbTypes(true) mult = Effectiveness.calculate(:FLYING, - targetTypes[0],targetTypes[1],targetTypes[2]) - baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round + targetTypes[0], targetTypes[1], targetTypes[2]) + baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round else mult = Effectiveness.calculate(:FLYING, target.types[0], target.types[1], target.effects[PBEffects::Type3]) - baseDmg = (baseDmg.to_f*mult/Effectiveness::NORMAL_EFFECTIVE).round + baseDmg = (baseDmg.to_f * mult / Effectiveness::NORMAL_EFFECTIVE).round end end - baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] + baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] when "DoublePowerIfUserLastMoveFailed" # Stomping Tantrum baseDmg *= 2 if user.lastRoundMoveFailed when "HitTwoTimesFlinchTarget" # Double Iron Bash baseDmg *= 2 - baseDmg *= 2 if skill>=PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] + baseDmg *= 2 if skill >= PBTrainerAI.mediumSkill && target.effects[PBEffects::Minimize] end return baseDmg end @@ -293,28 +293,28 @@ class Battle::AI #============================================================================= # Damage calculation #============================================================================= - def pbRoughDamage(move,user,target,skill,baseDmg) + def pbRoughDamage(move, user, target, skill, baseDmg) # Fixed damage moves return baseDmg if move.is_a?(Battle::Move::FixedDamageMove) # Get the move's type - type = pbRoughType(move,user,skill) + type = pbRoughType(move, user, skill) ##### Calculate user's attack stat ##### - atk = pbRoughStat(user,:ATTACK,skill) - if move.function=="UseTargetAttackInsteadOfUserAttack" # Foul Play - atk = pbRoughStat(target,:ATTACK,skill) - elsif move.function=="UseUserBaseDefenseInsteadOfUserBaseAttack" # Body Press - atk = pbRoughStat(user,:DEFENSE,skill) + atk = pbRoughStat(user, :ATTACK, skill) + if move.function == "UseTargetAttackInsteadOfUserAttack" # Foul Play + atk = pbRoughStat(target, :ATTACK, skill) + elsif move.function == "UseUserBaseDefenseInsteadOfUserBaseAttack" # Body Press + atk = pbRoughStat(user, :DEFENSE, skill) elsif move.specialMove?(type) - if move.function=="UseTargetAttackInsteadOfUserAttack" # Foul Play - atk = pbRoughStat(target,:SPECIAL_ATTACK,skill) + if move.function == "UseTargetAttackInsteadOfUserAttack" # Foul Play + atk = pbRoughStat(target, :SPECIAL_ATTACK, skill) else - atk = pbRoughStat(user,:SPECIAL_ATTACK,skill) + atk = pbRoughStat(user, :SPECIAL_ATTACK, skill) end end ##### Calculate target's defense stat ##### - defense = pbRoughStat(target,:DEFENSE,skill) - if move.specialMove?(type) && move.function!="UseTargetDefenseInsteadOfTargetSpDef" # Psyshock - defense = pbRoughStat(target,:SPECIAL_DEFENSE,skill) + defense = pbRoughStat(target, :DEFENSE, skill) + if move.specialMove?(type) && move.function != "UseTargetDefenseInsteadOfTargetSpDef" # Psyshock + defense = pbRoughStat(target, :SPECIAL_DEFENSE, skill) end ##### Calculate all multiplier effects ##### multipliers = { @@ -325,13 +325,13 @@ class Battle::AI } # Ability effects that alter damage moldBreaker = false - if skill>=PBTrainerAI.highSkill && target.hasMoldBreaker? + if skill >= PBTrainerAI.highSkill && target.hasMoldBreaker? moldBreaker = true end - if skill>=PBTrainerAI.mediumSkill && user.abilityActive? + if skill >= PBTrainerAI.mediumSkill && user.abilityActive? # NOTE: These abilities aren't suitable for checking at the start of the # round. - abilityBlacklist = [:ANALYTIC,:SNIPER,:TINTEDLENS,:AERILATE,:PIXILATE,:REFRIGERATE] + abilityBlacklist = [:ANALYTIC, :SNIPER, :TINTEDLENS, :AERILATE, :PIXILATE, :REFRIGERATE] canCheck = true abilityBlacklist.each do |m| next if move.id != m @@ -340,20 +340,20 @@ class Battle::AI end if canCheck Battle::AbilityEffects.triggerDamageCalcFromUser(user.ability, - user,target,move,multipliers,baseDmg,type) + user, target, move, multipliers, baseDmg, type) end end - if skill>=PBTrainerAI.mediumSkill && !moldBreaker + if skill >= PBTrainerAI.mediumSkill && !moldBreaker user.allAllies.each do |b| next if !b.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromAlly(b.ability, - user,target,move,multipliers,baseDmg,type) + user, target, move, multipliers, baseDmg, type) end end - if skill>=PBTrainerAI.bestSkill && !moldBreaker && target.abilityActive? + if skill >= PBTrainerAI.bestSkill && !moldBreaker && target.abilityActive? # NOTE: These abilities aren't suitable for checking at the start of the # round. - abilityBlacklist = [:FILTER,:SOLIDROCK] + abilityBlacklist = [:FILTER, :SOLIDROCK] canCheck = true abilityBlacklist.each do |m| next if move.id != m @@ -362,38 +362,38 @@ class Battle::AI end if canCheck Battle::AbilityEffects.triggerDamageCalcFromTarget(target.ability, - user,target,move,multipliers,baseDmg,type) + user, target, move, multipliers, baseDmg, type) end end - if skill>=PBTrainerAI.bestSkill && !moldBreaker + if skill >= PBTrainerAI.bestSkill && !moldBreaker target.allAllies.each do |b| next if !b.abilityActive? Battle::AbilityEffects.triggerDamageCalcFromTargetAlly(b.ability, - user,target,move,multipliers,baseDmg,type) + user, target, move, multipliers, baseDmg, type) end end # Item effects that alter damage # NOTE: Type-boosting gems aren't suitable for checking at the start of the # round. - if skill>=PBTrainerAI.mediumSkill && user.itemActive? + if skill >= PBTrainerAI.mediumSkill && user.itemActive? # NOTE: These items aren't suitable for checking at the start of the # round. - itemBlacklist = [:EXPERTBELT,:LIFEORB] + itemBlacklist = [:EXPERTBELT, :LIFEORB] if !itemBlacklist.include?(user.item_id) Battle::ItemEffects.triggerDamageCalcFromUser(user.item, - user,target,move,multipliers,baseDmg,type) + user, target, move, multipliers, baseDmg, type) end end - if skill>=PBTrainerAI.bestSkill && target.itemActive? + if skill >= PBTrainerAI.bestSkill && target.itemActive? # NOTE: Type-weakening berries aren't suitable for checking at the start # of the round. if target.item && !target.item.is_berry? Battle::ItemEffects.triggerDamageCalcFromTarget(target.item, - user,target,move,multipliers,baseDmg,type) + user, target, move, multipliers, baseDmg, type) end end # Global abilities - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if (@battle.pbCheckGlobalAbility(:DARKAURA) && type == :DARK) || (@battle.pbCheckGlobalAbility(:FAIRYAURA) && type == :FAIRY) if @battle.pbCheckGlobalAbility(:AURABREAK) @@ -404,25 +404,25 @@ class Battle::AI end end # Parental Bond - if skill>=PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND) + if skill >= PBTrainerAI.mediumSkill && user.hasActiveAbility?(:PARENTALBOND) multipliers[:base_damage_multiplier] *= 1.25 end # Me First # TODO # Helping Hand - n/a # Charge - if skill>=PBTrainerAI.mediumSkill - if user.effects[PBEffects::Charge]>0 && type == :ELECTRIC + if skill >= PBTrainerAI.mediumSkill + if user.effects[PBEffects::Charge] > 0 && type == :ELECTRIC multipliers[:base_damage_multiplier] *= 2 end end # Mud Sport and Water Sport - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if type == :ELECTRIC if @battle.allBattlers.any? { |b| b.effects[PBEffects::MudSport] } multipliers[:base_damage_multiplier] /= 3 end - if @battle.field.effects[PBEffects::MudSportField]>0 + if @battle.field.effects[PBEffects::MudSportField] > 0 multipliers[:base_damage_multiplier] /= 3 end end @@ -430,13 +430,13 @@ class Battle::AI if @battle.allBattlers.any? { |b| b.effects[PBEffects::WaterSport] } multipliers[:base_damage_multiplier] /= 3 end - if @battle.field.effects[PBEffects::WaterSportField]>0 + if @battle.field.effects[PBEffects::WaterSportField] > 0 multipliers[:base_damage_multiplier] /= 3 end end end # Terrain moves - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill case @battle.field.terrain when :Electric multipliers[:base_damage_multiplier] *= 1.5 if type == :ELECTRIC && user.affectedByTerrain? @@ -449,7 +449,7 @@ class Battle::AI end end # Badge multipliers - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if @battle.internalBattle # Don't need to check the Atk/Sp Atk-boosting badges because the AI # won't control the player's Pokémon. @@ -463,13 +463,13 @@ class Battle::AI end end # Multi-targeting attacks - if skill>=PBTrainerAI.highSkill - if pbTargetsMultiple?(move,user) + if skill >= PBTrainerAI.highSkill + if pbTargetsMultiple?(move, user) multipliers[:final_damage_multiplier] *= 0.75 end end # Weather - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill case user.effectiveWeather when :Sun, :HarshSun if type == :FIRE @@ -493,7 +493,7 @@ class Battle::AI # Critical hits - n/a # Random variance - n/a # STAB - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if type && user.pbHasType?(type) if user.hasActiveAbility?(:ADAPTABILITY) multipliers[:final_damage_multiplier] *= 2 @@ -503,12 +503,12 @@ class Battle::AI end end # Type effectiveness - if skill>=PBTrainerAI.mediumSkill - typemod = pbCalcTypeMod(type,user,target) + if skill >= PBTrainerAI.mediumSkill + typemod = pbCalcTypeMod(type, user, target) multipliers[:final_damage_multiplier] *= typemod.to_f / Effectiveness::NORMAL_EFFECTIVE end # Burn - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if user.status == :BURN && move.physicalMove?(type) && !user.hasActiveAbility?(:GUTS) && !(Settings::MECHANICS_GENERATION >= 6 && move.function == "DoublePowerIfUserPoisonedBurnedParalyzed") # Facade @@ -516,7 +516,7 @@ class Battle::AI end end # Aurora Veil, Reflect, Light Screen - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if !move.ignoresReflect? && !user.hasActiveAbility?(:INFILTRATOR) if target.pbOwnSide.effects[PBEffects::AuroraVeil] > 0 if @battle.pbSideBattlerCount(target) > 1 @@ -540,7 +540,7 @@ class Battle::AI end end # Minimize - if skill>=PBTrainerAI.highSkill + if skill >= PBTrainerAI.highSkill if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(2) multipliers[:final_damage_multiplier] *= 2 end @@ -554,39 +554,39 @@ class Battle::AI atk = [(atk * multipliers[:attack_multiplier]).round, 1].max defense = [(defense * multipliers[:defense_multiplier]).round, 1].max damage = (((2.0 * user.level / 5 + 2).floor * baseDmg * atk / defense).floor / 50).floor + 2 - damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max + damage = [(damage * multipliers[:final_damage_multiplier]).round, 1].max # "AI-specific calculations below" # Increased critical hit rates - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill c = 0 # Ability effects that alter critical hit rate - if c>=0 && user.abilityActive? + if c >= 0 && user.abilityActive? c = Battle::AbilityEffects.triggerCriticalCalcFromUser(user.ability, user, target, c) end - if skill>=PBTrainerAI.bestSkill - if c>=0 && !moldBreaker && target.abilityActive? + if skill >= PBTrainerAI.bestSkill + if c >= 0 && !moldBreaker && target.abilityActive? c = Battle::AbilityEffects.triggerCriticalCalcFromTarget(target.ability, user, target, c) end end # Item effects that alter critical hit rate - if c>=0 && user.itemActive? + if c >= 0 && user.itemActive? c = Battle::ItemEffects.triggerCriticalCalcFromUser(user.item, user, target, c) end - if skill>=PBTrainerAI.bestSkill - if c>=0 && target.itemActive? + if skill >= PBTrainerAI.bestSkill + if c >= 0 && target.itemActive? c = Battle::ItemEffects.triggerCriticalCalcFromTarget(target.item, user, target, c) end end # Other efffects - c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant]>0 - if c>=0 + c = -1 if target.pbOwnSide.effects[PBEffects::LuckyChant] > 0 + if c >= 0 c += 1 if move.highCriticalRate? c += user.effects[PBEffects::FocusEnergy] c += 1 if user.inHyperMode? && move.type == :SHADOW end - if c>=0 - c = 4 if c>4 - damage += damage*0.1*c + if c >= 0 + c = 4 if c > 4 + damage += damage * 0.1 * c end end return damage.floor @@ -595,19 +595,19 @@ class Battle::AI #============================================================================= # Accuracy calculation #============================================================================= - def pbRoughAccuracy(move,user,target,skill) + def pbRoughAccuracy(move, user, target, skill) # "Always hit" effects and "always hit" accuracy - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill return 125 if target.effects[PBEffects::Minimize] && move.tramplesMinimize?(1) - return 125 if target.effects[PBEffects::Telekinesis]>0 + return 125 if target.effects[PBEffects::Telekinesis] > 0 end baseAcc = move.accuracy - if skill>=PBTrainerAI.highSkill - baseAcc = move.pbBaseAccuracy(user,target) + if skill >= PBTrainerAI.highSkill + baseAcc = move.pbBaseAccuracy(user, target) end - return 125 if baseAcc==0 && skill>=PBTrainerAI.mediumSkill + return 125 if baseAcc == 0 && skill >= PBTrainerAI.mediumSkill # Get the move's type - type = pbRoughType(move,user,skill) + type = pbRoughType(move, user, skill) # Calculate all modifier effects modifiers = {} modifiers[:base_accuracy] = baseAcc @@ -615,62 +615,62 @@ class Battle::AI modifiers[:evasion_stage] = target.stages[:EVASION] modifiers[:accuracy_multiplier] = 1.0 modifiers[:evasion_multiplier] = 1.0 - pbCalcAccuracyModifiers(user,target,modifiers,move,type,skill) + pbCalcAccuracyModifiers(user, target, modifiers, move, type, skill) # Check if move can't miss - return 125 if modifiers[:base_accuracy]==0 + return 125 if modifiers[:base_accuracy] == 0 # Calculation accStage = [[modifiers[:accuracy_stage], -6].max, 6].min + 6 evaStage = [[modifiers[:evasion_stage], -6].max, 6].min + 6 - stageMul = [3,3,3,3,3,3, 3, 4,5,6,7,8,9] - stageDiv = [9,8,7,6,5,4, 3, 3,3,3,3,3,3] + stageMul = [3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9] + stageDiv = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3] accuracy = 100.0 * stageMul[accStage] / stageDiv[accStage] evasion = 100.0 * stageMul[evaStage] / stageDiv[evaStage] accuracy = (accuracy * modifiers[:accuracy_multiplier]).round evasion = (evasion * modifiers[:evasion_multiplier]).round - evasion = 1 if evasion<1 + evasion = 1 if evasion < 1 return modifiers[:base_accuracy] * accuracy / evasion end - def pbCalcAccuracyModifiers(user,target,modifiers,move,type,skill) + def pbCalcAccuracyModifiers(user, target, modifiers, move, type, skill) moldBreaker = false - if skill>=PBTrainerAI.highSkill && target.hasMoldBreaker? + if skill >= PBTrainerAI.highSkill && target.hasMoldBreaker? moldBreaker = true end # Ability effects that alter accuracy calculation - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if user.abilityActive? Battle::AbilityEffects.triggerAccuracyCalcFromUser(user.ability, - modifiers,user,target,move,type) + modifiers, user, target, move, type) end user.allAllies.each do |b| next if !b.abilityActive? Battle::AbilityEffects.triggerAccuracyCalcFromAlly(b.ability, - modifiers,user,target,move,type) + modifiers, user, target, move, type) end end - if skill>=PBTrainerAI.bestSkill + if skill >= PBTrainerAI.bestSkill if target.abilityActive? && !moldBreaker Battle::AbilityEffects.triggerAccuracyCalcFromTarget(target.ability, - modifiers,user,target,move,type) + modifiers, user, target, move, type) end end # Item effects that alter accuracy calculation - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if user.itemActive? Battle::ItemEffects.triggerAccuracyCalcFromUser(user.item, - modifiers,user,target,move,type) + modifiers, user, target, move, type) end end - if skill>=PBTrainerAI.bestSkill + if skill >= PBTrainerAI.bestSkill if target.itemActive? Battle::ItemEffects.triggerAccuracyCalcFromTarget(target.item, - modifiers,user,target,move,type) + modifiers, user, target, move, type) end end # Other effects, inc. ones that set accuracy_multiplier or evasion_stage to specific values - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill if @battle.field.effects[PBEffects::Gravity] > 0 - modifiers[:accuracy_multiplier] *= 5/3.0 + modifiers[:accuracy_multiplier] *= 5 / 3.0 end if user.effects[PBEffects::MicleBerry] modifiers[:accuracy_multiplier] *= 1.2 @@ -679,20 +679,20 @@ class Battle::AI modifiers[:evasion_stage] = 0 if target.effects[PBEffects::MiracleEye] && modifiers[:evasion_stage] > 0 end # "AI-specific calculations below" - if skill>=PBTrainerAI.mediumSkill + if skill >= PBTrainerAI.mediumSkill modifiers[:evasion_stage] = 0 if move.function == "IgnoreTargetDefSpDefEvaStatStages" # Chip Away - modifiers[:base_accuracy] = 0 if user.effects[PBEffects::LockOn]>0 && - user.effects[PBEffects::LockOnPos]==target.index + modifiers[:base_accuracy] = 0 if user.effects[PBEffects::LockOn] > 0 && + user.effects[PBEffects::LockOnPos] == target.index end - if skill>=PBTrainerAI.highSkill - if move.function=="BadPoisonTarget" # Toxic + if skill >= PBTrainerAI.highSkill + if move.function == "BadPoisonTarget" # Toxic modifiers[:base_accuracy] = 0 if Settings::MORE_TYPE_EFFECTS && move.statusMove? && user.pbHasType?(:POISON) end if ["OHKO", "OHKOIce", "OHKOHitsUndergroundTarget"].include?(move.function) modifiers[:base_accuracy] = move.accuracy + user.level - target.level modifiers[:accuracy_multiplier] = 0 if target.level > user.level - if skill>=PBTrainerAI.bestSkill + if skill >= PBTrainerAI.bestSkill modifiers[:accuracy_multiplier] = 0 if target.hasActiveAbility?(:STURDY) end end diff --git a/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb b/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb index 1ac68c416..32f4767b6 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/004_Battle_Peers.rb @@ -2,7 +2,7 @@ # #=============================================================================== class Battle::Peer - def pbStorePokemon(player,pkmn) + def pbStorePokemon(player, pkmn) if !player.party_full? player.party[player.party.length] = pkmn return -1 @@ -14,7 +14,7 @@ class Battle::Peer end oldCurBox = pbCurrentBox storedBox = $PokemonStorage.pbStoreCaught(pkmn) - if storedBox<0 + if storedBox < 0 # NOTE: Poké Balls can't be used if storage is full, so you shouldn't ever # see this message. pbDisplayPaused(_INTL("Can't catch any more...")) @@ -33,22 +33,22 @@ class Battle::Peer end def pbBoxName(box) - return (box<0) ? "" : $PokemonStorage[box].name + return (box < 0) ? "" : $PokemonStorage[box].name end def pbOnEnteringBattle(battle, battler, pkmn, wild = false) - f = MultipleForms.call("getFormOnEnteringBattle",pkmn,wild) + f = MultipleForms.call("getFormOnEnteringBattle", pkmn, wild) pkmn.form = f if f battler.form = pkmn.form if battler.form != pkmn.form MultipleForms.call("changePokemonOnEnteringBattle", battler, pkmn, battle) end # For switching out, including due to fainting, and for the end of battle - def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle = false) + def pbOnLeavingBattle(battle, pkmn, usedInBattle, endBattle = false) return if !pkmn - f = MultipleForms.call("getFormOnLeavingBattle",pkmn,battle,usedInBattle,endBattle) - pkmn.form = f if f && pkmn.form!=f - pkmn.hp = pkmn.totalhp if pkmn.hp>pkmn.totalhp + f = MultipleForms.call("getFormOnLeavingBattle", pkmn, battle, usedInBattle, endBattle) + pkmn.form = f if f && pkmn.form != f + pkmn.hp = pkmn.totalhp if pkmn.hp > pkmn.totalhp MultipleForms.call("changePokemonOnLeavingBattle", pkmn, battle, usedInBattle, endBattle) end end @@ -58,9 +58,9 @@ end #=============================================================================== class Battle::NullPeer def pbOnEnteringBattle(battle, battler, pkmn, wild = false); end - def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle = false); end + def pbOnLeavingBattle(battle, pkmn, usedInBattle, endBattle = false); end - def pbStorePokemon(player,pkmn) + def pbStorePokemon(player, pkmn) player.party[player.party.length] = pkmn if !player.party_full? return -1 end diff --git a/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb b/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb index 3dc2a4275..8d2ec5d4d 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/005_Battle_CatchAndStoreMixin.rb @@ -31,7 +31,7 @@ module Battle::CatchAndStoreMixin if !pbPlayer.owned?(pkmn.species) pbPlayer.pokedex.set_owned(pkmn.species) if $player.has_pokedex - pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pkmn.name)) + pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.", pkmn.name)) pbPlayer.pokedex.register_last_seen(pkmn) @scene.pbShowPokedex(pkmn.species) end @@ -47,7 +47,7 @@ module Battle::CatchAndStoreMixin #============================================================================= # Throw a Poké Ball #============================================================================= - def pbThrowPokeBall(idxBattler,ball,catch_rate = nil,showPlayer = false) + def pbThrowPokeBall(idxBattler, ball, catch_rate = nil, showPlayer = false) # Determine which Pokémon you're throwing the Poké Ball at battler = nil if opposes?(idxBattler) @@ -60,32 +60,32 @@ module Battle::CatchAndStoreMixin itemName = GameData::Item.get(ball).name if battler.fainted? if itemName.starts_with_vowel? - pbDisplay(_INTL("{1} threw an {2}!",pbPlayer.name,itemName)) + pbDisplay(_INTL("{1} threw an {2}!", pbPlayer.name, itemName)) else - pbDisplay(_INTL("{1} threw a {2}!",pbPlayer.name,itemName)) + pbDisplay(_INTL("{1} threw a {2}!", pbPlayer.name, itemName)) end pbDisplay(_INTL("But there was no target...")) return end if itemName.starts_with_vowel? - pbDisplayBrief(_INTL("{1} threw an {2}!",pbPlayer.name,itemName)) + pbDisplayBrief(_INTL("{1} threw an {2}!", pbPlayer.name, itemName)) else - pbDisplayBrief(_INTL("{1} threw a {2}!",pbPlayer.name,itemName)) + pbDisplayBrief(_INTL("{1} threw a {2}!", pbPlayer.name, itemName)) end # Animation of opposing trainer blocking Poké Balls (unless it's a Snag Ball # at a Shadow Pokémon) if trainerBattle? && !(GameData::Item.get(ball).is_snag_ball? && battler.shadowPokemon?) - @scene.pbThrowAndDeflect(ball,1) + @scene.pbThrowAndDeflect(ball, 1) pbDisplay(_INTL("The Trainer blocked your Poké Ball! Don't be a thief!")) return end # Calculate the number of shakes (4=capture) pkmn = battler.pokemon @criticalCapture = false - numShakes = pbCaptureCalc(pkmn,battler,catch_rate,ball) + numShakes = pbCaptureCalc(pkmn, battler, catch_rate, ball) PBDebug.log("[Threw Poké Ball] #{itemName}, #{numShakes} shakes (4=capture)") # Animation of Ball throw, absorb, shake and capture/burst out - @scene.pbThrow(ball,numShakes,@criticalCapture,battler.index,showPlayer) + @scene.pbThrow(ball, numShakes, @criticalCapture, battler.index, showPlayer) # Outcome message case numShakes when 0 @@ -101,9 +101,9 @@ module Battle::CatchAndStoreMixin pbDisplay(_INTL("Gah! It was so close, too!")) Battle::PokeBallEffects.onFailCatch(ball, self, battler) when 4 - pbDisplayBrief(_INTL("Gotcha! {1} was caught!",pkmn.name)) + pbDisplayBrief(_INTL("Gotcha! {1} was caught!", pkmn.name)) @scene.pbThrowSuccess # Play capture success jingle - pbRemoveFromParty(battler.index,battler.pokemonIndex) + pbRemoveFromParty(battler.index, battler.pokemonIndex) # Gain Exp if Settings::GAIN_EXP_FOR_CAPTURE battler.captured = true @@ -125,8 +125,8 @@ module Battle::CatchAndStoreMixin pkmn.update_shadow_moves if pkmn.shadowPokemon? pkmn.record_first_moves # Reset form - pkmn.forced_form = nil if MultipleForms.hasFunction?(pkmn.species,"getForm") - @peer.pbOnLeavingBattle(self,pkmn,true,true) + pkmn.forced_form = nil if MultipleForms.hasFunction?(pkmn.species, "getForm") + @peer.pbOnLeavingBattle(self, pkmn, true, true) # Make the Poké Ball and data box disappear @scene.pbHideCaptureBall(idxBattler) # Save the Pokémon for storage at the end of battle @@ -141,7 +141,7 @@ module Battle::CatchAndStoreMixin #============================================================================= # Calculate how many shakes a thrown Poké Ball will make (4 = capture) #============================================================================= - def pbCaptureCalc(pkmn,battler,catch_rate,ball) + def pbCaptureCalc(pkmn, battler, catch_rate, ball) return 4 if $DEBUG && Input.press?(Input::CTRL) # Get a catch rate if one wasn't provided catch_rate = pkmn.species_data.catch_rate if !catch_rate @@ -154,7 +154,7 @@ module Battle::CatchAndStoreMixin # First half of the shakes calculation a = battler.totalhp b = battler.hp - x = ((3*a-2*b)*catch_rate.to_f)/(3*a) + x = ((3 * a - 2 * b) * catch_rate.to_f) / (3 * a) # Calculation modifiers if battler.status == :SLEEP || battler.status == :FROZEN x *= 2.5 @@ -162,40 +162,40 @@ module Battle::CatchAndStoreMixin x *= 1.5 end x = x.floor - x = 1 if x<1 + x = 1 if x < 1 # Definite capture, no need to perform randomness checks - return 4 if x>=255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler) + return 4 if x >= 255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler) # Second half of the shakes calculation - y = (65536 / ((255.0/x)**0.1875)).floor + y = (65536 / ((255.0 / x)**0.1875)).floor # Critical capture check if Settings::ENABLE_CRITICAL_CAPTURES dex_modifier = 0 numOwned = $player.pokedex.owned_count - if numOwned>600 + if numOwned > 600 dex_modifier = 5 - elsif numOwned>450 + elsif numOwned > 450 dex_modifier = 4 - elsif numOwned>300 + elsif numOwned > 300 dex_modifier = 3 - elsif numOwned>150 + elsif numOwned > 150 dex_modifier = 2 - elsif numOwned>30 + elsif numOwned > 30 dex_modifier = 1 end dex_modifier *= 2 if $bag.has?(:CATCHINGCHARM) c = x * dex_modifier / 12 # Calculate the number of shakes - if c>0 && pbRandom(256) 0 && pbRandom(256) < c @criticalCapture = true - return 4 if pbRandom(65536)p2able + if p1able > p2able @decision = 1 # loss - elsif p1able0 + return count > 0 end end @@ -105,12 +105,12 @@ end class Battle::Move::RaiseUserEvasion1 # Double Team alias __clauses__pbMoveFailed? pbMoveFailed? - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !damagingMove? && @battle.rules["evasionclause"] @battle.pbDisplay(_INTL("But it failed!")) return true end - return __clauses__pbMoveFailed?(user,targets) + return __clauses__pbMoveFailed?(user, targets) end end @@ -119,12 +119,12 @@ end class Battle::Move::RaiseUserEvasion2MinimizeUser # Minimize alias __clauses__pbMoveFailed? pbMoveFailed? - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if !damagingMove? && @battle.rules["evasionclause"] @battle.pbDisplay(_INTL("But it failed!")) return true end - return __clauses__pbMoveFailed?(user,targets) + return __clauses__pbMoveFailed?(user, targets) end end @@ -220,12 +220,12 @@ class Battle::Move::UserFaintsExplosive # Self-Destruct @__clauses__aliased = true end - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @battle.rules["selfkoclause"] # Check whether no unfainted Pokemon remain in either party count = @battle.pbAbleNonActiveCount(user.idxOwnSide) count += @battle.pbAbleNonActiveCount(user.idxOpposingSide) - if count==0 + if count == 0 @battle.pbDisplay("But it failed!") return false end @@ -234,13 +234,13 @@ class Battle::Move::UserFaintsExplosive # Self-Destruct # Check whether no unfainted Pokemon remain in either party count = @battle.pbAbleNonActiveCount(user.idxOwnSide) count += @battle.pbAbleNonActiveCount(user.idxOpposingSide) - if count==0 - @battle.pbDisplay(_INTL("{1}'s team was disqualified!",user.pbThis)) + if count == 0 + @battle.pbDisplay(_INTL("{1}'s team was disqualified!", user.pbThis)) @battle.decision = (user.opposes?) ? 1 : 2 return false end end - return __clauses__pbMoveFailed?(user,targets) + return __clauses__pbMoveFailed?(user, targets) end end @@ -251,7 +251,7 @@ class Battle::Move::StartPerishCountsForAllBattlers # Perish Song def pbFailsAgainstTarget?(user, target, show_message) if @battle.rules["perishsongclause"] && - @battle.pbAbleNonActiveCount(user.idxOwnSide)==0 + @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end @@ -266,7 +266,7 @@ class Battle::Move::AttackerFaintsIfUserFaints # Destiny Bond def pbFailsAgainstTarget?(user, target, show_message) if @battle.rules["perishsongclause"] && - @battle.pbAbleNonActiveCount(user.idxOwnSide)==0 + @battle.pbAbleNonActiveCount(user.idxOwnSide) == 0 @battle.pbDisplay(_INTL("But it failed!")) if show_message return true end diff --git a/Data/Scripts/011_Battle/006_Other battle code/007_BattleAnimationPlayer.rb b/Data/Scripts/011_Battle/006_Other battle code/007_BattleAnimationPlayer.rb index d7a972780..2c3a1a149 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/007_BattleAnimationPlayer.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/007_BattleAnimationPlayer.rb @@ -34,47 +34,47 @@ end #=============================================================================== # #=============================================================================== -def yaxisIntersect(x1,y1,x2,y2,px,py) - dx = x2-x1 - dy = y2-y1 - x = (dx==0) ? 0.0 : (px-x1).to_f/dx - y = (dy==0) ? 0.0 : (py-y1).to_f/dy - return [x,y] +def yaxisIntersect(x1, y1, x2, y2, px, py) + dx = x2 - x1 + dy = y2 - y1 + x = (dx == 0) ? 0.0 : (px - x1).to_f / dx + y = (dy == 0) ? 0.0 : (py - y1).to_f / dy + return [x, y] end -def repositionY(x1,y1,x2,y2,tx,ty) - dx = x2-x1 - dy = y2-y1 - x = x1+tx*dx.to_f - y = y1+ty*dy.to_f - return [x,y] +def repositionY(x1, y1, x2, y2, tx, ty) + dx = x2 - x1 + dy = y2 - y1 + x = x1 + tx * dx.to_f + y = y1 + ty * dy.to_f + return [x, y] end -def transformPoint(x1,y1,x2,y2, # Source line - x3,y3,x4,y4, # Destination line - px,py) # Source point - ret = yaxisIntersect(x1,y1,x2,y2,px,py) - ret2 = repositionY(x3,y3,x4,y4,ret[0],ret[1]) +def transformPoint(x1, y1, x2, y2, # Source line + x3, y3, x4, y4, # Destination line + px, py) # Source point + ret = yaxisIntersect(x1, y1, x2, y2, px, py) + ret2 = repositionY(x3, y3, x4, y4, ret[0], ret[1]) return ret2 end def getSpriteCenter(sprite) - return [0,0] if !sprite || sprite.disposed? - return [sprite.x,sprite.y] if !sprite.bitmap || sprite.bitmap.disposed? - centerX = sprite.src_rect.width/2 - centerY = sprite.src_rect.height/2 - offsetX = (centerX-sprite.ox)*sprite.zoom_x - offsetY = (centerY-sprite.oy)*sprite.zoom_y - return [sprite.x+offsetX,sprite.y+offsetY] + return [0, 0] if !sprite || sprite.disposed? + return [sprite.x, sprite.y] if !sprite.bitmap || sprite.bitmap.disposed? + centerX = sprite.src_rect.width / 2 + centerY = sprite.src_rect.height / 2 + offsetX = (centerX - sprite.ox) * sprite.zoom_x + offsetY = (centerY - sprite.oy) * sprite.zoom_y + return [sprite.x + offsetX, sprite.y + offsetY] end -def isReversed(src0,src1,dst0,dst1) - return false if src0==src1 - return (dst0>dst1) if src0 dst1) if src0 < src1 + return (dst0 < dst1) end -def pbCreateCel(x,y,pattern,focus = 4) +def pbCreateCel(x, y, pattern, focus = 4) frame = [] frame[AnimFrame::X] = x frame[AnimFrame::Y] = y @@ -121,33 +121,33 @@ def pbConvertRPGAnimation(animation) pbAnim.array.clear yOffset = 0 pbAnim.position = animation.position - yOffset = -64 if animation.position==0 - yOffset = 64 if animation.position==2 + yOffset = -64 if animation.position == 0 + yOffset = 64 if animation.position == 2 for i in 0...animation.frames.length frame = pbAnim.addFrame animFrame = animation.frames[i] for j in 0...animFrame.cell_max data = animFrame.cell_data - if data[j,0]==-1 + if data[j, 0] == -1 frame.push(nil) next end - if animation.position==3 # Screen + if animation.position == 3 # Screen point = transformPoint( - -160,80,160,-80, - Battle::Scene::FOCUSUSER_X,Battle::Scene::FOCUSUSER_Y, - Battle::Scene::FOCUSTARGET_X,Battle::Scene::FOCUSTARGET_Y, - data[j,1],data[j,2] + -160, 80, 160, -80, + Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y, + Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y, + data[j, 1], data[j, 2] ) - cel = pbCreateCel(point[0],point[1],data[j,0]) + cel = pbCreateCel(point[0], point[1], data[j, 0]) else - cel = pbCreateCel(data[j,1],data[j,2]+yOffset,data[j,0]) + cel = pbCreateCel(data[j, 1], data[j, 2] + yOffset, data[j, 0]) end - cel[AnimFrame::ZOOMX] = data[j,3] - cel[AnimFrame::ZOOMY] = data[j,3] - cel[AnimFrame::ANGLE] = data[j,4] - cel[AnimFrame::MIRROR] = data[j,5] - cel[AnimFrame::OPACITY] = data[j,6] + cel[AnimFrame::ZOOMX] = data[j, 3] + cel[AnimFrame::ZOOMY] = data[j, 3] + cel[AnimFrame::ANGLE] = data[j, 4] + cel[AnimFrame::MIRROR] = data[j, 5] + cel[AnimFrame::OPACITY] = data[j, 6] cel[AnimFrame::BLENDTYPE] = 0 frame.push(cel) end @@ -173,7 +173,7 @@ end # #=============================================================================== class RPG::Animation - def self.fromOther(otherAnim,id) + def self.fromOther(otherAnim, id) ret = RPG::Animation.new ret.id = id ret.name = otherAnim.name.clone @@ -183,42 +183,42 @@ class RPG::Animation return ret end - def addSound(frame,se) + def addSound(frame, se) timing = RPG::Animation::Timing.new timing.frame = frame - timing.se = RPG::AudioFile.new(se,100) + timing.se = RPG::AudioFile.new(se, 100) self.timings.push(timing) end - def addAnimation(otherAnim,frame,x,y) # frame is zero-based - if frame+otherAnim.frames.length>=self.frames.length - totalframes = frame+otherAnim.frames.length+1 + def addAnimation(otherAnim, frame, x, y) # frame is zero-based + if frame + otherAnim.frames.length >= self.frames.length + totalframes = frame + otherAnim.frames.length + 1 for i in self.frames.length...totalframes self.frames.push(RPG::Animation::Frame.new) end end self.frame_max = self.frames.length for i in 0...otherAnim.frame_max - thisframe = self.frames[frame+i] + thisframe = self.frames[frame + i] otherframe = otherAnim.frames[i] cellStart = thisframe.cell_max thisframe.cell_max += otherframe.cell_max - thisframe.cell_data.resize(thisframe.cell_max,8) + thisframe.cell_data.resize(thisframe.cell_max, 8) for j in 0...otherframe.cell_max - thisframe.cell_data[cellStart+j,0] = otherframe.cell_data[j,0] - thisframe.cell_data[cellStart+j,1] = otherframe.cell_data[j,1]+x - thisframe.cell_data[cellStart+j,2] = otherframe.cell_data[j,2]+y - thisframe.cell_data[cellStart+j,3] = otherframe.cell_data[j,3] - thisframe.cell_data[cellStart+j,4] = otherframe.cell_data[j,4] - thisframe.cell_data[cellStart+j,5] = otherframe.cell_data[j,5] - thisframe.cell_data[cellStart+j,6] = otherframe.cell_data[j,6] - thisframe.cell_data[cellStart+j,7] = otherframe.cell_data[j,7] + thisframe.cell_data[cellStart + j, 0] = otherframe.cell_data[j, 0] + thisframe.cell_data[cellStart + j, 1] = otherframe.cell_data[j, 1] + x + thisframe.cell_data[cellStart + j, 2] = otherframe.cell_data[j, 2] + y + thisframe.cell_data[cellStart + j, 3] = otherframe.cell_data[j, 3] + thisframe.cell_data[cellStart + j, 4] = otherframe.cell_data[j, 4] + thisframe.cell_data[cellStart + j, 5] = otherframe.cell_data[j, 5] + thisframe.cell_data[cellStart + j, 6] = otherframe.cell_data[j, 6] + thisframe.cell_data[cellStart + j, 7] = otherframe.cell_data[j, 7] end end for i in 0...otherAnim.timings.length timing = RPG::Animation::Timing.new othertiming = otherAnim.timings[i] - timing.frame = frame+othertiming.frame + timing.frame = frame + othertiming.frame timing.se = RPG::AudioFile.new( othertiming.se.name.clone, othertiming.se.volume, @@ -229,7 +229,7 @@ class RPG::Animation timing.condition = othertiming.condition self.timings.push(timing) end - self.timings.sort! { |a,b| a.frame<=>b.frame } + self.timings.sort! { |a, b| a.frame <=> b.frame } end end @@ -271,7 +271,7 @@ class PBAnimTiming @colorAlpha = nil @duration = 5 @flashScope = 0 - @flashColor = Color.new(255,255,255,255) + @flashColor = Color.new(255, 255, 255, 255) @flashDuration = 5 end @@ -286,61 +286,61 @@ class PBAnimTiming def to_s case self.timingType when 0 - return "[#{@frame+1}] Play SE: #{name} (volume #{@volume}, pitch #{@pitch})" + return "[#{@frame + 1}] Play SE: #{name} (volume #{@volume}, pitch #{@pitch})" when 1 - text = sprintf("[%d] Set BG: \"%s\"",@frame+1,name) + text = sprintf("[%d] Set BG: \"%s\"", @frame + 1, name) text += sprintf(" (color=%s,%s,%s,%s)", - (@colorRed!=nil) ? @colorRed.to_i : "-", - (@colorGreen!=nil) ? @colorGreen.to_i : "-", - (@colorBlue!=nil) ? @colorBlue.to_i : "-", - (@colorAlpha!=nil) ? @colorAlpha.to_i : "-") - text += sprintf(" (opacity=%s)",@opacity.to_i) + (@colorRed != nil) ? @colorRed.to_i : "-", + (@colorGreen != nil) ? @colorGreen.to_i : "-", + (@colorBlue != nil) ? @colorBlue.to_i : "-", + (@colorAlpha != nil) ? @colorAlpha.to_i : "-") + text += sprintf(" (opacity=%s)", @opacity.to_i) text += sprintf(" (coords=%s,%s)", - (@bgX!=nil) ? @bgX : "-", - (@bgY!=nil) ? @bgY : "-") + (@bgX != nil) ? @bgX : "-", + (@bgY != nil) ? @bgY : "-") return text when 2 - text = sprintf("[%d] Change BG: @%d",@frame+1,duration) - if @colorRed!=nil || @colorGreen!=nil || @colorBlue!=nil || @colorAlpha!=nil + text = sprintf("[%d] Change BG: @%d", @frame + 1, duration) + if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil text += sprintf(" (color=%s,%s,%s,%s)", - (@colorRed!=nil) ? @colorRed.to_i : "-", - (@colorGreen!=nil) ? @colorGreen.to_i : "-", - (@colorBlue!=nil) ? @colorBlue.to_i : "-", - (@colorAlpha!=nil) ? @colorAlpha.to_i : "-") + (@colorRed != nil) ? @colorRed.to_i : "-", + (@colorGreen != nil) ? @colorGreen.to_i : "-", + (@colorBlue != nil) ? @colorBlue.to_i : "-", + (@colorAlpha != nil) ? @colorAlpha.to_i : "-") end - text += sprintf(" (opacity=%s)",@opacity.to_i) if @opacity!=nil - if @bgX!=nil || @bgY!=nil + text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil + if @bgX != nil || @bgY != nil text += sprintf(" (coords=%s,%s)", - (@bgX!=nil) ? @bgX : "-", - (@bgY!=nil) ? @bgY : "-") + (@bgX != nil) ? @bgX : "-", + (@bgY != nil) ? @bgY : "-") end return text when 3 - text = sprintf("[%d] Set FG: \"%s\"",@frame+1,name) + text = sprintf("[%d] Set FG: \"%s\"", @frame + 1, name) text += sprintf(" (color=%s,%s,%s,%s)", - (@colorRed!=nil) ? @colorRed.to_i : "-", - (@colorGreen!=nil) ? @colorGreen.to_i : "-", - (@colorBlue!=nil) ? @colorBlue.to_i : "-", - (@colorAlpha!=nil) ? @colorAlpha.to_i : "-") - text += sprintf(" (opacity=%s)",@opacity.to_i) + (@colorRed != nil) ? @colorRed.to_i : "-", + (@colorGreen != nil) ? @colorGreen.to_i : "-", + (@colorBlue != nil) ? @colorBlue.to_i : "-", + (@colorAlpha != nil) ? @colorAlpha.to_i : "-") + text += sprintf(" (opacity=%s)", @opacity.to_i) text += sprintf(" (coords=%s,%s)", - (@bgX!=nil) ? @bgX : "-", - (@bgY!=nil) ? @bgY : "-") + (@bgX != nil) ? @bgX : "-", + (@bgY != nil) ? @bgY : "-") return text when 4 - text = sprintf("[%d] Change FG: @%d",@frame+1,duration) - if @colorRed!=nil || @colorGreen!=nil || @colorBlue!=nil || @colorAlpha!=nil + text = sprintf("[%d] Change FG: @%d", @frame + 1, duration) + if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil text += sprintf(" (color=%s,%s,%s,%s)", - (@colorRed!=nil) ? @colorRed.to_i : "-", - (@colorGreen!=nil) ? @colorGreen.to_i : "-", - (@colorBlue!=nil) ? @colorBlue.to_i : "-", - (@colorAlpha!=nil) ? @colorAlpha.to_i : "-") + (@colorRed != nil) ? @colorRed.to_i : "-", + (@colorGreen != nil) ? @colorGreen.to_i : "-", + (@colorBlue != nil) ? @colorBlue.to_i : "-", + (@colorAlpha != nil) ? @colorAlpha.to_i : "-") end - text += sprintf(" (opacity=%s)",@opacity.to_i) if @opacity!=nil - if @bgX!=nil || @bgY!=nil + text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil + if @bgX != nil || @bgY != nil text += sprintf(" (coords=%s,%s)", - (@bgX!=nil) ? @bgX : "-", - (@bgY!=nil) ? @bgY : "-") + (@bgX != nil) ? @bgX : "-", + (@bgY != nil) ? @bgY : "-") end return text end @@ -361,7 +361,7 @@ class PBAnimations < Array def initialize(size = 1) @array = [] @selected = 0 - size = 1 if size<1 # Always create at least one animation + size = 1 if size < 1 # Always create at least one animation size.times do @array.push(PBAnimation.new) end @@ -379,7 +379,7 @@ class PBAnimations < Array return @array[i] end - def []=(i,value) + def []=(i, value) @array[i] = value end @@ -387,8 +387,8 @@ class PBAnimations < Array @array.compact! end - def insert(index,val) - @array.insert(index,val) + def insert(index, val) + @array.insert(index, val) end def delete_at(index) @@ -398,7 +398,7 @@ class PBAnimations < Array def resize(len) idxStart = @array.length idxEnd = len - if idxStart>idxEnd + if idxStart > idxEnd for i in idxEnd...idxStart @array.pop end @@ -407,7 +407,7 @@ class PBAnimations < Array @array.push(PBAnimation.new) end end - self.selected = len if self.selected>=len + self.selected = len if self.selected >= len end end @@ -440,7 +440,7 @@ class PBAnimation < Array @hue = 0 @position = 4 # 1=target, 2=user, 3=user and target, 4=screen @array = [] - size = 1 if size<1 # Always create at least one frame + size = 1 if size < 1 # Always create at least one frame size.times { addFrame } @timing = [] @scope = 0 @@ -458,7 +458,7 @@ class PBAnimation < Array return @array[i] end - def []=(i,value) + def []=(i, value) @array[i] = value end @@ -471,10 +471,10 @@ class PBAnimation < Array end def resize(len) - if len<@array.length - @array[len,@array.length-len] = [] - elsif len>@array.length - (len-@array.length).times do + if len < @array.length + @array[len, @array.length - len] = [] + elsif len > @array.length + (len - @array.length).times do addFrame end end @@ -484,128 +484,128 @@ class PBAnimation < Array pos = @array.length @array[pos] = [] # Move's user - @array[pos][0] = pbCreateCel(Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y,-1) + @array[pos][0] = pbCreateCel(Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y, -1) @array[pos][0][AnimFrame::FOCUS] = 2 @array[pos][0][AnimFrame::LOCKED] = 1 # Move's target - @array[pos][1] = pbCreateCel(Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y,-2) + @array[pos][1] = pbCreateCel(Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y, -2) @array[pos][1][AnimFrame::FOCUS] = 1 @array[pos][1][AnimFrame::LOCKED] = 1 return @array[pos] end - def playTiming(frame,bgGraphic,bgColor,foGraphic,foColor,oldbg = [],oldfo = [],user = nil) + def playTiming(frame, bgGraphic, bgColor, foGraphic, foColor, oldbg = [], oldfo = [], user = nil) for i in @timing - next if i.frame!=frame + next if i.frame != frame case i.timingType when 0 # Play SE - if i.name && i.name!="" - pbSEPlay("Anim/"+i.name,i.volume,i.pitch) + if i.name && i.name != "" + pbSEPlay("Anim/" + i.name, i.volume, i.pitch) elsif user && user.pokemon name = GameData::Species.cry_filename_from_pokemon(user.pokemon) - pbSEPlay(name,i.volume,i.pitch) if name + pbSEPlay(name, i.volume, i.pitch) if name end # if sprite # sprite.flash(i.flashColor,i.flashDuration*2) if i.flashScope==1 # sprite.flash(nil,i.flashDuration*2) if i.flashScope==3 # end when 1 # Set background graphic (immediate) - if i.name && i.name!="" - bgGraphic.setBitmap("Graphics/Animations/"+i.name) + if i.name && i.name != "" + bgGraphic.setBitmap("Graphics/Animations/" + i.name) bgGraphic.ox = -i.bgX || 0 bgGraphic.oy = -i.bgY || 0 - bgGraphic.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0) + bgGraphic.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0) bgGraphic.opacity = i.opacity || 0 bgColor.opacity = 0 else bgGraphic.setBitmap(nil) bgGraphic.opacity = 0 - bgColor.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0) + bgColor.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0) bgColor.opacity = i.opacity || 0 end when 2 # Move/recolour background graphic - if bgGraphic.bitmap!=nil + if bgGraphic.bitmap != nil oldbg[0] = bgGraphic.ox || 0 oldbg[1] = bgGraphic.oy || 0 oldbg[2] = bgGraphic.opacity || 0 - oldbg[3] = bgGraphic.color.clone || Color.new(0,0,0,0) + oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0) else oldbg[0] = 0 oldbg[1] = 0 oldbg[2] = bgColor.opacity || 0 - oldbg[3] = bgColor.color.clone || Color.new(0,0,0,0) + oldbg[3] = bgColor.color.clone || Color.new(0, 0, 0, 0) end when 3 # Set foreground graphic (immediate) - if i.name && i.name!="" - foGraphic.setBitmap("Graphics/Animations/"+i.name) + if i.name && i.name != "" + foGraphic.setBitmap("Graphics/Animations/" + i.name) foGraphic.ox = -i.bgX || 0 foGraphic.oy = -i.bgY || 0 - foGraphic.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0) + foGraphic.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0) foGraphic.opacity = i.opacity || 0 foColor.opacity = 0 else foGraphic.setBitmap(nil) foGraphic.opacity = 0 - foColor.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0) + foColor.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0) foColor.opacity = i.opacity || 0 end when 4 # Move/recolour foreground graphic - if foGraphic.bitmap!=nil + if foGraphic.bitmap != nil oldfo[0] = foGraphic.ox || 0 oldfo[1] = foGraphic.oy || 0 oldfo[2] = foGraphic.opacity || 0 - oldfo[3] = foGraphic.color.clone || Color.new(0,0,0,0) + oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0) else oldfo[0] = 0 oldfo[1] = 0 oldfo[2] = foColor.opacity || 0 - oldfo[3] = foColor.color.clone || Color.new(0,0,0,0) + oldfo[3] = foColor.color.clone || Color.new(0, 0, 0, 0) end end end for i in @timing case i.timingType when 2 - next if !i.duration || i.duration<=0 - next if framei.frame+i.duration - fraction = (frame-i.frame).to_f/i.duration - if bgGraphic.bitmap!=nil - bgGraphic.ox = oldbg[0]-(i.bgX-oldbg[0])*fraction if i.bgX!=nil - bgGraphic.oy = oldbg[1]-(i.bgY-oldbg[1])*fraction if i.bgY!=nil - bgGraphic.opacity = oldbg[2]+(i.opacity-oldbg[2])*fraction if i.opacity!=nil - cr = (i.colorRed!=nil) ? oldbg[3].red+(i.colorRed-oldbg[3].red)*fraction : oldbg[3].red - cg = (i.colorGreen!=nil) ? oldbg[3].green+(i.colorGreen-oldbg[3].green)*fraction : oldbg[3].green - cb = (i.colorBlue!=nil) ? oldbg[3].blue+(i.colorBlue-oldbg[3].blue)*fraction : oldbg[3].blue - ca = (i.colorAlpha!=nil) ? oldbg[3].alpha+(i.colorAlpha-oldbg[3].alpha)*fraction : oldbg[3].alpha - bgGraphic.color = Color.new(cr,cg,cb,ca) + next if !i.duration || i.duration <= 0 + next if frame < i.frame || frame > i.frame + i.duration + fraction = (frame - i.frame).to_f / i.duration + if bgGraphic.bitmap != nil + bgGraphic.ox = oldbg[0] - (i.bgX - oldbg[0]) * fraction if i.bgX != nil + bgGraphic.oy = oldbg[1] - (i.bgY - oldbg[1]) * fraction if i.bgY != nil + bgGraphic.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil + cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red + cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green + cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue + ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha + bgGraphic.color = Color.new(cr, cg, cb, ca) else - bgColor.opacity = oldbg[2]+(i.opacity-oldbg[2])*fraction if i.opacity!=nil - cr = (i.colorRed!=nil) ? oldbg[3].red+(i.colorRed-oldbg[3].red)*fraction : oldbg[3].red - cg = (i.colorGreen!=nil) ? oldbg[3].green+(i.colorGreen-oldbg[3].green)*fraction : oldbg[3].green - cb = (i.colorBlue!=nil) ? oldbg[3].blue+(i.colorBlue-oldbg[3].blue)*fraction : oldbg[3].blue - ca = (i.colorAlpha!=nil) ? oldbg[3].alpha+(i.colorAlpha-oldbg[3].alpha)*fraction : oldbg[3].alpha - bgColor.color = Color.new(cr,cg,cb,ca) + bgColor.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil + cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red + cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green + cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue + ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha + bgColor.color = Color.new(cr, cg, cb, ca) end when 4 - next if !i.duration || i.duration<=0 - next if framei.frame+i.duration - fraction = (frame-i.frame).to_f/i.duration - if foGraphic.bitmap!=nil - foGraphic.ox = oldfo[0]-(i.bgX-oldfo[0])*fraction if i.bgX!=nil - foGraphic.oy = oldfo[1]-(i.bgY-oldfo[1])*fraction if i.bgY!=nil - foGraphic.opacity = oldfo[2]+(i.opacity-oldfo[2])*fraction if i.opacity!=nil - cr = (i.colorRed!=nil) ? oldfo[3].red+(i.colorRed-oldfo[3].red)*fraction : oldfo[3].red - cg = (i.colorGreen!=nil) ? oldfo[3].green+(i.colorGreen-oldfo[3].green)*fraction : oldfo[3].green - cb = (i.colorBlue!=nil) ? oldfo[3].blue+(i.colorBlue-oldfo[3].blue)*fraction : oldfo[3].blue - ca = (i.colorAlpha!=nil) ? oldfo[3].alpha+(i.colorAlpha-oldfo[3].alpha)*fraction : oldfo[3].alpha - foGraphic.color = Color.new(cr,cg,cb,ca) + next if !i.duration || i.duration <= 0 + next if frame < i.frame || frame > i.frame + i.duration + fraction = (frame - i.frame).to_f / i.duration + if foGraphic.bitmap != nil + foGraphic.ox = oldfo[0] - (i.bgX - oldfo[0]) * fraction if i.bgX != nil + foGraphic.oy = oldfo[1] - (i.bgY - oldfo[1]) * fraction if i.bgY != nil + foGraphic.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil + cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red + cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green + cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue + ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha + foGraphic.color = Color.new(cr, cg, cb, ca) else - foColor.opacity = oldfo[2]+(i.opacity-oldfo[2])*fraction if i.opacity!=nil - cr = (i.colorRed!=nil) ? oldfo[3].red+(i.colorRed-oldfo[3].red)*fraction : oldfo[3].red - cg = (i.colorGreen!=nil) ? oldfo[3].green+(i.colorGreen-oldfo[3].green)*fraction : oldfo[3].green - cb = (i.colorBlue!=nil) ? oldfo[3].blue+(i.colorBlue-oldfo[3].blue)*fraction : oldfo[3].blue - ca = (i.colorAlpha!=nil) ? oldfo[3].alpha+(i.colorAlpha-oldfo[3].alpha)*fraction : oldfo[3].alpha - foColor.color = Color.new(cr,cg,cb,ca) + foColor.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil + cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red + cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green + cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue + ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha + foColor.color = Color.new(cr, cg, cb, ca) end end end @@ -617,35 +617,35 @@ end #=============================================================================== # #=============================================================================== -def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false) +def pbSpriteSetAnimFrame(sprite, frame, user = nil, target = nil, inEditor = false) return if !sprite if !frame sprite.visible = false - sprite.src_rect = Rect.new(0,0,1,1) + sprite.src_rect = Rect.new(0, 0, 1, 1) return end sprite.blend_type = frame[AnimFrame::BLENDTYPE] sprite.angle = frame[AnimFrame::ANGLE] - sprite.mirror = (frame[AnimFrame::MIRROR]>0) + sprite.mirror = (frame[AnimFrame::MIRROR] > 0) sprite.opacity = frame[AnimFrame::OPACITY] sprite.visible = true - if !frame[AnimFrame::VISIBLE]==1 && inEditor - sprite.opacity /= 2 + if !frame[AnimFrame::VISIBLE] == 1 && inEditor + sprite.opacity /= 2 else - sprite.visible = (frame[AnimFrame::VISIBLE]==1) + sprite.visible = (frame[AnimFrame::VISIBLE] == 1) end pattern = frame[AnimFrame::PATTERN] - if pattern>=0 + if pattern >= 0 animwidth = 192 - sprite.src_rect.set((pattern%5)*animwidth,(pattern/5)*animwidth, - animwidth,animwidth) + sprite.src_rect.set((pattern % 5) * animwidth, (pattern / 5) * animwidth, + animwidth, animwidth) else - sprite.src_rect.set(0,0, + sprite.src_rect.set(0, 0, (sprite.bitmap) ? sprite.bitmap.width : 128, (sprite.bitmap) ? sprite.bitmap.height : 128) end - sprite.zoom_x = frame[AnimFrame::ZOOMX]/100.0 - sprite.zoom_y = frame[AnimFrame::ZOOMY]/100.0 + sprite.zoom_x = frame[AnimFrame::ZOOMX] / 100.0 + sprite.zoom_y = frame[AnimFrame::ZOOMY] / 100.0 sprite.color.set( frame[AnimFrame::COLORRED], frame[AnimFrame::COLORGREEN], @@ -658,11 +658,11 @@ def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false) frame[AnimFrame::TONEBLUE], frame[AnimFrame::TONEGRAY] ) - sprite.ox = sprite.src_rect.width/2 - sprite.oy = sprite.src_rect.height/2 + sprite.ox = sprite.src_rect.width / 2 + sprite.oy = sprite.src_rect.height / 2 sprite.x = frame[AnimFrame::X] sprite.y = frame[AnimFrame::Y] - if sprite!=user && sprite!=target + if sprite != user && sprite != target case frame[AnimFrame::PRIORITY] when 0 # Behind everything sprite.z = 10 @@ -671,18 +671,18 @@ def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false) when 2 # Just behind focus case frame[AnimFrame::FOCUS] when 1 # Focused on target - sprite.z = (target) ? target.z-1 : 20 + sprite.z = (target) ? target.z - 1 : 20 when 2 # Focused on user - sprite.z = (user) ? user.z-1 : 20 + sprite.z = (user) ? user.z - 1 : 20 else # Focused on user and target, or screen sprite.z = 20 end when 3 # Just in front of focus case frame[AnimFrame::FOCUS] when 1 # Focused on target - sprite.z = (target) ? target.z+1 : 80 + sprite.z = (target) ? target.z + 1 : 80 when 2 # Focused on user - sprite.z = (user) ? user.z+1 : 80 + sprite.z = (user) ? user.z + 1 : 80 else # Focused on user and target, or screen sprite.z = 80 end @@ -702,7 +702,7 @@ class PBAnimationPlayerX MAX_SPRITES = 60 - def initialize(animation,user,target,scene = nil,oppMove = false,inEditor = false) + def initialize(animation, user, target, scene = nil, oppMove = false, inEditor = false) @animation = animation @user = (oppMove) ? target : user # Just used for playing user's cry @usersprite = (user) ? scene.sprites["pokemon_#{user.index}"] : nil @@ -715,7 +715,7 @@ class PBAnimationPlayerX @looping = false @animbitmap = nil # Animation sheet graphic @frame = -1 - @framesPerTick = [Graphics.frame_rate/20,1].max # 20 ticks per second + @framesPerTick = [Graphics.frame_rate / 20, 1].max # 20 ticks per second @srcLine = nil @dstLine = nil @userOrig = getSpriteCenter(@usersprite) @@ -727,7 +727,7 @@ class PBAnimationPlayerX def initializeSprites # Create animation sprites (0=user's sprite, 1=target's sprite) - @animsprites = [] + @animsprites = [] @animsprites[0] = @usersprite @animsprites[1] = @targetsprite for i in 2...MAX_SPRITES @@ -736,7 +736,7 @@ class PBAnimationPlayerX @animsprites[i].visible = false end # Create background colour sprite - @bgColor = ColoredPlane.new(Color.new(0,0,0),@viewport) + @bgColor = ColoredPlane.new(Color.new(0, 0, 0), @viewport) @bgColor.borderX = 64 if @inEditor @bgColor.borderY = 64 if @inEditor @bgColor.z = 5 @@ -751,7 +751,7 @@ class PBAnimationPlayerX @bgGraphic.opacity = 0 @bgGraphic.refresh # Create foreground colour sprite - @foColor = ColoredPlane.new(Color.new(0,0,0),@viewport) + @foColor = ColoredPlane.new(Color.new(0, 0, 0), @viewport) @foColor.borderX = 64 if @inEditor @foColor.borderY = 64 if @inEditor @foColor.z = 85 @@ -783,22 +783,22 @@ class PBAnimationPlayerX end def animDone? - return @frame<0 + return @frame < 0 end - def setLineTransform(x1,y1,x2,y2,x3,y3,x4,y4) - @srcLine = [x1,y1,x2,y2] - @dstLine = [x3,y3,x4,y4] + def setLineTransform(x1, y1, x2, y2, x3, y3, x4, y4) + @srcLine = [x1, y1, x2, y2] + @dstLine = [x3, y3, x4, y4] end def update - return if @frame<0 - animFrame = @frame/@framesPerTick + return if @frame < 0 + animFrame = @frame / @framesPerTick # Loop or end the animation if the animation has reached the end if animFrame >= @animation.length @frame = (@looping) ? 0 : -1 - if @frame<0 + if @frame < 0 @animbitmap.dispose if @animbitmap @animbitmap = nil return @@ -806,7 +806,7 @@ class PBAnimationPlayerX end # Load the animation's spritesheet and assign it to all the sprites. if !@animbitmap || @animbitmap.disposed? - @animbitmap = AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic, + @animbitmap = AnimatedBitmap.new("Graphics/Animations/" + @animation.graphic, @animation.hue).deanimate for i in 0...MAX_SPRITES @animsprites[i].bitmap = @animbitmap if @animsprites[i] @@ -819,7 +819,7 @@ class PBAnimationPlayerX @foColor.update # Update all the sprites to depict the animation's next frame - if @framesPerTick==1 || (@frame%@framesPerTick)==0 + if @framesPerTick == 1 || (@frame % @framesPerTick) == 0 thisframe = @animation[animFrame] # Make all cel sprites invisible for i in 0...MAX_SPRITES @@ -841,7 +841,7 @@ class PBAnimationPlayerX sprite.bitmap = @animbitmap end # Apply settings to the cel sprite - pbSpriteSetAnimFrame(sprite,cel,@usersprite,@targetsprite) + pbSpriteSetAnimFrame(sprite, cel, @usersprite, @targetsprite) case cel[AnimFrame::FOCUS] when 1 # Focused on target sprite.x = cel[AnimFrame::X] + @targetOrig[0] - Battle::Scene::FOCUSTARGET_X @@ -852,13 +852,13 @@ class PBAnimationPlayerX when 3 # Focused on user and target next if !@srcLine || !@dstLine point = transformPoint( - @srcLine[0],@srcLine[1],@srcLine[2],@srcLine[3], - @dstLine[0],@dstLine[1],@dstLine[2],@dstLine[3], - sprite.x,sprite.y) + @srcLine[0], @srcLine[1], @srcLine[2], @srcLine[3], + @dstLine[0], @dstLine[1], @dstLine[2], @dstLine[3], + sprite.x, sprite.y) sprite.x = point[0] sprite.y = point[1] - if isReversed(@srcLine[0],@srcLine[2],@dstLine[0],@dstLine[2]) && - cel[AnimFrame::PATTERN]>=0 + if isReversed(@srcLine[0], @srcLine[2], @dstLine[0], @dstLine[2]) && + cel[AnimFrame::PATTERN] >= 0 # Reverse direction sprite.mirror = !sprite.mirror end @@ -867,7 +867,7 @@ class PBAnimationPlayerX sprite.y += 64 if @inEditor end # Play timings - @animation.playTiming(animFrame,@bgGraphic,@bgColor,@foGraphic,@foColor,@oldbg,@oldfo,@user) + @animation.playTiming(animFrame, @bgGraphic, @bgColor, @foGraphic, @foColor, @oldbg, @oldfo, @user) end @frame += 1 end diff --git a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb index 2666e2d33..dd6eeb6e6 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/008_Battle_AbilityEffects.rb @@ -297,50 +297,50 @@ end #=============================================================================== Battle::AbilityEffects::SpeedCalc.add(:CHLOROPHYLL, - proc { |ability,battler,mult| + proc { |ability, battler, mult| next mult * 2 if [:Sun, :HarshSun].include?(battler.effectiveWeather) } ) Battle::AbilityEffects::SpeedCalc.add(:QUICKFEET, - proc { |ability,battler,mult| - next mult*1.5 if battler.pbHasAnyStatus? + proc { |ability, battler, mult| + next mult * 1.5 if battler.pbHasAnyStatus? } ) Battle::AbilityEffects::SpeedCalc.add(:SANDRUSH, - proc { |ability,battler,mult| + proc { |ability, battler, mult| next mult * 2 if [:Sandstorm].include?(battler.effectiveWeather) } ) Battle::AbilityEffects::SpeedCalc.add(:SLOWSTART, - proc { |ability,battler,mult| - next mult/2 if battler.effects[PBEffects::SlowStart]>0 + proc { |ability, battler, mult| + next mult / 2 if battler.effects[PBEffects::SlowStart] > 0 } ) Battle::AbilityEffects::SpeedCalc.add(:SLUSHRUSH, - proc { |ability,battler,mult| + proc { |ability, battler, mult| next mult * 2 if [:Hail].include?(battler.effectiveWeather) } ) Battle::AbilityEffects::SpeedCalc.add(:SURGESURFER, - proc { |ability,battler,mult| - next mult*2 if battler.battle.field.terrain == :Electric + proc { |ability, battler, mult| + next mult * 2 if battler.battle.field.terrain == :Electric } ) Battle::AbilityEffects::SpeedCalc.add(:SWIFTSWIM, - proc { |ability,battler,mult| + proc { |ability, battler, mult| next mult * 2 if [:Rain, :HeavyRain].include?(battler.effectiveWeather) } ) Battle::AbilityEffects::SpeedCalc.add(:UNBURDEN, - proc { |ability,battler,mult| - next mult*2 if battler.effects[PBEffects::Unburden] && !battler.item + proc { |ability, battler, mult| + next mult * 2 if battler.effects[PBEffects::Unburden] && !battler.item } ) @@ -349,14 +349,14 @@ Battle::AbilityEffects::SpeedCalc.add(:UNBURDEN, #=============================================================================== Battle::AbilityEffects::WeightCalc.add(:HEAVYMETAL, - proc { |ability,battler,w| - next w*2 + proc { |ability, battler, w| + next w * 2 } ) Battle::AbilityEffects::WeightCalc.add(:LIGHTMETAL, - proc { |ability,battler,w| - next [w/2,1].max + proc { |ability, battler, w| + next [w / 2, 1].max } ) @@ -366,16 +366,16 @@ Battle::AbilityEffects::WeightCalc.add(:LIGHTMETAL, Battle::AbilityEffects::OnHPDroppedBelowHalf.add(:EMERGENCYEXIT, proc { |ability, battler, move_user, battle| - next false if battler.effects[PBEffects::SkyDrop]>=0 || + next false if battler.effects[PBEffects::SkyDrop] >= 0 || battler.inTwoTurnAttack?("TwoTurnAttackInvulnerableInSkyTargetCannotAct") # Sky Drop # In wild battles if battle.wildBattle? - next false if battler.opposes? && battle.pbSideBattlerCount(battler.index)>1 + next false if battler.opposes? && battle.pbSideBattlerCount(battler.index) > 1 next false if !battle.pbCanRun?(battler.index) - battle.pbShowAbilitySplash(battler,true) + battle.pbShowAbilitySplash(battler, true) battle.pbHideAbilitySplash(battler) pbSEPlay("Battle flee") - battle.pbDisplay(_INTL("{1} fled from battle!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} fled from battle!", battler.pbThis)) battle.decision = 3 # Escaped next true end @@ -383,21 +383,21 @@ Battle::AbilityEffects::OnHPDroppedBelowHalf.add(:EMERGENCYEXIT, next false if battle.pbAllFainted?(battler.idxOpposingSide) next false if !battle.pbCanSwitch?(battler.index) # Battler can't switch out next false if !battle.pbCanChooseNonActive?(battler.index) # No Pokémon can switch in - battle.pbShowAbilitySplash(battler,true) + battle.pbShowAbilitySplash(battler, true) battle.pbHideAbilitySplash(battler) if !Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s {2} activated!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} activated!", battler.pbThis, battler.abilityName)) end battle.pbDisplay(_INTL("{1} went back to {2}!", - battler.pbThis,battle.pbGetOwnerName(battler.index))) + battler.pbThis, battle.pbGetOwnerName(battler.index))) if battle.endOfRound # Just switch out battle.scene.pbRecall(battler.index) if !battler.fainted? battler.pbAbilitiesOnSwitchOut # Inc. primordial weather check next true end newPkmn = battle.pbGetReplacementPokemonIndex(battler.index) # Owner chooses - next false if newPkmn<0 # Shouldn't ever do this - battle.pbRecallAndReplace(battler.index,newPkmn) + next false if newPkmn < 0 # Shouldn't ever do this + battle.pbRecallAndReplace(battler.index, newPkmn) battle.pbClearChoice(battler.index) # Replacement Pokémon does nothing this round battle.moldBreaker = false if move_user && battler.index == move_user.index battle.pbOnBattlerEnteringBattle(battler.index) @@ -405,14 +405,14 @@ Battle::AbilityEffects::OnHPDroppedBelowHalf.add(:EMERGENCYEXIT, } ) -Battle::AbilityEffects::OnHPDroppedBelowHalf.copy(:EMERGENCYEXIT,:WIMPOUT) +Battle::AbilityEffects::OnHPDroppedBelowHalf.copy(:EMERGENCYEXIT, :WIMPOUT) #=============================================================================== # StatusCheckNonIgnorable handlers #=============================================================================== Battle::AbilityEffects::StatusCheckNonIgnorable.add(:COMATOSE, - proc { |ability,battler,status| + proc { |ability, battler, status| next false if !battler.isSpecies?(:KOMALA) next true if status.nil? || status == :SLEEP } @@ -423,13 +423,13 @@ Battle::AbilityEffects::StatusCheckNonIgnorable.add(:COMATOSE, #=============================================================================== Battle::AbilityEffects::StatusImmunity.add(:FLOWERVEIL, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if battler.pbHasType?(:GRASS) } ) Battle::AbilityEffects::StatusImmunity.add(:IMMUNITY, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if status == :POISON } ) @@ -437,7 +437,7 @@ Battle::AbilityEffects::StatusImmunity.add(:IMMUNITY, Battle::AbilityEffects::StatusImmunity.copy(:IMMUNITY, :PASTELVEIL) Battle::AbilityEffects::StatusImmunity.add(:INSOMNIA, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if status == :SLEEP } ) @@ -445,44 +445,44 @@ Battle::AbilityEffects::StatusImmunity.add(:INSOMNIA, Battle::AbilityEffects::StatusImmunity.copy(:INSOMNIA, :SWEETVEIL, :VITALSPIRIT) Battle::AbilityEffects::StatusImmunity.add(:LEAFGUARD, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if [:Sun, :HarshSun].include?(battler.effectiveWeather) } ) Battle::AbilityEffects::StatusImmunity.add(:LIMBER, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if status == :PARALYSIS } ) Battle::AbilityEffects::StatusImmunity.add(:MAGMAARMOR, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if status == :FROZEN } ) Battle::AbilityEffects::StatusImmunity.add(:WATERVEIL, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if status == :BURN } ) -Battle::AbilityEffects::StatusImmunity.copy(:WATERVEIL,:WATERBUBBLE) +Battle::AbilityEffects::StatusImmunity.copy(:WATERVEIL, :WATERBUBBLE) #=============================================================================== # StatusImmunityNonIgnorable handlers #=============================================================================== Battle::AbilityEffects::StatusImmunityNonIgnorable.add(:COMATOSE, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if battler.isSpecies?(:KOMALA) } ) Battle::AbilityEffects::StatusImmunityNonIgnorable.add(:SHIELDSDOWN, - proc { |ability,battler,status| - next true if battler.isSpecies?(:MINIOR) && battler.form<7 + proc { |ability, battler, status| + next true if battler.isSpecies?(:MINIOR) && battler.form < 7 } ) @@ -491,13 +491,13 @@ Battle::AbilityEffects::StatusImmunityNonIgnorable.add(:SHIELDSDOWN, #=============================================================================== Battle::AbilityEffects::StatusImmunityFromAlly.add(:FLOWERVEIL, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if battler.pbHasType?(:GRASS) } ) Battle::AbilityEffects::StatusImmunityFromAlly.add(:SWEETVEIL, - proc { |ability,battler,status| + proc { |ability, battler, status| next true if status == :SLEEP } ) @@ -507,17 +507,17 @@ Battle::AbilityEffects::StatusImmunityFromAlly.add(:SWEETVEIL, #=============================================================================== Battle::AbilityEffects::OnStatusInflicted.add(:SYNCHRONIZE, - proc { |ability,battler,user,status| - next if !user || user.index==battler.index + proc { |ability, battler, user, status| + next if !user || user.index == battler.index case status when :POISON if user.pbCanPoisonSynchronize?(battler) battler.battle.pbShowAbilitySplash(battler) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} poisoned {3}!",battler.pbThis,battler.abilityName,user.pbThis(true)) + msg = _INTL("{1}'s {2} poisoned {3}!", battler.pbThis, battler.abilityName, user.pbThis(true)) end - user.pbPoison(nil,msg,(battler.statusCount>0)) + user.pbPoison(nil, msg, (battler.statusCount > 0)) battler.battle.pbHideAbilitySplash(battler) end when :BURN @@ -525,9 +525,9 @@ Battle::AbilityEffects::OnStatusInflicted.add(:SYNCHRONIZE, battler.battle.pbShowAbilitySplash(battler) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} burned {3}!",battler.pbThis,battler.abilityName,user.pbThis(true)) + msg = _INTL("{1}'s {2} burned {3}!", battler.pbThis, battler.abilityName, user.pbThis(true)) end - user.pbBurn(nil,msg) + user.pbBurn(nil, msg) battler.battle.pbHideAbilitySplash(battler) end when :PARALYSIS @@ -536,9 +536,9 @@ Battle::AbilityEffects::OnStatusInflicted.add(:SYNCHRONIZE, msg = nil if !Battle::Scene::USE_ABILITY_SPLASH msg = _INTL("{1}'s {2} paralyzed {3}! It may be unable to move!", - battler.pbThis,battler.abilityName,user.pbThis(true)) + battler.pbThis, battler.abilityName, user.pbThis(true)) end - user.pbParalyze(nil,msg) + user.pbParalyze(nil, msg) battler.battle.pbHideAbilitySplash(battler) end end @@ -550,24 +550,24 @@ Battle::AbilityEffects::OnStatusInflicted.add(:SYNCHRONIZE, #=============================================================================== Battle::AbilityEffects::StatusCure.add(:IMMUNITY, - proc { |ability,battler| + proc { |ability, battler| next if battler.status != :POISON battler.battle.pbShowAbilitySplash(battler) battler.pbCureStatus(Battle::Scene::USE_ABILITY_SPLASH) if !Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning!",battler.pbThis,battler.abilityName)) + battler.battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning!", battler.pbThis, battler.abilityName)) end battler.battle.pbHideAbilitySplash(battler) } ) Battle::AbilityEffects::StatusCure.add(:INSOMNIA, - proc { |ability,battler| + proc { |ability, battler| next if battler.status != :SLEEP battler.battle.pbShowAbilitySplash(battler) battler.pbCureStatus(Battle::Scene::USE_ABILITY_SPLASH) if !Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1}'s {2} woke it up!",battler.pbThis,battler.abilityName)) + battler.battle.pbDisplay(_INTL("{1}'s {2} woke it up!", battler.pbThis, battler.abilityName)) end battler.battle.pbHideAbilitySplash(battler) } @@ -576,50 +576,50 @@ Battle::AbilityEffects::StatusCure.add(:INSOMNIA, Battle::AbilityEffects::StatusCure.copy(:INSOMNIA, :VITALSPIRIT) Battle::AbilityEffects::StatusCure.add(:LIMBER, - proc { |ability,battler| + proc { |ability, battler| next if battler.status != :PARALYSIS battler.battle.pbShowAbilitySplash(battler) battler.pbCureStatus(Battle::Scene::USE_ABILITY_SPLASH) if !Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!",battler.pbThis,battler.abilityName)) + battler.battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!", battler.pbThis, battler.abilityName)) end battler.battle.pbHideAbilitySplash(battler) } ) Battle::AbilityEffects::StatusCure.add(:MAGMAARMOR, - proc { |ability,battler| + proc { |ability, battler| next if battler.status != :FROZEN battler.battle.pbShowAbilitySplash(battler) battler.pbCureStatus(Battle::Scene::USE_ABILITY_SPLASH) if !Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1}'s {2} defrosted it!",battler.pbThis,battler.abilityName)) + battler.battle.pbDisplay(_INTL("{1}'s {2} defrosted it!", battler.pbThis, battler.abilityName)) end battler.battle.pbHideAbilitySplash(battler) } ) Battle::AbilityEffects::StatusCure.add(:OBLIVIOUS, - proc { |ability,battler| - next if battler.effects[PBEffects::Attract]<0 && - (battler.effects[PBEffects::Taunt]==0 || Settings::MECHANICS_GENERATION <= 5) + proc { |ability, battler| + next if battler.effects[PBEffects::Attract] < 0 && + (battler.effects[PBEffects::Taunt] == 0 || Settings::MECHANICS_GENERATION <= 5) battler.battle.pbShowAbilitySplash(battler) - if battler.effects[PBEffects::Attract]>=0 + if battler.effects[PBEffects::Attract] >= 0 battler.pbCureAttract if Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1} got over its infatuation.",battler.pbThis)) + battler.battle.pbDisplay(_INTL("{1} got over its infatuation.", battler.pbThis)) else battler.battle.pbDisplay(_INTL("{1}'s {2} cured its infatuation status!", - battler.pbThis,battler.abilityName)) + battler.pbThis, battler.abilityName)) end end - if battler.effects[PBEffects::Taunt]>0 && Settings::MECHANICS_GENERATION >= 6 + if battler.effects[PBEffects::Taunt] > 0 && Settings::MECHANICS_GENERATION >= 6 battler.effects[PBEffects::Taunt] = 0 if Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1}'s Taunt wore off!",battler.pbThis)) + battler.battle.pbDisplay(_INTL("{1}'s Taunt wore off!", battler.pbThis)) else battler.battle.pbDisplay(_INTL("{1}'s {2} made its taunt wear off!", - battler.pbThis,battler.abilityName)) + battler.pbThis, battler.abilityName)) end end battler.battle.pbHideAbilitySplash(battler) @@ -627,27 +627,27 @@ Battle::AbilityEffects::StatusCure.add(:OBLIVIOUS, ) Battle::AbilityEffects::StatusCure.add(:OWNTEMPO, - proc { |ability,battler| - next if battler.effects[PBEffects::Confusion]==0 + proc { |ability, battler| + next if battler.effects[PBEffects::Confusion] == 0 battler.battle.pbShowAbilitySplash(battler) battler.pbCureConfusion if Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1} snapped out of its confusion.",battler.pbThis)) + battler.battle.pbDisplay(_INTL("{1} snapped out of its confusion.", battler.pbThis)) else battler.battle.pbDisplay(_INTL("{1}'s {2} snapped it out of its confusion!", - battler.pbThis,battler.abilityName)) + battler.pbThis, battler.abilityName)) end battler.battle.pbHideAbilitySplash(battler) } ) Battle::AbilityEffects::StatusCure.add(:WATERVEIL, - proc { |ability,battler| + proc { |ability, battler| next if battler.status != :BURN battler.battle.pbShowAbilitySplash(battler) battler.pbCureStatus(Battle::Scene::USE_ABILITY_SPLASH) if !Battle::Scene::USE_ABILITY_SPLASH - battler.battle.pbDisplay(_INTL("{1}'s {2} healed its burn!",battler.pbThis,battler.abilityName)) + battler.battle.pbDisplay(_INTL("{1}'s {2} healed its burn!", battler.pbThis, battler.abilityName)) end battler.battle.pbHideAbilitySplash(battler) } @@ -660,15 +660,15 @@ Battle::AbilityEffects::StatusCure.copy(:WATERVEIL, :WATERBUBBLE) #=============================================================================== Battle::AbilityEffects::StatLossImmunity.add(:BIGPECKS, - proc { |ability,battler,stat,battle,showMessages| - next false if stat!=:DEFENSE + proc { |ability, battler, stat, battle, showMessages| + next false if stat != :DEFENSE if showMessages battle.pbShowAbilitySplash(battler) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s {2} cannot be lowered!",battler.pbThis,GameData::Stat.get(stat).name)) + battle.pbDisplay(_INTL("{1}'s {2} cannot be lowered!", battler.pbThis, GameData::Stat.get(stat).name)) else - battle.pbDisplay(_INTL("{1}'s {2} prevents {3} loss!",battler.pbThis, - battler.abilityName,GameData::Stat.get(stat).name)) + battle.pbDisplay(_INTL("{1}'s {2} prevents {3} loss!", battler.pbThis, + battler.abilityName, GameData::Stat.get(stat).name)) end battle.pbHideAbilitySplash(battler) end @@ -677,13 +677,13 @@ Battle::AbilityEffects::StatLossImmunity.add(:BIGPECKS, ) Battle::AbilityEffects::StatLossImmunity.add(:CLEARBODY, - proc { |ability,battler,stat,battle,showMessages| + proc { |ability, battler, stat, battle, showMessages| if showMessages battle.pbShowAbilitySplash(battler) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!", battler.pbThis)) else - battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!", battler.pbThis, battler.abilityName)) end battle.pbHideAbilitySplash(battler) end @@ -694,14 +694,14 @@ Battle::AbilityEffects::StatLossImmunity.add(:CLEARBODY, Battle::AbilityEffects::StatLossImmunity.copy(:CLEARBODY, :WHITESMOKE) Battle::AbilityEffects::StatLossImmunity.add(:FLOWERVEIL, - proc { |ability,battler,stat,battle,showMessages| + proc { |ability, battler, stat, battle, showMessages| next false if !battler.pbHasType?(:GRASS) if showMessages battle.pbShowAbilitySplash(battler) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!", battler.pbThis)) else - battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!", battler.pbThis, battler.abilityName)) end battle.pbHideAbilitySplash(battler) end @@ -710,15 +710,15 @@ Battle::AbilityEffects::StatLossImmunity.add(:FLOWERVEIL, ) Battle::AbilityEffects::StatLossImmunity.add(:HYPERCUTTER, - proc { |ability,battler,stat,battle,showMessages| - next false if stat!=:ATTACK + proc { |ability, battler, stat, battle, showMessages| + next false if stat != :ATTACK if showMessages battle.pbShowAbilitySplash(battler) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s {2} cannot be lowered!",battler.pbThis,GameData::Stat.get(stat).name)) + battle.pbDisplay(_INTL("{1}'s {2} cannot be lowered!", battler.pbThis, GameData::Stat.get(stat).name)) else - battle.pbDisplay(_INTL("{1}'s {2} prevents {3} loss!",battler.pbThis, - battler.abilityName,GameData::Stat.get(stat).name)) + battle.pbDisplay(_INTL("{1}'s {2} prevents {3} loss!", battler.pbThis, + battler.abilityName, GameData::Stat.get(stat).name)) end battle.pbHideAbilitySplash(battler) end @@ -727,15 +727,15 @@ Battle::AbilityEffects::StatLossImmunity.add(:HYPERCUTTER, ) Battle::AbilityEffects::StatLossImmunity.add(:KEENEYE, - proc { |ability,battler,stat,battle,showMessages| - next false if stat!=:ACCURACY + proc { |ability, battler, stat, battle, showMessages| + next false if stat != :ACCURACY if showMessages battle.pbShowAbilitySplash(battler) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s {2} cannot be lowered!",battler.pbThis,GameData::Stat.get(stat).name)) + battle.pbDisplay(_INTL("{1}'s {2} cannot be lowered!", battler.pbThis, GameData::Stat.get(stat).name)) else - battle.pbDisplay(_INTL("{1}'s {2} prevents {3} loss!",battler.pbThis, - battler.abilityName,GameData::Stat.get(stat).name)) + battle.pbDisplay(_INTL("{1}'s {2} prevents {3} loss!", battler.pbThis, + battler.abilityName, GameData::Stat.get(stat).name)) end battle.pbHideAbilitySplash(battler) end @@ -748,13 +748,13 @@ Battle::AbilityEffects::StatLossImmunity.add(:KEENEYE, #=============================================================================== Battle::AbilityEffects::StatLossImmunityNonIgnorable.add(:FULLMETALBODY, - proc { |ability,battler,stat,battle,showMessages| + proc { |ability, battler, stat, battle, showMessages| if showMessages battle.pbShowAbilitySplash(battler) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!", battler.pbThis)) else - battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} prevents stat loss!", battler.pbThis, battler.abilityName)) end battle.pbHideAbilitySplash(battler) end @@ -767,15 +767,15 @@ Battle::AbilityEffects::StatLossImmunityNonIgnorable.add(:FULLMETALBODY, #=============================================================================== Battle::AbilityEffects::StatLossImmunityFromAlly.add(:FLOWERVEIL, - proc { |ability,bearer,battler,stat,battle,showMessages| + proc { |ability, bearer, battler, stat, battle, showMessages| next false if !battler.pbHasType?(:GRASS) if showMessages battle.pbShowAbilitySplash(bearer) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s stats cannot be lowered!", battler.pbThis)) else battle.pbDisplay(_INTL("{1}'s {2} prevents {3}'s stat loss!", - bearer.pbThis,bearer.abilityName,battler.pbThis(true))) + bearer.pbThis, bearer.abilityName, battler.pbThis(true))) end battle.pbHideAbilitySplash(bearer) end @@ -794,16 +794,16 @@ Battle::AbilityEffects::StatLossImmunityFromAlly.add(:FLOWERVEIL, #=============================================================================== Battle::AbilityEffects::OnStatLoss.add(:COMPETITIVE, - proc { |ability,battler,stat,user| + proc { |ability, battler, stat, user| next if user && !user.opposes?(battler) - battler.pbRaiseStatStageByAbility(:SPECIAL_ATTACK,2,battler) + battler.pbRaiseStatStageByAbility(:SPECIAL_ATTACK, 2, battler) } ) Battle::AbilityEffects::OnStatLoss.add(:DEFIANT, - proc { |ability,battler,stat,user| + proc { |ability, battler, stat, user| next if user && !user.opposes?(battler) - battler.pbRaiseStatStageByAbility(:ATTACK,2,battler) + battler.pbRaiseStatStageByAbility(:ATTACK, 2, battler) } ) @@ -812,24 +812,24 @@ Battle::AbilityEffects::OnStatLoss.add(:DEFIANT, #=============================================================================== Battle::AbilityEffects::PriorityChange.add(:GALEWINGS, - proc { |ability,battler,move,pri| + proc { |ability, battler, move, pri| next pri + 1 if (Settings::MECHANICS_GENERATION <= 6 || battler.hp == battler.totalhp) && move.type == :FLYING } ) Battle::AbilityEffects::PriorityChange.add(:PRANKSTER, - proc { |ability,battler,move,pri| + proc { |ability, battler, move, pri| if move.statusMove? battler.effects[PBEffects::Prankster] = true - next pri+1 + next pri + 1 end } ) Battle::AbilityEffects::PriorityChange.add(:TRIAGE, - proc { |ability,battler,move,pri| - next pri+3 if move.healingMove? + proc { |ability, battler, move, pri| + next pri + 3 if move.healingMove? } ) @@ -844,8 +844,8 @@ Battle::AbilityEffects::PriorityBracketChange.add(:QUICKDRAW, ) Battle::AbilityEffects::PriorityBracketChange.add(:STALL, - proc { |ability,battler,subPri,battle| - next -1 if subPri==0 + proc { |ability, battler, subPri, battle| + next -1 if subPri == 0 } ) @@ -866,8 +866,8 @@ Battle::AbilityEffects::PriorityBracketUse.add(:QUICKDRAW, #=============================================================================== Battle::AbilityEffects::OnFlinch.add(:STEADFAST, - proc { |ability,battler,battle| - battler.pbRaiseStatStageByAbility(:SPEED,1,battler) + proc { |ability, battler, battle| + battler.pbRaiseStatStageByAbility(:SPEED, 1, battler) } ) @@ -876,8 +876,8 @@ Battle::AbilityEffects::OnFlinch.add(:STEADFAST, #=============================================================================== Battle::AbilityEffects::MoveBlocking.add(:DAZZLING, - proc { |ability,bearer,user,targets,move,battle| - next false if battle.choices[user.index][4]<=0 + proc { |ability, bearer, user, targets, move, battle| + next false if battle.choices[user.index][4] <= 0 next false if !bearer.opposes?(user) ret = false targets.each do |b| @@ -913,7 +913,7 @@ Battle::AbilityEffects::MoveImmunity.add(:BULLETPROOF, Battle::AbilityEffects::MoveImmunity.add(:FLASHFIRE, proc { |ability, user, target, move, type, battle, show_message| - next false if user.index==target.index + next false if user.index == target.index next false if type != :FIRE if show_message battle.pbShowAbilitySplash(target) @@ -987,7 +987,7 @@ Battle::AbilityEffects::MoveImmunity.add(:STORMDRAIN, Battle::AbilityEffects::MoveImmunity.add(:TELEPATHY, proc { |ability, user, target, move, type, battle, show_message| next false if move.statusMove? - next false if user.index==target.index || target.opposes?(user) + next false if user.index == target.index || target.opposes?(user) if show_message battle.pbShowAbilitySplash(target) if Battle::Scene::USE_ABILITY_SPLASH @@ -1038,7 +1038,7 @@ Battle::AbilityEffects::MoveImmunity.add(:WONDERGUARD, #=============================================================================== Battle::AbilityEffects::ModifyMoveBaseType.add(:AERILATE, - proc { |ability,user,move,type| + proc { |ability, user, move, type| next if type != :NORMAL || !GameData::Type.exists?(:FLYING) move.powerBoost = true next :FLYING @@ -1046,7 +1046,7 @@ Battle::AbilityEffects::ModifyMoveBaseType.add(:AERILATE, ) Battle::AbilityEffects::ModifyMoveBaseType.add(:GALVANIZE, - proc { |ability,user,move,type| + proc { |ability, user, move, type| next if type != :NORMAL || !GameData::Type.exists?(:ELECTRIC) move.powerBoost = true next :ELECTRIC @@ -1054,13 +1054,13 @@ Battle::AbilityEffects::ModifyMoveBaseType.add(:GALVANIZE, ) Battle::AbilityEffects::ModifyMoveBaseType.add(:LIQUIDVOICE, - proc { |ability,user,move,type| + proc { |ability, user, move, type| next :WATER if GameData::Type.exists?(:WATER) && move.soundMove? } ) Battle::AbilityEffects::ModifyMoveBaseType.add(:NORMALIZE, - proc { |ability,user,move,type| + proc { |ability, user, move, type| next if !GameData::Type.exists?(:NORMAL) move.powerBoost = true if Settings::MECHANICS_GENERATION >= 7 next :NORMAL @@ -1068,7 +1068,7 @@ Battle::AbilityEffects::ModifyMoveBaseType.add(:NORMALIZE, ) Battle::AbilityEffects::ModifyMoveBaseType.add(:PIXILATE, - proc { |ability,user,move,type| + proc { |ability, user, move, type| next if type != :NORMAL || !GameData::Type.exists?(:FAIRY) move.powerBoost = true next :FAIRY @@ -1076,7 +1076,7 @@ Battle::AbilityEffects::ModifyMoveBaseType.add(:PIXILATE, ) Battle::AbilityEffects::ModifyMoveBaseType.add(:REFRIGERATE, - proc { |ability,user,move,type| + proc { |ability, user, move, type| next if type != :NORMAL || !GameData::Type.exists?(:ICE) move.powerBoost = true next :ICE @@ -1088,37 +1088,37 @@ Battle::AbilityEffects::ModifyMoveBaseType.add(:REFRIGERATE, #=============================================================================== Battle::AbilityEffects::AccuracyCalcFromUser.add(:COMPOUNDEYES, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:accuracy_multiplier] *= 1.3 } ) Battle::AbilityEffects::AccuracyCalcFromUser.add(:HUSTLE, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:accuracy_multiplier] *= 0.8 if move.physicalMove? } ) Battle::AbilityEffects::AccuracyCalcFromUser.add(:KEENEYE, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:evasion_stage] = 0 if mods[:evasion_stage] > 0 && Settings::MECHANICS_GENERATION >= 6 } ) Battle::AbilityEffects::AccuracyCalcFromUser.add(:NOGUARD, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:base_accuracy] = 0 } ) Battle::AbilityEffects::AccuracyCalcFromUser.add(:UNAWARE, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:evasion_stage] = 0 if move.damagingMove? } ) Battle::AbilityEffects::AccuracyCalcFromUser.add(:VICTORYSTAR, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:accuracy_multiplier] *= 1.1 } ) @@ -1128,7 +1128,7 @@ Battle::AbilityEffects::AccuracyCalcFromUser.add(:VICTORYSTAR, #=============================================================================== Battle::AbilityEffects::AccuracyCalcFromAlly.add(:VICTORYSTAR, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:accuracy_multiplier] *= 1.1 } ) @@ -1138,49 +1138,49 @@ Battle::AbilityEffects::AccuracyCalcFromAlly.add(:VICTORYSTAR, #=============================================================================== Battle::AbilityEffects::AccuracyCalcFromTarget.add(:LIGHTNINGROD, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:base_accuracy] = 0 if type == :ELECTRIC } ) Battle::AbilityEffects::AccuracyCalcFromTarget.add(:NOGUARD, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:base_accuracy] = 0 } ) Battle::AbilityEffects::AccuracyCalcFromTarget.add(:SANDVEIL, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:evasion_multiplier] *= 1.25 if target.effectiveWeather == :Sandstorm } ) Battle::AbilityEffects::AccuracyCalcFromTarget.add(:SNOWCLOAK, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:evasion_multiplier] *= 1.25 if target.effectiveWeather == :Hail } ) Battle::AbilityEffects::AccuracyCalcFromTarget.add(:STORMDRAIN, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:base_accuracy] = 0 if type == :WATER } ) Battle::AbilityEffects::AccuracyCalcFromTarget.add(:TANGLEDFEET, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:accuracy_multiplier] /= 2 if target.effects[PBEffects::Confusion] > 0 } ) Battle::AbilityEffects::AccuracyCalcFromTarget.add(:UNAWARE, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| mods[:accuracy_stage] = 0 if move.damagingMove? } ) Battle::AbilityEffects::AccuracyCalcFromTarget.add(:WONDERSKIN, - proc { |ability,mods,user,target,move,type| + proc { |ability, mods, user, target, move, type| if move.statusMove? && user.opposes?(target) mods[:base_accuracy] = 50 if mods[:base_accuracy] > 50 end @@ -1192,7 +1192,7 @@ Battle::AbilityEffects::AccuracyCalcFromTarget.add(:WONDERSKIN, #=============================================================================== Battle::AbilityEffects::DamageCalcFromUser.add(:AERILATE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if move.powerBoost } ) @@ -1200,7 +1200,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:AERILATE, Battle::AbilityEffects::DamageCalcFromUser.copy(:AERILATE, :PIXILATE, :REFRIGERATE, :GALVANIZE, :NORMALIZE) Battle::AbilityEffects::DamageCalcFromUser.add(:ANALYTIC, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| # NOTE: If another battler faints earlier in the round, but it would have # moved after the user, then Analytic would not power up the move. # However, this makes the determination so much more complicated @@ -1215,7 +1215,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:ANALYTIC, ) Battle::AbilityEffects::DamageCalcFromUser.add(:BLAZE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.hp <= user.totalhp / 3 && type == :FIRE mults[:attack_multiplier] *= 1.5 end @@ -1223,7 +1223,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:BLAZE, ) Battle::AbilityEffects::DamageCalcFromUser.add(:DEFEATIST, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:attack_multiplier] /= 2 if user.hp <= user.totalhp / 2 } ) @@ -1235,7 +1235,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:DRAGONSMAW, ) Battle::AbilityEffects::DamageCalcFromUser.add(:FLAREBOOST, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.burned? && move.specialMove? mults[:base_damage_multiplier] *= 1.5 end @@ -1243,7 +1243,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:FLAREBOOST, ) Battle::AbilityEffects::DamageCalcFromUser.add(:FLASHFIRE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.effects[PBEffects::FlashFire] && type == :FIRE mults[:attack_multiplier] *= 1.5 end @@ -1251,7 +1251,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:FLASHFIRE, ) Battle::AbilityEffects::DamageCalcFromUser.add(:FLOWERGIFT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if move.physicalMove? && [:Sun, :HarshSun].include?(user.effectiveWeather) mults[:attack_multiplier] *= 1.5 end @@ -1265,7 +1265,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:GORILLATACTICS, ) Battle::AbilityEffects::DamageCalcFromUser.add(:GUTS, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.pbHasAnyStatus? && move.physicalMove? mults[:attack_multiplier] *= 1.5 end @@ -1273,7 +1273,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:GUTS, ) Battle::AbilityEffects::DamageCalcFromUser.add(:HUGEPOWER, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:attack_multiplier] *= 2 if move.physicalMove? } ) @@ -1281,25 +1281,25 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:HUGEPOWER, Battle::AbilityEffects::DamageCalcFromUser.copy(:HUGEPOWER, :PUREPOWER) Battle::AbilityEffects::DamageCalcFromUser.add(:HUSTLE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:attack_multiplier] *= 1.5 if move.physicalMove? } ) Battle::AbilityEffects::DamageCalcFromUser.add(:IRONFIST, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if move.punchingMove? } ) Battle::AbilityEffects::DamageCalcFromUser.add(:MEGALAUNCHER, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.5 if move.pulseMove? } ) Battle::AbilityEffects::DamageCalcFromUser.add(:MINUS, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| next if !move.specialMove? if user.allAllies.any? { |b| b.hasActiveAbility?([:MINUS, :PLUS]) } mults[:attack_multiplier] *= 1.5 @@ -1310,7 +1310,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:MINUS, Battle::AbilityEffects::DamageCalcFromUser.copy(:MINUS, :PLUS) Battle::AbilityEffects::DamageCalcFromUser.add(:NEUROFORCE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if Effectiveness.super_effective?(target.damageState.typeMod) mults[:final_damage_multiplier] *= 1.25 end @@ -1318,7 +1318,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:NEUROFORCE, ) Battle::AbilityEffects::DamageCalcFromUser.add(:OVERGROW, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.hp <= user.totalhp / 3 && type == :GRASS mults[:attack_multiplier] *= 1.5 end @@ -1332,15 +1332,15 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:PUNKROCK, ) Battle::AbilityEffects::DamageCalcFromUser.add(:RECKLESS, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if move.recoilMove? } ) Battle::AbilityEffects::DamageCalcFromUser.add(:RIVALRY, - proc { |ability,user,target,move,mults,baseDmg,type| - if user.gender!=2 && target.gender!=2 - if user.gender==target.gender + proc { |ability, user, target, move, mults, baseDmg, type| + if user.gender != 2 && target.gender != 2 + if user.gender == target.gender mults[:base_damage_multiplier] *= 1.25 else mults[:base_damage_multiplier] *= 0.75 @@ -1350,7 +1350,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:RIVALRY, ) Battle::AbilityEffects::DamageCalcFromUser.add(:SANDFORCE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.effectiveWeather == :Sandstorm && [:ROCK, :GROUND, :STEEL].include?(type) mults[:base_damage_multiplier] *= 1.3 @@ -1359,19 +1359,19 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SANDFORCE, ) Battle::AbilityEffects::DamageCalcFromUser.add(:SHEERFORCE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.3 if move.addlEffect > 0 } ) Battle::AbilityEffects::DamageCalcFromUser.add(:SLOWSTART, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:attack_multiplier] /= 2 if user.effects[PBEffects::SlowStart] > 0 && move.physicalMove? } ) Battle::AbilityEffects::DamageCalcFromUser.add(:SOLARPOWER, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if move.specialMove? && [:Sun, :HarshSun].include?(user.effectiveWeather) mults[:attack_multiplier] *= 1.5 end @@ -1379,7 +1379,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SOLARPOWER, ) Battle::AbilityEffects::DamageCalcFromUser.add(:SNIPER, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if target.damageState.critical mults[:final_damage_multiplier] *= 1.5 end @@ -1387,13 +1387,13 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SNIPER, ) Battle::AbilityEffects::DamageCalcFromUser.add(:STAKEOUT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:attack_multiplier] *= 2 if target.battle.choices[target.index][0] == :SwitchOut } ) Battle::AbilityEffects::DamageCalcFromUser.add(:STEELWORKER, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:attack_multiplier] *= 1.5 if type == :STEEL } ) @@ -1405,13 +1405,13 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:STEELYSPIRIT, ) Battle::AbilityEffects::DamageCalcFromUser.add(:STRONGJAW, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.5 if move.bitingMove? } ) Battle::AbilityEffects::DamageCalcFromUser.add(:SWARM, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.hp <= user.totalhp / 3 && type == :BUG mults[:attack_multiplier] *= 1.5 end @@ -1419,7 +1419,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SWARM, ) Battle::AbilityEffects::DamageCalcFromUser.add(:TECHNICIAN, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.index != target.index && move && move.id != :STRUGGLE && baseDmg * mults[:base_damage_multiplier] <= 60 mults[:base_damage_multiplier] *= 1.5 @@ -1428,13 +1428,13 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:TECHNICIAN, ) Battle::AbilityEffects::DamageCalcFromUser.add(:TINTEDLENS, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:final_damage_multiplier] *= 2 if Effectiveness.resistant?(target.damageState.typeMod) } ) Battle::AbilityEffects::DamageCalcFromUser.add(:TORRENT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.hp <= user.totalhp / 3 && type == :WATER mults[:attack_multiplier] *= 1.5 end @@ -1442,13 +1442,13 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:TORRENT, ) Battle::AbilityEffects::DamageCalcFromUser.add(:TOUGHCLAWS, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 4 / 3.0 if move.contactMove? } ) Battle::AbilityEffects::DamageCalcFromUser.add(:TOXICBOOST, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.poisoned? && move.physicalMove? mults[:base_damage_multiplier] *= 1.5 end @@ -1462,7 +1462,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:TRANSISTOR, ) Battle::AbilityEffects::DamageCalcFromUser.add(:WATERBUBBLE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:attack_multiplier] *= 2 if type == :WATER } ) @@ -1472,14 +1472,14 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:WATERBUBBLE, #=============================================================================== Battle::AbilityEffects::DamageCalcFromAlly.add(:BATTERY, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| next if !move.specialMove? mults[:final_damage_multiplier] *= 1.3 } ) Battle::AbilityEffects::DamageCalcFromAlly.add(:FLOWERGIFT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if move.physicalMove? && [:Sun, :HarshSun].include?(user.effectiveWeather) mults[:attack_multiplier] *= 1.5 end @@ -1503,13 +1503,13 @@ Battle::AbilityEffects::DamageCalcFromAlly.add(:STEELYSPIRIT, #=============================================================================== Battle::AbilityEffects::DamageCalcFromTarget.add(:DRYSKIN, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.25 if type == :FIRE } ) Battle::AbilityEffects::DamageCalcFromTarget.add(:FILTER, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if Effectiveness.super_effective?(target.damageState.typeMod) mults[:final_damage_multiplier] *= 0.75 end @@ -1519,7 +1519,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:FILTER, Battle::AbilityEffects::DamageCalcFromTarget.copy(:FILTER, :SOLIDROCK) Battle::AbilityEffects::DamageCalcFromTarget.add(:FLOWERGIFT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if move.specialMove? && [:Sun, :HarshSun].include?(target.effectiveWeather) mults[:defense_multiplier] *= 1.5 end @@ -1527,21 +1527,21 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:FLOWERGIFT, ) Battle::AbilityEffects::DamageCalcFromTarget.add(:FLUFFY, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:final_damage_multiplier] *= 2 if move.calcType == :FIRE mults[:final_damage_multiplier] /= 2 if move.pbContactMove? } ) Battle::AbilityEffects::DamageCalcFromTarget.add(:FURCOAT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:defense_multiplier] *= 2 if move.physicalMove? || move.function == "UseTargetDefenseInsteadOfTargetSpDef" # Psyshock } ) Battle::AbilityEffects::DamageCalcFromTarget.add(:GRASSPELT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if user.battle.field.terrain == :Grassy mults[:defense_multiplier] *= 1.5 end @@ -1549,7 +1549,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:GRASSPELT, ) Battle::AbilityEffects::DamageCalcFromTarget.add(:HEATPROOF, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] /= 2 if type == :FIRE } ) @@ -1561,7 +1561,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:ICESCALES, ) Battle::AbilityEffects::DamageCalcFromTarget.add(:MARVELSCALE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if target.pbHasAnyStatus? && move.physicalMove? mults[:defense_multiplier] *= 1.5 end @@ -1569,7 +1569,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:MARVELSCALE, ) Battle::AbilityEffects::DamageCalcFromTarget.add(:MULTISCALE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:final_damage_multiplier] /= 2 if target.hp == target.totalhp } ) @@ -1581,13 +1581,13 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:PUNKROCK, ) Battle::AbilityEffects::DamageCalcFromTarget.add(:THICKFAT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] /= 2 if type == :FIRE || type == :ICE } ) Battle::AbilityEffects::DamageCalcFromTarget.add(:WATERBUBBLE, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:final_damage_multiplier] /= 2 if type == :FIRE } ) @@ -1597,7 +1597,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:WATERBUBBLE, #=============================================================================== Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:PRISMARMOR, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if Effectiveness.super_effective?(target.damageState.typeMod) mults[:final_damage_multiplier] *= 0.75 end @@ -1605,8 +1605,8 @@ Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:PRISMARMOR, ) Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:SHADOWSHIELD, - proc { |ability,user,target,move,mults,baseDmg,type| - if target.hp==target.totalhp + proc { |ability, user, target, move, mults, baseDmg, type| + if target.hp == target.totalhp mults[:final_damage_multiplier] /= 2 end } @@ -1617,7 +1617,7 @@ Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:SHADOWSHIELD, #=============================================================================== Battle::AbilityEffects::DamageCalcFromTargetAlly.add(:FLOWERGIFT, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| if move.specialMove? && [:Sun, :HarshSun].include?(target.effectiveWeather) mults[:defense_multiplier] *= 1.5 end @@ -1625,7 +1625,7 @@ Battle::AbilityEffects::DamageCalcFromTargetAlly.add(:FLOWERGIFT, ) Battle::AbilityEffects::DamageCalcFromTargetAlly.add(:FRIENDGUARD, - proc { |ability,user,target,move,mults,baseDmg,type| + proc { |ability, user, target, move, mults, baseDmg, type| mults[:final_damage_multiplier] *= 0.75 } ) @@ -1635,14 +1635,14 @@ Battle::AbilityEffects::DamageCalcFromTargetAlly.add(:FRIENDGUARD, #=============================================================================== Battle::AbilityEffects::CriticalCalcFromUser.add(:MERCILESS, - proc { |ability,user,target,c| + proc { |ability, user, target, c| next 99 if target.poisoned? } ) Battle::AbilityEffects::CriticalCalcFromUser.add(:SUPERLUCK, - proc { |ability,user,target,c| - next c+1 + proc { |ability, user, target, c| + next c + 1 } ) @@ -1651,7 +1651,7 @@ Battle::AbilityEffects::CriticalCalcFromUser.add(:SUPERLUCK, #=============================================================================== Battle::AbilityEffects::CriticalCalcFromTarget.add(:BATTLEARMOR, - proc { |ability,user,target,c| + proc { |ability, user, target, c| next -1 } ) @@ -1663,7 +1663,7 @@ Battle::AbilityEffects::CriticalCalcFromTarget.copy(:BATTLEARMOR, :SHELLARMOR) #=============================================================================== Battle::AbilityEffects::OnBeingHit.add(:AFTERMATH, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !target.fainted? next if !move.pbContactMove?(user) battle.pbShowAbilitySplash(target) @@ -1672,10 +1672,10 @@ Battle::AbilityEffects::OnBeingHit.add(:AFTERMATH, if dampBattler battle.pbShowAbilitySplash(dampBattler) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} cannot use {2}!",target.pbThis,target.abilityName)) + battle.pbDisplay(_INTL("{1} cannot use {2}!", target.pbThis, target.abilityName)) else battle.pbDisplay(_INTL("{1} cannot use {2} because of {3}'s {4}!", - target.pbThis,target.abilityName,dampBattler.pbThis(true),dampBattler.abilityName)) + target.pbThis, target.abilityName, dampBattler.pbThis(true), dampBattler.abilityName)) end battle.pbHideAbilitySplash(dampBattler) battle.pbHideAbilitySplash(target) @@ -1685,26 +1685,26 @@ Battle::AbilityEffects::OnBeingHit.add(:AFTERMATH, if user.takesIndirectDamage?(Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) battle.scene.pbDamageAnimation(user) - user.pbReduceHP(user.totalhp/4,false) - battle.pbDisplay(_INTL("{1} was caught in the aftermath!",user.pbThis)) + user.pbReduceHP(user.totalhp / 4, false) + battle.pbDisplay(_INTL("{1} was caught in the aftermath!", user.pbThis)) end battle.pbHideAbilitySplash(target) } ) Battle::AbilityEffects::OnBeingHit.add(:ANGERPOINT, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !target.damageState.critical - next if !target.pbCanRaiseStatStage?(:ATTACK,target) + next if !target.pbCanRaiseStatStage?(:ATTACK, target) battle.pbShowAbilitySplash(target) target.stages[:ATTACK] = 6 target.statsRaisedThisRound = true - battle.pbCommonAnimation("StatUp",target) + battle.pbCommonAnimation("StatUp", target) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} maxed its {2}!",target.pbThis,GameData::Stat.get(:ATTACK).name)) + battle.pbDisplay(_INTL("{1} maxed its {2}!", target.pbThis, GameData::Stat.get(:ATTACK).name)) else battle.pbDisplay(_INTL("{1}'s {2} maxed its {3}!", - target.pbThis,target.abilityName,GameData::Stat.get(:ATTACK).name)) + target.pbThis, target.abilityName, GameData::Stat.get(:ATTACK).name)) end battle.pbHideAbilitySplash(target) } @@ -1722,26 +1722,26 @@ Battle::AbilityEffects::OnBeingHit.add(:COTTONDOWN, ) Battle::AbilityEffects::OnBeingHit.add(:CURSEDBODY, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if user.fainted? - next if user.effects[PBEffects::Disable]>0 + next if user.effects[PBEffects::Disable] > 0 regularMove = nil user.eachMove do |m| - next if m.id!=user.lastRegularMoveUsed + next if m.id != user.lastRegularMoveUsed regularMove = m break end - next if !regularMove || (regularMove.pp==0 && regularMove.total_pp>0) - next if battle.pbRandom(100)>=30 + next if !regularMove || (regularMove.pp == 0 && regularMove.total_pp > 0) + next if battle.pbRandom(100) >= 30 battle.pbShowAbilitySplash(target) - if !move.pbMoveFailedAromaVeil?(target,user,Battle::Scene::USE_ABILITY_SPLASH) + if !move.pbMoveFailedAromaVeil?(target, user, Battle::Scene::USE_ABILITY_SPLASH) user.effects[PBEffects::Disable] = 3 user.effects[PBEffects::DisableMove] = regularMove.id if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s {2} was disabled!",user.pbThis,regularMove.name)) + battle.pbDisplay(_INTL("{1}'s {2} was disabled!", user.pbThis, regularMove.name)) else battle.pbDisplay(_INTL("{1}'s {2} was disabled by {3}'s {4}!", - user.pbThis,regularMove.name,target.pbThis(true),target.abilityName)) + user.pbThis, regularMove.name, target.pbThis(true), target.abilityName)) end battle.pbHideAbilitySplash(target) user.pbItemStatusCureCheck @@ -1751,65 +1751,65 @@ Battle::AbilityEffects::OnBeingHit.add(:CURSEDBODY, ) Battle::AbilityEffects::OnBeingHit.add(:CUTECHARM, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if target.fainted? next if !move.pbContactMove?(user) - next if battle.pbRandom(100)>=30 + next if battle.pbRandom(100) >= 30 battle.pbShowAbilitySplash(target) - if user.pbCanAttract?(target,Battle::Scene::USE_ABILITY_SPLASH) && + if user.pbCanAttract?(target, Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} made {3} fall in love!",target.pbThis, - target.abilityName,user.pbThis(true)) + msg = _INTL("{1}'s {2} made {3} fall in love!", target.pbThis, + target.abilityName, user.pbThis(true)) end - user.pbAttract(target,msg) + user.pbAttract(target, msg) end battle.pbHideAbilitySplash(target) } ) Battle::AbilityEffects::OnBeingHit.add(:EFFECTSPORE, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| # NOTE: This ability has a 30% chance of triggering, not a 30% chance of # inflicting a status condition. It can try (and fail) to inflict a # status condition that the user is immune to. next if !move.pbContactMove?(user) - next if battle.pbRandom(100)>=30 + next if battle.pbRandom(100) >= 30 r = battle.pbRandom(3) - next if r==0 && user.asleep? - next if r==1 && user.poisoned? - next if r==2 && user.paralyzed? + next if r == 0 && user.asleep? + next if r == 1 && user.poisoned? + next if r == 2 && user.paralyzed? battle.pbShowAbilitySplash(target) if user.affectedByPowder?(Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) case r when 0 - if user.pbCanSleep?(target,Battle::Scene::USE_ABILITY_SPLASH) + if user.pbCanSleep?(target, Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} made {3} fall asleep!",target.pbThis, - target.abilityName,user.pbThis(true)) + msg = _INTL("{1}'s {2} made {3} fall asleep!", target.pbThis, + target.abilityName, user.pbThis(true)) end user.pbSleep(msg) end when 1 - if user.pbCanPoison?(target,Battle::Scene::USE_ABILITY_SPLASH) + if user.pbCanPoison?(target, Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} poisoned {3}!",target.pbThis, - target.abilityName,user.pbThis(true)) + msg = _INTL("{1}'s {2} poisoned {3}!", target.pbThis, + target.abilityName, user.pbThis(true)) end - user.pbPoison(target,msg) + user.pbPoison(target, msg) end when 2 - if user.pbCanParalyze?(target,Battle::Scene::USE_ABILITY_SPLASH) + if user.pbCanParalyze?(target, Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH msg = _INTL("{1}'s {2} paralyzed {3}! It may be unable to move!", - target.pbThis,target.abilityName,user.pbThis(true)) + target.pbThis, target.abilityName, user.pbThis(true)) end - user.pbParalyze(target,msg) + user.pbParalyze(target, msg) end end end @@ -1818,54 +1818,54 @@ Battle::AbilityEffects::OnBeingHit.add(:EFFECTSPORE, ) Battle::AbilityEffects::OnBeingHit.add(:FLAMEBODY, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) - next if user.burned? || battle.pbRandom(100)>=30 + next if user.burned? || battle.pbRandom(100) >= 30 battle.pbShowAbilitySplash(target) - if user.pbCanBurn?(target,Battle::Scene::USE_ABILITY_SPLASH) && + if user.pbCanBurn?(target, Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} burned {3}!",target.pbThis,target.abilityName,user.pbThis(true)) + msg = _INTL("{1}'s {2} burned {3}!", target.pbThis, target.abilityName, user.pbThis(true)) end - user.pbBurn(target,msg) + user.pbBurn(target, msg) end battle.pbHideAbilitySplash(target) } ) Battle::AbilityEffects::OnBeingHit.add(:GOOEY, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) - user.pbLowerStatStageByAbility(:SPEED,1,target,true,true) + user.pbLowerStatStageByAbility(:SPEED, 1, target, true, true) } ) Battle::AbilityEffects::OnBeingHit.copy(:GOOEY, :TANGLINGHAIR) Battle::AbilityEffects::OnBeingHit.add(:ILLUSION, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| # NOTE: This intentionally doesn't show the ability splash. next if !target.effects[PBEffects::Illusion] target.effects[PBEffects::Illusion] = nil - battle.scene.pbChangePokemon(target,target.pokemon) - battle.pbDisplay(_INTL("{1}'s illusion wore off!",target.pbThis)) + battle.scene.pbChangePokemon(target, target.pokemon) + battle.pbDisplay(_INTL("{1}'s illusion wore off!", target.pbThis)) battle.pbSetSeen(target) } ) Battle::AbilityEffects::OnBeingHit.add(:INNARDSOUT, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !target.fainted? || user.dummy battle.pbShowAbilitySplash(target) if user.takesIndirectDamage?(Battle::Scene::USE_ABILITY_SPLASH) battle.scene.pbDamageAnimation(user) - user.pbReduceHP(target.damageState.hpLost,false) + user.pbReduceHP(target.damageState.hpLost, false) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} is hurt!",user.pbThis)) + battle.pbDisplay(_INTL("{1} is hurt!", user.pbThis)) else - battle.pbDisplay(_INTL("{1} is hurt by {2}'s {3}!",user.pbThis, - target.pbThis(true),target.abilityName)) + battle.pbDisplay(_INTL("{1} is hurt by {2}'s {3}!", user.pbThis, + target.pbThis(true), target.abilityName)) end end battle.pbHideAbilitySplash(target) @@ -1873,18 +1873,18 @@ Battle::AbilityEffects::OnBeingHit.add(:INNARDSOUT, ) Battle::AbilityEffects::OnBeingHit.add(:IRONBARBS, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) battle.pbShowAbilitySplash(target) if user.takesIndirectDamage?(Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) battle.scene.pbDamageAnimation(user) - user.pbReduceHP(user.totalhp/8,false) + user.pbReduceHP(user.totalhp / 8, false) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} is hurt!",user.pbThis)) + battle.pbDisplay(_INTL("{1} is hurt!", user.pbThis)) else - battle.pbDisplay(_INTL("{1} is hurt by {2}'s {3}!",user.pbThis, - target.pbThis(true),target.abilityName)) + battle.pbDisplay(_INTL("{1} is hurt by {2}'s {3}!", user.pbThis, + target.pbThis(true), target.abilityName)) end end battle.pbHideAbilitySplash(target) @@ -1894,14 +1894,14 @@ Battle::AbilityEffects::OnBeingHit.add(:IRONBARBS, Battle::AbilityEffects::OnBeingHit.copy(:IRONBARBS, :ROUGHSKIN) Battle::AbilityEffects::OnBeingHit.add(:JUSTIFIED, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if move.calcType != :DARK - target.pbRaiseStatStageByAbility(:ATTACK,1,target) + target.pbRaiseStatStageByAbility(:ATTACK, 1, target) } ) Battle::AbilityEffects::OnBeingHit.add(:MUMMY, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) next if user.fainted? next if user.unstoppableAbility? || user.ability == ability @@ -1909,14 +1909,14 @@ Battle::AbilityEffects::OnBeingHit.add(:MUMMY, battle.pbShowAbilitySplash(target) if user.opposes?(target) if user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) oldAbil = user.ability - battle.pbShowAbilitySplash(user,true,false) if user.opposes?(target) + battle.pbShowAbilitySplash(user, true, false) if user.opposes?(target) user.ability = ability battle.pbReplaceAbilitySplash(user) if user.opposes?(target) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s Ability became {2}!",user.pbThis,user.abilityName)) + battle.pbDisplay(_INTL("{1}'s Ability became {2}!", user.pbThis, user.abilityName)) else battle.pbDisplay(_INTL("{1}'s Ability became {2} because of {3}!", - user.pbThis,user.abilityName,target.pbThis(true))) + user.pbThis, user.abilityName, target.pbThis(true))) end battle.pbHideAbilitySplash(user) if user.opposes?(target) end @@ -1949,26 +1949,26 @@ Battle::AbilityEffects::OnBeingHit.add(:PERISHBODY, ) Battle::AbilityEffects::OnBeingHit.add(:POISONPOINT, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) - next if user.poisoned? || battle.pbRandom(100)>=30 + next if user.poisoned? || battle.pbRandom(100) >= 30 battle.pbShowAbilitySplash(target) - if user.pbCanPoison?(target,Battle::Scene::USE_ABILITY_SPLASH) && + if user.pbCanPoison?(target, Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} poisoned {3}!",target.pbThis,target.abilityName,user.pbThis(true)) + msg = _INTL("{1}'s {2} poisoned {3}!", target.pbThis, target.abilityName, user.pbThis(true)) end - user.pbPoison(target,msg) + user.pbPoison(target, msg) end battle.pbHideAbilitySplash(target) } ) Battle::AbilityEffects::OnBeingHit.add(:RATTLED, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if ![:BUG, :DARK, :GHOST].include?(move.calcType) - target.pbRaiseStatStageByAbility(:SPEED,1,target) + target.pbRaiseStatStageByAbility(:SPEED, 1, target) } ) @@ -1979,24 +1979,24 @@ Battle::AbilityEffects::OnBeingHit.add(:SANDSPIT, ) Battle::AbilityEffects::OnBeingHit.add(:STAMINA, - proc { |ability,user,target,move,battle| - target.pbRaiseStatStageByAbility(:DEFENSE,1,target) + proc { |ability, user, target, move, battle| + target.pbRaiseStatStageByAbility(:DEFENSE, 1, target) } ) Battle::AbilityEffects::OnBeingHit.add(:STATIC, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.pbContactMove?(user) - next if user.paralyzed? || battle.pbRandom(100)>=30 + next if user.paralyzed? || battle.pbRandom(100) >= 30 battle.pbShowAbilitySplash(target) - if user.pbCanParalyze?(target,Battle::Scene::USE_ABILITY_SPLASH) && + if user.pbCanParalyze?(target, Battle::Scene::USE_ABILITY_SPLASH) && user.affectedByContactEffect?(Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH msg = _INTL("{1}'s {2} paralyzed {3}! It may be unable to move!", - target.pbThis,target.abilityName,user.pbThis(true)) + target.pbThis, target.abilityName, user.pbThis(true)) end - user.pbParalyze(target,msg) + user.pbParalyze(target, msg) end battle.pbHideAbilitySplash(target) } @@ -2039,14 +2039,14 @@ Battle::AbilityEffects::OnBeingHit.add(:WANDERINGSPIRIT, ) Battle::AbilityEffects::OnBeingHit.add(:WATERCOMPACTION, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if move.calcType != :WATER - target.pbRaiseStatStageByAbility(:DEFENSE,2,target) + target.pbRaiseStatStageByAbility(:DEFENSE, 2, target) } ) Battle::AbilityEffects::OnBeingHit.add(:WEAKARMOR, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.physicalMove? next if !target.pbCanLowerStatStage?(:DEFENSE, target) && !target.pbCanRaiseStatStage?(:SPEED, target) @@ -2063,22 +2063,22 @@ Battle::AbilityEffects::OnBeingHit.add(:WEAKARMOR, #=============================================================================== Battle::AbilityEffects::OnDealingHit.add(:POISONTOUCH, - proc { |ability,user,target,move,battle| + proc { |ability, user, target, move, battle| next if !move.contactMove? - next if battle.pbRandom(100)>=30 + next if battle.pbRandom(100) >= 30 battle.pbShowAbilitySplash(user) if target.hasActiveAbility?(:SHIELDDUST) && !battle.moldBreaker battle.pbShowAbilitySplash(target) if !Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} is unaffected!",target.pbThis)) + battle.pbDisplay(_INTL("{1} is unaffected!", target.pbThis)) end battle.pbHideAbilitySplash(target) - elsif target.pbCanPoison?(user,Battle::Scene::USE_ABILITY_SPLASH) + elsif target.pbCanPoison?(user, Battle::Scene::USE_ABILITY_SPLASH) msg = nil if !Battle::Scene::USE_ABILITY_SPLASH - msg = _INTL("{1}'s {2} poisoned {3}!",user.pbThis,user.abilityName,target.pbThis(true)) + msg = _INTL("{1}'s {2} poisoned {3}!", user.pbThis, user.abilityName, target.pbThis(true)) end - target.pbPoison(user,msg) + target.pbPoison(user, msg) end battle.pbHideAbilitySplash(user) } @@ -2089,7 +2089,7 @@ Battle::AbilityEffects::OnDealingHit.add(:POISONTOUCH, #=============================================================================== Battle::AbilityEffects::OnEndOfUsingMove.add(:BEASTBOOST, - proc { |ability,user,targets,move,battle| + proc { |ability, user, targets, move, battle| next if battle.pbAllFainted?(user.idxOpposingSide) numFainted = 0 targets.each { |b| numFainted += 1 if b.damageState.fainted } @@ -2136,7 +2136,7 @@ Battle::AbilityEffects::OnEndOfUsingMove.add(:GRIMNEIGH, Battle::AbilityEffects::OnEndOfUsingMove.copy(:GRIMNEIGH, :ASONEGRIMNEIGH) Battle::AbilityEffects::OnEndOfUsingMove.add(:MAGICIAN, - proc { |ability,user,targets,move,battle| + proc { |ability, user, targets, move, battle| next if battle.futureSight next if !move.pbDamagingMove? next if user.item @@ -2149,7 +2149,7 @@ Battle::AbilityEffects::OnEndOfUsingMove.add(:MAGICIAN, if b.hasActiveAbility?(:STICKYHOLD) battle.pbShowAbilitySplash(b) if user.opposes?(b) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s item cannot be stolen!",b.pbThis)) + battle.pbDisplay(_INTL("{1}'s item cannot be stolen!", b.pbThis)) end battle.pbHideAbilitySplash(b) if user.opposes?(b) next @@ -2162,11 +2162,11 @@ Battle::AbilityEffects::OnEndOfUsingMove.add(:MAGICIAN, b.setInitialItem(nil) end if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} stole {2}'s {3}!",user.pbThis, - b.pbThis(true),user.itemName)) + battle.pbDisplay(_INTL("{1} stole {2}'s {3}!", user.pbThis, + b.pbThis(true), user.itemName)) else - battle.pbDisplay(_INTL("{1} stole {2}'s {3} with {4}!",user.pbThis, - b.pbThis(true),user.itemName,user.abilityName)) + battle.pbDisplay(_INTL("{1} stole {2}'s {3} with {4}!", user.pbThis, + b.pbThis(true), user.itemName, user.abilityName)) end battle.pbHideAbilitySplash(user) user.pbHeldItemTriggerCheck @@ -2176,12 +2176,12 @@ Battle::AbilityEffects::OnEndOfUsingMove.add(:MAGICIAN, ) Battle::AbilityEffects::OnEndOfUsingMove.add(:MOXIE, - proc { |ability,user,targets,move,battle| + proc { |ability, user, targets, move, battle| next if battle.pbAllFainted?(user.idxOpposingSide) numFainted = 0 targets.each { |b| numFainted += 1 if b.damageState.fainted } - next if numFainted==0 || !user.pbCanRaiseStatStage?(:ATTACK,user) - user.pbRaiseStatStageByAbility(:ATTACK,numFainted,user) + next if numFainted == 0 || !user.pbCanRaiseStatStage?(:ATTACK, user) + user.pbRaiseStatStageByAbility(:ATTACK, numFainted, user) } ) @@ -2193,14 +2193,14 @@ Battle::AbilityEffects::AfterMoveUseFromTarget.add(:BERSERK, proc { |ability, target, user, move, switched_battlers, battle| next if !move.damagingMove? next if !target.droppedBelowHalfHP - next if !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,target) - target.pbRaiseStatStageByAbility(:SPECIAL_ATTACK,1,target) + next if !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, target) + target.pbRaiseStatStageByAbility(:SPECIAL_ATTACK, 1, target) } ) Battle::AbilityEffects::AfterMoveUseFromTarget.add(:COLORCHANGE, proc { |ability, target, user, move, switched_battlers, battle| - next if target.damageState.calcDamage==0 || target.damageState.substitute + next if target.damageState.calcDamage == 0 || target.damageState.substitute next if !move.calcType || GameData::Type.get(move.calcType).pseudo_type next if target.pbHasType?(move.calcType) && !target.pbHasOtherType?(move.calcType) typeName = GameData::Type.get(move.calcType).name @@ -2220,14 +2220,14 @@ Battle::AbilityEffects::AfterMoveUseFromTarget.add(:PICKPOCKET, next if target.wild? next if switched_battlers.include?(user.index) # User was switched out next if !move.contactMove? - next if user.effects[PBEffects::Substitute]>0 || target.damageState.substitute + next if user.effects[PBEffects::Substitute] > 0 || target.damageState.substitute next if target.item || !user.item next if user.unlosableItem?(user.item) || target.unlosableItem?(user.item) battle.pbShowAbilitySplash(target) if user.hasActiveAbility?(:STICKYHOLD) battle.pbShowAbilitySplash(user) if target.opposes?(user) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s item cannot be stolen!",user.pbThis)) + battle.pbDisplay(_INTL("{1}'s item cannot be stolen!", user.pbThis)) end battle.pbHideAbilitySplash(user) if target.opposes?(user) battle.pbHideAbilitySplash(target) @@ -2240,8 +2240,8 @@ Battle::AbilityEffects::AfterMoveUseFromTarget.add(:PICKPOCKET, target.setInitialItem(target.item) user.setInitialItem(nil) end - battle.pbDisplay(_INTL("{1} pickpocketed {2}'s {3}!",target.pbThis, - user.pbThis(true),target.itemName)) + battle.pbDisplay(_INTL("{1} pickpocketed {2}'s {3}!", target.pbThis, + user.pbThis(true), target.itemName)) battle.pbHideAbilitySplash(target) target.pbHeldItemTriggerCheck } @@ -2252,23 +2252,23 @@ Battle::AbilityEffects::AfterMoveUseFromTarget.add(:PICKPOCKET, #=============================================================================== Battle::AbilityEffects::EndOfRoundWeather.add(:DRYSKIN, - proc { |ability,weather,battler,battle| + proc { |ability, weather, battler, battle| case weather when :Sun, :HarshSun battle.pbShowAbilitySplash(battler) battle.scene.pbDamageAnimation(battler) - battler.pbReduceHP(battler.totalhp/8,false) - battle.pbDisplay(_INTL("{1} was hurt by the sunlight!",battler.pbThis)) + battler.pbReduceHP(battler.totalhp / 8, false) + battle.pbDisplay(_INTL("{1} was hurt by the sunlight!", battler.pbThis)) battle.pbHideAbilitySplash(battler) battler.pbItemHPHealCheck when :Rain, :HeavyRain next if !battler.canHeal? battle.pbShowAbilitySplash(battler) - battler.pbRecoverHP(battler.totalhp/8) + battler.pbRecoverHP(battler.totalhp / 8) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1}'s {2} restored its HP.",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", battler.pbThis, battler.abilityName)) end battle.pbHideAbilitySplash(battler) end @@ -2276,15 +2276,15 @@ Battle::AbilityEffects::EndOfRoundWeather.add(:DRYSKIN, ) Battle::AbilityEffects::EndOfRoundWeather.add(:ICEBODY, - proc { |ability,weather,battler,battle| + proc { |ability, weather, battler, battle| next unless weather == :Hail next if !battler.canHeal? battle.pbShowAbilitySplash(battler) - battler.pbRecoverHP(battler.totalhp/16) + battler.pbRecoverHP(battler.totalhp / 16) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1}'s {2} restored its HP.",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", battler.pbThis, battler.abilityName)) end battle.pbHideAbilitySplash(battler) } @@ -2304,27 +2304,27 @@ Battle::AbilityEffects::EndOfRoundWeather.add(:ICEFACE, ) Battle::AbilityEffects::EndOfRoundWeather.add(:RAINDISH, - proc { |ability,weather,battler,battle| + proc { |ability, weather, battler, battle| next unless [:Rain, :HeavyRain].include?(weather) next if !battler.canHeal? battle.pbShowAbilitySplash(battler) - battler.pbRecoverHP(battler.totalhp/16) + battler.pbRecoverHP(battler.totalhp / 16) if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1}'s {2} restored its HP.",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", battler.pbThis, battler.abilityName)) end battle.pbHideAbilitySplash(battler) } ) Battle::AbilityEffects::EndOfRoundWeather.add(:SOLARPOWER, - proc { |ability,weather,battler,battle| + proc { |ability, weather, battler, battle| next unless [:Sun, :HarshSun].include?(weather) battle.pbShowAbilitySplash(battler) battle.scene.pbDamageAnimation(battler) - battler.pbReduceHP(battler.totalhp/8,false) - battle.pbDisplay(_INTL("{1} was hurt by the sunlight!",battler.pbThis)) + battler.pbReduceHP(battler.totalhp / 8, false) + battle.pbDisplay(_INTL("{1} was hurt by the sunlight!", battler.pbThis)) battle.pbHideAbilitySplash(battler) battler.pbItemHPHealCheck } @@ -2335,8 +2335,8 @@ Battle::AbilityEffects::EndOfRoundWeather.add(:SOLARPOWER, #=============================================================================== Battle::AbilityEffects::EndOfRoundHealing.add(:HEALER, - proc { |ability,battler,battle| - next unless battle.pbRandom(100)<30 + proc { |ability, battler, battle| + next unless battle.pbRandom(100) < 30 battler.allAllies.each do |b| next if b.status == :NONE battle.pbShowAbilitySplash(battler) @@ -2345,15 +2345,15 @@ Battle::AbilityEffects::EndOfRoundHealing.add(:HEALER, if !Battle::Scene::USE_ABILITY_SPLASH case oldStatus when :SLEEP - battle.pbDisplay(_INTL("{1}'s {2} woke its partner up!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} woke its partner up!", battler.pbThis, battler.abilityName)) when :POISON - battle.pbDisplay(_INTL("{1}'s {2} cured its partner's poison!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its partner's poison!", battler.pbThis, battler.abilityName)) when :BURN - battle.pbDisplay(_INTL("{1}'s {2} healed its partner's burn!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} healed its partner's burn!", battler.pbThis, battler.abilityName)) when :PARALYSIS - battle.pbDisplay(_INTL("{1}'s {2} cured its partner's paralysis!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its partner's paralysis!", battler.pbThis, battler.abilityName)) when :FROZEN - battle.pbDisplay(_INTL("{1}'s {2} defrosted its partner!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} defrosted its partner!", battler.pbThis, battler.abilityName)) end end battle.pbHideAbilitySplash(battler) @@ -2362,7 +2362,7 @@ Battle::AbilityEffects::EndOfRoundHealing.add(:HEALER, ) Battle::AbilityEffects::EndOfRoundHealing.add(:HYDRATION, - proc { |ability,battler,battle| + proc { |ability, battler, battle| next if battler.status == :NONE next if ![:Rain, :HeavyRain].include?(battler.effectiveWeather) battle.pbShowAbilitySplash(battler) @@ -2371,15 +2371,15 @@ Battle::AbilityEffects::EndOfRoundHealing.add(:HYDRATION, if !Battle::Scene::USE_ABILITY_SPLASH case oldStatus when :SLEEP - battle.pbDisplay(_INTL("{1}'s {2} woke it up!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} woke it up!", battler.pbThis, battler.abilityName)) when :POISON - battle.pbDisplay(_INTL("{1}'s {2} cured its poison!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its poison!", battler.pbThis, battler.abilityName)) when :BURN - battle.pbDisplay(_INTL("{1}'s {2} healed its burn!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} healed its burn!", battler.pbThis, battler.abilityName)) when :PARALYSIS - battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!", battler.pbThis, battler.abilityName)) when :FROZEN - battle.pbDisplay(_INTL("{1}'s {2} defrosted it!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} defrosted it!", battler.pbThis, battler.abilityName)) end end battle.pbHideAbilitySplash(battler) @@ -2387,24 +2387,24 @@ Battle::AbilityEffects::EndOfRoundHealing.add(:HYDRATION, ) Battle::AbilityEffects::EndOfRoundHealing.add(:SHEDSKIN, - proc { |ability,battler,battle| + proc { |ability, battler, battle| next if battler.status == :NONE - next unless battle.pbRandom(100)<30 + next unless battle.pbRandom(100) < 30 battle.pbShowAbilitySplash(battler) oldStatus = battler.status battler.pbCureStatus(Battle::Scene::USE_ABILITY_SPLASH) if !Battle::Scene::USE_ABILITY_SPLASH case oldStatus when :SLEEP - battle.pbDisplay(_INTL("{1}'s {2} woke it up!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} woke it up!", battler.pbThis, battler.abilityName)) when :POISON - battle.pbDisplay(_INTL("{1}'s {2} cured its poison!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its poison!", battler.pbThis, battler.abilityName)) when :BURN - battle.pbDisplay(_INTL("{1}'s {2} healed its burn!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} healed its burn!", battler.pbThis, battler.abilityName)) when :PARALYSIS - battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!", battler.pbThis, battler.abilityName)) when :FROZEN - battle.pbDisplay(_INTL("{1}'s {2} defrosted it!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} defrosted it!", battler.pbThis, battler.abilityName)) end end battle.pbHideAbilitySplash(battler) @@ -2416,7 +2416,7 @@ Battle::AbilityEffects::EndOfRoundHealing.add(:SHEDSKIN, #=============================================================================== Battle::AbilityEffects::EndOfRoundEffect.add(:BADDREAMS, - proc { |ability,battler,battle| + proc { |ability, battler, battle| battle.allOtherSideBattlers(battler.index).each do |b| next if !b.near?(battler) || !b.asleep? battle.pbShowAbilitySplash(battler) @@ -2435,7 +2435,7 @@ Battle::AbilityEffects::EndOfRoundEffect.add(:BADDREAMS, ) Battle::AbilityEffects::EndOfRoundEffect.add(:MOODY, - proc { |ability,battler,battle| + proc { |ability, battler, battle| randomUp = [] randomDown = [] if Settings::MECHANICS_GENERATION >= 8 @@ -2449,30 +2449,30 @@ Battle::AbilityEffects::EndOfRoundEffect.add(:MOODY, randomDown.push(s.id) if battler.pbCanLowerStatStage?(s.id, battler) end end - next if randomUp.length==0 && randomDown.length==0 + next if randomUp.length == 0 && randomDown.length == 0 battle.pbShowAbilitySplash(battler) - if randomUp.length>0 + if randomUp.length > 0 r = battle.pbRandom(randomUp.length) - battler.pbRaiseStatStageByAbility(randomUp[r],2,battler,false) + battler.pbRaiseStatStageByAbility(randomUp[r], 2, battler, false) randomDown.delete(randomUp[r]) end - if randomDown.length>0 + if randomDown.length > 0 r = battle.pbRandom(randomDown.length) - battler.pbLowerStatStageByAbility(randomDown[r],1,battler,false) + battler.pbLowerStatStageByAbility(randomDown[r], 1, battler, false) end battle.pbHideAbilitySplash(battler) - battler.pbItemStatRestoreCheck if randomDown.length>0 + battler.pbItemStatRestoreCheck if randomDown.length > 0 battler.pbItemOnStatDropped } ) Battle::AbilityEffects::EndOfRoundEffect.add(:SPEEDBOOST, - proc { |ability,battler,battle| + proc { |ability, battler, battle| # A Pokémon's turnCount is 0 if it became active after the beginning of a # round if battler.turnCount > 0 && battle.choices[battler.index][0] != :Run && battler.pbCanRaiseStatStage?(:SPEED, battler) - battler.pbRaiseStatStageByAbility(:SPEED,1,battler) + battler.pbRaiseStatStageByAbility(:SPEED, 1, battler) end } ) @@ -2496,31 +2496,31 @@ Battle::AbilityEffects::EndOfRoundGainItem.add(:BALLFETCH, ) Battle::AbilityEffects::EndOfRoundGainItem.add(:HARVEST, - proc { |ability,battler,battle| + proc { |ability, battler, battle| next if battler.item next if !battler.recycleItem || !GameData::Item.get(battler.recycleItem).is_berry? if ![:Sun, :HarshSun].include?(battler.effectiveWeather) - next unless battle.pbRandom(100)<50 + next unless battle.pbRandom(100) < 50 end battle.pbShowAbilitySplash(battler) battler.item = battler.recycleItem battler.setRecycleItem(nil) battler.setInitialItem(battler.item) if !battler.initialItem - battle.pbDisplay(_INTL("{1} harvested one {2}!",battler.pbThis,battler.itemName)) + battle.pbDisplay(_INTL("{1} harvested one {2}!", battler.pbThis, battler.itemName)) battle.pbHideAbilitySplash(battler) battler.pbHeldItemTriggerCheck } ) Battle::AbilityEffects::EndOfRoundGainItem.add(:PICKUP, - proc { |ability,battler,battle| + proc { |ability, battler, battle| next if battler.item foundItem = nil fromBattler = nil use = 0 battle.allBattlers.each do |b| - next if b.index==battler.index - next if b.effects[PBEffects::PickupUse]<=use + next if b.index == battler.index + next if b.effects[PBEffects::PickupUse] <= use foundItem = b.effects[PBEffects::PickupItem] fromBattler = b use = b.effects[PBEffects::PickupUse] @@ -2530,12 +2530,12 @@ Battle::AbilityEffects::EndOfRoundGainItem.add(:PICKUP, battler.item = foundItem fromBattler.effects[PBEffects::PickupItem] = nil fromBattler.effects[PBEffects::PickupUse] = 0 - fromBattler.setRecycleItem(nil) if fromBattler.recycleItem==foundItem - if battle.wildBattle? && !battler.initialItem && fromBattler.initialItem==foundItem + fromBattler.setRecycleItem(nil) if fromBattler.recycleItem == foundItem + if battle.wildBattle? && !battler.initialItem && fromBattler.initialItem == foundItem battler.setInitialItem(foundItem) fromBattler.setInitialItem(nil) end - battle.pbDisplay(_INTL("{1} found one {2}!",battler.pbThis,battler.itemName)) + battle.pbDisplay(_INTL("{1} found one {2}!", battler.pbThis, battler.itemName)) battle.pbHideAbilitySplash(battler) battler.pbHeldItemTriggerCheck } @@ -2552,19 +2552,19 @@ Battle::AbilityEffects::EndOfRoundGainItem.add(:PICKUP, #=============================================================================== Battle::AbilityEffects::TrappingByTarget.add(:ARENATRAP, - proc { |ability,switcher,bearer,battle| + proc { |ability, switcher, bearer, battle| next true if !switcher.airborne? } ) Battle::AbilityEffects::TrappingByTarget.add(:MAGNETPULL, - proc { |ability,switcher,bearer,battle| + proc { |ability, switcher, bearer, battle| next true if switcher.pbHasType?(:STEEL) } ) Battle::AbilityEffects::TrappingByTarget.add(:SHADOWTAG, - proc { |ability,switcher,bearer,battle| + proc { |ability, switcher, bearer, battle| next true if !switcher.hasActiveAbility?(:SHADOWTAG) } ) @@ -2577,7 +2577,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:AIRLOCK, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) if !Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} has {2}!",battler.pbThis,battler.abilityName)) + battle.pbDisplay(_INTL("{1} has {2}!", battler.pbThis, battler.abilityName)) end battle.pbDisplay(_INTL("The effects of the weather disappeared.")) battle.pbHideAbilitySplash(battler) @@ -2614,7 +2614,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:ANTICIPATION, end if found battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} shuddered with anticipation!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} shuddered with anticipation!", battler.pbThis)) battle.pbHideAbilitySplash(battler) end } @@ -2638,7 +2638,7 @@ Battle::AbilityEffects::OnSwitchIn.copy(:ASONECHILLINGNEIGH, :ASONEGRIMNEIGH) Battle::AbilityEffects::OnSwitchIn.add(:AURABREAK, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} reversed all other Pokémon's auras!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} reversed all other Pokémon's auras!", battler.pbThis)) battle.pbHideAbilitySplash(battler) } ) @@ -2646,7 +2646,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:AURABREAK, Battle::AbilityEffects::OnSwitchIn.add(:COMATOSE, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} is drowsing!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} is drowsing!", battler.pbThis)) battle.pbHideAbilitySplash(battler) } ) @@ -2672,7 +2672,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:CURIOUSMEDICINE, Battle::AbilityEffects::OnSwitchIn.add(:DARKAURA, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} is radiating a dark aura!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} is radiating a dark aura!", battler.pbThis)) battle.pbHideAbilitySplash(battler) } ) @@ -2702,8 +2702,8 @@ Battle::AbilityEffects::OnSwitchIn.add(:DOWNLOAD, oDef += b.defense oSpDef += b.spdef end - stat = (oDefhighestPower + next if power < highestPower + forewarnMoves = [] if power > highestPower forewarnMoves.push(m.name) highestPower = power end end - if forewarnMoves.length>0 + if forewarnMoves.length > 0 battle.pbShowAbilitySplash(battler) forewarnMoveName = forewarnMoves[battle.pbRandom(forewarnMoves.length)] if Battle::Scene::USE_ABILITY_SPLASH @@ -2792,17 +2792,17 @@ Battle::AbilityEffects::OnSwitchIn.add(:FRISK, proc { |ability, battler, battle, switch_in| next if !battler.pbOwnedByPlayer? foes = battle.allOtherSideBattlers(battler.index).select { |b| b.item } - if foes.length>0 + if foes.length > 0 battle.pbShowAbilitySplash(battler) if Settings::MECHANICS_GENERATION >= 6 foes.each do |b| battle.pbDisplay(_INTL("{1} frisked {2} and found its {3}!", - battler.pbThis,b.pbThis(true),b.itemName)) + battler.pbThis, b.pbThis(true), b.itemName)) end else foe = foes[battle.pbRandom(foes.length)] battle.pbDisplay(_INTL("{1} frisked the foe and found one {2}!", - battler.pbThis,foe.itemName)) + battler.pbThis, foe.itemName)) end battle.pbHideAbilitySplash(battler) end @@ -2838,13 +2838,13 @@ Battle::AbilityEffects::OnSwitchIn.add(:IMPOSTER, next if choice.fainted? next if choice.effects[PBEffects::Transform] || choice.effects[PBEffects::Illusion] || - choice.effects[PBEffects::Substitute]>0 || - choice.effects[PBEffects::SkyDrop]>=0 || + choice.effects[PBEffects::Substitute] > 0 || + choice.effects[PBEffects::SkyDrop] >= 0 || choice.semiInvulnerable? - battle.pbShowAbilitySplash(battler,true) + battle.pbShowAbilitySplash(battler, true) battle.pbHideAbilitySplash(battler) - battle.pbAnimation(:TRANSFORM,battler,choice) - battle.scene.pbChangePokemon(battler,choice.pokemon) + battle.pbAnimation(:TRANSFORM, battler, choice) + battle.scene.pbChangePokemon(battler, choice.pokemon) battler.pbTransform(choice) } ) @@ -2893,7 +2893,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:MISTYSURGE, Battle::AbilityEffects::OnSwitchIn.add(:MOLDBREAKER, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} breaks the mold!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} breaks the mold!", battler.pbThis)) battle.pbHideAbilitySplash(battler) } ) @@ -2951,7 +2951,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:PASTELVEIL, Battle::AbilityEffects::OnSwitchIn.add(:PRESSURE, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} is exerting its pressure!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} is exerting its pressure!", battler.pbThis)) battle.pbHideAbilitySplash(battler) } ) @@ -3019,10 +3019,10 @@ Battle::AbilityEffects::OnSwitchIn.add(:SLOWSTART, battle.pbShowAbilitySplash(battler) battler.effects[PBEffects::SlowStart] = 5 if Battle::Scene::USE_ABILITY_SPLASH - battle.pbDisplay(_INTL("{1} can't get it going!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} can't get it going!", battler.pbThis)) else battle.pbDisplay(_INTL("{1} can't get it going because of its {2}!", - battler.pbThis,battler.abilityName)) + battler.pbThis, battler.abilityName)) end battle.pbHideAbilitySplash(battler) } @@ -3037,7 +3037,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:SNOWWARNING, Battle::AbilityEffects::OnSwitchIn.add(:TERAVOLT, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} is radiating a bursting aura!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} is radiating a bursting aura!", battler.pbThis)) battle.pbHideAbilitySplash(battler) } ) @@ -3045,7 +3045,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:TERAVOLT, Battle::AbilityEffects::OnSwitchIn.add(:TURBOBLAZE, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} is radiating a blazing aura!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} is radiating a blazing aura!", battler.pbThis)) battle.pbHideAbilitySplash(battler) } ) @@ -3053,7 +3053,7 @@ Battle::AbilityEffects::OnSwitchIn.add(:TURBOBLAZE, Battle::AbilityEffects::OnSwitchIn.add(:UNNERVE, proc { |ability, battler, battle, switch_in| battle.pbShowAbilitySplash(battler) - battle.pbDisplay(_INTL("{1} is too nervous to eat Berries!",battler.pbOpposingTeam)) + battle.pbDisplay(_INTL("{1} is too nervous to eat Berries!", battler.pbOpposingTeam)) battle.pbHideAbilitySplash(battler) } ) @@ -3097,17 +3097,17 @@ Battle::AbilityEffects::OnSwitchOut.add(:MAGMAARMOR, ) Battle::AbilityEffects::OnSwitchOut.add(:NATURALCURE, - proc { |ability,battler,endOfBattle| + proc { |ability, battler, endOfBattle| PBDebug.log("[Ability triggered] #{battler.pbThis}'s #{battler.abilityName}") battler.status = :NONE } ) Battle::AbilityEffects::OnSwitchOut.add(:REGENERATOR, - proc { |ability,battler,endOfBattle| + proc { |ability, battler, endOfBattle| next if endOfBattle PBDebug.log("[Ability triggered] #{battler.pbThis}'s #{battler.abilityName}") - battler.pbRecoverHP(battler.totalhp/3,false,false) + battler.pbRecoverHP(battler.totalhp / 3, false, false) } ) @@ -3126,14 +3126,14 @@ Battle::AbilityEffects::OnSwitchOut.copy(:WATERVEIL, :WATERBUBBLE) #=============================================================================== Battle::AbilityEffects::ChangeOnBattlerFainting.add(:POWEROFALCHEMY, - proc { |ability,battler,fainted,battle| + proc { |ability, battler, fainted, battle| next if battler.opposes?(fainted) next if fainted.ungainableAbility? || [:POWEROFALCHEMY, :RECEIVER, :TRACE, :WONDERGUARD].include?(fainted.ability_id) - battle.pbShowAbilitySplash(battler,true) + battle.pbShowAbilitySplash(battler, true) battler.ability = fainted.ability battle.pbReplaceAbilitySplash(battler) - battle.pbDisplay(_INTL("{1}'s {2} was taken over!",fainted.pbThis,fainted.abilityName)) + battle.pbDisplay(_INTL("{1}'s {2} was taken over!", fainted.pbThis, fainted.abilityName)) battle.pbHideAbilitySplash(battler) } ) @@ -3145,8 +3145,8 @@ Battle::AbilityEffects::ChangeOnBattlerFainting.copy(:POWEROFALCHEMY, :RECEIVER) #=============================================================================== Battle::AbilityEffects::OnBattlerFainting.add(:SOULHEART, - proc { |ability,battler,fainted,battle| - battler.pbRaiseStatStageByAbility(:SPECIAL_ATTACK,1,battler) + proc { |ability, battler, fainted, battle| + battler.pbRaiseStatStageByAbility(:SPECIAL_ATTACK, 1, battler) } ) @@ -3192,7 +3192,7 @@ Battle::AbilityEffects::OnTerrainChange.add(:MIMICRY, #=============================================================================== Battle::AbilityEffects::OnIntimidated.add(:RATTLED, - proc { |ability,battler,battle| + proc { |ability, battler, battle| next if Settings::MECHANICS_GENERATION < 8 battler.pbRaiseStatStageByAbility(:SPEED, 1, battler) } @@ -3203,7 +3203,7 @@ Battle::AbilityEffects::OnIntimidated.add(:RATTLED, #=============================================================================== Battle::AbilityEffects::CertainEscapeFromBattle.add(:RUNAWAY, - proc { |ability,battler| + proc { |ability, battler| next true } ) diff --git a/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb b/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb index ef5732f63..3e156973f 100644 --- a/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb +++ b/Data/Scripts/011_Battle/006_Other battle code/009_Battle_ItemEffects.rb @@ -219,14 +219,14 @@ end #=============================================================================== Battle::ItemEffects::SpeedCalc.add(:CHOICESCARF, - proc { |item,battler,mult| - next mult*1.5 + proc { |item, battler, mult| + next mult * 1.5 } ) Battle::ItemEffects::SpeedCalc.add(:MACHOBRACE, - proc { |item,battler,mult| - next mult/2 + proc { |item, battler, mult| + next mult / 2 } ) @@ -235,15 +235,15 @@ Battle::ItemEffects::SpeedCalc.copy(:MACHOBRACE, :POWERANKLET, :POWERBAND, :POWERLENS, :POWERWEIGHT) Battle::ItemEffects::SpeedCalc.add(:QUICKPOWDER, - proc { |item,battler,mult| - next mult*2 if battler.isSpecies?(:DITTO) && + proc { |item, battler, mult| + next mult * 2 if battler.isSpecies?(:DITTO) && !battler.effects[PBEffects::Transform] } ) Battle::ItemEffects::SpeedCalc.add(:IRONBALL, - proc { |item,battler,mult| - next mult/2 + proc { |item, battler, mult| + next mult / 2 } ) @@ -252,8 +252,8 @@ Battle::ItemEffects::SpeedCalc.add(:IRONBALL, #=============================================================================== Battle::ItemEffects::WeightCalc.add(:FLOATSTONE, - proc { |item,battler,w| - next [w/2,1].max + proc { |item, battler, w| + next [w / 2, 1].max } ) @@ -262,7 +262,7 @@ Battle::ItemEffects::WeightCalc.add(:FLOATSTONE, #=============================================================================== Battle::ItemEffects::HPHeal.add(:AGUAVBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbConfusionBerry(item, forced, 4, _INTL("For {1}, the {2} was too bitter!", battler.pbThis(true), GameData::Item.get(item).name) ) @@ -270,30 +270,30 @@ Battle::ItemEffects::HPHeal.add(:AGUAVBERRY, ) Battle::ItemEffects::HPHeal.add(:APICOTBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbStatIncreasingBerry(item, forced, :SPECIAL_DEFENSE) } ) Battle::ItemEffects::HPHeal.add(:BERRYJUICE, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !battler.canHeal? - next false if !forced && battler.hp>battler.totalhp/2 + next false if !forced && battler.hp > battler.totalhp / 2 itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] Forced consuming of #{itemName}") if forced - battle.pbCommonAnimation("UseItem",battler) if !forced + battle.pbCommonAnimation("UseItem", battler) if !forced battler.pbRecoverHP(20) if forced - battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1} restored its health using its {2}!", battler.pbThis, itemName)) end next true } ) Battle::ItemEffects::HPHeal.add(:FIGYBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbConfusionBerry(item, forced, 0, _INTL("For {1}, the {2} was too spicy!", battler.pbThis(true), GameData::Item.get(item).name) ) @@ -301,13 +301,13 @@ Battle::ItemEffects::HPHeal.add(:FIGYBERRY, ) Battle::ItemEffects::HPHeal.add(:GANLONBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbStatIncreasingBerry(item, forced, :DEFENSE) } ) Battle::ItemEffects::HPHeal.add(:IAPAPABERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbConfusionBerry(item, forced, 1, _INTL("For {1}, the {2} was too sour!", battler.pbThis(true), GameData::Item.get(item).name) ) @@ -315,29 +315,29 @@ Battle::ItemEffects::HPHeal.add(:IAPAPABERRY, ) Battle::ItemEffects::HPHeal.add(:LANSATBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumePinchBerry? - next false if battler.effects[PBEffects::FocusEnergy]>=2 - battle.pbCommonAnimation("EatBerry",battler) if !forced + next false if battler.effects[PBEffects::FocusEnergy] >= 2 + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.effects[PBEffects::FocusEnergy] = 2 itemName = GameData::Item.get(item).name if forced - battle.pbDisplay(_INTL("{1} got pumped from the {2}!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1} got pumped from the {2}!", battler.pbThis, itemName)) else - battle.pbDisplay(_INTL("{1} used its {2} to get pumped!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1} used its {2} to get pumped!", battler.pbThis, itemName)) end next true } ) Battle::ItemEffects::HPHeal.add(:LIECHIBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbStatIncreasingBerry(item, forced, :ATTACK) } ) Battle::ItemEffects::HPHeal.add(:MAGOBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbConfusionBerry(item, forced, 2, _INTL("For {1}, the {2} was too sweet!", battler.pbThis(true), GameData::Item.get(item).name) ) @@ -345,25 +345,25 @@ Battle::ItemEffects::HPHeal.add(:MAGOBERRY, ) Battle::ItemEffects::HPHeal.add(:MICLEBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumePinchBerry? next false if !battler.effects[PBEffects::MicleBerry] - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.effects[PBEffects::MicleBerry] = true itemName = GameData::Item.get(item).name if forced PBDebug.log("[Item triggered] Forced consuming of #{itemName}") - battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move!",battler.pbThis)) + battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move!", battler.pbThis)) else battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move using its {2}!", - battler.pbThis,itemName)) + battler.pbThis, itemName)) end next true } ) Battle::ItemEffects::HPHeal.add(:ORANBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !battler.canHeal? next false if !forced && !battler.canConsumePinchBerry?(false) amt = 10 @@ -373,34 +373,34 @@ Battle::ItemEffects::HPHeal.add(:ORANBERRY, amt *= 2 ripening = true end - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battle.pbHideAbilitySplash(battler) if ripening battler.pbRecoverHP(amt) itemName = GameData::Item.get(item).name if forced PBDebug.log("[Item triggered] Forced consuming of #{itemName}") - battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!", battler.pbThis, itemName)) end next true } ) Battle::ItemEffects::HPHeal.add(:PETAYABERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbStatIncreasingBerry(item, forced, :SPECIAL_ATTACK) } ) Battle::ItemEffects::HPHeal.add(:SALACBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbStatIncreasingBerry(item, forced, :SPEED) } ) Battle::ItemEffects::HPHeal.add(:SITRUSBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !battler.canHeal? next false if !forced && !battler.canConsumePinchBerry?(false) amt = battler.totalhp / 4 @@ -410,32 +410,32 @@ Battle::ItemEffects::HPHeal.add(:SITRUSBERRY, amt *= 2 ripening = true end - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battle.pbHideAbilitySplash(battler) if ripening battler.pbRecoverHP(amt) itemName = GameData::Item.get(item).name if forced PBDebug.log("[Item triggered] Forced consuming of #{itemName}") - battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1} restored its health using its {2}!", battler.pbThis, itemName)) end next true } ) Battle::ItemEffects::HPHeal.add(:STARFBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| stats = [] GameData::Stat.each_main_battle { |s| stats.push(s.id) if battler.pbCanRaiseStatStage?(s.id, battler) } - next false if stats.length==0 + next false if stats.length == 0 stat = stats[battle.pbRandom(stats.length)] next battler.pbStatIncreasingBerry(item, forced, stat, 2) } ) Battle::ItemEffects::HPHeal.add(:WIKIBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next battler.pbConfusionBerry(item, forced, 3, _INTL("For {1}, the {2} was too dry!", battler.pbThis(true), GameData::Item.get(item).name) ) @@ -476,73 +476,73 @@ Battle::ItemEffects::OnStatLoss.add(:EJECTPACK, #=============================================================================== Battle::ItemEffects::StatusCure.add(:ASPEARBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? next false if battler.status != :FROZEN itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.pbCureStatus(forced) - battle.pbDisplay(_INTL("{1}'s {2} defrosted it!",battler.pbThis,itemName)) if !forced + battle.pbDisplay(_INTL("{1}'s {2} defrosted it!", battler.pbThis, itemName)) if !forced next true } ) Battle::ItemEffects::StatusCure.add(:CHERIBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? next false if battler.status != :PARALYSIS itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.pbCureStatus(forced) - battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!",battler.pbThis,itemName)) if !forced + battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!", battler.pbThis, itemName)) if !forced next true } ) Battle::ItemEffects::StatusCure.add(:CHESTOBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? next false if battler.status != :SLEEP itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.pbCureStatus(forced) - battle.pbDisplay(_INTL("{1}'s {2} woke it up!",battler.pbThis,itemName)) if !forced + battle.pbDisplay(_INTL("{1}'s {2} woke it up!", battler.pbThis, itemName)) if !forced next true } ) Battle::ItemEffects::StatusCure.add(:LUMBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? next false if battler.status == :NONE && - battler.effects[PBEffects::Confusion]==0 + battler.effects[PBEffects::Confusion] == 0 itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced oldStatus = battler.status - oldConfusion = (battler.effects[PBEffects::Confusion]>0) + oldConfusion = (battler.effects[PBEffects::Confusion] > 0) battler.pbCureStatus(forced) battler.pbCureConfusion if forced - battle.pbDisplay(_INTL("{1} snapped out of its confusion.",battler.pbThis)) if oldConfusion + battle.pbDisplay(_INTL("{1} snapped out of its confusion.", battler.pbThis)) if oldConfusion else case oldStatus when :SLEEP - battle.pbDisplay(_INTL("{1}'s {2} woke it up!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1}'s {2} woke it up!", battler.pbThis, itemName)) when :POISON - battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning!", battler.pbThis, itemName)) when :BURN - battle.pbDisplay(_INTL("{1}'s {2} healed its burn!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1}'s {2} healed its burn!", battler.pbThis, itemName)) when :PARALYSIS - battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1}'s {2} cured its paralysis!", battler.pbThis, itemName)) when :FROZEN - battle.pbDisplay(_INTL("{1}'s {2} defrosted it!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1}'s {2} defrosted it!", battler.pbThis, itemName)) end if oldConfusion - battle.pbDisplay(_INTL("{1}'s {2} snapped it out of its confusion!",battler.pbThis,itemName)) + battle.pbDisplay(_INTL("{1}'s {2} snapped it out of its confusion!", battler.pbThis, itemName)) end end next true @@ -550,65 +550,65 @@ Battle::ItemEffects::StatusCure.add(:LUMBERRY, ) Battle::ItemEffects::StatusCure.add(:MENTALHERB, - proc { |item,battler,battle,forced| - next false if battler.effects[PBEffects::Attract]==-1 && - battler.effects[PBEffects::Taunt]==0 && - battler.effects[PBEffects::Encore]==0 && + proc { |item, battler, battle, forced| + next false if battler.effects[PBEffects::Attract] == -1 && + battler.effects[PBEffects::Taunt] == 0 && + battler.effects[PBEffects::Encore] == 0 && !battler.effects[PBEffects::Torment] && - battler.effects[PBEffects::Disable]==0 && - battler.effects[PBEffects::HealBlock]==0 + battler.effects[PBEffects::Disable] == 0 && + battler.effects[PBEffects::HealBlock] == 0 itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") - battle.pbCommonAnimation("UseItem",battler) if !forced - if battler.effects[PBEffects::Attract]>=0 + battle.pbCommonAnimation("UseItem", battler) if !forced + if battler.effects[PBEffects::Attract] >= 0 if forced - battle.pbDisplay(_INTL("{1} got over its infatuation.",battler.pbThis)) + battle.pbDisplay(_INTL("{1} got over its infatuation.", battler.pbThis)) else battle.pbDisplay(_INTL("{1} cured its infatuation status using its {2}!", - battler.pbThis,itemName)) + battler.pbThis, itemName)) end battler.pbCureAttract end - battle.pbDisplay(_INTL("{1}'s taunt wore off!",battler.pbThis)) if battler.effects[PBEffects::Taunt]>0 - battler.effects[PBEffects::Taunt] = 0 - battle.pbDisplay(_INTL("{1}'s encore ended!",battler.pbThis)) if battler.effects[PBEffects::Encore]>0 + battle.pbDisplay(_INTL("{1}'s taunt wore off!", battler.pbThis)) if battler.effects[PBEffects::Taunt] > 0 + battler.effects[PBEffects::Taunt] = 0 + battle.pbDisplay(_INTL("{1}'s encore ended!", battler.pbThis)) if battler.effects[PBEffects::Encore] > 0 battler.effects[PBEffects::Encore] = 0 battler.effects[PBEffects::EncoreMove] = nil - battle.pbDisplay(_INTL("{1}'s torment wore off!",battler.pbThis)) if battler.effects[PBEffects::Torment] - battler.effects[PBEffects::Torment] = false - battle.pbDisplay(_INTL("{1} is no longer disabled!",battler.pbThis)) if battler.effects[PBEffects::Disable]>0 - battler.effects[PBEffects::Disable] = 0 - battle.pbDisplay(_INTL("{1}'s Heal Block wore off!",battler.pbThis)) if battler.effects[PBEffects::HealBlock]>0 - battler.effects[PBEffects::HealBlock] = 0 + battle.pbDisplay(_INTL("{1}'s torment wore off!", battler.pbThis)) if battler.effects[PBEffects::Torment] + battler.effects[PBEffects::Torment] = false + battle.pbDisplay(_INTL("{1} is no longer disabled!", battler.pbThis)) if battler.effects[PBEffects::Disable] > 0 + battler.effects[PBEffects::Disable] = 0 + battle.pbDisplay(_INTL("{1}'s Heal Block wore off!", battler.pbThis)) if battler.effects[PBEffects::HealBlock] > 0 + battler.effects[PBEffects::HealBlock] = 0 next true } ) Battle::ItemEffects::StatusCure.add(:PECHABERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? next false if battler.status != :POISON itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.pbCureStatus(forced) - battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning!",battler.pbThis,itemName)) if !forced + battle.pbDisplay(_INTL("{1}'s {2} cured its poisoning!", battler.pbThis, itemName)) if !forced next true } ) Battle::ItemEffects::StatusCure.add(:PERSIMBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? - next false if battler.effects[PBEffects::Confusion]==0 + next false if battler.effects[PBEffects::Confusion] == 0 itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.pbCureConfusion if forced - battle.pbDisplay(_INTL("{1} snapped out of its confusion.",battler.pbThis)) + battle.pbDisplay(_INTL("{1} snapped out of its confusion.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1}'s {2} snapped it out of its confusion!",battler.pbThis, + battle.pbDisplay(_INTL("{1}'s {2} snapped it out of its confusion!", battler.pbThis, itemName)) end next true @@ -616,14 +616,14 @@ Battle::ItemEffects::StatusCure.add(:PERSIMBERRY, ) Battle::ItemEffects::StatusCure.add(:RAWSTBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? next false if battler.status != :BURN itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battler.pbCureStatus(forced) - battle.pbDisplay(_INTL("{1}'s {2} healed its burn!",battler.pbThis,itemName)) if !forced + battle.pbDisplay(_INTL("{1}'s {2} healed its burn!", battler.pbThis, itemName)) if !forced next true } ) @@ -633,23 +633,23 @@ Battle::ItemEffects::StatusCure.add(:RAWSTBERRY, #=============================================================================== Battle::ItemEffects::PriorityBracketChange.add(:CUSTAPBERRY, - proc { |item,battler,subPri,battle| + proc { |item, battler, subPri, battle| next if !battler.canConsumePinchBerry? - next 1 if subPri<1 + next 1 if subPri < 1 } ) Battle::ItemEffects::PriorityBracketChange.add(:LAGGINGTAIL, - proc { |item,battler,subPri,battle| - next -1 if subPri==0 + proc { |item, battler, subPri, battle| + next -1 if subPri == 0 } ) Battle::ItemEffects::PriorityBracketChange.copy(:LAGGINGTAIL, :FULLINCENSE) Battle::ItemEffects::PriorityBracketChange.add(:QUICKCLAW, - proc { |item,battler,subPri,battle| - next 1 if subPri<1 && battle.pbRandom(100)<20 + proc { |item, battler, subPri, battle| + next 1 if subPri < 1 && battle.pbRandom(100) < 20 } ) @@ -658,17 +658,17 @@ Battle::ItemEffects::PriorityBracketChange.add(:QUICKCLAW, #=============================================================================== Battle::ItemEffects::PriorityBracketUse.add(:CUSTAPBERRY, - proc { |item,battler,battle| - battle.pbCommonAnimation("EatBerry",battler) - battle.pbDisplay(_INTL("{1}'s {2} let it move first!",battler.pbThis,battler.itemName)) + proc { |item, battler, battle| + battle.pbCommonAnimation("EatBerry", battler) + battle.pbDisplay(_INTL("{1}'s {2} let it move first!", battler.pbThis, battler.itemName)) battler.pbConsumeItem } ) Battle::ItemEffects::PriorityBracketUse.add(:QUICKCLAW, - proc { |item,battler,battle| - battle.pbCommonAnimation("UseItem",battler) - battle.pbDisplay(_INTL("{1}'s {2} let it move first!",battler.pbThis,battler.itemName)) + proc { |item, battler, battle| + battle.pbCommonAnimation("UseItem", battler) + battle.pbDisplay(_INTL("{1}'s {2} let it move first!", battler.pbThis, battler.itemName)) } ) @@ -693,15 +693,15 @@ Battle::ItemEffects::OnMissingTarget.add(:BLUNDERPOLICY, #=============================================================================== Battle::ItemEffects::AccuracyCalcFromUser.add(:WIDELENS, - proc { |item,mods,user,target,move,type| + proc { |item, mods, user, target, move, type| mods[:accuracy_multiplier] *= 1.1 } ) Battle::ItemEffects::AccuracyCalcFromUser.add(:ZOOMLENS, - proc { |item,mods,user,target,move,type| - if (target.battle.choices[target.index][0]!=:UseMove && - target.battle.choices[target.index][0]!=:Shift) || + proc { |item, mods, user, target, move, type| + if (target.battle.choices[target.index][0] != :UseMove && + target.battle.choices[target.index][0] != :Shift) || target.movedThisRound? mods[:accuracy_multiplier] *= 1.2 end @@ -713,7 +713,7 @@ Battle::ItemEffects::AccuracyCalcFromUser.add(:ZOOMLENS, #=============================================================================== Battle::ItemEffects::AccuracyCalcFromTarget.add(:BRIGHTPOWDER, - proc { |item,mods,user,target,move,type| + proc { |item, mods, user, target, move, type| mods[:accuracy_multiplier] *= 0.9 } ) @@ -725,7 +725,7 @@ Battle::ItemEffects::AccuracyCalcFromTarget.copy(:BRIGHTPOWDER, :LAXINCENSE) #=============================================================================== Battle::ItemEffects::DamageCalcFromUser.add(:ADAMANTORB, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if user.isSpecies?(:DIALGA) && (type == :DRAGON || type == :STEEL) mults[:base_damage_multiplier] *= 1.2 end @@ -733,7 +733,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:ADAMANTORB, ) Battle::ItemEffects::DamageCalcFromUser.add(:BLACKBELT, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :FIGHTING } ) @@ -741,7 +741,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:BLACKBELT, Battle::ItemEffects::DamageCalcFromUser.copy(:BLACKBELT, :FISTPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:BLACKGLASSES, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :DARK } ) @@ -749,13 +749,13 @@ Battle::ItemEffects::DamageCalcFromUser.add(:BLACKGLASSES, Battle::ItemEffects::DamageCalcFromUser.copy(:BLACKGLASSES, :DREADPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:BUGGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:BUG, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:CHARCOAL, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :FIRE } ) @@ -763,25 +763,25 @@ Battle::ItemEffects::DamageCalcFromUser.add(:CHARCOAL, Battle::ItemEffects::DamageCalcFromUser.copy(:CHARCOAL, :FLAMEPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:CHOICEBAND, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.5 if move.physicalMove? } ) Battle::ItemEffects::DamageCalcFromUser.add(:CHOICESPECS, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.5 if move.specialMove? } ) Battle::ItemEffects::DamageCalcFromUser.add(:DARKGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:DARK, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:DEEPSEATOOTH, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if user.isSpecies?(:CLAMPERL) && move.specialMove? mults[:attack_multiplier] *= 2 end @@ -789,7 +789,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:DEEPSEATOOTH, ) Battle::ItemEffects::DamageCalcFromUser.add(:DRAGONFANG, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :DRAGON } ) @@ -797,19 +797,19 @@ Battle::ItemEffects::DamageCalcFromUser.add(:DRAGONFANG, Battle::ItemEffects::DamageCalcFromUser.copy(:DRAGONFANG, :DRACOPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:DRAGONGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:DRAGON, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:ELECTRICGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:ELECTRIC, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:EXPERTBELT, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if Effectiveness.super_effective?(target.damageState.typeMod) mults[:final_damage_multiplier] *= 1.2 end @@ -817,43 +817,43 @@ Battle::ItemEffects::DamageCalcFromUser.add(:EXPERTBELT, ) Battle::ItemEffects::DamageCalcFromUser.add(:FAIRYGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:FAIRY, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:FIGHTINGGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:FIGHTING, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:FIREGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:FIRE, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:FLYINGGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:FLYING, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:GHOSTGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:GHOST, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:GRASSGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:GRASS, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:GRISEOUSORB, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if user.isSpecies?(:GIRATINA) && (type == :DRAGON || type == :GHOST) mults[:base_damage_multiplier] *= 1.2 end @@ -861,13 +861,13 @@ Battle::ItemEffects::DamageCalcFromUser.add(:GRISEOUSORB, ) Battle::ItemEffects::DamageCalcFromUser.add(:GROUNDGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:GROUND, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:HARDSTONE, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :ROCK } ) @@ -875,13 +875,13 @@ Battle::ItemEffects::DamageCalcFromUser.add(:HARDSTONE, Battle::ItemEffects::DamageCalcFromUser.copy(:HARDSTONE, :STONEPLATE, :ROCKINCENSE) Battle::ItemEffects::DamageCalcFromUser.add(:ICEGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:ICE, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:LIFEORB, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if !move.is_a?(Battle::Move::Confusion) mults[:final_damage_multiplier] *= 1.3 end @@ -889,7 +889,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LIFEORB, ) Battle::ItemEffects::DamageCalcFromUser.add(:LIGHTBALL, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if user.isSpecies?(:PIKACHU) mults[:attack_multiplier] *= 2 end @@ -897,7 +897,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LIGHTBALL, ) Battle::ItemEffects::DamageCalcFromUser.add(:LUSTROUSORB, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if user.isSpecies?(:PALKIA) && (type == :DRAGON || type == :WATER) mults[:base_damage_multiplier] *= 1.2 end @@ -905,7 +905,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LUSTROUSORB, ) Battle::ItemEffects::DamageCalcFromUser.add(:MAGNET, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :ELECTRIC } ) @@ -913,7 +913,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:MAGNET, Battle::ItemEffects::DamageCalcFromUser.copy(:MAGNET, :ZAPPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:METALCOAT, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :STEEL } ) @@ -921,14 +921,14 @@ Battle::ItemEffects::DamageCalcFromUser.add(:METALCOAT, Battle::ItemEffects::DamageCalcFromUser.copy(:METALCOAT, :IRONPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:METRONOME, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| met = 1 + 0.2 * [user.effects[PBEffects::Metronome], 5].min mults[:final_damage_multiplier] *= met } ) Battle::ItemEffects::DamageCalcFromUser.add(:MIRACLESEED, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :GRASS } ) @@ -936,13 +936,13 @@ Battle::ItemEffects::DamageCalcFromUser.add(:MIRACLESEED, Battle::ItemEffects::DamageCalcFromUser.copy(:MIRACLESEED, :MEADOWPLATE, :ROSEINCENSE) Battle::ItemEffects::DamageCalcFromUser.add(:MUSCLEBAND, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.1 if move.physicalMove? } ) Battle::ItemEffects::DamageCalcFromUser.add(:MYSTICWATER, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :WATER } ) @@ -950,7 +950,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:MYSTICWATER, Battle::ItemEffects::DamageCalcFromUser.copy(:MYSTICWATER, :SPLASHPLATE, :SEAINCENSE, :WAVEINCENSE) Battle::ItemEffects::DamageCalcFromUser.add(:NEVERMELTICE, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :ICE } ) @@ -958,19 +958,19 @@ Battle::ItemEffects::DamageCalcFromUser.add(:NEVERMELTICE, Battle::ItemEffects::DamageCalcFromUser.copy(:NEVERMELTICE, :ICICLEPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:NORMALGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:NORMAL, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:PIXIEPLATE, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :FAIRY } ) Battle::ItemEffects::DamageCalcFromUser.add(:POISONBARB, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :POISON } ) @@ -978,25 +978,25 @@ Battle::ItemEffects::DamageCalcFromUser.add(:POISONBARB, Battle::ItemEffects::DamageCalcFromUser.copy(:POISONBARB, :TOXICPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:POISONGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:POISON, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:PSYCHICGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:PSYCHIC, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:ROCKGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:ROCK, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:SHARPBEAK, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :FLYING } ) @@ -1004,13 +1004,13 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SHARPBEAK, Battle::ItemEffects::DamageCalcFromUser.copy(:SHARPBEAK, :SKYPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:SILKSCARF, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :NORMAL } ) Battle::ItemEffects::DamageCalcFromUser.add(:SILVERPOWDER, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :BUG } ) @@ -1018,7 +1018,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SILVERPOWDER, Battle::ItemEffects::DamageCalcFromUser.copy(:SILVERPOWDER, :INSECTPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:SOFTSAND, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :GROUND } ) @@ -1026,7 +1026,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SOFTSAND, Battle::ItemEffects::DamageCalcFromUser.copy(:SOFTSAND, :EARTHPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:SOULDEW, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| next if !user.isSpecies?(:LATIAS) && !user.isSpecies?(:LATIOS) if Settings::SOUL_DEW_POWERS_UP_TYPES mults[:final_damage_multiplier] *= 1.2 if type == :PSYCHIC || type == :DRAGON @@ -1039,7 +1039,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SOULDEW, ) Battle::ItemEffects::DamageCalcFromUser.add(:SPELLTAG, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :GHOST } ) @@ -1047,13 +1047,13 @@ Battle::ItemEffects::DamageCalcFromUser.add(:SPELLTAG, Battle::ItemEffects::DamageCalcFromUser.copy(:SPELLTAG, :SPOOKYPLATE) Battle::ItemEffects::DamageCalcFromUser.add(:STEELGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:STEEL, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:THICKCLUB, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if (user.isSpecies?(:CUBONE) || user.isSpecies?(:MAROWAK)) && move.physicalMove? mults[:attack_multiplier] *= 2 end @@ -1061,7 +1061,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:THICKCLUB, ) Battle::ItemEffects::DamageCalcFromUser.add(:TWISTEDSPOON, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.2 if type == :PSYCHIC } ) @@ -1069,13 +1069,13 @@ Battle::ItemEffects::DamageCalcFromUser.add(:TWISTEDSPOON, Battle::ItemEffects::DamageCalcFromUser.copy(:TWISTEDSPOON, :MINDPLATE, :ODDINCENSE) Battle::ItemEffects::DamageCalcFromUser.add(:WATERGEM, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| user.pbMoveTypePoweringUpGem(:WATER, move, type, mults) } ) Battle::ItemEffects::DamageCalcFromUser.add(:WISEGLASSES, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:base_damage_multiplier] *= 1.1 if move.specialMove? } ) @@ -1088,49 +1088,49 @@ Battle::ItemEffects::DamageCalcFromUser.add(:WISEGLASSES, # are Metal/Quick Powder, which don't work if the holder is transformed. Battle::ItemEffects::DamageCalcFromTarget.add(:ASSAULTVEST, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| mults[:defense_multiplier] *= 1.5 if move.specialMove? } ) Battle::ItemEffects::DamageCalcFromTarget.add(:BABIRIBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:STEEL, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:CHARTIBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:ROCK, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:CHILANBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:NORMAL, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:CHOPLEBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:FIGHTING, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:COBABERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:FLYING, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:COLBURBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:DARK, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:DEEPSEASCALE, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if target.isSpecies?(:CLAMPERL) && move.specialMove? mults[:defense_multiplier] *= 2 end @@ -1138,7 +1138,7 @@ Battle::ItemEffects::DamageCalcFromTarget.add(:DEEPSEASCALE, ) Battle::ItemEffects::DamageCalcFromTarget.add(:EVIOLITE, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| # NOTE: Eviolite cares about whether the Pokémon itself can evolve, which # means it also cares about the Pokémon's form. Some forms cannot # evolve even if the species generally can, and such forms are not @@ -1150,25 +1150,25 @@ Battle::ItemEffects::DamageCalcFromTarget.add(:EVIOLITE, ) Battle::ItemEffects::DamageCalcFromTarget.add(:HABANBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:DRAGON, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:KASIBBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:GHOST, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:KEBIABERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:POISON, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:METALPOWDER, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| if target.isSpecies?(:DITTO) && !target.effects[PBEffects::Transform] mults[:defense_multiplier] *= 1.5 end @@ -1176,43 +1176,43 @@ Battle::ItemEffects::DamageCalcFromTarget.add(:METALPOWDER, ) Battle::ItemEffects::DamageCalcFromTarget.add(:OCCABERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:FIRE, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:PASSHOBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:WATER, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:PAYAPABERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:PSYCHIC, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:RINDOBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:GRASS, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:ROSELIBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:FAIRY, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:SHUCABERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:GROUND, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:SOULDEW, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| next if Settings::SOUL_DEW_POWERS_UP_TYPES next if !target.isSpecies?(:LATIAS) && !target.isSpecies?(:LATIOS) if move.specialMove? && !user.battle.rules["souldewclause"] @@ -1222,19 +1222,19 @@ Battle::ItemEffects::DamageCalcFromTarget.add(:SOULDEW, ) Battle::ItemEffects::DamageCalcFromTarget.add(:TANGABERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:BUG, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:WACANBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:ELECTRIC, type, mults) } ) Battle::ItemEffects::DamageCalcFromTarget.add(:YACHEBERRY, - proc { |item,user,target,move,mults,baseDmg,type| + proc { |item, user, target, move, mults, baseDmg, type| target.pbMoveTypeWeakeningBerry(:ICE, type, mults) } ) @@ -1244,22 +1244,22 @@ Battle::ItemEffects::DamageCalcFromTarget.add(:YACHEBERRY, #=============================================================================== Battle::ItemEffects::CriticalCalcFromUser.add(:LUCKYPUNCH, - proc { |item,user,target,c| - next c+2 if user.isSpecies?(:CHANSEY) + proc { |item, user, target, c| + next c + 2 if user.isSpecies?(:CHANSEY) } ) Battle::ItemEffects::CriticalCalcFromUser.add(:RAZORCLAW, - proc { |item,user,target,c| - next c+1 + proc { |item, user, target, c| + next c + 1 } ) Battle::ItemEffects::CriticalCalcFromUser.copy(:RAZORCLAW, :SCOPELENS) Battle::ItemEffects::CriticalCalcFromUser.add(:LEEK, - proc { |item,user,target,c| - next c+2 if user.isSpecies?(:FARFETCHD) || user.isSpecies?(:SIRFETCHD) + proc { |item, user, target, c| + next c + 2 if user.isSpecies?(:FARFETCHD) || user.isSpecies?(:SIRFETCHD) } ) @@ -1276,35 +1276,35 @@ Battle::ItemEffects::CriticalCalcFromUser.copy(:LEEK, :STICK) #=============================================================================== Battle::ItemEffects::OnBeingHit.add(:ABSORBBULB, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if move.calcType != :WATER - next if !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,target) - battle.pbCommonAnimation("UseItem",target) - target.pbRaiseStatStageByCause(:SPECIAL_ATTACK,1,target,target.itemName) + next if !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, target) + battle.pbCommonAnimation("UseItem", target) + target.pbRaiseStatStageByCause(:SPECIAL_ATTACK, 1, target, target.itemName) target.pbHeldItemTriggered(item) } ) Battle::ItemEffects::OnBeingHit.add(:AIRBALLOON, - proc { |item,user,target,move,battle| - battle.pbDisplay(_INTL("{1}'s {2} popped!",target.pbThis,target.itemName)) - target.pbConsumeItem(false,true) + proc { |item, user, target, move, battle| + battle.pbDisplay(_INTL("{1}'s {2} popped!", target.pbThis, target.itemName)) + target.pbConsumeItem(false, true) target.pbSymbiosis } ) Battle::ItemEffects::OnBeingHit.add(:CELLBATTERY, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if move.calcType != :ELECTRIC - next if !target.pbCanRaiseStatStage?(:ATTACK,target) - battle.pbCommonAnimation("UseItem",target) - target.pbRaiseStatStageByCause(:ATTACK,1,target,target.itemName) + next if !target.pbCanRaiseStatStage?(:ATTACK, target) + battle.pbCommonAnimation("UseItem", target) + target.pbRaiseStatStageByCause(:ATTACK, 1, target, target.itemName) target.pbHeldItemTriggered(item) } ) Battle::ItemEffects::OnBeingHit.add(:ENIGMABERRY, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if target.damageState.substitute || target.damageState.disguise || target.damageState.iceFace next if !Effectiveness.super_effective?(target.damageState.typeMod) @@ -1315,7 +1315,7 @@ Battle::ItemEffects::OnBeingHit.add(:ENIGMABERRY, ) Battle::ItemEffects::OnBeingHit.add(:JABOCABERRY, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if !target.canConsumeBerry? next if !move.physicalMove? next if !user.takesIndirectDamage? @@ -1330,8 +1330,8 @@ Battle::ItemEffects::OnBeingHit.add(:JABOCABERRY, battle.pbHideAbilitySplash(battler) if ripening battle.scene.pbDamageAnimation(user) user.pbReduceHP(amt, false) - battle.pbDisplay(_INTL("{1} consumed its {2} and hurt {3}!",target.pbThis, - target.itemName,user.pbThis(true))) + battle.pbDisplay(_INTL("{1} consumed its {2} and hurt {3}!", target.pbThis, + target.itemName, user.pbThis(true))) target.pbHeldItemTriggered(item) } ) @@ -1342,7 +1342,7 @@ Battle::ItemEffects::OnBeingHit.add(:JABOCABERRY, # stoppage is either a false report that no one ever corrected, or an # effect that later changed and wasn't noticed. Battle::ItemEffects::OnBeingHit.add(:KEEBERRY, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if !move.physicalMove? if Battle::ItemEffects.triggerOnBeingHitPositiveBerry(item, target, battle, false) target.pbHeldItemTriggered(item) @@ -1351,11 +1351,11 @@ Battle::ItemEffects::OnBeingHit.add(:KEEBERRY, ) Battle::ItemEffects::OnBeingHit.add(:LUMINOUSMOSS, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if move.calcType != :WATER - next if !target.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,target) - battle.pbCommonAnimation("UseItem",target) - target.pbRaiseStatStageByCause(:SPECIAL_DEFENSE,1,target,target.itemName) + next if !target.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, target) + battle.pbCommonAnimation("UseItem", target) + target.pbRaiseStatStageByCause(:SPECIAL_DEFENSE, 1, target, target.itemName) target.pbHeldItemTriggered(item) } ) @@ -1366,7 +1366,7 @@ Battle::ItemEffects::OnBeingHit.add(:LUMINOUSMOSS, # stoppage is either a false report that no one ever corrected, or an # effect that later changed and wasn't noticed. Battle::ItemEffects::OnBeingHit.add(:MARANGABERRY, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if !move.specialMove? if Battle::ItemEffects.triggerOnBeingHitPositiveBerry(item, target, battle, false) target.pbHeldItemTriggered(item) @@ -1375,17 +1375,17 @@ Battle::ItemEffects::OnBeingHit.add(:MARANGABERRY, ) Battle::ItemEffects::OnBeingHit.add(:ROCKYHELMET, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if !move.pbContactMove?(user) || !user.affectedByContactEffect? next if !user.takesIndirectDamage? battle.scene.pbDamageAnimation(user) - user.pbReduceHP(user.totalhp/6,false) - battle.pbDisplay(_INTL("{1} was hurt by the {2}!",user.pbThis,target.itemName)) + user.pbReduceHP(user.totalhp / 6, false) + battle.pbDisplay(_INTL("{1} was hurt by the {2}!", user.pbThis, target.itemName)) } ) Battle::ItemEffects::OnBeingHit.add(:ROWAPBERRY, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if !target.canConsumeBerry? next if !move.specialMove? next if !user.takesIndirectDamage? @@ -1400,24 +1400,24 @@ Battle::ItemEffects::OnBeingHit.add(:ROWAPBERRY, battle.pbHideAbilitySplash(battler) if ripening battle.scene.pbDamageAnimation(user) user.pbReduceHP(amt, false) - battle.pbDisplay(_INTL("{1} consumed its {2} and hurt {3}!",target.pbThis, - target.itemName,user.pbThis(true))) + battle.pbDisplay(_INTL("{1} consumed its {2} and hurt {3}!", target.pbThis, + target.itemName, user.pbThis(true))) target.pbHeldItemTriggered(item) } ) Battle::ItemEffects::OnBeingHit.add(:SNOWBALL, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if move.calcType != :ICE - next if !target.pbCanRaiseStatStage?(:ATTACK,target) - battle.pbCommonAnimation("UseItem",target) - target.pbRaiseStatStageByCause(:ATTACK,1,target,target.itemName) + next if !target.pbCanRaiseStatStage?(:ATTACK, target) + battle.pbCommonAnimation("UseItem", target) + target.pbRaiseStatStageByCause(:ATTACK, 1, target, target.itemName) target.pbHeldItemTriggered(item) } ) Battle::ItemEffects::OnBeingHit.add(:STICKYBARB, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if !move.pbContactMove?(user) || !user.affectedByContactEffect? next if user.fainted? || user.item user.item = target.item @@ -1430,24 +1430,24 @@ Battle::ItemEffects::OnBeingHit.add(:STICKYBARB, end end battle.pbDisplay(_INTL("{1}'s {2} was transferred to {3}!", - target.pbThis,user.itemName,user.pbThis(true))) + target.pbThis, user.itemName, user.pbThis(true))) } ) Battle::ItemEffects::OnBeingHit.add(:WEAKNESSPOLICY, - proc { |item,user,target,move,battle| + proc { |item, user, target, move, battle| next if target.damageState.disguise || target.damageState.iceFace next if !Effectiveness.super_effective?(target.damageState.typeMod) - next if !target.pbCanRaiseStatStage?(:ATTACK,target) && - !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,target) - battle.pbCommonAnimation("UseItem",target) + next if !target.pbCanRaiseStatStage?(:ATTACK, target) && + !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, target) + battle.pbCommonAnimation("UseItem", target) showAnim = true - if target.pbCanRaiseStatStage?(:ATTACK,target) - target.pbRaiseStatStageByCause(:ATTACK,2,target,target.itemName,showAnim) + if target.pbCanRaiseStatStage?(:ATTACK, target) + target.pbRaiseStatStageByCause(:ATTACK, 2, target, target.itemName, showAnim) showAnim = false end - if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,target) - target.pbRaiseStatStageByCause(:SPECIAL_ATTACK,2,target,target.itemName,showAnim) + if target.pbCanRaiseStatStage?(:SPECIAL_ATTACK, target) + target.pbRaiseStatStageByCause(:SPECIAL_ATTACK, 2, target, target.itemName, showAnim) end battle.pbDisplay(_INTL("The {1} was used up...", target.itemName)) target.pbHeldItemTriggered(item) @@ -1461,7 +1461,7 @@ Battle::ItemEffects::OnBeingHit.add(:WEAKNESSPOLICY, #=============================================================================== Battle::ItemEffects::OnBeingHitPositiveBerry.add(:ENIGMABERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !battler.canHeal? next false if !forced && !battler.canConsumeBerry? itemName = GameData::Item.get(item).name @@ -1473,13 +1473,13 @@ Battle::ItemEffects::OnBeingHitPositiveBerry.add(:ENIGMABERRY, amt *= 2 ripening = true end - battle.pbCommonAnimation("EatBerry",battler) if !forced + battle.pbCommonAnimation("EatBerry", battler) if !forced battle.pbHideAbilitySplash(battler) if ripening battler.pbRecoverHP(amt) if forced - battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) else - battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis, + battle.pbDisplay(_INTL("{1} restored its health using its {2}!", battler.pbThis, itemName)) end next true @@ -1487,9 +1487,9 @@ Battle::ItemEffects::OnBeingHitPositiveBerry.add(:ENIGMABERRY, ) Battle::ItemEffects::OnBeingHitPositiveBerry.add(:KEEBERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? - next false if !battler.pbCanRaiseStatStage?(:DEFENSE,battler) + next false if !battler.pbCanRaiseStatStage?(:DEFENSE, battler) itemName = GameData::Item.get(item).name amt = 1 ripening = false @@ -1507,9 +1507,9 @@ Battle::ItemEffects::OnBeingHitPositiveBerry.add(:KEEBERRY, ) Battle::ItemEffects::OnBeingHitPositiveBerry.add(:MARANGABERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? - next false if !battler.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,battler) + next false if !battler.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, battler) itemName = GameData::Item.get(item).name amt = 1 ripening = false @@ -1535,12 +1535,12 @@ Battle::ItemEffects::AfterMoveUseFromTarget.add(:EJECTBUTTON, next if !switched_battlers.empty? next if battle.pbAllFainted?(battler.idxOpposingSide) next if !battle.pbCanChooseNonActive?(battler.index) - battle.pbCommonAnimation("UseItem",battler) - battle.pbDisplay(_INTL("{1} is switched out with the {2}!",battler.pbThis,battler.itemName)) - battler.pbConsumeItem(true,false) + battle.pbCommonAnimation("UseItem", battler) + battle.pbDisplay(_INTL("{1} is switched out with the {2}!", battler.pbThis, battler.itemName)) + battler.pbConsumeItem(true, false) newPkmn = battle.pbGetReplacementPokemonIndex(battler.index) # Owner chooses - next if newPkmn<0 - battle.pbRecallAndReplace(battler.index,newPkmn) + next if newPkmn < 0 + battle.pbRecallAndReplace(battler.index, newPkmn) battle.pbClearChoice(battler.index) # Replacement Pokémon does nothing this round switched_battlers.push(battler.index) battle.moldBreaker = false if battler.index == user.index @@ -1551,11 +1551,11 @@ Battle::ItemEffects::AfterMoveUseFromTarget.add(:EJECTBUTTON, Battle::ItemEffects::AfterMoveUseFromTarget.add(:REDCARD, proc { |item, battler, user, move, switched_battlers, battle| next if !switched_battlers.empty? || user.fainted? - newPkmn = battle.pbGetReplacementPokemonIndex(user.index,true) # Random - next if newPkmn<0 - battle.pbCommonAnimation("UseItem",battler) + newPkmn = battle.pbGetReplacementPokemonIndex(user.index, true) # Random + next if newPkmn < 0 + battle.pbCommonAnimation("UseItem", battler) battle.pbDisplay(_INTL("{1} held up its {2} against {3}!", - battler.pbThis,battler.itemName,user.pbThis(true))) + battler.pbThis, battler.itemName, user.pbThis(true))) battler.pbConsumeItem if user.hasActiveAbility?(:SUCTIONCUPS) && !battle.moldBreaker battle.pbShowAbilitySplash(user) @@ -1572,7 +1572,7 @@ Battle::ItemEffects::AfterMoveUseFromTarget.add(:REDCARD, next end battle.pbRecallAndReplace(user.index, newPkmn, true) - battle.pbDisplay(_INTL("{1} was dragged out!",user.pbThis)) + battle.pbDisplay(_INTL("{1} was dragged out!", user.pbThis)) battle.pbClearChoice(user.index) # Replacement Pokémon does nothing this round switched_battlers.push(user.index) battle.moldBreaker = false @@ -1585,9 +1585,9 @@ Battle::ItemEffects::AfterMoveUseFromTarget.add(:REDCARD, #=============================================================================== Battle::ItemEffects::AfterMoveUseFromUser.add(:LIFEORB, - proc { |item,user,targets,move,numHits,battle| + proc { |item, user, targets, move, numHits, battle| next if !user.takesIndirectDamage? - next if !move.pbDamagingMove? || numHits==0 + next if !move.pbDamagingMove? || numHits == 0 hitBattler = false targets.each do |b| hitBattler = true if !b.damageState.unaffected && !b.damageState.substitute @@ -1595,8 +1595,8 @@ Battle::ItemEffects::AfterMoveUseFromUser.add(:LIFEORB, end next if !hitBattler PBDebug.log("[Item triggered] #{user.pbThis}'s #{user.itemName} (recoil)") - user.pbReduceHP(user.totalhp/10) - battle.pbDisplay(_INTL("{1} lost some of its HP!",user.pbThis)) + user.pbReduceHP(user.totalhp / 10) + battle.pbDisplay(_INTL("{1} lost some of its HP!", user.pbThis)) user.pbItemHPHealCheck user.pbFaint if user.fainted? } @@ -1606,14 +1606,14 @@ Battle::ItemEffects::AfterMoveUseFromUser.add(:LIFEORB, # Out triggering even if Shell Bell heals the holder back to 50% HP or # more. Essentials ignores this exception. Battle::ItemEffects::AfterMoveUseFromUser.add(:SHELLBELL, - proc { |item,user,targets,move,numHits,battle| + proc { |item, user, targets, move, numHits, battle| next if !user.canHeal? totalDamage = 0 targets.each { |b| totalDamage += b.damageState.totalHPLost } - next if totalDamage<=0 - user.pbRecoverHP(totalDamage/8) + next if totalDamage <= 0 + user.pbRecoverHP(totalDamage / 8) battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!", - user.pbThis,user.itemName)) + user.pbThis, user.itemName)) } ) @@ -1634,7 +1634,7 @@ Battle::ItemEffects::AfterMoveUseFromUser.add(:THROATSPRAY, #=============================================================================== Battle::ItemEffects::OnEndOfUsingMove.add(:LEPPABERRY, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| next false if !forced && !battler.canConsumeBerry? found_empty_moves = [] found_partial_moves = [] @@ -1675,7 +1675,7 @@ Battle::ItemEffects::OnEndOfUsingMove.add(:LEPPABERRY, #=============================================================================== Battle::ItemEffects::OnEndOfUsingMoveStatRestore.add(:WHITEHERB, - proc { |item,battler,battle,forced| + proc { |item, battler, battle, forced| reducedStats = false GameData::Stat.each_battle do |s| next if battler.stages[s.id] >= 0 @@ -1686,12 +1686,12 @@ Battle::ItemEffects::OnEndOfUsingMoveStatRestore.add(:WHITEHERB, next false if !reducedStats itemName = GameData::Item.get(item).name PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced - battle.pbCommonAnimation("UseItem",battler) if !forced + battle.pbCommonAnimation("UseItem", battler) if !forced if forced - battle.pbDisplay(_INTL("{1}'s status returned to normal!",battler.pbThis)) + battle.pbDisplay(_INTL("{1}'s status returned to normal!", battler.pbThis)) else battle.pbDisplay(_INTL("{1} returned its status to normal using its {2}!", - battler.pbThis,itemName)) + battler.pbThis, itemName)) end next true } @@ -1702,8 +1702,8 @@ Battle::ItemEffects::OnEndOfUsingMoveStatRestore.add(:WHITEHERB, #=============================================================================== Battle::ItemEffects::ExpGainModifier.add(:LUCKYEGG, - proc { |item,battler,exp| - next exp*3/2 + proc { |item, battler, exp| + next exp * 3 / 2 } ) @@ -1712,43 +1712,43 @@ Battle::ItemEffects::ExpGainModifier.add(:LUCKYEGG, #=============================================================================== Battle::ItemEffects::EVGainModifier.add(:MACHOBRACE, - proc { |item,battler,evYield| + proc { |item, battler, evYield| evYield.each_key { |stat| evYield[stat] *= 2 } } ) Battle::ItemEffects::EVGainModifier.add(:POWERANKLET, - proc { |item,battler,evYield| + proc { |item, battler, evYield| evYield[:SPEED] += (Settings::MORE_EVS_FROM_POWER_ITEMS) ? 8 : 4 } ) Battle::ItemEffects::EVGainModifier.add(:POWERBAND, - proc { |item,battler,evYield| + proc { |item, battler, evYield| evYield[:SPECIAL_DEFENSE] += (Settings::MORE_EVS_FROM_POWER_ITEMS) ? 8 : 4 } ) Battle::ItemEffects::EVGainModifier.add(:POWERBELT, - proc { |item,battler,evYield| + proc { |item, battler, evYield| evYield[:DEFENSE] += (Settings::MORE_EVS_FROM_POWER_ITEMS) ? 8 : 4 } ) Battle::ItemEffects::EVGainModifier.add(:POWERBRACER, - proc { |item,battler,evYield| + proc { |item, battler, evYield| evYield[:ATTACK] += (Settings::MORE_EVS_FROM_POWER_ITEMS) ? 8 : 4 } ) Battle::ItemEffects::EVGainModifier.add(:POWERLENS, - proc { |item,battler,evYield| + proc { |item, battler, evYield| evYield[:SPECIAL_ATTACK] += (Settings::MORE_EVS_FROM_POWER_ITEMS) ? 8 : 4 } ) Battle::ItemEffects::EVGainModifier.add(:POWERWEIGHT, - proc { |item,battler,evYield| + proc { |item, battler, evYield| evYield[:HP] += (Settings::MORE_EVS_FROM_POWER_ITEMS) ? 8 : 4 } ) @@ -1758,25 +1758,25 @@ Battle::ItemEffects::EVGainModifier.add(:POWERWEIGHT, #=============================================================================== Battle::ItemEffects::WeatherExtender.add(:DAMPROCK, - proc { |item,weather,duration,battler,battle| + proc { |item, weather, duration, battler, battle| next 8 if weather == :Rain } ) Battle::ItemEffects::WeatherExtender.add(:HEATROCK, - proc { |item,weather,duration,battler,battle| + proc { |item, weather, duration, battler, battle| next 8 if weather == :Sun } ) Battle::ItemEffects::WeatherExtender.add(:ICYROCK, - proc { |item,weather,duration,battler,battle| + proc { |item, weather, duration, battler, battle| next 8 if weather == :Hail } ) Battle::ItemEffects::WeatherExtender.add(:SMOOTHROCK, - proc { |item,weather,duration,battler,battle| + proc { |item, weather, duration, battler, battle| next 8 if weather == :Sandstorm } ) @@ -1786,7 +1786,7 @@ Battle::ItemEffects::WeatherExtender.add(:SMOOTHROCK, #=============================================================================== Battle::ItemEffects::TerrainExtender.add(:TERRAINEXTENDER, - proc { |item,terrain,duration,battler,battle| + proc { |item, terrain, duration, battler, battle| next 8 } ) @@ -1796,42 +1796,42 @@ Battle::ItemEffects::TerrainExtender.add(:TERRAINEXTENDER, #=============================================================================== Battle::ItemEffects::TerrainStatBoost.add(:ELECTRICSEED, - proc { |item,battler,battle| + proc { |item, battler, battle| next false if battle.field.terrain != :Electric - next false if !battler.pbCanRaiseStatStage?(:DEFENSE,battler) + next false if !battler.pbCanRaiseStatStage?(:DEFENSE, battler) itemName = GameData::Item.get(item).name - battle.pbCommonAnimation("UseItem",battler) - next battler.pbRaiseStatStageByCause(:DEFENSE,1,battler,itemName) + battle.pbCommonAnimation("UseItem", battler) + next battler.pbRaiseStatStageByCause(:DEFENSE, 1, battler, itemName) } ) Battle::ItemEffects::TerrainStatBoost.add(:GRASSYSEED, - proc { |item,battler,battle| + proc { |item, battler, battle| next false if battle.field.terrain != :Grassy - next false if !battler.pbCanRaiseStatStage?(:DEFENSE,battler) + next false if !battler.pbCanRaiseStatStage?(:DEFENSE, battler) itemName = GameData::Item.get(item).name - battle.pbCommonAnimation("UseItem",battler) - next battler.pbRaiseStatStageByCause(:DEFENSE,1,battler,itemName) + battle.pbCommonAnimation("UseItem", battler) + next battler.pbRaiseStatStageByCause(:DEFENSE, 1, battler, itemName) } ) Battle::ItemEffects::TerrainStatBoost.add(:MISTYSEED, - proc { |item,battler,battle| + proc { |item, battler, battle| next false if battle.field.terrain != :Misty - next false if !battler.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,battler) + next false if !battler.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, battler) itemName = GameData::Item.get(item).name - battle.pbCommonAnimation("UseItem",battler) - next battler.pbRaiseStatStageByCause(:SPECIAL_DEFENSE,1,battler,itemName) + battle.pbCommonAnimation("UseItem", battler) + next battler.pbRaiseStatStageByCause(:SPECIAL_DEFENSE, 1, battler, itemName) } ) Battle::ItemEffects::TerrainStatBoost.add(:PSYCHICSEED, - proc { |item,battler,battle| + proc { |item, battler, battle| next false if battle.field.terrain != :Psychic - next false if !battler.pbCanRaiseStatStage?(:SPECIAL_DEFENSE,battler) + next false if !battler.pbCanRaiseStatStage?(:SPECIAL_DEFENSE, battler) itemName = GameData::Item.get(item).name - battle.pbCommonAnimation("UseItem",battler) - next battler.pbRaiseStatStageByCause(:SPECIAL_DEFENSE,1,battler,itemName) + battle.pbCommonAnimation("UseItem", battler) + next battler.pbRaiseStatStageByCause(:SPECIAL_DEFENSE, 1, battler, itemName) } ) @@ -1840,15 +1840,15 @@ Battle::ItemEffects::TerrainStatBoost.add(:PSYCHICSEED, #=============================================================================== Battle::ItemEffects::EndOfRoundHealing.add(:BLACKSLUDGE, - proc { |item,battler,battle| + proc { |item, battler, battle| if battler.pbHasType?(:POISON) next if !battler.canHeal? - battle.pbCommonAnimation("UseItem",battler) - battler.pbRecoverHP(battler.totalhp/16) + battle.pbCommonAnimation("UseItem", battler) + battler.pbRecoverHP(battler.totalhp / 16) battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!", - battler.pbThis,battler.itemName)) + battler.pbThis, battler.itemName)) elsif battler.takesIndirectDamage? - battle.pbCommonAnimation("UseItem",battler) + battle.pbCommonAnimation("UseItem", battler) battler.pbTakeEffectDamage(battler.totalhp / 8) { |hp_lost| battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) } @@ -1857,12 +1857,12 @@ Battle::ItemEffects::EndOfRoundHealing.add(:BLACKSLUDGE, ) Battle::ItemEffects::EndOfRoundHealing.add(:LEFTOVERS, - proc { |item,battler,battle| + proc { |item, battler, battle| next if !battler.canHeal? - battle.pbCommonAnimation("UseItem",battler) - battler.pbRecoverHP(battler.totalhp/16) + battle.pbCommonAnimation("UseItem", battler) + battler.pbRecoverHP(battler.totalhp / 16) battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!", - battler.pbThis,battler.itemName)) + battler.pbThis, battler.itemName)) } ) @@ -1871,14 +1871,14 @@ Battle::ItemEffects::EndOfRoundHealing.add(:LEFTOVERS, #=============================================================================== Battle::ItemEffects::EndOfRoundEffect.add(:FLAMEORB, - proc { |item,battler,battle| + proc { |item, battler, battle| next if !battler.pbCanBurn?(battler, false) - battler.pbBurn(nil,_INTL("{1} was burned by the {2}!",battler.pbThis,battler.itemName)) + battler.pbBurn(nil, _INTL("{1} was burned by the {2}!", battler.pbThis, battler.itemName)) } ) Battle::ItemEffects::EndOfRoundEffect.add(:STICKYBARB, - proc { |item,battler,battle| + proc { |item, battler, battle| next if !battler.takesIndirectDamage? oldHP = battler.hp battle.scene.pbDamageAnimation(battler) @@ -1889,10 +1889,10 @@ Battle::ItemEffects::EndOfRoundEffect.add(:STICKYBARB, ) Battle::ItemEffects::EndOfRoundEffect.add(:TOXICORB, - proc { |item,battler,battle| + proc { |item, battler, battle| next if !battler.pbCanPoison?(battler, false) - battler.pbPoison(nil,_INTL("{1} was badly poisoned by the {2}!", - battler.pbThis,battler.itemName),true) + battler.pbPoison(nil, _INTL("{1} was badly poisoned by the {2}!", + battler.pbThis, battler.itemName), true) } ) @@ -1901,7 +1901,7 @@ Battle::ItemEffects::EndOfRoundEffect.add(:TOXICORB, #=============================================================================== Battle::ItemEffects::CertainSwitching.add(:SHEDSHELL, - proc { |item,battler,battle| + proc { |item, battler, battle| next true } ) @@ -1917,9 +1917,9 @@ Battle::ItemEffects::CertainSwitching.add(:SHEDSHELL, #=============================================================================== Battle::ItemEffects::OnSwitchIn.add(:AIRBALLOON, - proc { |item,battler,battle| + proc { |item, battler, battle| battle.pbDisplay(_INTL("{1} floats in the air with its {2}!", - battler.pbThis,battler.itemName)) + battler.pbThis, battler.itemName)) } ) @@ -1938,11 +1938,11 @@ Battle::ItemEffects::OnSwitchIn.add(:ROOMSERVICE, #=============================================================================== Battle::ItemEffects::OnIntimidated.add(:ADRENALINEORB, - proc { |item,battler,battle| - next false if !battler.pbCanRaiseStatStage?(:SPEED,battler) + proc { |item, battler, battle| + next false if !battler.pbCanRaiseStatStage?(:SPEED, battler) itemName = GameData::Item.get(item).name - battle.pbCommonAnimation("UseItem",battler) - next battler.pbRaiseStatStageByCause(:SPEED,1,battler,itemName) + battle.pbCommonAnimation("UseItem", battler) + next battler.pbRaiseStatStageByCause(:SPEED, 1, battler, itemName) } ) @@ -1951,7 +1951,7 @@ Battle::ItemEffects::OnIntimidated.add(:ADRENALINEORB, #=============================================================================== Battle::ItemEffects::CertainEscapeFromBattle.add(:SMOKEBALL, - proc { |item,battler| + proc { |item, battler| next true } ) diff --git a/Data/Scripts/011_Battle/007_Other battle types/001_SafariBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/001_SafariBattle.rb index a05e3a5f1..c2a0773a6 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/001_SafariBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/001_SafariBattle.rb @@ -7,7 +7,7 @@ class Battle::FakeBattler attr_reader :pokemon attr_reader :owned - def initialize(battle,index) + def initialize(battle, index) @battle = battle @pokemon = battle.party2[0] @index = index @@ -43,12 +43,12 @@ class Battle::FakeBattler end def pbThis(lowerCase = false) - return (lowerCase) ? _INTL("the wild {1}",name) : _INTL("The wild {1}",name) + return (lowerCase) ? _INTL("the wild {1}", name) : _INTL("The wild {1}", name) end def opposes?(i) i = i.index if i.is_a?(Battle::FakeBattler) - return (@index&1)!=(i&1) + return (@index & 1) != (i & 1) end def pbReset; end @@ -62,14 +62,14 @@ end class Battle::Scene::SafariDataBox < SpriteWrapper attr_accessor :selected - def initialize(battle,viewport = nil) + def initialize(battle, viewport = nil) super(viewport) @selected = 0 @battle = battle @databox = AnimatedBitmap.new("Graphics/Pictures/Battle/databox_safari") self.x = Graphics.width - 232 self.y = Graphics.height - 184 - @contents = BitmapWrapper.new(@databox.width,@databox.height) + @contents = BitmapWrapper.new(@databox.width, @databox.height) self.bitmap = @contents self.visible = false self.z = 50 @@ -79,13 +79,13 @@ class Battle::Scene::SafariDataBox < SpriteWrapper def refresh self.bitmap.clear - self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height)) - base = Color.new(72,72,72) - shadow = Color.new(184,184,184) + self.bitmap.blt(0, 0, @databox.bitmap, Rect.new(0, 0, @databox.width, @databox.height)) + base = Color.new(72, 72, 72) + shadow = Color.new(184, 184, 184) textpos = [] - textpos.push([_INTL("Safari Balls"),30,2,false,base,shadow]) - textpos.push([_INTL("Left: {1}",@battle.ballCount),30,32,false,base,shadow]) - pbDrawTextPositions(self.bitmap,textpos) + textpos.push([_INTL("Safari Balls"), 30, 2, false, base, shadow]) + textpos.push([_INTL("Left: {1}", @battle.ballCount), 30, 32, false, base, shadow]) + pbDrawTextPositions(self.bitmap, textpos) end def update(frameCounter = 0) @@ -101,59 +101,59 @@ end class Battle::Scene::Animation::ThrowBait < Battle::Scene::Animation include Battle::Scene::Animation::BallAnimationMixin - def initialize(sprites,viewport,battler) + def initialize(sprites, viewport, battler) @battler = battler @trainer = battler.battle.pbGetOwnerFromBattlerIndex(battler.index) - super(sprites,viewport) + super(sprites, viewport) end def createProcesses # Calculate start and end coordinates for battler sprite movement batSprite = @sprites["pokemon_#{@battler.index}"] traSprite = @sprites["player_1"] - ballPos = Battle::Scene.pbBattlerPosition(@battler.index,batSprite.sideSize) + ballPos = Battle::Scene.pbBattlerPosition(@battler.index, batSprite.sideSize) ballStartX = traSprite.x - ballStartY = traSprite.y-traSprite.bitmap.height/2 + ballStartY = traSprite.y - traSprite.bitmap.height / 2 ballMidX = 0 # Unused in arc calculation ballMidY = 122 - ballEndX = ballPos[0]-40 - ballEndY = ballPos[1]-4 + ballEndX = ballPos[0] - 40 + ballEndY = ballPos[1] - 4 # Set up trainer sprite - trainer = addSprite(traSprite,PictureOrigin::Bottom) + trainer = addSprite(traSprite, PictureOrigin::Bottom) # Set up bait sprite - ball = addNewSprite(ballStartX,ballStartY, - "Graphics/Battle animations/safari_bait",PictureOrigin::Center) - ball.setZ(0,batSprite.z+1) + ball = addNewSprite(ballStartX, ballStartY, + "Graphics/Battle animations/safari_bait", PictureOrigin::Center) + ball.setZ(0, batSprite.z + 1) # Trainer animation - if traSprite.bitmap.width>=traSprite.bitmap.height*2 - ballStartX, ballStartY = trainerThrowingFrames(ball,trainer,traSprite) + if traSprite.bitmap.width >= traSprite.bitmap.height * 2 + ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite) end delay = ball.totalDuration # 0 or 7 # Bait arc animation - ball.setSE(delay,"Battle throw") - createBallTrajectory(ball,delay,12, - ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY) - ball.setZ(9,batSprite.z+1) + ball.setSE(delay, "Battle throw") + createBallTrajectory(ball, delay, 12, + ballStartX, ballStartY, ballMidX, ballMidY, ballEndX, ballEndY) + ball.setZ(9, batSprite.z + 1) delay = ball.totalDuration - ball.moveOpacity(delay+8,2,0) - ball.setVisible(delay+10,false) + ball.moveOpacity(delay + 8, 2, 0) + ball.setVisible(delay + 10, false) # Set up battler sprite - battler = addSprite(batSprite,PictureOrigin::Bottom) + battler = addSprite(batSprite, PictureOrigin::Bottom) # Show Pokémon jumping before eating the bait - delay = ball.totalDuration+3 + delay = ball.totalDuration + 3 2.times do - battler.setSE(delay,"player jump") - battler.moveDelta(delay,3,0,-16) - battler.moveDelta(delay+4,3,0,16) - delay = battler.totalDuration+1 + battler.setSE(delay, "player jump") + battler.moveDelta(delay, 3, 0, -16) + battler.moveDelta(delay + 4, 3, 0, 16) + delay = battler.totalDuration + 1 end # Show Pokémon eating the bait - delay = battler.totalDuration+3 + delay = battler.totalDuration + 3 2.times do - battler.moveAngle(delay,7,5) - battler.moveDelta(delay,7,0,6) - battler.moveAngle(delay+7,7,0) - battler.moveDelta(delay+7,7,0,-6) + battler.moveAngle(delay, 7, 5) + battler.moveDelta(delay, 7, 0, 6) + battler.moveAngle(delay + 7, 7, 0) + battler.moveDelta(delay + 7, 7, 0, -6) delay = battler.totalDuration end end @@ -167,10 +167,10 @@ end class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation include Battle::Scene::Animation::BallAnimationMixin - def initialize(sprites,viewport,battler) + def initialize(sprites, viewport, battler) @battler = battler @trainer = battler.battle.pbGetOwnerFromBattlerIndex(battler.index) - super(sprites,viewport) + super(sprites, viewport) end def createProcesses @@ -178,46 +178,46 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation batSprite = @sprites["pokemon_#{@battler.index}"] traSprite = @sprites["player_1"] ballStartX = traSprite.x - ballStartY = traSprite.y-traSprite.bitmap.height/2 + ballStartY = traSprite.y - traSprite.bitmap.height / 2 ballMidX = 0 # Unused in arc calculation ballMidY = 122 ballEndX = batSprite.x - ballEndY = batSprite.y-batSprite.bitmap.height/2 + ballEndY = batSprite.y - batSprite.bitmap.height / 2 # Set up trainer sprite - trainer = addSprite(traSprite,PictureOrigin::Bottom) + trainer = addSprite(traSprite, PictureOrigin::Bottom) # Set up bait sprite - ball = addNewSprite(ballStartX,ballStartY, - "Graphics/Battle animations/safari_rock",PictureOrigin::Center) - ball.setZ(0,batSprite.z+1) + ball = addNewSprite(ballStartX, ballStartY, + "Graphics/Battle animations/safari_rock", PictureOrigin::Center) + ball.setZ(0, batSprite.z + 1) # Trainer animation - if traSprite.bitmap.width>=traSprite.bitmap.height*2 - ballStartX, ballStartY = trainerThrowingFrames(ball,trainer,traSprite) + if traSprite.bitmap.width >= traSprite.bitmap.height * 2 + ballStartX, ballStartY = trainerThrowingFrames(ball, trainer, traSprite) end delay = ball.totalDuration # 0 or 7 # Bait arc animation - ball.setSE(delay,"Battle throw") - createBallTrajectory(ball,delay,12, - ballStartX,ballStartY,ballMidX,ballMidY,ballEndX,ballEndY) - ball.setZ(9,batSprite.z+1) + ball.setSE(delay, "Battle throw") + createBallTrajectory(ball, delay, 12, + ballStartX, ballStartY, ballMidX, ballMidY, ballEndX, ballEndY) + ball.setZ(9, batSprite.z + 1) delay = ball.totalDuration - ball.setSE(delay,"Battle damage weak") - ball.moveOpacity(delay+2,2,0) - ball.setVisible(delay+4,false) + ball.setSE(delay, "Battle damage weak") + ball.moveOpacity(delay + 2, 2, 0) + ball.setVisible(delay + 4, false) # Set up anger sprite - anger = addNewSprite(ballEndX-42,ballEndY-36, - "Graphics/Battle animations/safari_anger",PictureOrigin::Center) - anger.setVisible(0,false) - anger.setZ(0,batSprite.z+1) + anger = addNewSprite(ballEndX - 42, ballEndY - 36, + "Graphics/Battle animations/safari_anger", PictureOrigin::Center) + anger.setVisible(0, false) + anger.setZ(0, batSprite.z + 1) # Show anger appearing - delay = ball.totalDuration+5 + delay = ball.totalDuration + 5 2.times do - anger.setSE(delay,"Player jump") - anger.setVisible(delay,true) - anger.moveZoom(delay,3,130) - anger.moveZoom(delay+3,3,100) - anger.setVisible(delay+6,false) - anger.setDelta(delay+6,96,-16) - delay = anger.totalDuration+3 + anger.setSE(delay, "Player jump") + anger.setVisible(delay, true) + anger.moveZoom(delay, 3, 130) + anger.moveZoom(delay + 3, 3, 100) + anger.setVisible(delay + 6, false) + anger.setDelta(delay + 6, 96, -16) + delay = anger.totalDuration + 3 end end end @@ -230,8 +230,8 @@ end class Battle::Scene def pbSafariStart @briefMessage = false - @sprites["dataBox_0"] = SafariDataBox.new(@battle,@viewport) - dataBoxAnim = Animation::DataBoxAppear.new(@sprites,@viewport,0) + @sprites["dataBox_0"] = SafariDataBox.new(@battle, @viewport) + dataBoxAnim = Animation::DataBoxAppear.new(@sprites, @viewport, 0) loop do dataBoxAnim.update pbUpdate @@ -242,18 +242,18 @@ class Battle::Scene end def pbSafariCommandMenu(index) - pbCommandMenuEx(index,[ - _INTL("What will\n{1} throw?",@battle.pbPlayer.name), + pbCommandMenuEx(index, [ + _INTL("What will\n{1} throw?", @battle.pbPlayer.name), _INTL("Ball"), _INTL("Bait"), _INTL("Rock"), _INTL("Run") - ],3) + ], 3) end def pbThrowBait @briefMessage = false - baitAnim = Animation::ThrowBait.new(@sprites,@viewport,@battle.battlers[1]) + baitAnim = Animation::ThrowBait.new(@sprites, @viewport, @battle.battlers[1]) loop do baitAnim.update pbUpdate @@ -264,7 +264,7 @@ class Battle::Scene def pbThrowRock @briefMessage = false - rockAnim = Animation::ThrowRock.new(@sprites,@viewport,@battle.battlers[1]) + rockAnim = Animation::ThrowRock.new(@sprites, @viewport, @battle.battlers[1]) loop do rockAnim.update pbUpdate @@ -311,7 +311,7 @@ class SafariBattle #============================================================================= # Initialize the battle class #============================================================================= - def initialize(scene,player,party2) + def initialize(scene, player, party2) @scene = scene @peer = Battle::Peer.new @backdrop = "" @@ -323,10 +323,10 @@ class SafariBattle @caughtPokemon = [] @player = [player] @party2 = party2 - @sideSizes = [1,1] + @sideSizes = [1, 1] @battlers = [ - Battle::FakeBattler.new(self,0), - Battle::FakeBattler.new(self,1) + Battle::FakeBattler.new(self, 0), + Battle::FakeBattler.new(self, 1) ] @rules = {} @ballCount = 0 @@ -344,7 +344,7 @@ class SafariBattle def setBattleMode(mode); end def pbSideSize(index) - return @sideSizes[index%2] + return @sideSizes[index % 2] end #============================================================================= @@ -386,28 +386,28 @@ class SafariBattle #============================================================================= # Battler-related #============================================================================= - def opposes?(idxBattler1,idxBattler2 = 0) + def opposes?(idxBattler1, idxBattler2 = 0) idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index") idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index") - return (idxBattler1&1)!=(idxBattler2&1) + return (idxBattler1 & 1) != (idxBattler2 & 1) end - def pbRemoveFromParty(idxBattler,idxParty); end + def pbRemoveFromParty(idxBattler, idxParty); end def pbGainExp; end #============================================================================= # Messages and animations #============================================================================= - def pbDisplay(msg,&block) - @scene.pbDisplayMessage(msg,&block) + def pbDisplay(msg, &block) + @scene.pbDisplayMessage(msg, &block) end - def pbDisplayPaused(msg,&block) - @scene.pbDisplayPausedMessage(msg,&block) + def pbDisplayPaused(msg, &block) + @scene.pbDisplayPausedMessage(msg, &block) end def pbDisplayBrief(msg) - @scene.pbDisplayMessage(msg,true) + @scene.pbDisplayMessage(msg, true) end def pbDisplayConfirm(msg) @@ -438,16 +438,16 @@ class SafariBattle pkmn = @party2[0] pbSetSeen(pkmn) @scene.pbStartBattle(self) - pbDisplayPaused(_INTL("Wild {1} appeared!",pkmn.name)) + pbDisplayPaused(_INTL("Wild {1} appeared!", pkmn.name)) @scene.pbSafariStart weather_data = GameData::BattleWeather.try_get(@weather) @scene.pbCommonAnimation(weather_data.animation) if weather_data safariBall = GameData::Item.get(:SAFARIBALL).id catch_rate = pkmn.species_data.catch_rate - catchFactor = (catch_rate*100)/1275 - catchFactor = [[catchFactor,3].max,20].min - escapeFactor = (pbEscapeRate(catch_rate)*100)/1275 - escapeFactor = [[escapeFactor,2].max,20].min + catchFactor = (catch_rate * 100) / 1275 + catchFactor = [[catchFactor, 3].max, 20].min + escapeFactor = (pbEscapeRate(catch_rate) * 100) / 1275 + escapeFactor = [[escapeFactor, 2].max, 20].min loop do cmd = @scene.pbSafariCommandMenu(0) case cmd @@ -458,46 +458,46 @@ class SafariBattle end @ballCount -= 1 @scene.pbRefresh - rare = (catchFactor*1275)/100 + rare = (catchFactor * 1275) / 100 if safariBall - pbThrowPokeBall(1,safariBall,rare,true) - if @caughtPokemon.length>0 + pbThrowPokeBall(1, safariBall, rare, true) + if @caughtPokemon.length > 0 pbRecordAndStoreCaughtPokemon @decision = 4 end end when 1 # Bait - pbDisplayBrief(_INTL("{1} threw some bait at the {2}!",self.pbPlayer.name,pkmn.name)) + pbDisplayBrief(_INTL("{1} threw some bait at the {2}!", self.pbPlayer.name, pkmn.name)) @scene.pbThrowBait - catchFactor /= 2 if pbRandom(100)<90 # Harder to catch + catchFactor /= 2 if pbRandom(100) < 90 # Harder to catch escapeFactor /= 2 # Less likely to escape when 2 # Rock - pbDisplayBrief(_INTL("{1} threw a rock at the {2}!",self.pbPlayer.name,pkmn.name)) + pbDisplayBrief(_INTL("{1} threw a rock at the {2}!", self.pbPlayer.name, pkmn.name)) @scene.pbThrowRock catchFactor *= 2 # Easier to catch - escapeFactor *= 2 if pbRandom(100)<90 # More likely to escape + escapeFactor *= 2 if pbRandom(100) < 90 # More likely to escape when 3 # Run pbSEPlay("Battle flee") pbDisplayPaused(_INTL("You got away safely!")) @decision = 3 end - catchFactor = [[catchFactor,3].max,20].min - escapeFactor = [[escapeFactor,2].max,20].min + catchFactor = [[catchFactor, 3].max, 20].min + escapeFactor = [[escapeFactor, 2].max, 20].min # End of round - if @decision==0 - if @ballCount<=0 + if @decision == 0 + if @ballCount <= 0 pbDisplay(_INTL("PA: You have no Safari Balls left! Game over!")) @decision = 2 - elsif pbRandom(100)<5*escapeFactor + elsif pbRandom(100) < 5 * escapeFactor pbSEPlay("Battle flee") - pbDisplay(_INTL("{1} fled!",pkmn.name)) + pbDisplay(_INTL("{1} fled!", pkmn.name)) @decision = 3 - elsif cmd==1 # Bait - pbDisplay(_INTL("{1} is eating!",pkmn.name)) - elsif cmd==2 # Rock - pbDisplay(_INTL("{1} is angry!",pkmn.name)) + elsif cmd == 1 # Bait + pbDisplay(_INTL("{1} is eating!", pkmn.name)) + elsif cmd == 2 # Rock + pbDisplay(_INTL("{1} is angry!", pkmn.name)) else - pbDisplay(_INTL("{1} is watching carefully!",pkmn.name)) + pbDisplay(_INTL("{1} is watching carefully!", pkmn.name)) end # Weather continues weather_data = GameData::BattleWeather.try_get(@weather) diff --git a/Data/Scripts/011_Battle/007_Other battle types/002_BugContestBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/002_BugContestBattle.rb index edf70a59a..96c946f23 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/002_BugContestBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/002_BugContestBattle.rb @@ -8,13 +8,13 @@ class Battle::Scene _bugContest_pbInitSprites # "helpwindow" shows the currently caught Pokémon's details when asking if # you want to replace it with a newly caught Pokémon. - @sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport) + @sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 32, 32, @viewport) @sprites["helpwindow"].z = 90 @sprites["helpwindow"].visible = false end def pbShowHelp(text) - @sprites["helpwindow"].resizeToFit(text,Graphics.width) + @sprites["helpwindow"].resizeToFit(text, Graphics.width) @sprites["helpwindow"].y = 0 @sprites["helpwindow"].x = 0 @sprites["helpwindow"].text = text @@ -40,31 +40,31 @@ class BugContestBattle < Battle super(*arg) end - def pbItemMenu(idxBattler,_firstAction) - return pbRegisterItem(idxBattler,@ballConst,1) + def pbItemMenu(idxBattler, _firstAction) + return pbRegisterItem(idxBattler, @ballConst, 1) end - def pbCommandMenu(idxBattler,_firstAction) - return @scene.pbCommandMenuEx(idxBattler,[ - _INTL("Sport Balls: {1}",@ballCount), + def pbCommandMenu(idxBattler, _firstAction) + return @scene.pbCommandMenuEx(idxBattler, [ + _INTL("Sport Balls: {1}", @ballCount), _INTL("Fight"), _INTL("Ball"), _INTL("Pokémon"), _INTL("Run") - ],4) + ], 4) end - def pbConsumeItemInBag(_item,_idxBattler) - @ballCount -= 1 if @ballCount>0 + def pbConsumeItemInBag(_item, _idxBattler) + @ballCount -= 1 if @ballCount > 0 end def pbStorePokemon(pkmn) if pbBugContestState.lastPokemon lastPokemon = pbBugContestState.lastPokemon - pbDisplayPaused(_INTL("You already caught a {1}.",lastPokemon.name)) + pbDisplayPaused(_INTL("You already caught a {1}.", lastPokemon.name)) helptext = _INTL("STOCK POKéMON:\n {1} Lv.{2} MaxHP: {3}\nTHIS POKéMON:\n {4} Lv.{5} MaxHP: {6}", - lastPokemon.name,lastPokemon.level,lastPokemon.totalhp, - pkmn.name,pkmn.level,pkmn.totalhp + lastPokemon.name, lastPokemon.level, lastPokemon.totalhp, + pkmn.name, pkmn.level, pkmn.totalhp ) @scene.pbShowHelp(helptext) if pbDisplayConfirm(_INTL("Switch Pokémon?")) @@ -77,11 +77,11 @@ class BugContestBattle < Battle else pbBugContestState.lastPokemon = pkmn end - pbDisplay(_INTL("Caught {1}!",pkmn.name)) + pbDisplay(_INTL("Caught {1}!", pkmn.name)) end def pbEndOfRoundPhase super - @decision = 3 if @ballCount<=0 && @decision==0 + @decision = 3 if @ballCount <= 0 && @decision == 0 end end diff --git a/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb index 180540a85..bb67e2132 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/003_BattlePalaceBattle.rb @@ -60,7 +60,7 @@ class BattlePalaceBattle < Battle def initialize(*arg) super - @justswitched = [false,false,false,false] + @justswitched = [false, false, false, false] @battleAI.battlePalace = true end @@ -76,26 +76,26 @@ class BattlePalaceBattle < Battle end # Different implementation of pbCanChooseMove, ignores Imprison/Torment/Taunt/Disable/Encore - def pbCanChooseMovePartial?(idxPokemon,idxMove) + def pbCanChooseMovePartial?(idxPokemon, idxMove) thispkmn = @battlers[idxPokemon] thismove = thispkmn.moves[idxMove] return false if !thismove - return false if thismove.pp<=0 + return false if thismove.pp <= 0 if thispkmn.effects[PBEffects::ChoiceBand] && - thismove.id!=thispkmn.effects[PBEffects::ChoiceBand] && + thismove.id != thispkmn.effects[PBEffects::ChoiceBand] && thispkmn.hasActiveItem?(:CHOICEBAND) return false end # though incorrect, just for convenience (actually checks Torment later) if thispkmn.effects[PBEffects::Torment] && thispkmn.lastMoveUsed - return false if thismove.id==thispkmn.lastMoveUsed + return false if thismove.id == thispkmn.lastMoveUsed end return true end - def pbRegisterMove(idxBattler,idxMove,_showMessages = true) + def pbRegisterMove(idxBattler, idxMove, _showMessages = true) this_battler = @battlers[idxBattler] - if idxMove==-2 + if idxMove == -2 @choices[idxBattler][0] = :UseMove # "Use move" @choices[idxBattler][1] = -2 # "Incapable of using its power..." @choices[idxBattler][2] = @struggle @@ -117,30 +117,30 @@ class BattlePalaceBattle < Battle defpercent = 0 if this_battler.effects[PBEffects::Pinch] atkpercent = @@BattlePalacePinchTable[nature][0] - defpercent = atkpercent+@@BattlePalacePinchTable[nature][1] + defpercent = atkpercent + @@BattlePalacePinchTable[nature][1] else atkpercent = @@BattlePalaceUsualTable[nature][0] - defpercent = atkpercent+@@BattlePalaceUsualTable[nature][1] + defpercent = atkpercent + @@BattlePalaceUsualTable[nature][1] end - if randnum5 + thispkmn.turnCount && thispkmn.turnCount > 5 shouldswitch = true else - hppercent = thispkmn.hp*100/thispkmn.totalhp + hppercent = thispkmn.hp * 100 / thispkmn.totalhp percents = [] maxindex = -1 maxpercent = 0 factor = 0 - @battle.pbParty(idxBattler).each_with_index do |pkmn,i| - if @battle.pbCanSwitch?(idxBattler,i) - percents[i] = 100*pkmn.hp/pkmn.totalhp - if percents[i]>maxpercent + @battle.pbParty(idxBattler).each_with_index do |pkmn, i| + if @battle.pbCanSwitch?(idxBattler, i) + percents[i] = 100 * pkmn.hp / pkmn.totalhp + if percents[i] > maxpercent maxindex = i maxpercent = percents[i] end @@ -213,11 +213,11 @@ class Battle::AI percents[i] = 0 end end - if hppercent<50 - factor = (maxpercent=0 - @battle.pbRegisterSwitch(idxBattler,maxindex) + shouldswitch = (pbAIRandom(100) < factor) + if shouldswitch && maxindex >= 0 + @battle.pbRegisterSwitch(idxBattler, maxindex) return true end end @justswitched[idxBattler] = shouldswitch if shouldswitch - @battle.pbParty(idxBattler).each_with_index do |_pkmn,i| - next if !@battle.pbCanSwitch?(idxBattler,i) - @battle.pbRegisterSwitch(idxBattler,i) + @battle.pbParty(idxBattler).each_with_index do |_pkmn, i| + next if !@battle.pbCanSwitch?(idxBattler, i) + @battle.pbRegisterSwitch(idxBattler, i) return true end end diff --git a/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb index 6bb157b28..7c2511a3c 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/004_BattleArenaBattle.rb @@ -17,9 +17,9 @@ class Battle::SuccessState end def updateSkill - if @useState==1 + if @useState == 1 @skill = -2 if !@protected - elsif @useState==2 + elsif @useState == 2 if Effectiveness.super_effective?(@typeMod) @skill = 2 elsif Effectiveness.normal?(@typeMod) @@ -43,33 +43,33 @@ class BattleArenaBattle < Battle def initialize(*arg) super @battlersChanged = true - @mind = [0,0] - @skill = [0,0] - @starthp = [0,0] + @mind = [0, 0] + @skill = [0, 0] + @starthp = [0, 0] @count = 0 - @partyindexes = [0,0] + @partyindexes = [0, 0] @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)) + partyScene.pbDisplay(_INTL("{1} can't be switched out!", @battlers[idxBattler].pbThis)) end return false end def pbEORSwitch(favorDraws = false) - return if favorDraws && @decision==5 - return if !favorDraws && @decision>0 + return if favorDraws && @decision == 5 + return if !favorDraws && @decision > 0 pbJudge - return if @decision>0 + return if @decision > 0 for side in 0...2 next if !@battlers[side].fainted? - next if @partyindexes[side]+1>=self.pbParty(side).length + next if @partyindexes[side] + 1 >= self.pbParty(side).length @partyindexes[side] += 1 newpoke = @partyindexes[side] - pbMessagesOnReplace(side,newpoke) - pbReplace(side,newpoke) + pbMessagesOnReplace(side, newpoke) + pbReplace(side, newpoke) pbOnBattlerEnteringBattle(side) end end @@ -97,14 +97,14 @@ class BattleArenaBattle < Battle end def pbMindScore(move) - if move.function=="ProtectUser" || # Detect/Protect - move.function=="UserEnduresFaintingThisTurn" || # Endure - move.function=="FlinchTargetFailsIfNotUserFirstTurn" # Fake Out + if move.function == "ProtectUser" || # Detect/Protect + move.function == "UserEnduresFaintingThisTurn" || # Endure + move.function == "FlinchTargetFailsIfNotUserFirstTurn" # Fake Out return -1 end - if move.function=="CounterPhysicalDamage" || # Counter - move.function=="CounterSpecialDamage" || # Mirror Coat - move.function=="MultiTurnAttackBideThenReturnDoubleDamage" # Bide + if move.function == "CounterPhysicalDamage" || # Counter + move.function == "CounterSpecialDamage" || # Mirror Coat + move.function == "MultiTurnAttackBideThenReturnDoubleDamage" # Bide return 0 end return 0 if move.statusMove? @@ -113,16 +113,16 @@ class BattleArenaBattle < Battle def pbCommandPhase if @battlersChanged - @scene.pbBattleArenaBattlers(@battlers[0],@battlers[1]) + @scene.pbBattleArenaBattlers(@battlers[0], @battlers[1]) @battlersChanged = false @count = 0 end super - return if @decision!=0 + return if @decision != 0 # Update mind rating (asserting that a move was chosen) # TODO: Actually done at Pokémon's turn for side in 0...2 - if @choices[side][2] && @choices[side][0]==:UseMove + if @choices[side][2] && @choices[side][0] == :UseMove @mind[side] += pbMindScore(@choices[side][2]) end end @@ -230,7 +230,7 @@ class Battle::Scene pbGraphicsUpdate end - def updateJudgment(window,phase,battler1,battler2,ratings1,ratings2) + def updateJudgment(window, phase, battler1, battler2, ratings1, ratings2) total1 = 0 total2 = 0 for i in 0...phase @@ -240,50 +240,50 @@ class Battle::Scene window.contents.clear pbSetSystemFont(window.contents) textpos = [ - [battler1.name,64,-6,2,Color.new(248,0,0),Color.new(208,208,200)], - [_INTL("VS"),144,-6,2,Color.new(72,72,72),Color.new(208,208,200)], - [battler2.name,224,-6,2,Color.new(72,72,72),Color.new(208,208,200)], - [_INTL("Mind"),144,42,2,Color.new(72,72,72),Color.new(208,208,200)], - [_INTL("Skill"),144,74,2,Color.new(72,72,72),Color.new(208,208,200)], - [_INTL("Body"),144,106,2,Color.new(72,72,72),Color.new(208,208,200)], - [sprintf("%d",total1),64,154,2,Color.new(72,72,72),Color.new(208,208,200)], - [_INTL("Judgment"),144,154,2,Color.new(72,72,72),Color.new(208,208,200)], - [sprintf("%d",total2),224,154,2,Color.new(72,72,72),Color.new(208,208,200)] + [battler1.name, 64, -6, 2, Color.new(248, 0, 0), Color.new(208, 208, 200)], + [_INTL("VS"), 144, -6, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)], + [battler2.name, 224, -6, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)], + [_INTL("Mind"), 144, 42, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)], + [_INTL("Skill"), 144, 74, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)], + [_INTL("Body"), 144, 106, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)], + [sprintf("%d", total1), 64, 154, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)], + [_INTL("Judgment"), 144, 154, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)], + [sprintf("%d", total2), 224, 154, 2, Color.new(72, 72, 72), Color.new(208, 208, 200)] ] - pbDrawTextPositions(window.contents,textpos) + pbDrawTextPositions(window.contents, textpos) images = [] for i in 0...phase - y = [48,80,112][i] - x = (ratings1[i]==ratings2[i]) ? 64 : ((ratings1[i]>ratings2[i]) ? 0 : 32) - images.push(["Graphics/Pictures/judgment",64-16,y,x,0,32,32]) - x = (ratings1[i]==ratings2[i]) ? 64 : ((ratings1[i] ratings2[i]) ? 0 : 32) + images.push(["Graphics/Pictures/judgment", 64 - 16, y, x, 0, 32, 32]) + x = (ratings1[i] == ratings2[i]) ? 64 : ((ratings1[i] < ratings2[i]) ? 0 : 32) + images.push(["Graphics/Pictures/judgment", 224 - 16, y, x, 0, 32, 32]) end - pbDrawImagePositions(window.contents,images) - window.contents.fill_rect(16,150,256,4,Color.new(80,80,80)) + pbDrawImagePositions(window.contents, images) + window.contents.fill_rect(16, 150, 256, 4, Color.new(80, 80, 80)) end - def pbBattleArenaBattlers(battler1,battler2) + def pbBattleArenaBattlers(battler1, battler2) pbMessage(_INTL("REFEREE: {1} VS {2}!\nCommence battling!\\wtnp[20]", - battler1.name,battler2.name)) { pbBattleArenaUpdate } + battler1.name, battler2.name)) { pbBattleArenaUpdate } end - def pbBattleArenaJudgment(battler1,battler2,ratings1,ratings2) + def pbBattleArenaJudgment(battler1, battler2, ratings1, ratings2) msgwindow = nil dimmingvp = nil infowindow = nil begin msgwindow = pbCreateMessageWindow - dimmingvp = Viewport.new(0,0,Graphics.width,Graphics.height-msgwindow.height) + dimmingvp = Viewport.new(0, 0, Graphics.width, Graphics.height - msgwindow.height) pbMessageDisplay(msgwindow, _INTL("REFEREE: That's it! We will now go to judging to determine the winner!\\wtnp[20]")) { pbBattleArenaUpdate dimmingvp.update } dimmingvp.z = 99999 - infowindow = SpriteWindow_Base.new(80,0,320,224) - infowindow.contents = Bitmap.new(infowindow.width-infowindow.borderX, - infowindow.height-infowindow.borderY) + infowindow = SpriteWindow_Base.new(80, 0, 320, 224) + infowindow.contents = Bitmap.new(infowindow.width - infowindow.borderX, + infowindow.height - infowindow.borderY) infowindow.z = 99999 infowindow.visible = false for i in 0..10 @@ -291,9 +291,9 @@ class Battle::Scene pbInputUpdate msgwindow.update dimmingvp.update - dimmingvp.color = Color.new(0,0,0,i*128/10) + dimmingvp.color = Color.new(0, 0, 0, i * 128 / 10) end - updateJudgment(infowindow,0,battler1,battler2,ratings1,ratings2) + updateJudgment(infowindow, 0, battler1, battler2, ratings1, ratings2) infowindow.visible = true for i in 0..10 pbGraphicsUpdate @@ -302,21 +302,21 @@ class Battle::Scene dimmingvp.update infowindow.update end - updateJudgment(infowindow,1,battler1,battler2,ratings1,ratings2) + updateJudgment(infowindow, 1, battler1, battler2, ratings1, ratings2) pbMessageDisplay(msgwindow, _INTL("REFEREE: Judging category 1, Mind!\nThe Pokémon showing the most guts!\\wtnp[40]")) { pbBattleArenaUpdate dimmingvp.update infowindow.update } - updateJudgment(infowindow,2,battler1,battler2,ratings1,ratings2) + updateJudgment(infowindow, 2, battler1, battler2, ratings1, ratings2) pbMessageDisplay(msgwindow, _INTL("REFEREE: Judging category 2, Skill!\nThe Pokémon using moves the best!\\wtnp[40]")) { pbBattleArenaUpdate dimmingvp.update infowindow.update } - updateJudgment(infowindow,3,battler1,battler2,ratings1,ratings2) + updateJudgment(infowindow, 3, battler1, battler2, ratings1, ratings2) pbMessageDisplay(msgwindow, _INTL("REFEREE: Judging category 3, Body!\nThe Pokémon with the most vitality!\\wtnp[40]")) { pbBattleArenaUpdate @@ -329,17 +329,17 @@ class Battle::Scene total1 += ratings1[i] total2 += ratings2[i] end - if total1==total2 + if total1 == total2 pbMessageDisplay(msgwindow, - _INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]",total1,total2)) { + _INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]", total1, total2)) { pbBattleArenaUpdate dimmingvp.update infowindow.update } - elsif total1>total2 + elsif total1 > total2 pbMessageDisplay(msgwindow, _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}'s {4}!\\wtnp[40]", - total1,total2,@battle.pbGetOwnerName(battler1.index),battler1.name)) { + total1, total2, @battle.pbGetOwnerName(battler1.index), battler1.name)) { pbBattleArenaUpdate dimmingvp.update infowindow.update @@ -347,7 +347,7 @@ class Battle::Scene else pbMessageDisplay(msgwindow, _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}!\\wtnp[40]", - total1,total2,battler2.name)) { + total1, total2, battler2.name)) { pbBattleArenaUpdate dimmingvp.update infowindow.update @@ -360,7 +360,7 @@ class Battle::Scene pbInputUpdate msgwindow.update dimmingvp.update - dimmingvp.color = Color.new(0,0,0,(10-i)*128/10) + dimmingvp.color = Color.new(0, 0, 0, (10 - i) * 128 / 10) end ensure pbDisposeMessageWindow(msgwindow) diff --git a/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb b/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb index b568a85f8..cbb95f042 100644 --- a/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb +++ b/Data/Scripts/011_Battle/007_Other battle types/005_RecordedBattle.rb @@ -31,16 +31,16 @@ module RecordedBattleModule ret = [] for i in 0...trainer.length if trainer[i].is_a?(Player) - ret.push([trainer[i].trainer_type,trainer[i].name.clone,trainer[i].id,trainer[i].badges.clone]) + ret.push([trainer[i].trainer_type, trainer[i].name.clone, trainer[i].id, trainer[i].badges.clone]) else # NPCTrainer - ret.push([trainer[i].trainer_type,trainer[i].name.clone,trainer[i].id]) + ret.push([trainer[i].trainer_type, trainer[i].name.clone, trainer[i].id]) end end return ret elsif trainer[i].is_a?(Player) - return [[trainer.trainer_type,trainer.name.clone,trainer.id,trainer.badges.clone]] + return [[trainer.trainer_type, trainer.name.clone, trainer.id, trainer.badges.clone]] else - return [[trainer.trainer_type,trainer.name.clone,trainer.id]] + return [[trainer.trainer_type, trainer.name.clone, trainer.id]] end end @@ -70,51 +70,51 @@ module RecordedBattleModule end def pbDumpRecord - return Marshal.dump([pbGetBattleType,@properties,@rounds,@randomnumbers,@switches]) + return Marshal.dump([pbGetBattleType, @properties, @rounds, @randomnumbers, @switches]) end - def pbSwitchInBetween(idxBattler,checkLaxOnly = false,canCancel = false) + def pbSwitchInBetween(idxBattler, checkLaxOnly = false, canCancel = false) ret = super @switches.push(ret) return ret end - def pbRegisterMove(idxBattler,idxMove,showMessages = true) + def pbRegisterMove(idxBattler, idxMove, showMessages = true) if super - @rounds[@roundindex][idxBattler] = [Commands::Fight,idxMove] + @rounds[@roundindex][idxBattler] = [Commands::Fight, idxMove] return true end return false end - def pbRegisterTarget(idxBattler,idxTarget) + def pbRegisterTarget(idxBattler, idxTarget) super @rounds[@roundindex][idxBattler][2] = idxTarget end - def pbRun(idxBattler,duringBattle = false) + def pbRun(idxBattler, duringBattle = false) ret = super - @rounds[@roundindex][idxBattler] = [Commands::Run,@decision] + @rounds[@roundindex][idxBattler] = [Commands::Run, @decision] return ret end - def pbAutoChooseMove(idxBattler,showMessages = true) + def pbAutoChooseMove(idxBattler, showMessages = true) ret = super - @rounds[@roundindex][idxBattler] = [Commands::Fight,-1] + @rounds[@roundindex][idxBattler] = [Commands::Fight, -1] return ret end - def pbRegisterSwitch(idxBattler,idxParty) + def pbRegisterSwitch(idxBattler, idxParty) if super - @rounds[@roundindex][idxBattler] = [Commands::Pokemon,idxParty] + @rounds[@roundindex][idxBattler] = [Commands::Pokemon, idxParty] return true end return false end - def pbRegisterItem(idxBattler,item,idxTarget = nil,idxMove = nil) + def pbRegisterItem(idxBattler, item, idxTarget = nil, idxMove = nil) if super - @rounds[@roundindex][idxBattler] = [Commands::Bag,item,idxTarget,idxMove] + @rounds[@roundindex][idxBattler] = [Commands::Bag, item, idxTarget, idxMove] return true end return false @@ -122,7 +122,7 @@ module RecordedBattleModule def pbCommandPhase @roundindex += 1 - @rounds[@roundindex] = [[],[],[],[]] + @rounds[@roundindex] = [[], [], [], []] super end @@ -146,7 +146,7 @@ module RecordedBattlePlaybackModule Run = 3 end - def initialize(scene,battle) + def initialize(scene, battle) @battletype = battle[0] @properties = battle[1] @rounds = battle[2] @@ -183,7 +183,7 @@ module RecordedBattlePlaybackModule super end - def pbSwitchInBetween(_idxBattler,_checkLaxOnly = false,_canCancel = false) + def pbSwitchInBetween(_idxBattler, _checkLaxOnly = false, _canCancel = false) ret = @switches[@switchindex] @switchindex += 1 return ret @@ -203,22 +203,22 @@ module RecordedBattlePlaybackModule return if !isPlayer @roundindex += 1 for i in 0...4 - next if @rounds[@roundindex][i].length==0 + next if @rounds[@roundindex][i].length == 0 pbClearChoice(i) case @rounds[@roundindex][i][0] when Commands::Fight - if @rounds[@roundindex][i][1]==-1 - pbAutoChooseMove(i,false) + if @rounds[@roundindex][i][1] == -1 + pbAutoChooseMove(i, false) else - pbRegisterMove(i,@rounds[@roundindex][i][1]) + pbRegisterMove(i, @rounds[@roundindex][i][1]) end if @rounds[@roundindex][i][2] - pbRegisterTarget(i,@rounds[@roundindex][i][2]) + pbRegisterTarget(i, @rounds[@roundindex][i][2]) end when Commands::Bag - pbRegisterItem(i,@rounds[@roundindex][i][1],@rounds[@roundindex][i][2],@rounds[@roundindex][i][3]) + pbRegisterItem(i, @rounds[@roundindex][i][1], @rounds[@roundindex][i][2], @rounds[@roundindex][i][3]) when Commands::Pokemon - pbRegisterSwitch(i,@rounds[@roundindex][i][1]) + pbRegisterSwitch(i, @rounds[@roundindex][i][1]) when Commands::Run @decision = @rounds[@roundindex][i][1] end diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb index 3e035c196..273618774 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb @@ -4,10 +4,10 @@ class LocationWindow def initialize(name) @window = Window_AdvancedTextPokemon.new(name) - @window.resizeToFit(name,Graphics.width) + @window.resizeToFit(name, Graphics.width) @window.x = 0 @window.y = -@window.height - @window.viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @window.viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @window.viewport.z = 99999 @currentmap = $game_map.map_id @frames = 0 @@ -24,15 +24,15 @@ class LocationWindow def update return if @window.disposed? @window.update - if $game_temp.message_window_showing || @currentmap!=$game_map.map_id + if $game_temp.message_window_showing || @currentmap != $game_map.map_id @window.dispose return end if @frames > Graphics.frame_rate * 2 @window.y -= 4 - @window.dispose if @window.y+@window.height<0 + @window.dispose if @window.y + @window.height < 0 else - @window.y += 4 if @window.y<0 + @window.y += 4 if @window.y < 0 @frames += 1 end end @@ -48,7 +48,7 @@ class DarknessSprite < SpriteWrapper def initialize(viewport = nil) super(viewport) - @darkness = BitmapWrapper.new(Graphics.width,Graphics.height) + @darkness = BitmapWrapper.new(Graphics.width, Graphics.height) @radius = radiusMin self.bitmap = @darkness self.z = 99998 @@ -69,18 +69,18 @@ class DarknessSprite < SpriteWrapper end def refresh - @darkness.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0,255)) - cx = Graphics.width/2 - cy = Graphics.height/2 + @darkness.fill_rect(0, 0, Graphics.width, Graphics.height, Color.new(0, 0, 0, 255)) + cx = Graphics.width / 2 + cy = Graphics.height / 2 cradius = @radius numfades = 5 for i in 1..numfades - for j in cx-cradius..cx+cradius + for j in cx - cradius..cx + cradius diff2 = (cradius * cradius) - ((j - cx) * (j - cx)) diff = Math.sqrt(diff2) - @darkness.fill_rect(j,cy-diff,1,diff*2,Color.new(0,0,0,255.0*(numfades-i)/numfades)) + @darkness.fill_rect(j, cy - diff, 1, diff * 2, Color.new(0, 0, 0, 255.0 * (numfades - i) / numfades)) end - cradius = (cradius*0.9).floor + cradius = (cradius * 0.9).floor end end end @@ -91,10 +91,10 @@ end # Light effects #=============================================================================== class LightEffect - def initialize(event,viewport = nil,map = nil,filename = nil) - @light = IconSprite.new(0,0,viewport) - if filename!=nil && filename!="" && pbResolveBitmap("Graphics/Pictures/"+filename) - @light.setBitmap("Graphics/Pictures/"+filename) + def initialize(event, viewport = nil, map = nil, filename = nil) + @light = IconSprite.new(0, 0, viewport) + if filename != nil && filename != "" && pbResolveBitmap("Graphics/Pictures/" + filename) + @light.setBitmap("Graphics/Pictures/" + filename) else @light.setBitmap("Graphics/Pictures/LE") end @@ -123,10 +123,10 @@ end class LightEffect_Lamp < LightEffect - def initialize(event,viewport = nil,map = nil) + def initialize(event, viewport = nil, map = nil) lamp = AnimatedBitmap.new("Graphics/Pictures/LE") @light = Sprite.new(viewport) - @light.bitmap = Bitmap.new(128,64) + @light.bitmap = Bitmap.new(128, 64) src_rect = Rect.new(0, 0, 64, 64) @light.bitmap.blt(0, 0, lamp.bitmap, src_rect) @light.bitmap.blt(20, 0, lamp.bitmap, src_rect) @@ -177,15 +177,15 @@ class LightEffect_DayNight < LightEffect return if !@light || !@event super shade = PBDayNight.getShade - if shade>=144 # If light enough, call it fully day + if shade >= 144 # If light enough, call it fully day shade = 255 - elsif shade<=64 # If dark enough, call it fully night + elsif shade <= 64 # If dark enough, call it fully night shade = 0 else - shade = 255-(255*(144-shade)/(144-64)) + shade = 255 - (255 * (144 - shade) / (144 - 64)) end - @light.opacity = 255-shade - if @light.opacity>0 + @light.opacity = 255 - shade + if @light.opacity > 0 if (Object.const_defined?(:ScreenPosHelper) rescue false) @light.x = ScreenPosHelper.pbScreenX(@event) @light.y = ScreenPosHelper.pbScreenY(@event) - Game_Map::TILE_HEIGHT / 2 @@ -205,22 +205,22 @@ 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) for i in map.events.keys if map.events[i].name[/^outdoorlight\((\w+)\)$/i] filename = $~[1].to_s - spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],viewport,map,filename)) + spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map, filename)) elsif map.events[i].name[/^outdoorlight$/i] - spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],viewport,map)) + spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i], viewport, map)) elsif map.events[i].name[/^light\((\w+)\)$/i] filename = $~[1].to_s - spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],viewport,map,filename)) + spriteset.addUserSprite(LightEffect_Basic.new(map.events[i], viewport, map, filename)) elsif map.events[i].name[/^light$/i] - spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],viewport,map)) + spriteset.addUserSprite(LightEffect_Basic.new(map.events[i], viewport, map)) end end - spriteset.addUserSprite(Particle_Engine.new(viewport,map)) + spriteset.addUserSprite(Particle_Engine.new(viewport, map)) } diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb index d48a81df6..127a5785b 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/003_Overworld_MapTransitionAnims.rb @@ -3,14 +3,14 @@ #=============================================================================== def pbCaveEntranceEx(exiting) # Create bitmap - sprite = BitmapSprite.new(Graphics.width,Graphics.height) + sprite = BitmapSprite.new(Graphics.width, Graphics.height) sprite.z = 100000 # Define values used for the animation - totalFrames = (Graphics.frame_rate*0.4).floor - increment = (255.0/totalFrames).ceil + totalFrames = (Graphics.frame_rate * 0.4).floor + increment = (255.0 / totalFrames).ceil totalBands = 15 - bandheight = ((Graphics.height/2.0)-10)/totalBands - bandwidth = ((Graphics.width/2.0)-12)/totalBands + bandheight = ((Graphics.height / 2.0) - 10) / totalBands + bandwidth = ((Graphics.width / 2.0) - 12) / totalBands # Create initial array of band colors (black if exiting, white if entering) grays = Array.new(totalBands) { |i| (exiting) ? 0 : 255 } # Animate bands changing color @@ -19,47 +19,47 @@ def pbCaveEntranceEx(exiting) y = 0 # Calculate color of each band for k in 0...totalBands - next if k>=totalBands*j/totalFrames + next if k >= totalBands * j / totalFrames inc = increment inc *= -1 if exiting grays[k] -= inc - grays[k] = 0 if grays[k]<0 + grays[k] = 0 if grays[k] < 0 end # Draw gray rectangles rectwidth = Graphics.width rectheight = Graphics.height for i in 0...totalBands currentGray = grays[i] - sprite.bitmap.fill_rect(Rect.new(x,y,rectwidth,rectheight), - Color.new(currentGray,currentGray,currentGray)) + sprite.bitmap.fill_rect(Rect.new(x, y, rectwidth, rectheight), + Color.new(currentGray, currentGray, currentGray)) x += bandwidth y += bandheight - rectwidth -= bandwidth*2 - rectheight -= bandheight*2 + rectwidth -= bandwidth * 2 + rectheight -= bandheight * 2 end Graphics.update Input.update end # Set the tone at end of band animation if exiting - pbToneChangeAll(Tone.new(255,255,255),0) + pbToneChangeAll(Tone.new(255, 255, 255), 0) else - pbToneChangeAll(Tone.new(-255,-255,-255),0) + pbToneChangeAll(Tone.new(-255, -255, -255), 0) end # Animate fade to white (if exiting) or black (if entering) for j in 0...totalFrames if exiting - sprite.color = Color.new(255,255,255,j*increment) + sprite.color = Color.new(255, 255, 255, j * increment) else - sprite.color = Color.new(0,0,0,j*increment) + sprite.color = Color.new(0, 0, 0, j * increment) end Graphics.update Input.update end # Set the tone at end of fading animation - pbToneChangeAll(Tone.new(0,0,0),8) + pbToneChangeAll(Tone.new(0, 0, 0), 8) # Pause briefly - (Graphics.frame_rate/10).times do + (Graphics.frame_rate / 10).times do Graphics.update Input.update end @@ -88,7 +88,7 @@ def pbStartOver(gameover = false) end $stats.blacked_out_count += 1 $player.heal_party - if $PokemonGlobal.pokecenterMapId && $PokemonGlobal.pokecenterMapId>=0 + if $PokemonGlobal.pokecenterMapId && $PokemonGlobal.pokecenterMapId >= 0 if gameover pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]After the unfortunate defeat, you scurry back to a Pokémon Center.")) else @@ -106,9 +106,9 @@ def pbStartOver(gameover = false) else homedata = GameData::PlayerMetadata.get($player.character_ID)&.home homedata = GameData::Metadata.get.home if !homedata - if homedata && !pbRgssExists?(sprintf("Data/Map%03d.rxdata",homedata[0])) + if homedata && !pbRgssExists?(sprintf("Data/Map%03d.rxdata", homedata[0])) if $DEBUG - pbMessage(_ISPRINTF("Can't find the map 'Map{1:03d}' in the Data folder. The game will resume at the player's position.",homedata[0])) + pbMessage(_ISPRINTF("Can't find the map 'Map{1:03d}' in the Data folder. The game will resume at the player's position.", homedata[0])) end $player.heal_party return diff --git a/Data/Scripts/012_Overworld/001_Overworld.rb b/Data/Scripts/012_Overworld/001_Overworld.rb index 704c806ae..dfaf908c5 100644 --- a/Data/Scripts/012_Overworld/001_Overworld.rb +++ b/Data/Scripts/012_Overworld/001_Overworld.rb @@ -2,11 +2,11 @@ # Constant checks #=============================================================================== # Pokérus check -Events.onMapUpdate += proc { |_sender,_e| +Events.onMapUpdate += proc { |_sender, _e| next if !$player last = $PokemonGlobal.pokerusTime now = pbGetTimeNow - if !last || last.year!=now.year || last.month!=now.month || last.day!=now.day + if !last || last.year != now.year || last.month != now.month || last.day != now.day for i in $player.pokemon_party i.lowerPokerusCount end @@ -19,7 +19,7 @@ Events.onMapUpdate += proc { |_sender,_e| def pbPokerus? return false if $game_switches[Settings::SEEN_POKERUS_SWITCH] for i in $player.party - return true if i.pokerusStage==1 + return true if i.pokerusStage == 1 end return false end @@ -46,12 +46,12 @@ def pbBatteryLow? return false end -Events.onMapUpdate += proc { |_sender,_e| +Events.onMapUpdate += proc { |_sender, _e| if !$game_temp.warned_low_battery && pbBatteryLow? if !$game_temp.in_menu && !$game_temp.in_battle && !$game_player.move_route_forcing && !$game_temp.message_window_showing && !pbMapInterpreterRunning? - if pbGetTimeNow.sec==0 + if pbGetTimeNow.sec == 0 pbMessage(_INTL("The game has detected that the battery is low. You should save soon to avoid losing your progress.")) $game_temp.warned_low_battery = true end @@ -77,19 +77,19 @@ Events.onMapUpdate += proc { |_sender,_e| Events.onStepTaken += proc { $PokemonGlobal.happinessSteps = 0 if !$PokemonGlobal.happinessSteps $PokemonGlobal.happinessSteps += 1 - if $PokemonGlobal.happinessSteps>=128 + if $PokemonGlobal.happinessSteps >= 128 for pkmn in $player.able_party - pkmn.changeHappiness("walking") if rand(2)==0 + pkmn.changeHappiness("walking") if rand(2) == 0 end $PokemonGlobal.happinessSteps = 0 end } # 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 && Settings::POISON_IN_FIELD + if $PokemonGlobal.stepcount % 4 == 0 && Settings::POISON_IN_FIELD flashed = false for i in $player.able_party if i.status == :POISON && !i.hasAbility?(:IMMUNITY) @@ -97,15 +97,15 @@ Events.onStepTakenTransferPossible += proc { |_sender,e| pbFlash(Color.new(255, 0, 0, 128), 8) flashed = true end - i.hp -= 1 if i.hp>1 || Settings::POISON_FAINT_IN_FIELD - if i.hp==1 && !Settings::POISON_FAINT_IN_FIELD + i.hp -= 1 if i.hp > 1 || Settings::POISON_FAINT_IN_FIELD + if i.hp == 1 && !Settings::POISON_FAINT_IN_FIELD i.status = :NONE - pbMessage(_INTL("{1} survived the poisoning.\\nThe poison faded away!\1",i.name)) + pbMessage(_INTL("{1} survived the poisoning.\\nThe poison faded away!\1", i.name)) next - elsif i.hp==0 + elsif i.hp == 0 i.changeHappiness("faint") i.status = :NONE - pbMessage(_INTL("{1} fainted...",i.name)) + pbMessage(_INTL("{1} fainted...", i.name)) end if $player.able_pokemon_count == 0 handled[0] = true @@ -127,12 +127,12 @@ 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 = $map_factory.getRealTilePos(event.map.map_id,event.x,event.y) + thistile = $map_factory.getRealTilePos(event.map.map_id, event.x, event.y) map = $map_factory.getMap(thistile[0]) for i in [2, 1, 0] - tile_id = map.data[thistile[1],thistile[2],i] + tile_id = map.data[thistile[1], thistile[2], i] next if tile_id == nil next if GameData::TerrainTag.try_get(map.terrain_tags[tile_id]).id != :SootGrass if event == $game_player && $bag.has?(:SOOTSACK) @@ -167,7 +167,7 @@ Events.onStepTakenFieldMovement += proc { |_sender, e| def pbOnStepTaken(eventTriggered) if $game_player.move_route_forcing || pbMapInterpreterRunning? - Events.onStepTakenFieldMovement.trigger(nil,$game_player) + Events.onStepTakenFieldMovement.trigger(nil, $game_player) return end $PokemonGlobal.stepcount = 0 if !$PokemonGlobal.stepcount @@ -177,7 +177,7 @@ def pbOnStepTaken(eventTriggered) Events.onStepTaken.trigger(nil) # Events.onStepTakenFieldMovement.trigger(nil,$game_player) handled = [nil] - Events.onStepTakenTransferPossible.trigger(nil,handled) + Events.onStepTakenTransferPossible.trigger(nil, handled) return if handled[0] pbBattleOnStepTaken(repel_active) if !eventTriggered && !$game_temp.in_menu $game_temp.encounter_triggered = false # This info isn't needed here @@ -311,9 +311,9 @@ Events.onMapSceneChange += proc { |_sender, e| # Event locations, terrain tags #=============================================================================== # NOTE: Assumes the event is 1x1 tile in size. Only returns one tile. -def pbFacingTile(direction = nil,event = nil) - return $map_factory.getFacingTile(direction,event) if $map_factory - return pbFacingTileRegular(direction,event) +def pbFacingTile(direction = nil, event = nil) + return $map_factory.getFacingTile(direction, event) if $map_factory + return pbFacingTileRegular(direction, event) end # NOTE: Assumes the event is 1x1 tile in size. Only returns one tile. @@ -395,11 +395,11 @@ end #=============================================================================== # Audio playing #=============================================================================== -def pbCueBGM(bgm,seconds,volume = nil,pitch = nil) +def pbCueBGM(bgm, seconds, volume = nil, pitch = nil) return if !bgm - bgm = pbResolveAudioFile(bgm,volume,pitch) + bgm = pbResolveAudioFile(bgm, volume, pitch) playingBGM = $game_system.playing_bgm - if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch + if !playingBGM || playingBGM.name != bgm.name || playingBGM.pitch != bgm.pitch pbBGMFade(seconds) if !$game_temp.cue_bgm_frame_delay $game_temp.cue_bgm_frame_delay = (seconds * Graphics.frame_rate) * 3 / 5 @@ -484,30 +484,30 @@ end -def pbMoveRoute(event,commands,waitComplete = false) +def pbMoveRoute(event, commands, waitComplete = false) route = RPG::MoveRoute.new route.repeat = false route.skippable = true route.list.clear route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn)) - i=0 - while i1) ? item.name_plural : item.name + return false if !item || quantity < 1 + itemname = (quantity > 1) ? item.name_plural : item.name pocket = item.pocket move = item.move if $bag.add(item, quantity) # If item can be picked up meName = (item.is_key_item?) ? "Key item get" : "Item get" if item == :LEFTOVERS - pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You found some \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) elsif item == :DNASPLICERS - pbMessage(_INTL("\\me[{1}]You found \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You found \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) elsif item.is_machine? # TM or HM - pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,GameData::Move.get(move).name)) - elsif quantity>1 - pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname)) + pbMessage(_INTL("\\me[{1}]You found \\c[1]{2} {3}\\c[0]!\\wtnp[30]", meName, itemname, GameData::Move.get(move).name)) + elsif quantity > 1 + pbMessage(_INTL("\\me[{1}]You found {2} \\c[1]{3}\\c[0]!\\wtnp[30]", meName, quantity, itemname)) elsif itemname.starts_with_vowel? - pbMessage(_INTL("\\me[{1}]You found an \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You found an \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) else - pbMessage(_INTL("\\me[{1}]You found a \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You found a \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) end pbMessage(_INTL("You put the {1} in\\nyour Bag's \\c[1]{3}\\c[0] pocket.", itemname, pocket, PokemonBag.pocket_names[pocket - 1])) @@ -733,15 +733,15 @@ def pbItemBall(item,quantity = 1) end # Can't add the item if item == :LEFTOVERS - pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) + pbMessage(_INTL("You found some \\c[1]{1}\\c[0]!\\wtnp[30]", itemname)) elsif item.is_machine? # TM or HM - pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,GameData::Move.get(move).name)) - elsif quantity>1 - pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]",quantity,itemname)) + pbMessage(_INTL("You found \\c[1]{1} {2}\\c[0]!\\wtnp[30]", itemname, GameData::Move.get(move).name)) + elsif quantity > 1 + pbMessage(_INTL("You found {1} \\c[1]{2}\\c[0]!\\wtnp[30]", quantity, itemname)) elsif itemname.starts_with_vowel? - pbMessage(_INTL("You found an \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) + pbMessage(_INTL("You found an \\c[1]{1}\\c[0]!\\wtnp[30]", itemname)) else - pbMessage(_INTL("You found a \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) + pbMessage(_INTL("You found a \\c[1]{1}\\c[0]!\\wtnp[30]", itemname)) end pbMessage(_INTL("But your Bag is full...")) return false @@ -752,25 +752,25 @@ end #=============================================================================== # Being given an item #=============================================================================== -def pbReceiveItem(item,quantity = 1) +def pbReceiveItem(item, quantity = 1) item = GameData::Item.get(item) - return false if !item || quantity<1 - itemname = (quantity>1) ? item.name_plural : item.name + return false if !item || quantity < 1 + itemname = (quantity > 1) ? item.name_plural : item.name pocket = item.pocket move = item.move meName = (item.is_key_item?) ? "Key item get" : "Item get" if item == :LEFTOVERS - pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You obtained some \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) elsif item == :DNASPLICERS - pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) elsif item.is_machine? # TM or HM - pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]",meName,itemname,GameData::Move.get(move).name)) - elsif quantity>1 - pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]",meName,quantity,itemname)) + pbMessage(_INTL("\\me[{1}]You obtained \\c[1]{2} {3}\\c[0]!\\wtnp[30]", meName, itemname, GameData::Move.get(move).name)) + elsif quantity > 1 + pbMessage(_INTL("\\me[{1}]You obtained {2} \\c[1]{3}\\c[0]!\\wtnp[30]", meName, quantity, itemname)) elsif itemname.starts_with_vowel? - pbMessage(_INTL("\\me[{1}]You obtained an \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You obtained an \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) else - pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]",meName,itemname)) + pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]", meName, itemname)) end if $bag.add(item, quantity) # If item can be added pbMessage(_INTL("You put the {1} in\\nyour Bag's \\c[1]{3}\\c[0] pocket.", diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb index 90de30bf5..5f9f9cfb5 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/001_Overworld_BattleStarting.rb @@ -80,7 +80,7 @@ def setBattleRule(*args) $game_temp.add_battle_rule(arg) end end - raise _INTL("Argument {1} expected a variable after it but didn't have one.",r) if r + raise _INTL("Argument {1} expected a variable after it but didn't have one.", r) if r end def pbNewBattleScene @@ -103,10 +103,10 @@ def pbPrepareBattle(battle) # Whether the player gains/loses money at the end of the battle (default: true) battle.moneyGain = battleRules["moneyGain"] if !battleRules["moneyGain"].nil? # Whether the player is able to switch when an opponent's Pokémon faints - battle.switchStyle = ($PokemonSystem.battlestyle==0) + battle.switchStyle = ($PokemonSystem.battlestyle == 0) battle.switchStyle = battleRules["switchStyle"] if !battleRules["switchStyle"].nil? # Whether battle animations are shown - battle.showAnims = ($PokemonSystem.battlescene==0) + battle.showAnims = ($PokemonSystem.battlescene == 0) battle.showAnims = battleRules["battleAnims"] if !battleRules["battleAnims"].nil? # Terrain battle.defaultTerrain = battleRules["defaultTerrain"] if !battleRules["defaultTerrain"].nil? @@ -219,7 +219,7 @@ def pbWildBattleCore(*args) # Skip battle if the player has no able Pokémon, or if holding Ctrl in Debug mode if $player.able_pokemon_count == 0 || ($DEBUG && Input.press?(Input::CTRL)) pbMessage(_INTL("SKIPPING BATTLE...")) if $player.pokemon_count > 0 - pbSet(outcomeVar,1) # Treat it as a win + pbSet(outcomeVar, 1) # Treat it as a win $game_temp.clear_battle_rules $PokemonGlobal.nextBattleBGM = nil $PokemonGlobal.nextBattleME = nil @@ -239,18 +239,18 @@ def pbWildBattleCore(*args) foeParty.push(arg) elsif arg.is_a?(Array) species = GameData::Species.get(arg[0]).id - pkmn = pbGenerateWildPokemon(species,arg[1]) + pkmn = pbGenerateWildPokemon(species, arg[1]) foeParty.push(pkmn) elsif sp species = GameData::Species.get(sp).id - pkmn = pbGenerateWildPokemon(species,arg) + pkmn = pbGenerateWildPokemon(species, arg) foeParty.push(pkmn) sp = nil else sp = arg end end - raise _INTL("Expected a level after being given {1}, but one wasn't found.",sp) if sp + raise _INTL("Expected a level after being given {1}, but one wasn't found.", sp) if sp # Calculate who the trainers and their party are playerTrainers = [$player] playerParty = $player.party @@ -261,7 +261,7 @@ def pbWildBattleCore(*args) room_for_partner = true end if $PokemonGlobal.partner && !$game_temp.battle_rules["noPartner"] && room_for_partner - ally = NPCTrainer.new($PokemonGlobal.partner[1],$PokemonGlobal.partner[0]) + ally = NPCTrainer.new($PokemonGlobal.partner[1], $PokemonGlobal.partner[0]) ally.id = $PokemonGlobal.partner[2] ally.party = $PokemonGlobal.partner[3] playerTrainers.push(ally) @@ -274,18 +274,18 @@ def pbWildBattleCore(*args) # Create the battle scene (the visual side of it) scene = pbNewBattleScene # Create the battle class (the mechanics side of it) - battle = Battle.new(scene,playerParty,foeParty,playerTrainers,nil) + battle = Battle.new(scene, playerParty, foeParty, playerTrainers, nil) battle.party1starts = playerPartyStarts # Set various other properties in the battle class pbPrepareBattle(battle) $game_temp.clear_battle_rules # Perform the battle itself decision = 0 - pbBattleAnimation(pbGetWildBattleBGM(foeParty),(foeParty.length==1) ? 0 : 2,foeParty) { + pbBattleAnimation(pbGetWildBattleBGM(foeParty), (foeParty.length == 1) ? 0 : 2, foeParty) { pbSceneStandby { decision = battle.pbStartBattle } - pbAfterBattle(decision,canLose) + pbAfterBattle(decision, canLose) } Input.update # Save the result of the battle in a Game Variable (1 by default) @@ -301,7 +301,7 @@ def pbWildBattleCore(*args) when 2, 3, 5 # Lost, fled, draw $stats.wild_battles_lost += 1 end - pbSet(outcomeVar,decision) + pbSet(outcomeVar, decision) return decision end @@ -314,44 +314,44 @@ def pbWildBattle(species, level, outcomeVar = 1, canRun = true, canLose = false) # Potentially call a different pbWildBattle-type method instead (for roaming # Pokémon, Safari battles, Bug Contest battles) handled = [nil] - Events.onWildBattleOverride.trigger(nil,species,level,handled) - return handled[0] if handled[0]!=nil + Events.onWildBattleOverride.trigger(nil, species, level, handled) + return handled[0] if handled[0] != nil # Set some battle rules - setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1 + setBattleRule("outcomeVar", outcomeVar) if outcomeVar != 1 setBattleRule("cannotRun") if !canRun setBattleRule("canLose") if canLose # Perform the battle decision = pbWildBattleCore(species, level) # Used by the Poké Radar to update/break the chain - Events.onWildBattleEnd.trigger(nil,species,level,decision) + Events.onWildBattleEnd.trigger(nil, species, level, decision) # Return false if the player lost or drew the battle, and true if any other result - return (decision!=2 && decision!=5) + return (decision != 2 && decision != 5) end def pbDoubleWildBattle(species1, level1, species2, level2, outcomeVar = 1, canRun = true, canLose = false) # Set some battle rules - setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1 + setBattleRule("outcomeVar", outcomeVar) if outcomeVar != 1 setBattleRule("cannotRun") if !canRun setBattleRule("canLose") if canLose setBattleRule("double") # Perform the battle decision = pbWildBattleCore(species1, level1, species2, level2) # Return false if the player lost or drew the battle, and true if any other result - return (decision!=2 && decision!=5) + return (decision != 2 && decision != 5) end def pbTripleWildBattle(species1, level1, species2, level2, species3, level3, outcomeVar = 1, canRun = true, canLose = false) # Set some battle rules - setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1 + setBattleRule("outcomeVar", outcomeVar) if outcomeVar != 1 setBattleRule("cannotRun") if !canRun setBattleRule("canLose") if canLose setBattleRule("triple") # Perform the battle decision = pbWildBattleCore(species1, level1, species2, level2, species3, level3) # Return false if the player lost or drew the battle, and true if any other result - return (decision!=2 && decision!=5) + return (decision != 2 && decision != 5) end #=============================================================================== @@ -390,10 +390,10 @@ def pbTrainerBattleCore(*args) foeEndSpeeches.push(arg.lose_text) foeItems.push(arg.items) elsif arg.is_a?(Array) # [trainer type, trainer name, ID, speech (optional)] - trainer = pbLoadTrainer(arg[0],arg[1],arg[2]) - pbMissingTrainer(arg[0],arg[1],arg[2]) if !trainer + trainer = pbLoadTrainer(arg[0], arg[1], arg[2]) + pbMissingTrainer(arg[0], arg[1], arg[2]) if !trainer return 0 if !trainer - Events.onTrainerPartyLoad.trigger(nil,trainer) + Events.onTrainerPartyLoad.trigger(nil, trainer) foeTrainers.push(trainer) foePartyStarts.push(foeParty.length) trainer.party.each { |pkmn| foeParty.push(pkmn) } @@ -426,7 +426,7 @@ def pbTrainerBattleCore(*args) # Create the battle scene (the visual side of it) scene = pbNewBattleScene # Create the battle class (the mechanics side of it) - battle = Battle.new(scene,playerParty,foeParty,playerTrainers,foeTrainers) + battle = Battle.new(scene, playerParty, foeParty, playerTrainers, foeTrainers) battle.party1starts = playerPartyStarts battle.party2starts = foePartyStarts battle.items = foeItems @@ -438,11 +438,11 @@ def pbTrainerBattleCore(*args) Audio.me_stop # Perform the battle itself decision = 0 - pbBattleAnimation(pbGetTrainerBattleBGM(foeTrainers),(battle.singleBattle?) ? 1 : 3,foeTrainers) { + pbBattleAnimation(pbGetTrainerBattleBGM(foeTrainers), (battle.singleBattle?) ? 1 : 3, foeTrainers) { pbSceneStandby { decision = battle.pbStartBattle } - pbAfterBattle(decision,canLose) + pbAfterBattle(decision, canLose) } Input.update # Save the result of the battle in a Game Variable (1 by default) @@ -457,7 +457,7 @@ def pbTrainerBattleCore(*args) when 2, 3, 5 # Lost, fled, draw $stats.trainer_battles_lost += 1 end - pbSet(outcomeVar,decision) + pbSet(outcomeVar, decision) return decision end @@ -480,18 +480,18 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech = nil, ($player.able_pokemon_count > 0 && $PokemonGlobal.partner)) thisEvent = pbMapInterpreter.get_self # Find all other triggered trainer events - triggeredEvents = $game_player.pbTriggeredTrainerEvents([2],false) + triggeredEvents = $game_player.pbTriggeredTrainerEvents([2], false) otherEvent = [] for i in triggeredEvents - next if i.id==thisEvent.id - next if $game_self_switches[[$game_map.map_id,i.id,"A"]] + next if i.id == thisEvent.id + next if $game_self_switches[[$game_map.map_id, i.id, "A"]] otherEvent.push(i) end # Load the trainer's data, and call an event which might modify it - trainer = pbLoadTrainer(trainerID,trainerName,trainerPartyID) - pbMissingTrainer(trainerID,trainerName,trainerPartyID) if !trainer + trainer = pbLoadTrainer(trainerID, trainerName, trainerPartyID) + pbMissingTrainer(trainerID, trainerName, trainerPartyID) if !trainer return false if !trainer - Events.onTrainerPartyLoad.trigger(nil,trainer) + Events.onTrainerPartyLoad.trigger(nil, trainer) # If there is exactly 1 other triggered trainer event, and this trainer has # 6 or fewer Pokémon, record this trainer for a double battle caused by the # other triggered trainer event @@ -502,40 +502,40 @@ def pbTrainerBattle(trainerID, trainerName, endSpeech = nil, end end # Set some battle rules - setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1 + setBattleRule("outcomeVar", outcomeVar) if outcomeVar != 1 setBattleRule("canLose") if canLose setBattleRule("double") if doubleBattle || $game_temp.waiting_trainer # Perform the battle if $game_temp.waiting_trainer decision = pbTrainerBattleCore($game_temp.waiting_trainer[0], - [trainerID,trainerName,trainerPartyID,endSpeech] + [trainerID, trainerName, trainerPartyID, endSpeech] ) else - decision = pbTrainerBattleCore([trainerID,trainerName,trainerPartyID,endSpeech]) + decision = pbTrainerBattleCore([trainerID, trainerName, trainerPartyID, endSpeech]) end # Finish off the recorded waiting trainer, because they have now been battled - if decision==1 && $game_temp.waiting_trainer # Win + if decision == 1 && $game_temp.waiting_trainer # Win pbMapInterpreter.pbSetSelfSwitch($game_temp.waiting_trainer[1], "A", true) end $game_temp.waiting_trainer = nil # Return true if the player won the battle, and false if any other result - return (decision==1) + return (decision == 1) end def pbDoubleTrainerBattle(trainerID1, trainerName1, trainerPartyID1, endSpeech1, trainerID2, trainerName2, trainerPartyID2 = 0, endSpeech2 = nil, canLose = false, outcomeVar = 1) # Set some battle rules - setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1 + setBattleRule("outcomeVar", outcomeVar) if outcomeVar != 1 setBattleRule("canLose") if canLose setBattleRule("double") # Perform the battle decision = pbTrainerBattleCore( - [trainerID1,trainerName1,trainerPartyID1,endSpeech1], - [trainerID2,trainerName2,trainerPartyID2,endSpeech2] + [trainerID1, trainerName1, trainerPartyID1, endSpeech1], + [trainerID2, trainerName2, trainerPartyID2, endSpeech2] ) # Return true if the player won the battle, and false if any other result - return (decision==1) + return (decision == 1) end def pbTripleTrainerBattle(trainerID1, trainerName1, trainerPartyID1, endSpeech1, @@ -543,23 +543,23 @@ def pbTripleTrainerBattle(trainerID1, trainerName1, trainerPartyID1, endSpeech1, trainerID3, trainerName3, trainerPartyID3 = 0, endSpeech3 = nil, canLose = false, outcomeVar = 1) # Set some battle rules - setBattleRule("outcomeVar",outcomeVar) if outcomeVar!=1 + setBattleRule("outcomeVar", outcomeVar) if outcomeVar != 1 setBattleRule("canLose") if canLose setBattleRule("triple") # Perform the battle decision = pbTrainerBattleCore( - [trainerID1,trainerName1,trainerPartyID1,endSpeech1], - [trainerID2,trainerName2,trainerPartyID2,endSpeech2], - [trainerID3,trainerName3,trainerPartyID3,endSpeech3] + [trainerID1, trainerName1, trainerPartyID1, endSpeech1], + [trainerID2, trainerName2, trainerPartyID2, endSpeech2], + [trainerID3, trainerName3, trainerPartyID3, endSpeech3] ) # Return true if the player won the battle, and false if any other result - return (decision==1) + return (decision == 1) end #=============================================================================== # After battles #=============================================================================== -def pbAfterBattle(decision,canLose) +def pbAfterBattle(decision, canLose) $player.party.each do |pkmn| pkmn.statusCount = 0 if pkmn.status == :POISON # Bad poison becomes regular pkmn.makeUnmega @@ -573,22 +573,22 @@ def pbAfterBattle(decision,canLose) pkmn.makeUnprimal end end - if decision==2 || decision==5 # if loss or draw + if decision == 2 || decision == 5 # if loss or draw if canLose $player.party.each { |pkmn| pkmn.heal } - (Graphics.frame_rate/4).times { Graphics.update } + (Graphics.frame_rate / 4).times { Graphics.update } end end - Events.onEndBattle.trigger(nil,decision,canLose) + Events.onEndBattle.trigger(nil, decision, canLose) $game_player.straighten end -Events.onEndBattle += proc { |_sender,e| +Events.onEndBattle += proc { |_sender, e| decision = e[0] canLose = e[1] # Check for evolutions pbEvolutionCheck if Settings::CHECK_EVOLUTION_AFTER_ALL_BATTLES || - (decision!=2 && decision!=5) # not a loss or a draw + (decision != 2 && decision != 5) # not a loss or a draw $game_temp.party_levels_before_battle = nil $game_temp.party_critical_hits_dealt = nil $game_temp.party_direct_damage_taken = nil @@ -642,7 +642,7 @@ end def pbPickup(pkmn) return if pkmn.egg? || !pkmn.hasAbility?(:PICKUP) return if pkmn.hasItem? - return unless rand(100)<10 # 10% chance + return unless rand(100) < 10 # 10% chance # Common items to find (9 items from this list are added to the pool) pickupList = pbDynamicItemList( :POTION, @@ -678,29 +678,29 @@ def pbPickup(pkmn) :LEFTOVERS, :DESTINYKNOT ) - return if pickupList.length<18 - return if pickupListRare.length<11 + return if pickupList.length < 18 + return if pickupListRare.length < 11 # Generate a pool of items depending on the Pokémon's level items = [] - pkmnLevel = [100,pkmn.level].min - itemStartIndex = (pkmnLevel-1)/10 - itemStartIndex = 0 if itemStartIndex<0 + pkmnLevel = [100, pkmn.level].min + itemStartIndex = (pkmnLevel - 1) / 10 + itemStartIndex = 0 if itemStartIndex < 0 for i in 0...9 - items.push(pickupList[itemStartIndex+i]) + items.push(pickupList[itemStartIndex + i]) end for i in 0...2 - items.push(pickupListRare[itemStartIndex+i]) + items.push(pickupListRare[itemStartIndex + i]) end # Probabilities of choosing each item in turn from the pool - chances = [30,10,10,10,10,10,10,4,4,1,1] # Needs to be 11 numbers + chances = [30, 10, 10, 10, 10, 10, 10, 4, 4, 1, 1] # Needs to be 11 numbers chanceSum = 0 chances.each { |c| chanceSum += c } # Randomly choose an item from the pool to give to the Pokémon rnd = rand(chanceSum) cumul = 0 - chances.each_with_index do |c,i| + chances.each_with_index do |c, i| cumul += c - next if rnd>=cumul + next if rnd >= cumul pkmn.item = items[i] break end diff --git a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb index 68400ae0e..c95cc593f 100644 --- a/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb +++ b/Data/Scripts/012_Overworld/002_Battle triggering/002_Overworld_BattleIntroAnim.rb @@ -39,9 +39,9 @@ def pbSceneStandby $scene.createSpritesets if $scene && $scene.is_a?(Scene_Map) end -def pbBattleAnimation(bgm = nil,battletype = 0,foe = nil) +def pbBattleAnimation(bgm = nil, battletype = 0, foe = nil) $game_temp.in_battle = true - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 # Set up audio playingBGS = nil @@ -53,7 +53,7 @@ def pbBattleAnimation(bgm = nil,battletype = 0,foe = nil) $game_system.bgs_pause end pbMEFade(0.25) - pbWait(Graphics.frame_rate/4) + pbWait(Graphics.frame_rate / 4) pbMEStop # Play battle music bgm = pbGetWildBattleBGM([]) if !bgm @@ -83,34 +83,34 @@ def pbBattleAnimation(bgm = nil,battletype = 0,foe = nil) if PBDayNight.isDay? case battletype when 0, 2 # Wild, double wild - anim = ["SnakeSquares","DiagonalBubbleTL","DiagonalBubbleBR","RisingSplash"][location] + anim = ["SnakeSquares", "DiagonalBubbleTL", "DiagonalBubbleBR", "RisingSplash"][location] when 1 # Trainer - anim = ["TwoBallPass","ThreeBallDown","BallDown","WavyThreeBallUp"][location] + anim = ["TwoBallPass", "ThreeBallDown", "BallDown", "WavyThreeBallUp"][location] when 3 # Double trainer anim = "FourBallBurst" end else case battletype when 0, 2 # Wild, double wild - anim = ["SnakeSquares","DiagonalBubbleBR","DiagonalBubbleBR","RisingSplash"][location] + anim = ["SnakeSquares", "DiagonalBubbleBR", "DiagonalBubbleBR", "RisingSplash"][location] when 1 # Trainer - anim = ["SpinBallSplit","BallDown","BallDown","WavySpinBall"][location] + anim = ["SpinBallSplit", "BallDown", "BallDown", "WavySpinBall"][location] when 3 # Double trainer anim = "FourBallBurst" end end # Initial screen flashing - if location==2 || PBDayNight.isNight? - viewport.color = Color.new(0,0,0) # Fade to black a few times + if location == 2 || PBDayNight.isNight? + viewport.color = Color.new(0, 0, 0) # Fade to black a few times else - viewport.color = Color.new(255,255,255) # Fade to white a few times + viewport.color = Color.new(255, 255, 255) # Fade to white a few times end - halfFlashTime = Graphics.frame_rate*2/10 # 0.2 seconds, 8 frames - alphaDiff = (255.0/halfFlashTime).ceil + halfFlashTime = Graphics.frame_rate * 2 / 10 # 0.2 seconds, 8 frames + alphaDiff = (255.0 / halfFlashTime).ceil 2.times do viewport.color.alpha = 0 - for i in 0...halfFlashTime*2 - if i0 && !$game_switches[roamData[2]] # Game Switch is off + return if roamData[2] > 0 && !$game_switches[roamData[2]] # Game Switch is off return if !GameData::Species.exists?(roamData[0]) # Get hash of area patrolled by the roaming Pokémon mapIDs = pbRoamingAreas(idxRoamer).keys - return if !mapIDs || mapIDs.length==0 # No roaming area defined somehow + return if !mapIDs || mapIDs.length == 0 # No roaming area defined somehow # Get the roaming Pokémon's current map currentMap = $PokemonGlobal.roamPosition[idxRoamer] if !currentMap @@ -82,23 +82,23 @@ def pbRoamPokemonOne(idxRoamer) newMapChoices.push(map) end # Rarely, add a random possible map into the mix - if rand(32)==0 + if rand(32) == 0 newMapChoices.push(mapIDs[rand(mapIDs.length)]) end # Choose a random new map to roam to - if newMapChoices.length>0 + if newMapChoices.length > 0 $PokemonGlobal.roamPosition[idxRoamer] = newMapChoices[rand(newMapChoices.length)] end 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 = pbLoadMapInfos - next if mapInfos && oldMapID>0 && mapInfos[oldMapID] && - mapInfos[oldMapID].name && $game_map.name==mapInfos[oldMapID].name + next if mapInfos && oldMapID > 0 && mapInfos[oldMapID] && + mapInfos[oldMapID].name && $game_map.name == mapInfos[oldMapID].name # Make roaming Pokémon roam pbRoamPokemon $PokemonGlobal.roamedAlready = false @@ -185,11 +185,11 @@ EncounterModifier.register(proc { |encounter| next [roamer[1], roamer[2]] # Species, level }) -Events.onWildBattleOverride += proc { |_sender,e| +Events.onWildBattleOverride += proc { |_sender, e| species = e[0] level = e[1] handled = e[2] - next if handled[0]!=nil + next if handled[0] != nil next if !$PokemonGlobal.roamEncounter || $game_temp.roamer_index_for_encounter.nil? handled[0] = pbRoamingPokemonBattle(species, level) } @@ -200,7 +200,7 @@ def pbRoamingPokemonBattle(species, level) idxRoamer = $game_temp.roamer_index_for_encounter if !$PokemonGlobal.roamPokemon[idxRoamer] || !$PokemonGlobal.roamPokemon[idxRoamer].is_a?(Pokemon) - $PokemonGlobal.roamPokemon[idxRoamer] = pbGenerateWildPokemon(species,level,true) + $PokemonGlobal.roamPokemon[idxRoamer] = pbGenerateWildPokemon(species, level, true) end # Set some battle rules setBattleRule("single") @@ -208,16 +208,16 @@ def pbRoamingPokemonBattle(species, level) # Perform the battle decision = pbWildBattleCore($PokemonGlobal.roamPokemon[idxRoamer]) # Update Roaming Pokémon data based on result of battle - if decision==1 || decision==4 # Defeated or caught + if decision == 1 || decision == 4 # Defeated or caught $PokemonGlobal.roamPokemon[idxRoamer] = true - $PokemonGlobal.roamPokemonCaught[idxRoamer] = (decision==4) + $PokemonGlobal.roamPokemonCaught[idxRoamer] = (decision == 4) end $PokemonGlobal.roamEncounter = nil $PokemonGlobal.roamedAlready = true # Used by the Poké Radar to update/break the chain - Events.onWildBattleEnd.trigger(nil,species,level,decision) + Events.onWildBattleEnd.trigger(nil, species, level, decision) # Return false if the player lost or drew the battle, and true if any other result - return (decision!=2 && decision!=5) + return (decision != 2 && decision != 5) end EncounterModifier.registerEncounterEnd(proc { diff --git a/Data/Scripts/012_Overworld/002_Overworld_Metadata.rb b/Data/Scripts/012_Overworld/002_Overworld_Metadata.rb index 407f76091..6f44708f1 100644 --- a/Data/Scripts/012_Overworld/002_Overworld_Metadata.rb +++ b/Data/Scripts/012_Overworld/002_Overworld_Metadata.rb @@ -70,11 +70,11 @@ class PokemonGlobalMetadata @creditsPlayed = false # Pokédex numRegions = pbLoadRegionalDexes.length - @pokedexDex = (numRegions==0) ? -1 : 0 + @pokedexDex = (numRegions == 0) ? -1 : 0 @pokedexIndex = [] @pokedexMode = 0 - for i in 0...numRegions+1 # National Dex isn't a region, but is included - @pokedexIndex[i] = 0 + for i in 0...numRegions + 1 # National Dex isn't a region, but is included + @pokedexIndex[i] = 0 end # Day Care @day_care = DayCare.new @@ -142,27 +142,27 @@ class PokemonMapMetadata end def addErasedEvent(eventID) - key = [$game_map.map_id,eventID] + key = [$game_map.map_id, eventID] @erasedEvents[key] = true end def addMovedEvent(eventID) - key = [$game_map.map_id,eventID] + key = [$game_map.map_id, eventID] event = $game_map.events[eventID] if eventID.is_a?(Integer) - @movedEvents[key] = [event.x,event.y,event.direction,event.through] if event + @movedEvents[key] = [event.x, event.y, event.direction, event.through] if event end def updateMap for i in @erasedEvents - if i[0][0]==$game_map.map_id && i[1] + if i[0][0] == $game_map.map_id && i[1] event = $game_map.events[i[0][1]] event.erase if event end end for i in @movedEvents - if i[0][0]==$game_map.map_id && i[1] + if i[0][0] == $game_map.map_id && i[1] next if !$game_map.events[i[0][1]] - $game_map.events[i[0][1]].moveto(i[1][0],i[1][1]) + $game_map.events[i[0][1]].moveto(i[1][0], i[1][1]) case i[1][2] when 2 then $game_map.events[i[0][1]].turn_down when 4 then $game_map.events[i[0][1]].turn_left @@ -170,7 +170,7 @@ class PokemonMapMetadata when 8 then $game_map.events[i[0][1]].turn_up end end - if i[1][3]!=nil + if i[1][3] != nil $game_map.events[i[0][1]].through = i[1][3] end end diff --git a/Data/Scripts/012_Overworld/003_Overworld_Time.rb b/Data/Scripts/012_Overworld/003_Overworld_Time.rb index 881736b3b..eb6fedd6b 100644 --- a/Data/Scripts/012_Overworld/003_Overworld_Time.rb +++ b/Data/Scripts/012_Overworld/003_Overworld_Time.rb @@ -36,52 +36,52 @@ module PBDayNight ] @cachedTone = nil @dayNightToneLastUpdate = nil - @oneOverSixty = 1/60.0 + @oneOverSixty = 1 / 60.0 # Returns true if it's day. def self.isDay?(time = nil) time = pbGetTimeNow if !time - return (time.hour>=5 && time.hour<20) + return (time.hour >= 5 && time.hour < 20) end # Returns true if it's night. def self.isNight?(time = nil) time = pbGetTimeNow if !time - return (time.hour>=20 || time.hour<5) + return (time.hour >= 20 || time.hour < 5) end # Returns true if it's morning. def self.isMorning?(time = nil) time = pbGetTimeNow if !time - return (time.hour>=5 && time.hour<10) + return (time.hour >= 5 && time.hour < 10) end # Returns true if it's the afternoon. def self.isAfternoon?(time = nil) time = pbGetTimeNow if !time - return (time.hour>=14 && time.hour<17) + return (time.hour >= 14 && time.hour < 17) end # Returns true if it's the evening. def self.isEvening?(time = nil) time = pbGetTimeNow if !time - return (time.hour>=17 && time.hour<20) + return (time.hour >= 17 && time.hour < 20) end # Gets a number representing the amount of daylight (0=full night, 255=full day). def self.getShade time = pbGetDayNightMinutes - time = (24*60)-time if time>(12*60) - return 255*time/(12*60) + time = (24 * 60) - time if time > (12 * 60) + return 255 * time / (12 * 60) end # Gets a Tone object representing a suggested shading # tone for the current time of day. def self.getTone - @cachedTone = Tone.new(0,0,0) if !@cachedTone + @cachedTone = Tone.new(0, 0, 0) if !@cachedTone return @cachedTone if !Settings::TIME_SHADING if !@dayNightToneLastUpdate || - Graphics.frame_count-@dayNightToneLastUpdate>=Graphics.frame_rate*30 + Graphics.frame_count - @dayNightToneLastUpdate >= Graphics.frame_rate * 30 getToneInternal @dayNightToneLastUpdate = Graphics.frame_count end @@ -90,7 +90,7 @@ module PBDayNight def self.pbGetDayNightMinutes now = pbGetTimeNow # Get the current in-game time - return (now.hour*60)+now.min + return (now.hour * 60) + now.min end private @@ -98,16 +98,16 @@ module PBDayNight def self.getToneInternal # Calculates the tone for the current frame, used for day/night effects realMinutes = pbGetDayNightMinutes - hour = realMinutes/60 - minute = realMinutes%60 + hour = realMinutes / 60 + minute = realMinutes % 60 tone = PBDayNight::HourlyTones[hour] - nexthourtone = PBDayNight::HourlyTones[(hour+1)%24] + nexthourtone = PBDayNight::HourlyTones[(hour + 1) % 24] # Calculate current tint according to current and next hour's tint and # depending on current minute - @cachedTone.red = ((nexthourtone.red-tone.red)*minute*@oneOverSixty)+tone.red - @cachedTone.green = ((nexthourtone.green-tone.green)*minute*@oneOverSixty)+tone.green - @cachedTone.blue = ((nexthourtone.blue-tone.blue)*minute*@oneOverSixty)+tone.blue - @cachedTone.gray = ((nexthourtone.gray-tone.gray)*minute*@oneOverSixty)+tone.gray + @cachedTone.red = ((nexthourtone.red - tone.red) * minute * @oneOverSixty) + tone.red + @cachedTone.green = ((nexthourtone.green - tone.green) * minute * @oneOverSixty) + tone.green + @cachedTone.blue = ((nexthourtone.blue - tone.blue) * minute * @oneOverSixty) + tone.blue + @cachedTone.gray = ((nexthourtone.gray - tone.gray) * minute * @oneOverSixty) + tone.gray end end @@ -117,9 +117,9 @@ def pbDayNightTint(object) return if !$scene.is_a?(Scene_Map) if Settings::TIME_SHADING && $game_map.metadata&.outdoor_map tone = PBDayNight.getTone - object.tone.set(tone.red,tone.green,tone.blue,tone.gray) + object.tone.set(tone.red, tone.green, tone.blue, tone.gray) else - object.tone.set(0,0,0,0) + object.tone.set(0, 0, 0, 0) end end @@ -149,39 +149,39 @@ def moonphase(time = nil) # in UTC 23.9936034430625, 27.6849270496875 ] - yy = time.year-((12-time.mon)/10.0).floor - j = (365.25*(4712+yy)).floor + (((time.mon+9)%12)*30.6+0.5).floor + time.day+59 - j -= (((yy/100.0)+49).floor*0.75).floor-38 if j>2299160 - j += (((time.hour*60)+time.min*60)+time.sec)/86400.0 - v = (j-2451550.1)/29.530588853 - v = ((v-v.floor)+(v<0 ? 1 : 0)) - ag = v*29.53 + yy = time.year - ((12 - time.mon) / 10.0).floor + j = (365.25 * (4712 + yy)).floor + (((time.mon + 9) % 12) * 30.6 + 0.5).floor + time.day + 59 + j -= (((yy / 100.0) + 49).floor * 0.75).floor - 38 if j > 2299160 + j += (((time.hour * 60) + time.min * 60) + time.sec) / 86400.0 + v = (j - 2451550.1) / 29.530588853 + v = ((v - v.floor) + (v < 0 ? 1 : 0)) + ag = v * 29.53 for i in 0...transitions.length - return i if ag<=transitions[i] + return i if ag <= transitions[i] end return 0 end # Calculates the zodiac sign based on the given month and day: # 0 is Aries, 11 is Pisces. Month is 1 if January, and so on. -def zodiac(month,day) +def zodiac(month, day) time = [ - 3,21,4,19, # Aries - 4,20,5,20, # Taurus - 5,21,6,20, # Gemini - 6,21,7,20, # Cancer - 7,23,8,22, # Leo - 8,23,9,22, # Virgo - 9,23,10,22, # Libra - 10,23,11,21, # Scorpio - 11,22,12,21, # Sagittarius - 12,22,1,19, # Capricorn - 1,20,2,18, # Aquarius - 2,19,3,20 # Pisces + 3, 21, 4, 19, # Aries + 4, 20, 5, 20, # Taurus + 5, 21, 6, 20, # Gemini + 6, 21, 7, 20, # Cancer + 7, 23, 8, 22, # Leo + 8, 23, 9, 22, # Virgo + 9, 23, 10, 22, # Libra + 10, 23, 11, 21, # Scorpio + 11, 22, 12, 21, # Sagittarius + 12, 22, 1, 19, # Capricorn + 1, 20, 2, 18, # Aquarius + 2, 19, 3, 20 # Pisces ] for i in 0...12 - return i if month==time[i*4] && day>=time[i*4+1] - return i if month==time[i*4+2] && day<=time[i*4+3] + return i if month == time[i * 4] && day >= time[i * 4 + 1] + return i if month == time[i * 4 + 2] && day <= time[i * 4 + 3] end return 0 end @@ -189,30 +189,30 @@ end # Returns the opposite of the given zodiac sign. # 0 is Aries, 11 is Pisces. def zodiacOpposite(sign) - return (sign+6)%12 + return (sign + 6) % 12 end # 0 is Aries, 11 is Pisces. def zodiacPartners(sign) - return [(sign+4)%12,(sign+8)%12] + return [(sign + 4) % 12, (sign + 8) % 12] end # 0 is Aries, 11 is Pisces. def zodiacComplements(sign) - return [(sign+1)%12,(sign+11)%12] + return [(sign + 1) % 12, (sign + 11) % 12] end #=============================================================================== # Days of the week #=============================================================================== -def pbIsWeekday(wdayVariable,*arg) +def pbIsWeekday(wdayVariable, *arg) timenow = pbGetTimeNow wday = timenow.wday ret = false for wd in arg - ret = true if wd==wday + ret = true if wd == wday end - if wdayVariable>0 + if wdayVariable > 0 $game_variables[wdayVariable] = [ _INTL("Sunday"), _INTL("Monday"), @@ -230,14 +230,14 @@ end #=============================================================================== # Months #=============================================================================== -def pbIsMonth(monVariable,*arg) +def pbIsMonth(monVariable, *arg) timenow = pbGetTimeNow thismon = timenow.mon ret = false for wd in arg - ret = true if wd==thismon + ret = true if wd == thismon end - if monVariable>0 + if monVariable > 0 $game_variables[monVariable] = pbGetMonthName(thismon) $game_map.need_refresh = true if $game_map end @@ -256,7 +256,7 @@ def pbGetMonthName(month) _INTL("September"), _INTL("October"), _INTL("November"), - _INTL("December")][month-1] + _INTL("December")][month - 1] end def pbGetAbbrevMonthName(month) @@ -279,16 +279,16 @@ end # Seasons #=============================================================================== def pbGetSeason - return (pbGetTimeNow.mon-1)%4 + return (pbGetTimeNow.mon - 1) % 4 end -def pbIsSeason(seasonVariable,*arg) +def pbIsSeason(seasonVariable, *arg) thisseason = pbGetSeason ret = false for wd in arg - ret = true if wd==thisseason + ret = true if wd == thisseason end - if seasonVariable>0 + if seasonVariable > 0 $game_variables[seasonVariable] = [ _INTL("Spring"), _INTL("Summer"), @@ -300,11 +300,11 @@ def pbIsSeason(seasonVariable,*arg) return ret end -def pbIsSpring; return pbIsSeason(0,0); end # Jan, May, Sep -def pbIsSummer; return pbIsSeason(0,1); end # Feb, Jun, Oct -def pbIsAutumn; return pbIsSeason(0,2); end # Mar, Jul, Nov +def pbIsSpring; return pbIsSeason(0, 0); end # Jan, May, Sep +def pbIsSummer; return pbIsSeason(0, 1); end # Feb, Jun, Oct +def pbIsAutumn; return pbIsSeason(0, 2); end # Mar, Jul, Nov def pbIsFall; return pbIsAutumn; end -def pbIsWinter; return pbIsSeason(0,3); end # Apr, Aug, Dec +def pbIsWinter; return pbIsSeason(0, 3); end # Apr, Aug, Dec def pbGetSeasonName(season) return [_INTL("Spring"), diff --git a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb index 032ea9c7b..12dc0fb81 100644 --- a/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb +++ b/Data/Scripts/012_Overworld/004_Overworld_FieldMoves.rb @@ -6,45 +6,45 @@ module HiddenMoveHandlers ConfirmUseMove = MoveHandlerHash.new UseMove = MoveHandlerHash.new - def self.addCanUseMove(item,proc); CanUseMove.add(item,proc); end - def self.addConfirmUseMove(item,proc); ConfirmUseMove.add(item,proc); end - def self.addUseMove(item,proc); UseMove.add(item,proc); end + def self.addCanUseMove(item, proc); CanUseMove.add(item, proc); end + def self.addConfirmUseMove(item, proc); ConfirmUseMove.add(item, proc); end + def self.addUseMove(item, proc); UseMove.add(item, proc); end def self.hasHandler(item) - return CanUseMove[item]!=nil && UseMove[item]!=nil + return CanUseMove[item] != nil && UseMove[item] != nil end # Returns whether move can be used - def self.triggerCanUseMove(item,pokemon,showmsg) + def self.triggerCanUseMove(item, pokemon, showmsg) return false if !CanUseMove[item] - return CanUseMove.trigger(item,pokemon,showmsg) + return CanUseMove.trigger(item, pokemon, showmsg) end # Returns whether the player confirmed that they want to use the move - def self.triggerConfirmUseMove(item,pokemon) + def self.triggerConfirmUseMove(item, pokemon) return true if !ConfirmUseMove[item] - return ConfirmUseMove.trigger(item,pokemon) + return ConfirmUseMove.trigger(item, pokemon) end # Returns whether move was used - def self.triggerUseMove(item,pokemon) + def self.triggerUseMove(item, pokemon) return false if !UseMove[item] - return UseMove.trigger(item,pokemon) + return UseMove.trigger(item, pokemon) end end -def pbCanUseHiddenMove?(pkmn,move,showmsg = true) - return HiddenMoveHandlers.triggerCanUseMove(move,pkmn,showmsg) +def pbCanUseHiddenMove?(pkmn, move, showmsg = true) + return HiddenMoveHandlers.triggerCanUseMove(move, pkmn, showmsg) end -def pbConfirmUseHiddenMove(pokemon,move) - return HiddenMoveHandlers.triggerConfirmUseMove(move,pokemon) +def pbConfirmUseHiddenMove(pokemon, move) + return HiddenMoveHandlers.triggerConfirmUseMove(move, pokemon) end -def pbUseHiddenMove(pokemon,move) - return HiddenMoveHandlers.triggerUseMove(move,pokemon) +def pbUseHiddenMove(pokemon, move) + return HiddenMoveHandlers.triggerUseMove(move, pokemon) end # Unused @@ -52,8 +52,8 @@ def pbHiddenMoveEvent Events.onAction.trigger(nil) end -def pbCheckHiddenMoveBadge(badge = -1,showmsg = true) - return true if badge<0 # No badge requirement +def pbCheckHiddenMoveBadge(badge = -1, showmsg = true) + return true if badge < 0 # No badge requirement return true if $DEBUG if (Settings::FIELD_MOVES_COUNT_BADGES) ? $player.badge_count >= badge : $player.badges[badge] return true @@ -69,33 +69,33 @@ end #=============================================================================== def pbHiddenMoveAnimation(pokemon) return false if !pokemon - viewport=Viewport.new(0,0,0,0) - viewport.z=99999 - bg=Sprite.new(viewport) - bg.bitmap=RPG::Cache.picture("hiddenMovebg") - sprite=PokemonSprite.new(viewport) + viewport = Viewport.new(0, 0, 0, 0) + viewport.z = 99999 + bg = Sprite.new(viewport) + bg.bitmap = RPG::Cache.picture("hiddenMovebg") + sprite = PokemonSprite.new(viewport) sprite.setOffset(PictureOrigin::Center) sprite.setPokemonBitmap(pokemon) - sprite.z=1 - sprite.visible=false - strobebitmap=AnimatedBitmap.new("Graphics/Pictures/hiddenMoveStrobes") - strobes=[] + sprite.z = 1 + sprite.visible = false + strobebitmap = AnimatedBitmap.new("Graphics/Pictures/hiddenMoveStrobes") + strobes = [] 15.times do |i| - strobe=BitmapSprite.new(26*2,8*2,viewport) - strobe.bitmap.blt(0,0,strobebitmap.bitmap,Rect.new(0,(i%2)*8*2,26*2,8*2)) - strobe.z=((i%2)==0 ? 2 : 0) - strobe.visible=false + strobe = BitmapSprite.new(26 * 2, 8 * 2, viewport) + strobe.bitmap.blt(0, 0, strobebitmap.bitmap, Rect.new(0, (i % 2) * 8 * 2, 26 * 2, 8 * 2)) + strobe.z = ((i % 2) == 0 ? 2 : 0) + strobe.visible = false strobes.push(strobe) end strobebitmap.dispose - interp=RectInterpolator.new( - Rect.new(0,Graphics.height/2,Graphics.width,0), - Rect.new(0,(Graphics.height-bg.bitmap.height)/2,Graphics.width,bg.bitmap.height), - Graphics.frame_rate/4) - ptinterp=nil - phase=1 - frames=0 - strobeSpeed = 64*20/Graphics.frame_rate + interp = RectInterpolator.new( + Rect.new(0, Graphics.height / 2, Graphics.width, 0), + Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height), + Graphics.frame_rate / 4) + ptinterp = nil + phase = 1 + frames = 0 + strobeSpeed = 64 * 20 / Graphics.frame_rate loop do Graphics.update Input.update @@ -104,71 +104,71 @@ def pbHiddenMoveAnimation(pokemon) when 1 # Expand viewport height from zero to full interp.update interp.set(viewport.rect) - bg.oy=(bg.bitmap.height-viewport.rect.height)/2 + bg.oy = (bg.bitmap.height - viewport.rect.height) / 2 if interp.done? - phase=2 - ptinterp=PointInterpolator.new( - Graphics.width+(sprite.bitmap.width/2),bg.bitmap.height/2, - Graphics.width/2,bg.bitmap.height/2, - Graphics.frame_rate*4/10) + phase = 2 + ptinterp = PointInterpolator.new( + Graphics.width + (sprite.bitmap.width / 2), bg.bitmap.height / 2, + Graphics.width / 2, bg.bitmap.height / 2, + Graphics.frame_rate * 4 / 10) end when 2 # Slide Pokémon sprite in from right to centre ptinterp.update - sprite.x=ptinterp.x - sprite.y=ptinterp.y - sprite.visible=true + sprite.x = ptinterp.x + sprite.y = ptinterp.y + sprite.visible = true if ptinterp.done? - phase=3 + phase = 3 pokemon.play_cry - frames=0 + frames = 0 end when 3 # Wait - frames+=1 - if frames>Graphics.frame_rate*3/4 - phase=4 - ptinterp=PointInterpolator.new( - Graphics.width/2,bg.bitmap.height/2, - -(sprite.bitmap.width/2),bg.bitmap.height/2, - Graphics.frame_rate*4/10) - frames=0 + frames += 1 + if frames > Graphics.frame_rate * 3 / 4 + phase = 4 + ptinterp = PointInterpolator.new( + Graphics.width / 2, bg.bitmap.height / 2, + -(sprite.bitmap.width / 2), bg.bitmap.height / 2, + Graphics.frame_rate * 4 / 10) + frames = 0 end when 4 # Slide Pokémon sprite off from centre to left ptinterp.update - sprite.x=ptinterp.x - sprite.y=ptinterp.y + sprite.x = ptinterp.x + sprite.y = ptinterp.y if ptinterp.done? - phase=5 - sprite.visible=false - interp=RectInterpolator.new( - Rect.new(0,(Graphics.height-bg.bitmap.height)/2,Graphics.width,bg.bitmap.height), - Rect.new(0,Graphics.height/2,Graphics.width,0), - Graphics.frame_rate/4) + phase = 5 + sprite.visible = false + interp = RectInterpolator.new( + Rect.new(0, (Graphics.height - bg.bitmap.height) / 2, Graphics.width, bg.bitmap.height), + Rect.new(0, Graphics.height / 2, Graphics.width, 0), + Graphics.frame_rate / 4) end when 5 # Shrink viewport height from full to zero interp.update interp.set(viewport.rect) - bg.oy=(bg.bitmap.height-viewport.rect.height)/2 - phase=6 if interp.done? + bg.oy = (bg.bitmap.height - viewport.rect.height) / 2 + phase = 6 if interp.done? end # Constantly stream the strobes across the screen for strobe in strobes - strobe.ox=strobe.viewport.rect.x - strobe.oy=strobe.viewport.rect.y + strobe.ox = strobe.viewport.rect.x + strobe.oy = strobe.viewport.rect.y if !strobe.visible # Initial placement of strobes - randomY = 16*(1+rand(bg.bitmap.height/16-2)) - strobe.y = randomY+(Graphics.height-bg.bitmap.height)/2 + randomY = 16 * (1 + rand(bg.bitmap.height / 16 - 2)) + strobe.y = randomY + (Graphics.height - bg.bitmap.height) / 2 strobe.x = rand(Graphics.width) strobe.visible = true - elsif strobe.xdarkness.radiusMax + darkness.radius = darkness.radiusMax if darkness.radius > darkness.radiusMax end next true }) @@ -542,11 +542,11 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY) return true end -HiddenMoveHandlers::CanUseMove.add(:FLY,proc { |move, pkmn, showmsg| +HiddenMoveHandlers::CanUseMove.add(:FLY, proc { |move, pkmn, showmsg| next pbCanFly?(pkmn, showmsg) }) -HiddenMoveHandlers::UseMove.add(:FLY,proc { |move, pkmn| +HiddenMoveHandlers::UseMove.add(:FLY, proc { |move, pkmn| if $game_temp.fly_destination.nil? pbMessage(_INTL("Can't use that here.")) next false @@ -562,21 +562,21 @@ HiddenMoveHandlers::UseMove.add(:FLY,proc { |move, pkmn| #=============================================================================== def pbHeadbuttEffect(event = nil) event = $game_player.pbFacingEvent(true) if !event - a = (event.x+(event.x/24).floor+1)*(event.y+(event.y/24).floor+1) - a = (a*2/5)%10 # Even 2x as likely as odd, 0 is 1.5x as likely as odd + a = (event.x + (event.x / 24).floor + 1) * (event.y + (event.y / 24).floor + 1) + a = (a * 2 / 5) % 10 # Even 2x as likely as odd, 0 is 1.5x as likely as odd b = $player.public_ID % 10 # Practically equal odds of each value chance = 1 # ~50% - if a==b # 10% + if a == b # 10% chance = 8 - elsif a>b && (a-b).abs<5 # ~30.3% + elsif a > b && (a - b).abs < 5 # ~30.3% chance = 5 - elsif a5 # ~9.7% + elsif a < b && (a - b).abs > 5 # ~9.7% chance = 5 end - if rand(10)>=chance + if rand(10) >= chance pbMessage(_INTL("Nope. Nothing...")) else - enctype = (chance==1) ? :HeadbuttLow : :HeadbuttHigh + enctype = (chance == 1) ? :HeadbuttLow : :HeadbuttHigh if pbEncounter(enctype) $stats.headbutt_battles += 1 else @@ -595,7 +595,7 @@ def pbHeadbutt(event = nil) if pbConfirmMessage(_INTL("A Pokémon could be in this tree. Would you like to use Headbutt?")) $stats.headbutt_count += 1 speciesname = (movefinder) ? movefinder.name : $player.name - pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbHiddenMoveAnimation(movefinder) pbHeadbuttEffect(event) return true @@ -603,7 +603,7 @@ def pbHeadbutt(event = nil) return false end -HiddenMoveHandlers::CanUseMove.add(:HEADBUTT,proc { |move,pkmn,showmsg| +HiddenMoveHandlers::CanUseMove.add(:HEADBUTT, proc { |move, pkmn, showmsg| facingEvent = $game_player.pbFacingEvent if !facingEvent || !facingEvent.name[/headbutttree/i] pbMessage(_INTL("Can't use that here.")) if showmsg @@ -612,9 +612,9 @@ HiddenMoveHandlers::CanUseMove.add(:HEADBUTT,proc { |move,pkmn,showmsg| next true }) -HiddenMoveHandlers::UseMove.add(:HEADBUTT,proc { |move,pokemon| +HiddenMoveHandlers::UseMove.add(:HEADBUTT, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) - pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end $stats.headbutt_count += 1 facingEvent = $game_player.pbFacingEvent @@ -636,22 +636,22 @@ end def pbRockSmash move = :ROCKSMASH movefinder = $player.get_pokemon_with_move(move) - if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_ROCKSMASH,false) || (!$DEBUG && !movefinder) + if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_ROCKSMASH, false) || (!$DEBUG && !movefinder) pbMessage(_INTL("It's a rugged rock, but a Pokémon may be able to smash it.")) return false end if pbConfirmMessage(_INTL("This rock appears to be breakable. Would you like to use Rock Smash?")) $stats.rock_smash_count += 1 speciesname = (movefinder) ? movefinder.name : $player.name - pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbHiddenMoveAnimation(movefinder) return true end return false end -HiddenMoveHandlers::CanUseMove.add(:ROCKSMASH,proc { |move,pkmn,showmsg| - next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_ROCKSMASH,showmsg) +HiddenMoveHandlers::CanUseMove.add(:ROCKSMASH, proc { |move, pkmn, showmsg| + next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_ROCKSMASH, showmsg) facingEvent = $game_player.pbFacingEvent if !facingEvent || !facingEvent.name[/smashrock/i] pbMessage(_INTL("Can't use that here.")) if showmsg @@ -660,9 +660,9 @@ HiddenMoveHandlers::CanUseMove.add(:ROCKSMASH,proc { |move,pkmn,showmsg| next true }) -HiddenMoveHandlers::UseMove.add(:ROCKSMASH,proc { |move,pokemon| +HiddenMoveHandlers::UseMove.add(:ROCKSMASH, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) - pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end $stats.rock_smash_count += 1 facingEvent = $game_player.pbFacingEvent @@ -685,29 +685,29 @@ def pbStrength end move = :STRENGTH movefinder = $player.get_pokemon_with_move(move) - if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_STRENGTH,false) || (!$DEBUG && !movefinder) + if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_STRENGTH, false) || (!$DEBUG && !movefinder) pbMessage(_INTL("It's a big boulder, but a Pokémon may be able to push it aside.")) return false end pbMessage(_INTL("It's a big boulder, but a Pokémon may be able to push it aside.\1")) if pbConfirmMessage(_INTL("Would you like to use Strength?")) speciesname = (movefinder) ? movefinder.name : $player.name - pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbHiddenMoveAnimation(movefinder) - pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!",speciesname)) + pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!", speciesname)) $PokemonMap.strengthUsed = true return true end return false end -Events.onAction += proc { |_sender,_e| +Events.onAction += proc { |_sender, _e| facingEvent = $game_player.pbFacingEvent pbStrength if facingEvent && facingEvent.name[/strengthboulder/i] } -HiddenMoveHandlers::CanUseMove.add(:STRENGTH,proc { |move,pkmn,showmsg| - next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_STRENGTH,showmsg) +HiddenMoveHandlers::CanUseMove.add(:STRENGTH, proc { |move, pkmn, showmsg| + next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_STRENGTH, showmsg) if $PokemonMap.strengthUsed pbMessage(_INTL("Strength is already being used.")) if showmsg next false @@ -715,11 +715,11 @@ HiddenMoveHandlers::CanUseMove.add(:STRENGTH,proc { |move,pkmn,showmsg| next true }) -HiddenMoveHandlers::UseMove.add(:STRENGTH,proc { |move,pokemon| +HiddenMoveHandlers::UseMove.add(:STRENGTH, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) - pbMessage(_INTL("{1} used {2}!\1",pokemon.name,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!\1", pokemon.name, GameData::Move.get(move).name)) end - pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!",pokemon.name)) + pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!", pokemon.name)) $PokemonMap.strengthUsed = true next true }) @@ -734,16 +734,16 @@ def pbSurf return false if !$game_player.can_ride_vehicle_with_follower? move = :SURF movefinder = $player.get_pokemon_with_move(move) - if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF,false) || (!$DEBUG && !movefinder) + if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF, false) || (!$DEBUG && !movefinder) return false end if pbConfirmMessage(_INTL("The water is a deep blue...\nWould you like to surf on it?")) speciesname = (movefinder) ? movefinder.name : $player.name - pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbCancelVehicles pbHiddenMoveAnimation(movefinder) surfbgm = GameData::Metadata.get.surf_BGM - pbCueBGM(surfbgm,0.5) if surfbgm + pbCueBGM(surfbgm, 0.5) if surfbgm pbStartSurfing return true end @@ -759,19 +759,19 @@ def pbStartSurfing $game_temp.surf_base_coords = $map_factory.getFacingCoords($game_player.x, $game_player.y, $game_player.direction) pbJumpToward $game_temp.surf_base_coords = nil - $game_player.check_event_trigger_here([1,2]) + $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 - if $game_map.terrain_tag(x,y).can_surf && !$game_player.pbFacingTerrainTag.can_surf + if $game_map.terrain_tag(x, y).can_surf && !$game_player.pbFacingTerrainTag.can_surf $game_temp.surf_base_coords = [x, y] - if pbJumpToward(1,false,true) + if pbJumpToward(1, false, true) $game_map.autoplayAsCue $game_player.increase_steps - result = $game_player.check_event_trigger_here([1,2]) + result = $game_player.check_event_trigger_here([1, 2]) pbOnStepTaken(result) end $game_temp.surf_base_coords = nil @@ -781,7 +781,7 @@ def pbEndSurf(_xOffset,_yOffset) end # @deprecated This method is slated to be removed in v21. -def pbTransferSurfing(mapid,xcoord,ycoord,direction = $game_player.direction) +def pbTransferSurfing(mapid, xcoord, ycoord, direction = $game_player.direction) Deprecation.warn_method('pbTransferSurfing', 'v21', '"Transfer Player" event command') pbFadeOutIn { $game_temp.player_new_map_id = mapid @@ -794,16 +794,16 @@ 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 $game_map.metadata&.always_bicycle next if !$game_player.pbFacingTerrainTag.can_surf_freely - next if !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player) + next if !$game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player) pbSurf } -HiddenMoveHandlers::CanUseMove.add(:SURF,proc { |move,pkmn,showmsg| - next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF,showmsg) +HiddenMoveHandlers::CanUseMove.add(:SURF, proc { |move, pkmn, showmsg| + next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_SURF, showmsg) if $PokemonGlobal.surfing pbMessage(_INTL("You're already surfing.")) if showmsg next false @@ -817,21 +817,21 @@ HiddenMoveHandlers::CanUseMove.add(:SURF,proc { |move,pkmn,showmsg| next false end if !$game_player.pbFacingTerrainTag.can_surf_freely || - !$game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player) + !$game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player) pbMessage(_INTL("No surfing here!")) if showmsg next false end next true }) -HiddenMoveHandlers::UseMove.add(:SURF,proc { |move,pokemon| +HiddenMoveHandlers::UseMove.add(:SURF, proc { |move, pokemon| $game_temp.in_menu = false pbCancelVehicles if !pbHiddenMoveAnimation(pokemon) - pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end surfbgm = GameData::Metadata.get.surf_BGM - pbCueBGM(surfbgm,0.5) if surfbgm + pbCueBGM(surfbgm, 0.5) if surfbgm pbStartSurfing next true }) @@ -846,7 +846,7 @@ def pbSweetScent pbMessage(_INTL("The sweet scent faded for some reason...")) return end - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 count = 0 viewport.color.red = 255 @@ -855,9 +855,9 @@ def pbSweetScent viewport.color.alpha -= 10 alphaDiff = 12 * 20 / Graphics.frame_rate loop do - if count==0 && viewport.color.alpha<128 + if count == 0 && viewport.color.alpha < 128 viewport.color.alpha += alphaDiff - elsif count>Graphics.frame_rate/4 + elsif count > Graphics.frame_rate / 4 viewport.color.alpha -= alphaDiff else count += 1 @@ -865,7 +865,7 @@ def pbSweetScent Graphics.update Input.update pbUpdateSceneMap - break if viewport.color.alpha<=0 + break if viewport.color.alpha <= 0 end viewport.dispose enctype = $PokemonEncounters.encounter_type @@ -875,13 +875,13 @@ def pbSweetScent end end -HiddenMoveHandlers::CanUseMove.add(:SWEETSCENT,proc { |move,pkmn,showmsg| +HiddenMoveHandlers::CanUseMove.add(:SWEETSCENT, proc { |move, pkmn, showmsg| next true }) -HiddenMoveHandlers::UseMove.add(:SWEETSCENT,proc { |move,pokemon| +HiddenMoveHandlers::UseMove.add(:SWEETSCENT, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) - pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end pbSweetScent next true @@ -892,7 +892,7 @@ HiddenMoveHandlers::UseMove.add(:SWEETSCENT,proc { |move,pokemon| #=============================================================================== # Teleport #=============================================================================== -HiddenMoveHandlers::CanUseMove.add(:TELEPORT,proc { |move,pkmn,showmsg| +HiddenMoveHandlers::CanUseMove.add(:TELEPORT, proc { |move, pkmn, showmsg| if !$game_map.metadata&.outdoor_map pbMessage(_INTL("Can't use that here.")) if showmsg next false @@ -911,22 +911,22 @@ HiddenMoveHandlers::CanUseMove.add(:TELEPORT,proc { |move,pkmn,showmsg| next true }) -HiddenMoveHandlers::ConfirmUseMove.add(:TELEPORT,proc { |move,pkmn| +HiddenMoveHandlers::ConfirmUseMove.add(:TELEPORT, proc { |move, pkmn| healing = $PokemonGlobal.healingSpot healing = GameData::PlayerMetadata.get($player.character_ID)&.home if !healing healing = GameData::Metadata.get.home if !healing # Home next false if !healing mapname = pbGetMapNameFromId(healing[0]) - next pbConfirmMessage(_INTL("Want to return to the healing spot used last in {1}?",mapname)) + next pbConfirmMessage(_INTL("Want to return to the healing spot used last in {1}?", mapname)) }) -HiddenMoveHandlers::UseMove.add(:TELEPORT,proc { |move,pokemon| +HiddenMoveHandlers::UseMove.add(:TELEPORT, proc { |move, pokemon| healing = $PokemonGlobal.healingSpot healing = GameData::PlayerMetadata.get($player.character_ID)&.home if !healing healing = GameData::Metadata.get.home if !healing # Home next false if !healing if !pbHiddenMoveAnimation(pokemon) - pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end pbFadeOutIn { $game_temp.player_new_map_id = healing[0] @@ -985,13 +985,13 @@ end def pbWaterfall move = :WATERFALL movefinder = $player.get_pokemon_with_move(move) - if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_WATERFALL,false) || (!$DEBUG && !movefinder) + if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_WATERFALL, false) || (!$DEBUG && !movefinder) pbMessage(_INTL("A wall of water is crashing down with a mighty roar.")) return false end if pbConfirmMessage(_INTL("It's a large waterfall. Would you like to use Waterfall?")) speciesname = (movefinder) ? movefinder.name : $player.name - pbMessage(_INTL("{1} used {2}!",speciesname,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbHiddenMoveAnimation(movefinder) pbAscendWaterfall return true @@ -999,7 +999,7 @@ def pbWaterfall return false end -Events.onAction += proc { |_sender,_e| +Events.onAction += proc { |_sender, _e| terrain = $game_player.pbFacingTerrainTag if terrain.waterfall pbWaterfall @@ -1008,8 +1008,8 @@ Events.onAction += proc { |_sender,_e| end } -HiddenMoveHandlers::CanUseMove.add(:WATERFALL,proc { |move,pkmn,showmsg| - next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_WATERFALL,showmsg) +HiddenMoveHandlers::CanUseMove.add(:WATERFALL, proc { |move, pkmn, showmsg| + next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_WATERFALL, showmsg) if !$game_player.pbFacingTerrainTag.waterfall pbMessage(_INTL("Can't use that here.")) if showmsg next false @@ -1017,9 +1017,9 @@ HiddenMoveHandlers::CanUseMove.add(:WATERFALL,proc { |move,pkmn,showmsg| next true }) -HiddenMoveHandlers::UseMove.add(:WATERFALL,proc { |move,pokemon| +HiddenMoveHandlers::UseMove.add(:WATERFALL, proc { |move, pokemon| if !pbHiddenMoveAnimation(pokemon) - pbMessage(_INTL("{1} used {2}!",pokemon.name,GameData::Move.get(move).name)) + pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) end pbAscendWaterfall next true diff --git a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb index c30db647a..cb0276cab 100644 --- a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb +++ b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb @@ -37,38 +37,38 @@ def pbFishingEnd $PokemonGlobal.fishing = false end -def pbFishing(hasEncounter,rodType = 1) +def pbFishing(hasEncounter, rodType = 1) $stats.fishing_count += 1 speedup = ($player.first_pokemon && [:STICKYHOLD, :SUCTIONCUPS].include?($player.first_pokemon.ability_id)) - biteChance = 20+(25*rodType) # 45, 70, 95 + biteChance = 20 + (25 * rodType) # 45, 70, 95 biteChance *= 1.5 if speedup # 67.5, 100, 100 hookChance = 100 pbFishingBegin msgWindow = pbCreateMessageWindow ret = false loop do - time = 5+rand(6) - time = [time,5+rand(6)].min if speedup + time = 5 + rand(6) + time = [time, 5 + rand(6)].min if speedup message = "" time.times { message += ". " } - if pbWaitMessage(msgWindow,time) + if pbWaitMessage(msgWindow, time) pbFishingEnd { - pbMessageDisplay(msgWindow,_INTL("Not even a nibble...")) + pbMessageDisplay(msgWindow, _INTL("Not even a nibble...")) } break end - if hasEncounter && rand(100)0 - pbMessageDisplay(msgWindow,message,false) + periodTime = Graphics.frame_rate * 4 / 10 # 0.4 seconds, 16 frames per dot + (time + 1).times do |i| + message += ". " if i > 0 + pbMessageDisplay(msgWindow, message, false) periodTime.times do Graphics.update Input.update @@ -106,8 +106,8 @@ def pbWaitMessage(msgWindow,time) end # A Pokémon is biting, reflex test to reel it in -def pbWaitForInput(msgWindow,message,frames) - pbMessageDisplay(msgWindow,message,false) +def pbWaitForInput(msgWindow, message, frames) + pbMessageDisplay(msgWindow, message, false) numFrame = 0 twitchFrame = 0 twitchFrameTime = Graphics.frame_rate * 2 / 10 # 0.2 seconds, 8 frames @@ -116,8 +116,8 @@ def pbWaitForInput(msgWindow,message,frames) Input.update pbUpdateSceneMap # Twitch cycle: 1,0,1,0,0,0,0,0 - twitchFrame = (twitchFrame+1)%(twitchFrameTime*8) - case twitchFrame%twitchFrameTime + twitchFrame = (twitchFrame + 1) % (twitchFrameTime * 8) + case twitchFrame % twitchFrameTime when 0, 2 $game_player.pattern = 1 else diff --git a/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb b/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb index d9bc3c8cb..24f6868c5 100644 --- a/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb +++ b/Data/Scripts/012_Overworld/007_Overworld_DayCare.rb @@ -555,7 +555,7 @@ end # With each step taken, add Exp to Pokémon in the Day Care and try to generate # an egg. #=============================================================================== -Events.onStepTaken += proc { |_sender,_e| +Events.onStepTaken += proc { |_sender, _e| $PokemonGlobal.day_care.update_on_step_taken } diff --git a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb index 7929fe489..9e8034448 100644 --- a/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb +++ b/Data/Scripts/012_Overworld/008_Overworld_RandomDungeons.rb @@ -254,7 +254,7 @@ module RandomDungeonGenerator def clearVisited(x, y) return if x < 0 || y < 0 || x >= cellWidth || x >= cellHeight - @cells[y * cellWidth + x] &=~EdgeMasks::Visited + @cells[y * cellWidth + x] &= ~EdgeMasks::Visited end def clearAllCells @@ -367,7 +367,7 @@ module RandomDungeonGenerator setEdgeNode(ox, oy, dir) return end - setEdgeNode(ox,oy,dir) + setEdgeNode(ox, oy, dir) end end @@ -507,7 +507,7 @@ module RandomDungeonGenerator (r2[0] >= r1[0] + r1[2]) || (r2[1] + r2[3] <= r1[1]) || (r2[1] >= r1[1] + r1[3])) && - ((r1[0] <= r2[0] + r2[2])|| + ((r1[0] <= r2[0] + r2[2]) || (r1[0] >= r2[0] + r2[2]) || (r1[1] + r1[3] <= r2[1]) || (r1[1] >= r2[1] + r2[3])) @@ -543,7 +543,7 @@ module RandomDungeonGenerator return false end - def paint_room(rect,offsetX,offsetY) + def paint_room(rect, offsetX, offsetY) for y in (rect[1] + offsetY)...(rect[1] + offsetY + rect[3]) for x in (rect[0] + offsetX)...(rect[0] + offsetX + rect[2]) self[x, y] = DungeonTile::ROOM diff --git a/Data/Scripts/013_Items/001_Item_Utilities.rb b/Data/Scripts/013_Items/001_Item_Utilities.rb index 9a7ddd623..37c79b3e3 100644 --- a/Data/Scripts/013_Items/001_Item_Utilities.rb +++ b/Data/Scripts/013_Items/001_Item_Utilities.rb @@ -14,19 +14,19 @@ module ItemHandlers BattleUseOnPokemon = ItemHandlerHash.new def self.hasUseText(item) - return UseText[item]!=nil + return UseText[item] != nil end def self.hasOutHandler(item) # Shows "Use" option in Bag - return UseFromBag[item]!=nil || UseInField[item]!=nil || UseOnPokemon[item]!=nil + return UseFromBag[item] != nil || UseInField[item] != nil || UseOnPokemon[item] != nil end def self.hasUseInFieldHandler(item) # Shows "Register" option in Bag - return UseInField[item]!=nil + return UseInField[item] != nil end def self.hasUseOnPokemon(item) - return UseOnPokemon[item]!=nil + return UseOnPokemon[item] != nil end def self.hasUseOnPokemonMaximum(item) @@ -34,15 +34,15 @@ module ItemHandlers end def self.hasUseInBattle(item) - return UseInBattle[item]!=nil + return UseInBattle[item] != nil end def self.hasBattleUseOnBattler(item) - return BattleUseOnBattler[item]!=nil + return BattleUseOnBattler[item] != nil end def self.hasBattleUseOnPokemon(item) - return BattleUseOnPokemon[item]!=nil + return BattleUseOnPokemon[item] != nil end # Returns text to display instead of "Use" @@ -91,25 +91,25 @@ module ItemHandlers return [UseOnPokemonMaximum.trigger(item, pkmn), 1].max end - def self.triggerCanUseInBattle(item,pkmn,battler,move,firstAction,battle,scene,showMessages = true) + def self.triggerCanUseInBattle(item, pkmn, battler, move, firstAction, battle, scene, showMessages = true) return true if !CanUseInBattle[item] # Can use the item by default - return CanUseInBattle.trigger(item,pkmn,battler,move,firstAction,battle,scene,showMessages) + return CanUseInBattle.trigger(item, pkmn, battler, move, firstAction, battle, scene, showMessages) end - def self.triggerUseInBattle(item,battler,battle) - UseInBattle.trigger(item,battler,battle) + def self.triggerUseInBattle(item, battler, battle) + UseInBattle.trigger(item, battler, battle) end # Returns whether item was used - def self.triggerBattleUseOnBattler(item,battler,scene) + def self.triggerBattleUseOnBattler(item, battler, scene) return false if !BattleUseOnBattler[item] - return BattleUseOnBattler.trigger(item,battler,scene) + return BattleUseOnBattler.trigger(item, battler, scene) end # Returns whether item was used - def self.triggerBattleUseOnPokemon(item,pkmn,battler,choices,scene) + def self.triggerBattleUseOnPokemon(item, pkmn, battler, choices, scene) return false if !BattleUseOnPokemon[item] - return BattleUseOnPokemon.trigger(item,pkmn,battler,choices,scene) + return BattleUseOnPokemon.trigger(item, pkmn, battler, choices, scene) end end @@ -239,7 +239,7 @@ def pbChangeExp(pkmn, new_exp, scene) old_special_defense = pkmn.spdef old_speed = pkmn.speed if pkmn.exp > new_exp # Loses Exp - difference = pkmn.exp - new_exp + difference = pkmn.exp - new_exp if scene.is_a?(PokemonPartyScreen) scene.pbDisplay(_INTL("{1} lost {2} Exp. Points!", pkmn.name, difference)) else @@ -266,7 +266,7 @@ def pbChangeExp(pkmn, new_exp, scene) pbTopRightWindow(_INTL("Max. HP{1}\r\nAttack{2}\r\nDefense{3}\r\nSp. Atk{4}\r\nSp. Def{5}\r\nSpeed{6}", pkmn.totalhp, pkmn.attack, pkmn.defense, pkmn.spatk, pkmn.spdef, pkmn.speed), scene) else # Gains Exp - difference = new_exp - pkmn.exp + difference = new_exp - pkmn.exp if scene.is_a?(PokemonPartyScreen) scene.pbDisplay(_INTL("{1} gained {2} Exp. Points!", pkmn.name, difference)) else @@ -330,33 +330,33 @@ end #=============================================================================== # Restore HP #=============================================================================== -def pbItemRestoreHP(pkmn,restoreHP) - newHP = pkmn.hp+restoreHP - newHP = pkmn.totalhp if newHP>pkmn.totalhp - hpGain = newHP-pkmn.hp +def pbItemRestoreHP(pkmn, restoreHP) + newHP = pkmn.hp + restoreHP + newHP = pkmn.totalhp if newHP > pkmn.totalhp + hpGain = newHP - pkmn.hp pkmn.hp = newHP return hpGain end -def pbHPItem(pkmn,restoreHP,scene) - if !pkmn.able? || pkmn.hp==pkmn.totalhp +def pbHPItem(pkmn, restoreHP, scene) + if !pkmn.able? || pkmn.hp == pkmn.totalhp scene.pbDisplay(_INTL("It won't have any effect.")) return false end - hpGain = pbItemRestoreHP(pkmn,restoreHP) + hpGain = pbItemRestoreHP(pkmn, restoreHP) scene.pbRefresh - scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",pkmn.name,hpGain)) + scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.", pkmn.name, hpGain)) return true end -def pbBattleHPItem(pkmn,battler,restoreHP,scene) +def pbBattleHPItem(pkmn, battler, restoreHP, scene) if battler - if battler.pbRecoverHP(restoreHP)>0 - scene.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) + if battler.pbRecoverHP(restoreHP) > 0 + scene.pbDisplay(_INTL("{1}'s HP was restored.", battler.pbThis)) end else - if pbItemRestoreHP(pkmn,restoreHP)>0 - scene.pbDisplay(_INTL("{1}'s HP was restored.",pkmn.name)) + if pbItemRestoreHP(pkmn, restoreHP) > 0 + scene.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) end end return true @@ -365,18 +365,18 @@ end #=============================================================================== # Restore PP #=============================================================================== -def pbRestorePP(pkmn,idxMove,pp) +def pbRestorePP(pkmn, idxMove, pp) return 0 if !pkmn.moves[idxMove] || !pkmn.moves[idxMove].id - return 0 if pkmn.moves[idxMove].total_pp<=0 + return 0 if pkmn.moves[idxMove].total_pp <= 0 oldpp = pkmn.moves[idxMove].pp - newpp = pkmn.moves[idxMove].pp+pp - newpp = pkmn.moves[idxMove].total_pp if newpp>pkmn.moves[idxMove].total_pp + newpp = pkmn.moves[idxMove].pp + pp + newpp = pkmn.moves[idxMove].total_pp if newpp > pkmn.moves[idxMove].total_pp pkmn.moves[idxMove].pp = newpp - return newpp-oldpp + return newpp - oldpp end def pbBattleRestorePP(pkmn, battler, idxMove, pp) - return if pbRestorePP(pkmn,idxMove,pp) == 0 + return if pbRestorePP(pkmn, idxMove, pp) == 0 if battler && !battler.effects[PBEffects::Transform] && battler.moves[idxMove] && battler.moves[idxMove].id == pkmn.moves[idxMove].id battler.pbSetPP(battler.moves[idxMove], pkmn.moves[idxMove].pp) @@ -464,8 +464,8 @@ def pbMaxUsesOfEVLoweringBerry(stat, pkmn) end def pbRaiseHappinessAndLowerEV(pkmn, scene, stat, qty, messages) - h = pkmn.happiness<255 - e = pkmn.ev[stat]>0 + h = pkmn.happiness < 255 + e = pkmn.ev[stat] > 0 if !h && !e scene.pbDisplay(_INTL("It won't have any effect.")) return false @@ -475,11 +475,11 @@ def pbRaiseHappinessAndLowerEV(pkmn, scene, stat, qty, messages) end if e pkmn.ev[stat] -= 10 * qty - pkmn.ev[stat] = 0 if pkmn.ev[stat]<0 + pkmn.ev[stat] = 0 if pkmn.ev[stat] < 0 pkmn.calc_stats end scene.pbRefresh - scene.pbDisplay(messages[2-(h ? 0 : 2)-(e ? 0 : 1)]) + scene.pbDisplay(messages[2 - (h ? 0 : 2) - (e ? 0 : 1)]) return true end @@ -505,16 +505,16 @@ end #=============================================================================== # Battle items #=============================================================================== -def pbBattleItemCanCureStatus?(status,pkmn,scene,showMessages) - if !pkmn.able? || pkmn.status!=status +def pbBattleItemCanCureStatus?(status, pkmn, scene, showMessages) + if !pkmn.able? || pkmn.status != status scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages return false end return true end -def pbBattleItemCanRaiseStat?(stat,battler,scene,showMessages) - if !battler || !battler.pbCanRaiseStatStage?(stat,battler) +def pbBattleItemCanRaiseStat?(stat, battler, scene, showMessages) + if !battler || !battler.pbCanRaiseStatStage?(stat, battler) scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages return false end @@ -558,17 +558,17 @@ def pbClosestHiddenItem playerY = $game_player.y for event in $game_map.events.values next if !event.name[/hiddenitem/i] - next if (playerX-event.x).abs>=8 - next if (playerY-event.y).abs>=6 - next if $game_self_switches[[$game_map.map_id,event.id,"A"]] + next if (playerX - event.x).abs >= 8 + next if (playerY - event.y).abs >= 6 + next if $game_self_switches[[$game_map.map_id, event.id, "A"]] result.push(event) end - return nil if result.length==0 + return nil if result.length == 0 ret = nil retmin = 0 for event in result - dist = (playerX-event.x).abs+(playerY-event.y).abs - next if ret && retmin<=dist + dist = (playerX - event.x).abs + (playerY - event.y).abs + next if ret && retmin <= dist ret = event retmin = dist end @@ -605,10 +605,10 @@ def pbLearnMove(pkmn, move, ignore_if_known = false, by_machine = false, &block) move_index = pbForgetMove(pkmn, move) if move_index >= 0 old_move_name = pkmn.moves[move_index].name - oldmovepp = pkmn.moves[move_index].pp + oldmovepp = pkmn.moves[move_index].pp pkmn.moves[move_index] = Pokemon::Move.new(move) # Replaces current/total PP if by_machine && Settings::TAUGHT_MACHINES_KEEP_OLD_PP - pkmn.moves[move_index].pp = [oldmovepp,pkmn.moves[move_index].total_pp].min + pkmn.moves[move_index].pp = [oldmovepp, pkmn.moves[move_index].total_pp].min end pbMessage(_INTL("1, 2, and...\\wt[16] ...\\wt[16] ...\\wt[16] Ta-da!\\se[Battle ball drop]\1"), &block) pbMessage(_INTL("{1} forgot how to use {2}.\\nAnd...\1", pkmn_name, old_move_name), &block) @@ -626,12 +626,12 @@ def pbLearnMove(pkmn, move, ignore_if_known = false, by_machine = false, &block) return false end -def pbForgetMove(pkmn,moveToLearn) +def pbForgetMove(pkmn, moveToLearn) ret = -1 pbFadeOutIn { scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene) - ret = screen.pbStartForgetScreen([pkmn],0,moveToLearn) + ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn) } return ret end @@ -640,7 +640,7 @@ end # Use an item from the Bag and/or on a Pokémon #=============================================================================== # @return [Integer] 0 = item wasn't used; 1 = item used; 2 = close Bag to use in field -def pbUseItem(bag,item,bagscene = nil) +def pbUseItem(bag, item, bagscene = nil) itm = GameData::Item.get(item) useType = itm.field_use if itm.is_machine? # TM or TR or HM @@ -651,15 +651,15 @@ def pbUseItem(bag,item,bagscene = nil) machine = itm.move return 0 if !machine movename = GameData::Move.get(machine).name - pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",itm.name)) - if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",movename)) + pbMessage(_INTL("\\se[PC access]You booted up {1}.\1", itm.name)) + if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?", movename)) return 0 - elsif pbMoveTutorChoose(machine,nil,true,itm.is_TR?) + elsif pbMoveTutorChoose(machine, nil, true, itm.is_TR?) bag.remove(item) if itm.consumed_after_use? return 1 end return 0 - elsif useType==1 # Item is usable on a Pokémon + elsif useType == 1 # Item is usable on a Pokémon if $player.pokemon_count == 0 pbMessage(_INTL("There is no Pokémon.")) return 0 @@ -675,12 +675,12 @@ def pbUseItem(bag,item,bagscene = nil) end pbFadeOutIn { scene = PokemonParty_Scene.new - screen = PokemonPartyScreen.new(scene,$player.party) - screen.pbStartScene(_INTL("Use on which Pokémon?"),false,annot) + screen = PokemonPartyScreen.new(scene, $player.party) + screen.pbStartScene(_INTL("Use on which Pokémon?"), false, annot) loop do scene.pbSetHelpText(_INTL("Use on which Pokémon?")) chosen = screen.pbChoosePokemon - if chosen<0 + if chosen < 0 ret = false break end @@ -709,7 +709,7 @@ def pbUseItem(bag,item,bagscene = nil) bagscene.pbRefresh if bagscene } return (ret) ? 1 : 0 - elsif useType==2 # Item is usable from Bag + elsif useType == 2 # Item is usable from Bag intret = ItemHandlers.triggerUseFromBag(item) if intret >= 0 bag.remove(item) if intret == 1 && itm.consumed_after_use? @@ -724,7 +724,7 @@ end # Only called when in the party screen and having chosen an item to be used on # the selected Pokémon -def pbUseItemOnPokemon(item,pkmn,scene) +def pbUseItemOnPokemon(item, pkmn, scene) itm = GameData::Item.get(item) # TM or HM if itm.is_machine? @@ -734,11 +734,11 @@ def pbUseItemOnPokemon(item,pkmn,scene) if pkmn.shadowPokemon? pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { scene.pbUpdate } elsif !pkmn.compatible_with_move?(machine) - pbMessage(_INTL("{1} can't learn {2}.",pkmn.name,movename)) { scene.pbUpdate } + pbMessage(_INTL("{1} can't learn {2}.", pkmn.name, movename)) { scene.pbUpdate } else - pbMessage(_INTL("\\se[PC access]You booted up {1}.\1",itm.name)) { scene.pbUpdate } - if pbConfirmMessage(_INTL("Do you want to teach {1} to {2}?",movename,pkmn.name)) { scene.pbUpdate } - if pbLearnMove(pkmn,machine,false,true) { scene.pbUpdate } + pbMessage(_INTL("\\se[PC access]You booted up {1}.\1", itm.name)) { scene.pbUpdate } + if pbConfirmMessage(_INTL("Do you want to teach {1} to {2}?", movename, pkmn.name)) { scene.pbUpdate } + if pbLearnMove(pkmn, machine, false, true) { scene.pbUpdate } $bag.remove(item) if itm.consumed_after_use? return true end @@ -762,7 +762,7 @@ def pbUseItemOnPokemon(item,pkmn,scene) if ret && itm.consumed_after_use? $bag.remove(item, qty) if !$bag.has?(item) - pbMessage(_INTL("You used your last {1}.",itm.name)) { scene.pbUpdate } + pbMessage(_INTL("You used your last {1}.", itm.name)) { scene.pbUpdate } end end return ret @@ -770,7 +770,7 @@ end def pbUseKeyItemInField(item) ret = ItemHandlers.triggerUseInField(item) - if ret==-1 # Item effect not found + if ret == -1 # Item effect not found pbMessage(_INTL("Can't use that here.")) elsif ret > 0 && GameData::Item.get(item).consumed_after_use? $bag.remove(item) @@ -781,36 +781,36 @@ end def pbUseItemMessage(item) itemname = GameData::Item.get(item).name if itemname.starts_with_vowel? - pbMessage(_INTL("You used an {1}.",itemname)) + pbMessage(_INTL("You used an {1}.", itemname)) else - pbMessage(_INTL("You used a {1}.",itemname)) + pbMessage(_INTL("You used a {1}.", itemname)) end end -def pbCheckUseOnPokemon(_item,pkmn,_screen) +def pbCheckUseOnPokemon(_item, pkmn, _screen) return pkmn && !pkmn.egg? end #=============================================================================== # Give an item to a Pokémon to hold, and take a held item from a Pokémon #=============================================================================== -def pbGiveItemToPokemon(item,pkmn,scene,pkmnid = 0) +def pbGiveItemToPokemon(item, pkmn, scene, pkmnid = 0) newitemname = GameData::Item.get(item).name if pkmn.egg? scene.pbDisplay(_INTL("Eggs can't hold items.")) return false elsif pkmn.mail - scene.pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",pkmn.name)) - return false if !pbTakeItemFromPokemon(pkmn,scene) + scene.pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.", pkmn.name)) + return false if !pbTakeItemFromPokemon(pkmn, scene) end if pkmn.hasItem? olditemname = pkmn.item.name if pkmn.hasItem?(:LEFTOVERS) - scene.pbDisplay(_INTL("{1} is already holding some {2}.\1",pkmn.name,olditemname)) + scene.pbDisplay(_INTL("{1} is already holding some {2}.\1", pkmn.name, olditemname)) elsif newitemname.starts_with_vowel? - scene.pbDisplay(_INTL("{1} is already holding an {2}.\1",pkmn.name,olditemname)) + scene.pbDisplay(_INTL("{1} is already holding an {2}.\1", pkmn.name, olditemname)) else - scene.pbDisplay(_INTL("{1} is already holding a {2}.\1",pkmn.name,olditemname)) + scene.pbDisplay(_INTL("{1} is already holding a {2}.\1", pkmn.name, olditemname)) end if scene.pbConfirm(_INTL("Would you like to switch the two items?")) $bag.remove(item) @@ -821,9 +821,9 @@ def pbGiveItemToPokemon(item,pkmn,scene,pkmnid = 0) scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed.")) else if GameData::Item.get(item).is_mail? - if pbWriteMail(item,pkmn,pkmnid,scene) + if pbWriteMail(item, pkmn, pkmnid, scene) pkmn.item = item - scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.",olditemname,pkmn.name,newitemname)) + scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname)) return true else if !$bag.add(item) @@ -832,26 +832,26 @@ def pbGiveItemToPokemon(item,pkmn,scene,pkmnid = 0) end else pkmn.item = item - scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.",olditemname,pkmn.name,newitemname)) + scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname)) return true end end end else - if !GameData::Item.get(item).is_mail? || pbWriteMail(item,pkmn,pkmnid,scene) + if !GameData::Item.get(item).is_mail? || pbWriteMail(item, pkmn, pkmnid, scene) $bag.remove(item) pkmn.item = item - scene.pbDisplay(_INTL("{1} is now holding the {2}.",pkmn.name,newitemname)) + scene.pbDisplay(_INTL("{1} is now holding the {2}.", pkmn.name, newitemname)) return true end end return false end -def pbTakeItemFromPokemon(pkmn,scene) +def pbTakeItemFromPokemon(pkmn, scene) ret = false if !pkmn.hasItem? - scene.pbDisplay(_INTL("{1} isn't holding anything.",pkmn.name)) + scene.pbDisplay(_INTL("{1} isn't holding anything.", pkmn.name)) elsif !$bag.can_add?(pkmn.item) scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed.")) elsif pkmn.mail @@ -865,14 +865,14 @@ def pbTakeItemFromPokemon(pkmn,scene) end elsif scene.pbConfirm(_INTL("If the mail is removed, its message will be lost. OK?")) $bag.add(pkmn.item) - scene.pbDisplay(_INTL("Received the {1} from {2}.",pkmn.item.name,pkmn.name)) + scene.pbDisplay(_INTL("Received the {1} from {2}.", pkmn.item.name, pkmn.name)) pkmn.item = nil pkmn.mail = nil ret = true end else $bag.add(pkmn.item) - scene.pbDisplay(_INTL("Received the {1} from {2}.",pkmn.item.name,pkmn.name)) + scene.pbDisplay(_INTL("Received the {1} from {2}.", pkmn.item.name, pkmn.name)) pkmn.item = nil ret = true end @@ -934,7 +934,7 @@ def pbChooseItemFromList(message, variable, *args) commands.push(_INTL("Cancel")) itemid.push(nil) ret = pbMessage(message, commands, -1) - if ret < 0 || ret >= commands.length-1 + if ret < 0 || ret >= commands.length - 1 $game_variables[variable] = nil return nil end diff --git a/Data/Scripts/013_Items/002_Item_Effects.rb b/Data/Scripts/013_Items/002_Item_Effects.rb index 0bf2e397a..2039930df 100644 --- a/Data/Scripts/013_Items/002_Item_Effects.rb +++ b/Data/Scripts/013_Items/002_Item_Effects.rb @@ -1,11 +1,11 @@ #=============================================================================== # UseText handlers #=============================================================================== -ItemHandlers::UseText.add(:BICYCLE,proc { |item| +ItemHandlers::UseText.add(:BICYCLE, proc { |item| next ($PokemonGlobal.bicycle) ? _INTL("Walk") : _INTL("Use") }) -ItemHandlers::UseText.copy(:BICYCLE,:MACHBIKE,:ACROBIKE) +ItemHandlers::UseText.copy(:BICYCLE, :MACHBIKE, :ACROBIKE) #=============================================================================== # UseFromBag handlers @@ -16,42 +16,42 @@ ItemHandlers::UseText.copy(:BICYCLE,:MACHBIKE,:ACROBIKE) # a Pokémon and not a TM/HM), calls the UseInField handler for it instead. #=============================================================================== -ItemHandlers::UseFromBag.add(:HONEY,proc { |item| +ItemHandlers::UseFromBag.add(:HONEY, proc { |item| next 2 }) -ItemHandlers::UseFromBag.add(:ESCAPEROPE,proc { |item| +ItemHandlers::UseFromBag.add(:ESCAPEROPE, proc { |item| if !$game_player.can_map_transfer_with_follower? pbMessage(_INTL("It can't be used when you have someone with you.")) next 0 end - if ($PokemonGlobal.escapePoint rescue false) && $PokemonGlobal.escapePoint.length>0 + if ($PokemonGlobal.escapePoint rescue false) && $PokemonGlobal.escapePoint.length > 0 next 2 # End screen and use item end pbMessage(_INTL("Can't use that here.")) next 0 }) -ItemHandlers::UseFromBag.add(:BICYCLE,proc { |item| +ItemHandlers::UseFromBag.add(:BICYCLE, proc { |item| next (pbBikeCheck) ? 2 : 0 }) -ItemHandlers::UseFromBag.copy(:BICYCLE,:MACHBIKE,:ACROBIKE) +ItemHandlers::UseFromBag.copy(:BICYCLE, :MACHBIKE, :ACROBIKE) -ItemHandlers::UseFromBag.add(:OLDROD,proc { |item| - notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player) +ItemHandlers::UseFromBag.add(:OLDROD, proc { |item| + notCliff = $game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player) next 2 if $game_player.pbFacingTerrainTag.can_fish && ($PokemonGlobal.surfing || notCliff) pbMessage(_INTL("Can't use that here.")) next 0 }) -ItemHandlers::UseFromBag.copy(:OLDROD,:GOODROD,:SUPERROD) +ItemHandlers::UseFromBag.copy(:OLDROD, :GOODROD, :SUPERROD) -ItemHandlers::UseFromBag.add(:ITEMFINDER,proc { |item| +ItemHandlers::UseFromBag.add(:ITEMFINDER, proc { |item| next 2 }) -ItemHandlers::UseFromBag.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE) +ItemHandlers::UseFromBag.copy(:ITEMFINDER, :DOWSINGMCHN, :DOWSINGMACHINE) ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item| pbFadeOutIn { @@ -71,9 +71,9 @@ ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item| # If an item does not have this handler, it is treated as returning true. #=============================================================================== -ItemHandlers::ConfirmUseInField.add(:ESCAPEROPE,proc { |item| +ItemHandlers::ConfirmUseInField.add(:ESCAPEROPE, proc { |item| escape = ($PokemonGlobal.escapePoint rescue nil) - if !escape || escape==[] + if !escape || escape == [] pbMessage(_INTL("Can't use that here.")) next false end @@ -82,7 +82,7 @@ ItemHandlers::ConfirmUseInField.add(:ESCAPEROPE,proc { |item| next false end mapname = pbGetMapNameFromId(escape[0]) - next pbConfirmMessage(_INTL("Want to escape from here and return to {1}?",mapname)) + next pbConfirmMessage(_INTL("Want to escape from here and return to {1}?", mapname)) }) #=============================================================================== @@ -94,8 +94,8 @@ ItemHandlers::ConfirmUseInField.add(:ESCAPEROPE,proc { |item| # If an item has this handler, it can be registered to the Ready Menu. #=============================================================================== -def pbRepel(item,steps) - if $PokemonGlobal.repel>0 +def pbRepel(item, steps) + if $PokemonGlobal.repel > 0 pbMessage(_INTL("But a repellent's effect still lingers from earlier.")) return false end @@ -105,16 +105,16 @@ def pbRepel(item,steps) return true end -ItemHandlers::UseInField.add(:REPEL,proc { |item| - next pbRepel(item,100) +ItemHandlers::UseInField.add(:REPEL, proc { |item| + next pbRepel(item, 100) }) -ItemHandlers::UseInField.add(:SUPERREPEL,proc { |item| - next pbRepel(item,200) +ItemHandlers::UseInField.add(:SUPERREPEL, proc { |item| + next pbRepel(item, 200) }) -ItemHandlers::UseInField.add(:MAXREPEL,proc { |item| - next pbRepel(item,250) +ItemHandlers::UseInField.add(:MAXREPEL, proc { |item| + next pbRepel(item, 250) }) Events.onStepTaken += proc { @@ -140,7 +140,7 @@ Events.onStepTaken += proc { end } -ItemHandlers::UseInField.add(:BLACKFLUTE,proc { |item| +ItemHandlers::UseInField.add(:BLACKFLUTE, proc { |item| pbUseItemMessage(item) pbMessage(_INTL("Wild Pokémon will be repelled.")) $PokemonMap.blackFluteUsed = true @@ -148,7 +148,7 @@ ItemHandlers::UseInField.add(:BLACKFLUTE,proc { |item| next true }) -ItemHandlers::UseInField.add(:WHITEFLUTE,proc { |item| +ItemHandlers::UseInField.add(:WHITEFLUTE, proc { |item| pbUseItemMessage(item) pbMessage(_INTL("Wild Pokémon will be lured.")) $PokemonMap.blackFluteUsed = false @@ -156,15 +156,15 @@ ItemHandlers::UseInField.add(:WHITEFLUTE,proc { |item| next true }) -ItemHandlers::UseInField.add(:HONEY,proc { |item| +ItemHandlers::UseInField.add(:HONEY, proc { |item| pbUseItemMessage(item) pbSweetScent next true }) -ItemHandlers::UseInField.add(:ESCAPEROPE,proc { |item| +ItemHandlers::UseInField.add(:ESCAPEROPE, proc { |item| escape = ($PokemonGlobal.escapePoint rescue nil) - if !escape || escape==[] + if !escape || escape == [] pbMessage(_INTL("Can't use that here.")) next false end @@ -187,7 +187,7 @@ ItemHandlers::UseInField.add(:ESCAPEROPE,proc { |item| next true }) -ItemHandlers::UseInField.add(:SACREDASH,proc { |item| +ItemHandlers::UseInField.add(:SACREDASH, proc { |item| if $player.pokemon_count == 0 pbMessage(_INTL("There is no Pokémon.")) next false @@ -206,7 +206,7 @@ ItemHandlers::UseInField.add(:SACREDASH,proc { |item| pbFadeOutIn { scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) - screen.pbStartScene(_INTL("Using item..."),false) + screen.pbStartScene(_INTL("Using item..."), false) $player.party.each_with_index do |pkmn, i| next if !pkmn.fainted? revived += 1 @@ -214,7 +214,7 @@ ItemHandlers::UseInField.add(:SACREDASH,proc { |item| screen.pbRefreshSingle(i) screen.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) end - if revived==0 + if revived == 0 screen.pbDisplay(_INTL("It won't have any effect.")) end screen.pbEndScene @@ -222,7 +222,7 @@ ItemHandlers::UseInField.add(:SACREDASH,proc { |item| next (revived > 0) }) -ItemHandlers::UseInField.add(:BICYCLE,proc { |item| +ItemHandlers::UseInField.add(:BICYCLE, proc { |item| if pbBikeCheck if $PokemonGlobal.bicycle pbDismountBike @@ -234,71 +234,71 @@ ItemHandlers::UseInField.add(:BICYCLE,proc { |item| next false }) -ItemHandlers::UseInField.copy(:BICYCLE,:MACHBIKE,:ACROBIKE) +ItemHandlers::UseInField.copy(:BICYCLE, :MACHBIKE, :ACROBIKE) -ItemHandlers::UseInField.add(:OLDROD,proc { |item| - notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player) +ItemHandlers::UseInField.add(:OLDROD, proc { |item| + notCliff = $game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player) if !$game_player.pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff) pbMessage(_INTL("Can't use that here.")) next false end encounter = $PokemonEncounters.has_encounter_type?(:OldRod) - if pbFishing(encounter,1) + if pbFishing(encounter, 1) $stats.fishing_battles += 1 pbEncounter(:OldRod) end next true }) -ItemHandlers::UseInField.add(:GOODROD,proc { |item| - notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player) +ItemHandlers::UseInField.add(:GOODROD, proc { |item| + notCliff = $game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player) if !$game_player.pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff) pbMessage(_INTL("Can't use that here.")) next false end encounter = $PokemonEncounters.has_encounter_type?(:GoodRod) - if pbFishing(encounter,2) + if pbFishing(encounter, 2) $stats.fishing_battles += 1 pbEncounter(:GoodRod) end next true }) -ItemHandlers::UseInField.add(:SUPERROD,proc { |item| - notCliff = $game_map.passable?($game_player.x,$game_player.y,$game_player.direction,$game_player) +ItemHandlers::UseInField.add(:SUPERROD, proc { |item| + notCliff = $game_map.passable?($game_player.x, $game_player.y, $game_player.direction, $game_player) if !$game_player.pbFacingTerrainTag.can_fish || (!$PokemonGlobal.surfing && !notCliff) pbMessage(_INTL("Can't use that here.")) next false end encounter = $PokemonEncounters.has_encounter_type?(:SuperRod) - if pbFishing(encounter,3) + if pbFishing(encounter, 3) $stats.fishing_battles += 1 pbEncounter(:SuperRod) end next true }) -ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item| +ItemHandlers::UseInField.add(:ITEMFINDER, proc { |item| $stats.itemfinder_count += 1 event = pbClosestHiddenItem if !event pbMessage(_INTL("... \\wt[10]... \\wt[10]... \\wt[10]...\\wt[10]Nope! There's no response.")) else - offsetX = event.x-$game_player.x - offsetY = event.y-$game_player.y - if offsetX==0 && offsetY==0 # Standing on the item, spin around + offsetX = event.x - $game_player.x + offsetY = event.y - $game_player.y + if offsetX == 0 && offsetY == 0 # Standing on the item, spin around 4.times do - pbWait(Graphics.frame_rate*2/10) + pbWait(Graphics.frame_rate * 2 / 10) $game_player.turn_right_90 end - pbWait(Graphics.frame_rate*3/10) - pbMessage(_INTL("The {1}'s indicating something right underfoot!",GameData::Item.get(item).name)) + pbWait(Graphics.frame_rate * 3 / 10) + pbMessage(_INTL("The {1}'s indicating something right underfoot!", GameData::Item.get(item).name)) else # Item is nearby, face towards it direction = $game_player.direction - if offsetX.abs>offsetY.abs - direction = (offsetX<0) ? 4 : 6 + if offsetX.abs > offsetY.abs + direction = (offsetX < 0) ? 4 : 6 else - direction = (offsetY<0) ? 8 : 2 + direction = (offsetY < 0) ? 8 : 2 end case direction when 2 then $game_player.turn_down @@ -306,15 +306,15 @@ ItemHandlers::UseInField.add(:ITEMFINDER,proc { |item| when 6 then $game_player.turn_right when 8 then $game_player.turn_up end - pbWait(Graphics.frame_rate*3/10) - pbMessage(_INTL("Huh? The {1}'s responding!\1",GameData::Item.get(item).name)) + pbWait(Graphics.frame_rate * 3 / 10) + pbMessage(_INTL("Huh? The {1}'s responding!\1", GameData::Item.get(item).name)) pbMessage(_INTL("There's an item buried around here!")) end end next true }) -ItemHandlers::UseInField.copy(:ITEMFINDER,:DOWSINGMCHN,:DOWSINGMACHINE) +ItemHandlers::UseInField.copy(:ITEMFINDER, :DOWSINGMCHN, :DOWSINGMACHINE) ItemHandlers::UseInField.add(:TOWNMAP, proc { |item| pbShowMap(-1, false) if $game_temp.fly_destination.nil? @@ -322,18 +322,18 @@ ItemHandlers::UseInField.add(:TOWNMAP, proc { |item| next true }) -ItemHandlers::UseInField.add(:COINCASE,proc { |item| +ItemHandlers::UseInField.add(:COINCASE, proc { |item| pbMessage(_INTL("Coins: {1}", $player.coins.to_s_formatted)) next true }) -ItemHandlers::UseInField.add(:EXPALL,proc { |item| +ItemHandlers::UseInField.add(:EXPALL, proc { |item| $bag.replace_item(:EXPALL, :EXPALLOFF) pbMessage(_INTL("The Exp Share was turned off.")) next true }) -ItemHandlers::UseInField.add(:EXPALLOFF,proc { |item| +ItemHandlers::UseInField.add(:EXPALLOFF, proc { |item| $bag.replace_item(:EXPALLOFF, :EXPALL) pbMessage(_INTL("The Exp Share was turned on.")) next true @@ -355,7 +355,7 @@ ItemHandlers::UseOnPokemon.addIf(proc { |item| GameData::Item.get(item).is_evolu if newspecies pbFadeOutInWithMusic { evo = PokemonEvolutionScene.new - evo.pbStartScreen(pkmn,newspecies) + evo.pbStartScreen(pkmn, newspecies) evo.pbEvolution(false) evo.pbEndScreen if scene.is_a?(PokemonPartyScreen) @@ -370,160 +370,160 @@ ItemHandlers::UseOnPokemon.addIf(proc { |item| GameData::Item.get(item).is_evolu } ) -ItemHandlers::UseOnPokemon.add(:POTION,proc { |item, qty, pkmn, scene| - next pbHPItem(pkmn,20,scene) +ItemHandlers::UseOnPokemon.add(:POTION, proc { |item, qty, pkmn, scene| + next pbHPItem(pkmn, 20, scene) }) -ItemHandlers::UseOnPokemon.copy(:POTION,:BERRYJUICE,:SWEETHEART) -ItemHandlers::UseOnPokemon.copy(:POTION,:RAGECANDYBAR) if !Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS +ItemHandlers::UseOnPokemon.copy(:POTION, :BERRYJUICE, :SWEETHEART) +ItemHandlers::UseOnPokemon.copy(:POTION, :RAGECANDYBAR) if !Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS -ItemHandlers::UseOnPokemon.add(:SUPERPOTION,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:SUPERPOTION, proc { |item, qty, pkmn, scene| next pbHPItem(pkmn, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 60 : 50, scene) }) -ItemHandlers::UseOnPokemon.add(:HYPERPOTION,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:HYPERPOTION, proc { |item, qty, pkmn, scene| next pbHPItem(pkmn, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 120 : 200, scene) }) -ItemHandlers::UseOnPokemon.add(:MAXPOTION,proc { |item, qty, pkmn, scene| - next pbHPItem(pkmn,pkmn.totalhp-pkmn.hp,scene) +ItemHandlers::UseOnPokemon.add(:MAXPOTION, proc { |item, qty, pkmn, scene| + next pbHPItem(pkmn, pkmn.totalhp - pkmn.hp, scene) }) -ItemHandlers::UseOnPokemon.add(:FRESHWATER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:FRESHWATER, proc { |item, qty, pkmn, scene| next pbHPItem(pkmn, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 30 : 50, scene) }) -ItemHandlers::UseOnPokemon.add(:SODAPOP,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:SODAPOP, proc { |item, qty, pkmn, scene| next pbHPItem(pkmn, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 50 : 60, scene) }) -ItemHandlers::UseOnPokemon.add(:LEMONADE,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:LEMONADE, proc { |item, qty, pkmn, scene| next pbHPItem(pkmn, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 70 : 80, scene) }) -ItemHandlers::UseOnPokemon.add(:MOOMOOMILK,proc { |item, qty, pkmn, scene| - next pbHPItem(pkmn,100,scene) +ItemHandlers::UseOnPokemon.add(:MOOMOOMILK, proc { |item, qty, pkmn, scene| + next pbHPItem(pkmn, 100, scene) }) -ItemHandlers::UseOnPokemon.add(:ORANBERRY,proc { |item, qty, pkmn, scene| - next pbHPItem(pkmn,10,scene) +ItemHandlers::UseOnPokemon.add(:ORANBERRY, proc { |item, qty, pkmn, scene| + next pbHPItem(pkmn, 10, scene) }) -ItemHandlers::UseOnPokemon.add(:SITRUSBERRY,proc { |item, qty, pkmn, scene| - next pbHPItem(pkmn,pkmn.totalhp/4,scene) +ItemHandlers::UseOnPokemon.add(:SITRUSBERRY, proc { |item, qty, pkmn, scene| + next pbHPItem(pkmn, pkmn.totalhp / 4, scene) }) -ItemHandlers::UseOnPokemon.add(:AWAKENING,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:AWAKENING, proc { |item, qty, pkmn, scene| if pkmn.fainted? || pkmn.status != :SLEEP scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1} woke up.",pkmn.name)) + scene.pbDisplay(_INTL("{1} woke up.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.copy(:AWAKENING,:CHESTOBERRY,:BLUEFLUTE,:POKEFLUTE) +ItemHandlers::UseOnPokemon.copy(:AWAKENING, :CHESTOBERRY, :BLUEFLUTE, :POKEFLUTE) -ItemHandlers::UseOnPokemon.add(:ANTIDOTE,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:ANTIDOTE, proc { |item, qty, pkmn, scene| if pkmn.fainted? || pkmn.status != :POISON scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1} was cured of its poisoning.",pkmn.name)) + scene.pbDisplay(_INTL("{1} was cured of its poisoning.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.copy(:ANTIDOTE,:PECHABERRY) +ItemHandlers::UseOnPokemon.copy(:ANTIDOTE, :PECHABERRY) -ItemHandlers::UseOnPokemon.add(:BURNHEAL,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:BURNHEAL, proc { |item, qty, pkmn, scene| if pkmn.fainted? || pkmn.status != :BURN scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1}'s burn was healed.",pkmn.name)) + scene.pbDisplay(_INTL("{1}'s burn was healed.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.copy(:BURNHEAL,:RAWSTBERRY) +ItemHandlers::UseOnPokemon.copy(:BURNHEAL, :RAWSTBERRY) -ItemHandlers::UseOnPokemon.add(:PARALYZEHEAL,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:PARALYZEHEAL, proc { |item, qty, pkmn, scene| if pkmn.fainted? || pkmn.status != :PARALYSIS scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1} was cured of paralysis.",pkmn.name)) + scene.pbDisplay(_INTL("{1} was cured of paralysis.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.copy(:PARALYZEHEAL,:PARLYZHEAL,:CHERIBERRY) +ItemHandlers::UseOnPokemon.copy(:PARALYZEHEAL, :PARLYZHEAL, :CHERIBERRY) -ItemHandlers::UseOnPokemon.add(:ICEHEAL,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:ICEHEAL, proc { |item, qty, pkmn, scene| if pkmn.fainted? || pkmn.status != :FROZEN scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1} was thawed out.",pkmn.name)) + scene.pbDisplay(_INTL("{1} was thawed out.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.copy(:ICEHEAL,:ASPEARBERRY) +ItemHandlers::UseOnPokemon.copy(:ICEHEAL, :ASPEARBERRY) -ItemHandlers::UseOnPokemon.add(:FULLHEAL,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:FULLHEAL, proc { |item, qty, pkmn, scene| if pkmn.fainted? || pkmn.status == :NONE scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1} became healthy.",pkmn.name)) + scene.pbDisplay(_INTL("{1} became healthy.", pkmn.name)) next true }) ItemHandlers::UseOnPokemon.copy(:FULLHEAL, - :LAVACOOKIE,:OLDGATEAU,:CASTELIACONE,:LUMIOSEGALETTE,:SHALOURSABLE, - :BIGMALASADA,:PEWTERCRUNCHIES,:LUMBERRY) -ItemHandlers::UseOnPokemon.copy(:FULLHEAL,:RAGECANDYBAR) if Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS + :LAVACOOKIE, :OLDGATEAU, :CASTELIACONE, :LUMIOSEGALETTE, :SHALOURSABLE, + :BIGMALASADA, :PEWTERCRUNCHIES, :LUMBERRY) +ItemHandlers::UseOnPokemon.copy(:FULLHEAL, :RAGECANDYBAR) if Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS -ItemHandlers::UseOnPokemon.add(:FULLRESTORE,proc { |item, qty, pkmn, scene| - if pkmn.fainted? || (pkmn.hp==pkmn.totalhp && pkmn.status == :NONE) +ItemHandlers::UseOnPokemon.add(:FULLRESTORE, proc { |item, qty, pkmn, scene| + if pkmn.fainted? || (pkmn.hp == pkmn.totalhp && pkmn.status == :NONE) scene.pbDisplay(_INTL("It won't have any effect.")) next false end - hpgain = pbItemRestoreHP(pkmn,pkmn.totalhp-pkmn.hp) + hpgain = pbItemRestoreHP(pkmn, pkmn.totalhp - pkmn.hp) pkmn.heal_status scene.pbRefresh - if hpgain>0 - scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",pkmn.name,hpgain)) + if hpgain > 0 + scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.", pkmn.name, hpgain)) else - scene.pbDisplay(_INTL("{1} became healthy.",pkmn.name)) + scene.pbDisplay(_INTL("{1} became healthy.", pkmn.name)) end next true }) -ItemHandlers::UseOnPokemon.add(:REVIVE,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:REVIVE, proc { |item, qty, pkmn, scene| if !pkmn.fainted? scene.pbDisplay(_INTL("It won't have any effect.")) next false end - pkmn.hp = (pkmn.totalhp/2).floor - pkmn.hp = 1 if pkmn.hp<=0 + pkmn.hp = (pkmn.totalhp / 2).floor + pkmn.hp = 1 if pkmn.hp <= 0 pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1}'s HP was restored.",pkmn.name)) + scene.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.add(:MAXREVIVE,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:MAXREVIVE, proc { |item, qty, pkmn, scene| if !pkmn.fainted? scene.pbDisplay(_INTL("It won't have any effect.")) next false @@ -531,13 +531,13 @@ ItemHandlers::UseOnPokemon.add(:MAXREVIVE,proc { |item, qty, pkmn, scene| pkmn.heal_HP pkmn.heal_status scene.pbRefresh - scene.pbDisplay(_INTL("{1}'s HP was restored.",pkmn.name)) + scene.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) next true }) ItemHandlers::UseOnPokemon.copy(:MAXREVIVE, :MAXHONEY) -ItemHandlers::UseOnPokemon.add(:ENERGYPOWDER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:ENERGYPOWDER, proc { |item, qty, pkmn, scene| if pbHPItem(pkmn, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 60 : 50, scene) pkmn.changeHappiness("powder") next true @@ -545,7 +545,7 @@ ItemHandlers::UseOnPokemon.add(:ENERGYPOWDER,proc { |item, qty, pkmn, scene| next false }) -ItemHandlers::UseOnPokemon.add(:ENERGYROOT,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:ENERGYROOT, proc { |item, qty, pkmn, scene| if pbHPItem(pkmn, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 120 : 200, scene) pkmn.changeHappiness("energyroot") next true @@ -553,7 +553,7 @@ ItemHandlers::UseOnPokemon.add(:ENERGYROOT,proc { |item, qty, pkmn, scene| next false }) -ItemHandlers::UseOnPokemon.add(:HEALPOWDER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:HEALPOWDER, proc { |item, qty, pkmn, scene| if pkmn.fainted? || pkmn.status == :NONE scene.pbDisplay(_INTL("It won't have any effect.")) next false @@ -561,11 +561,11 @@ ItemHandlers::UseOnPokemon.add(:HEALPOWDER,proc { |item, qty, pkmn, scene| pkmn.heal_status pkmn.changeHappiness("powder") scene.pbRefresh - scene.pbDisplay(_INTL("{1} became healthy.",pkmn.name)) + scene.pbDisplay(_INTL("{1} became healthy.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.add(:REVIVALHERB,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:REVIVALHERB, proc { |item, qty, pkmn, scene| if !pkmn.fainted? scene.pbDisplay(_INTL("It won't have any effect.")) next false @@ -574,14 +574,14 @@ ItemHandlers::UseOnPokemon.add(:REVIVALHERB,proc { |item, qty, pkmn, scene| pkmn.heal_status pkmn.changeHappiness("revivalherb") scene.pbRefresh - scene.pbDisplay(_INTL("{1}'s HP was restored.",pkmn.name)) + scene.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) next true }) -ItemHandlers::UseOnPokemon.add(:ETHER,proc { |item, qty, pkmn, scene| - move = scene.pbChooseMove(pkmn,_INTL("Restore which move?")) - next false if move<0 - if pbRestorePP(pkmn,move,10)==0 +ItemHandlers::UseOnPokemon.add(:ETHER, proc { |item, qty, pkmn, scene| + move = scene.pbChooseMove(pkmn, _INTL("Restore which move?")) + next false if move < 0 + if pbRestorePP(pkmn, move, 10) == 0 scene.pbDisplay(_INTL("It won't have any effect.")) next false end @@ -589,12 +589,12 @@ ItemHandlers::UseOnPokemon.add(:ETHER,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.copy(:ETHER,:LEPPABERRY) +ItemHandlers::UseOnPokemon.copy(:ETHER, :LEPPABERRY) -ItemHandlers::UseOnPokemon.add(:MAXETHER,proc { |item, qty, pkmn, scene| - move = scene.pbChooseMove(pkmn,_INTL("Restore which move?")) - next false if move<0 - if pbRestorePP(pkmn,move,pkmn.moves[move].total_pp-pkmn.moves[move].pp)==0 +ItemHandlers::UseOnPokemon.add(:MAXETHER, proc { |item, qty, pkmn, scene| + move = scene.pbChooseMove(pkmn, _INTL("Restore which move?")) + next false if move < 0 + if pbRestorePP(pkmn, move, pkmn.moves[move].total_pp - pkmn.moves[move].pp) == 0 scene.pbDisplay(_INTL("It won't have any effect.")) next false end @@ -602,12 +602,12 @@ ItemHandlers::UseOnPokemon.add(:MAXETHER,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:ELIXIR,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:ELIXIR, proc { |item, qty, pkmn, scene| pprestored = 0 for i in 0...pkmn.moves.length - pprestored += pbRestorePP(pkmn,i,10) + pprestored += pbRestorePP(pkmn, i, 10) end - if pprestored==0 + if pprestored == 0 scene.pbDisplay(_INTL("It won't have any effect.")) next false end @@ -615,12 +615,12 @@ ItemHandlers::UseOnPokemon.add(:ELIXIR,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:MAXELIXIR,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:MAXELIXIR, proc { |item, qty, pkmn, scene| pprestored = 0 for i in 0...pkmn.moves.length - pprestored += pbRestorePP(pkmn,i,pkmn.moves[i].total_pp-pkmn.moves[i].pp) + pprestored += pbRestorePP(pkmn, i, pkmn.moves[i].total_pp - pkmn.moves[i].pp) end - if pprestored==0 + if pprestored == 0 scene.pbDisplay(_INTL("It won't have any effect.")) next false end @@ -628,31 +628,31 @@ ItemHandlers::UseOnPokemon.add(:MAXELIXIR,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:PPUP,proc { |item, qty, pkmn, scene| - move = scene.pbChooseMove(pkmn,_INTL("Boost PP of which move?")) - if move>=0 - if pkmn.moves[move].total_pp<=1 || pkmn.moves[move].ppup>=3 +ItemHandlers::UseOnPokemon.add(:PPUP, proc { |item, qty, pkmn, scene| + move = scene.pbChooseMove(pkmn, _INTL("Boost PP of which move?")) + if move >= 0 + if pkmn.moves[move].total_pp <= 1 || pkmn.moves[move].ppup >= 3 scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.moves[move].ppup += 1 movename = pkmn.moves[move].name - scene.pbDisplay(_INTL("{1}'s PP increased.",movename)) + scene.pbDisplay(_INTL("{1}'s PP increased.", movename)) next true end next false }) -ItemHandlers::UseOnPokemon.add(:PPMAX,proc { |item, qty, pkmn, scene| - move = scene.pbChooseMove(pkmn,_INTL("Boost PP of which move?")) - if move>=0 - if pkmn.moves[move].total_pp<=1 || pkmn.moves[move].ppup>=3 +ItemHandlers::UseOnPokemon.add(:PPMAX, proc { |item, qty, pkmn, scene| + move = scene.pbChooseMove(pkmn, _INTL("Boost PP of which move?")) + if move >= 0 + if pkmn.moves[move].total_pp <= 1 || pkmn.moves[move].ppup >= 3 scene.pbDisplay(_INTL("It won't have any effect.")) next false end pkmn.moves[move].ppup = 3 movename = pkmn.moves[move].name - scene.pbDisplay(_INTL("{1}'s PP increased.",movename)) + scene.pbDisplay(_INTL("{1}'s PP increased.", movename)) next true end next false @@ -662,7 +662,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:HPUP, proc { |item, pkmn| next pbMaxUsesOfEVRaisingItem(:HP, 10, pkmn, Settings::NO_VITAMIN_EV_CAP) }) -ItemHandlers::UseOnPokemon.add(:HPUP,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:HPUP, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:HP, 10, qty, pkmn, "vitamin", scene, Settings::NO_VITAMIN_EV_CAP) }) @@ -670,7 +670,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:PROTEIN, proc { |item, pkmn| next pbMaxUsesOfEVRaisingItem(:ATTACK, 10, pkmn, Settings::NO_VITAMIN_EV_CAP) }) -ItemHandlers::UseOnPokemon.add(:PROTEIN,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:PROTEIN, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:ATTACK, 10, qty, pkmn, "vitamin", scene, Settings::NO_VITAMIN_EV_CAP) }) @@ -678,7 +678,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:IRON, proc { |item, pkmn| next pbMaxUsesOfEVRaisingItem(:DEFENSE, 10, pkmn, Settings::NO_VITAMIN_EV_CAP) }) -ItemHandlers::UseOnPokemon.add(:IRON,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:IRON, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:DEFENSE, 10, qty, pkmn, "vitamin", scene, Settings::NO_VITAMIN_EV_CAP) }) @@ -686,7 +686,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:CALCIUM, proc { |item, pkmn| next pbMaxUsesOfEVRaisingItem(:SPECIAL_ATTACK, 10, pkmn, Settings::NO_VITAMIN_EV_CAP) }) -ItemHandlers::UseOnPokemon.add(:CALCIUM,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:CALCIUM, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:SPECIAL_ATTACK, 10, qty, pkmn, "vitamin", scene, Settings::NO_VITAMIN_EV_CAP) }) @@ -694,7 +694,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:ZINC, proc { |item, pkmn| next pbMaxUsesOfEVRaisingItem(:SPECIAL_DEFENSE, 10, pkmn, Settings::NO_VITAMIN_EV_CAP) }) -ItemHandlers::UseOnPokemon.add(:ZINC,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:ZINC, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:SPECIAL_DEFENSE, 10, qty, pkmn, "vitamin", scene, Settings::NO_VITAMIN_EV_CAP) }) @@ -702,7 +702,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:CARBOS, proc { |item, pkmn| next pbMaxUsesOfEVRaisingItem(:SPEED, 10, pkmn, Settings::NO_VITAMIN_EV_CAP) }) -ItemHandlers::UseOnPokemon.add(:CARBOS,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:CARBOS, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:SPEED, 10, qty, pkmn, "vitamin", scene, Settings::NO_VITAMIN_EV_CAP) }) @@ -712,7 +712,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:HEALTHFEATHER, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.copy(:HEALTHFEATHER, :HEALTHWING) -ItemHandlers::UseOnPokemon.add(:HEALTHFEATHER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:HEALTHFEATHER, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:HP, 1, qty, pkmn, "wing", scene, true) }) @@ -724,7 +724,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:MUSCLEFEATHER, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.copy(:MUSCLEFEATHER, :MUSCLEWING) -ItemHandlers::UseOnPokemon.add(:MUSCLEFEATHER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:MUSCLEFEATHER, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:ATTACK, 1, qty, pkmn, "wing", scene, true) }) @@ -736,7 +736,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:RESISTFEATHER, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.copy(:RESISTFEATHER, :RESISTWING) -ItemHandlers::UseOnPokemon.add(:RESISTFEATHER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:RESISTFEATHER, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:DEFENSE, 1, qty, pkmn, "wing", scene, true) }) @@ -748,7 +748,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:GENIUSFEATHER, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.copy(:GENIUSFEATHER, :GENIUSWING) -ItemHandlers::UseOnPokemon.add(:GENIUSFEATHER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:GENIUSFEATHER, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:SPECIAL_ATTACK, 1, qty, pkmn, "wing", scene, true) }) @@ -760,7 +760,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:CLEVERFEATHER, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.copy(:CLEVERFEATHER, :CLEVERWING) -ItemHandlers::UseOnPokemon.add(:CLEVERFEATHER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:CLEVERFEATHER, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:SPECIAL_DEFENSE, 1, qty, pkmn, "wing", scene, true) }) @@ -772,7 +772,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:SWIFTFEATHER, proc { |item, pkmn| ItemHandlers::UseOnPokemonMaximum.copy(:SWIFTFEATHER, :SWIFTWING) -ItemHandlers::UseOnPokemon.add(:SWIFTFEATHER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:SWIFTFEATHER, proc { |item, qty, pkmn, scene| next pbUseEVRaisingItem(:SPEED, 1, qty, pkmn, "wing", scene, true) }) @@ -866,7 +866,7 @@ ItemHandlers::UseOnPokemonMaximum.add(:RARECANDY, proc { |item, pkmn| next GameData::GrowthRate.max_level - pkmn.level }) -ItemHandlers::UseOnPokemon.add(:RARECANDY,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:RARECANDY, proc { |item, qty, pkmn, scene| if pkmn.shadowPokemon? scene.pbDisplay(_INTL("It won't have any effect.")) next false @@ -888,7 +888,7 @@ ItemHandlers::UseOnPokemon.add(:RARECANDY,proc { |item, qty, pkmn, scene| next true end # Level up - pbChangeLevel(pkmn,pkmn.level + qty, scene) + pbChangeLevel(pkmn, pkmn.level + qty, scene) scene.pbHardRefresh next true }) @@ -942,11 +942,11 @@ ItemHandlers::UseOnPokemonMaximum.add(:POMEGBERRY, proc { |item, pkmn| next pbMaxUsesOfEVLoweringBerry(:HP, pkmn) }) -ItemHandlers::UseOnPokemon.add(:POMEGBERRY,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:POMEGBERRY, proc { |item, qty, pkmn, scene| next pbRaiseHappinessAndLowerEV(pkmn, scene, :HP, qty, [ - _INTL("{1} adores you! Its base HP fell!",pkmn.name), - _INTL("{1} became more friendly. Its base HP can't go lower.",pkmn.name), - _INTL("{1} became more friendly. However, its base HP fell!",pkmn.name) + _INTL("{1} adores you! Its base HP fell!", pkmn.name), + _INTL("{1} became more friendly. Its base HP can't go lower.", pkmn.name), + _INTL("{1} became more friendly. However, its base HP fell!", pkmn.name) ]) }) @@ -954,11 +954,11 @@ ItemHandlers::UseOnPokemonMaximum.add(:KELPSYBERRY, proc { |item, pkmn| next pbMaxUsesOfEVLoweringBerry(:ATTACK, pkmn) }) -ItemHandlers::UseOnPokemon.add(:KELPSYBERRY,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:KELPSYBERRY, proc { |item, qty, pkmn, scene| next pbRaiseHappinessAndLowerEV(pkmn, scene, :ATTACK, qty, [ - _INTL("{1} adores you! Its base Attack fell!",pkmn.name), - _INTL("{1} became more friendly. Its base Attack can't go lower.",pkmn.name), - _INTL("{1} became more friendly. However, its base Attack fell!",pkmn.name) + _INTL("{1} adores you! Its base Attack fell!", pkmn.name), + _INTL("{1} became more friendly. Its base Attack can't go lower.", pkmn.name), + _INTL("{1} became more friendly. However, its base Attack fell!", pkmn.name) ]) }) @@ -966,11 +966,11 @@ ItemHandlers::UseOnPokemonMaximum.add(:QUALOTBERRY, proc { |item, pkmn| next pbMaxUsesOfEVLoweringBerry(:DEFENSE, pkmn) }) -ItemHandlers::UseOnPokemon.add(:QUALOTBERRY,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:QUALOTBERRY, proc { |item, qty, pkmn, scene| next pbRaiseHappinessAndLowerEV(pkmn, scene, :DEFENSE, qty, [ - _INTL("{1} adores you! Its base Defense fell!",pkmn.name), - _INTL("{1} became more friendly. Its base Defense can't go lower.",pkmn.name), - _INTL("{1} became more friendly. However, its base Defense fell!",pkmn.name) + _INTL("{1} adores you! Its base Defense fell!", pkmn.name), + _INTL("{1} became more friendly. Its base Defense can't go lower.", pkmn.name), + _INTL("{1} became more friendly. However, its base Defense fell!", pkmn.name) ]) }) @@ -978,11 +978,11 @@ ItemHandlers::UseOnPokemonMaximum.add(:HONDEWBERRY, proc { |item, pkmn| next pbMaxUsesOfEVLoweringBerry(:SPECIAL_ATTACK, pkmn) }) -ItemHandlers::UseOnPokemon.add(:HONDEWBERRY,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:HONDEWBERRY, proc { |item, qty, pkmn, scene| next pbRaiseHappinessAndLowerEV(pkmn, scene, :SPECIAL_ATTACK, qty, [ - _INTL("{1} adores you! Its base Special Attack fell!",pkmn.name), - _INTL("{1} became more friendly. Its base Special Attack can't go lower.",pkmn.name), - _INTL("{1} became more friendly. However, its base Special Attack fell!",pkmn.name) + _INTL("{1} adores you! Its base Special Attack fell!", pkmn.name), + _INTL("{1} became more friendly. Its base Special Attack can't go lower.", pkmn.name), + _INTL("{1} became more friendly. However, its base Special Attack fell!", pkmn.name) ]) }) @@ -990,11 +990,11 @@ ItemHandlers::UseOnPokemonMaximum.add(:GREPABERRY, proc { |item, pkmn| next pbMaxUsesOfEVLoweringBerry(:SPECIAL_DEFENSE, pkmn) }) -ItemHandlers::UseOnPokemon.add(:GREPABERRY,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:GREPABERRY, proc { |item, qty, pkmn, scene| next pbRaiseHappinessAndLowerEV(pkmn, scene, :SPECIAL_DEFENSE, qty, [ - _INTL("{1} adores you! Its base Special Defense fell!",pkmn.name), - _INTL("{1} became more friendly. Its base Special Defense can't go lower.",pkmn.name), - _INTL("{1} became more friendly. However, its base Special Defense fell!",pkmn.name) + _INTL("{1} adores you! Its base Special Defense fell!", pkmn.name), + _INTL("{1} became more friendly. Its base Special Defense can't go lower.", pkmn.name), + _INTL("{1} became more friendly. However, its base Special Defense fell!", pkmn.name) ]) }) @@ -1002,15 +1002,15 @@ ItemHandlers::UseOnPokemonMaximum.add(:TAMATOBERRY, proc { |item, pkmn| next pbMaxUsesOfEVLoweringBerry(:SPEED, pkmn) }) -ItemHandlers::UseOnPokemon.add(:TAMATOBERRY,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:TAMATOBERRY, proc { |item, qty, pkmn, scene| next pbRaiseHappinessAndLowerEV(pkmn, scene, :SPEED, qty, [ - _INTL("{1} adores you! Its base Speed fell!",pkmn.name), - _INTL("{1} became more friendly. Its base Speed can't go lower.",pkmn.name), - _INTL("{1} became more friendly. However, its base Speed fell!",pkmn.name) + _INTL("{1} adores you! Its base Speed fell!", pkmn.name), + _INTL("{1} became more friendly. Its base Speed can't go lower.", pkmn.name), + _INTL("{1} became more friendly. However, its base Speed fell!", pkmn.name) ]) }) -ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:ABILITYCAPSULE, proc { |item, qty, pkmn, scene| if scene.pbConfirm(_INTL("Do you want to change {1}'s Ability?", pkmn.name)) abils = pkmn.getAbilityList abil1 = nil @@ -1054,7 +1054,7 @@ ItemHandlers::UseOnPokemon.add(:ABILITYPATCH, proc { |item, qty, pkmn, scene| next false }) -ItemHandlers::UseOnPokemon.add(:GRACIDEA,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:GRACIDEA, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:SHAYMIN) || pkmn.form != 0 || pkmn.status == :FROZEN || PBDayNight.isNight? scene.pbDisplay(_INTL("It had no effect.")) @@ -1065,13 +1065,13 @@ ItemHandlers::UseOnPokemon.add(:GRACIDEA,proc { |item, qty, pkmn, scene| end pkmn.setForm(1) { scene.pbRefresh - scene.pbDisplay(_INTL("{1} changed Forme!",pkmn.name)) + scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) } next true }) -ItemHandlers::UseOnPokemon.add(:REDNECTAR,proc { |item, qty, pkmn, scene| - if !pkmn.isSpecies?(:ORICORIO) || pkmn.form==0 +ItemHandlers::UseOnPokemon.add(:REDNECTAR, proc { |item, qty, pkmn, scene| + if !pkmn.isSpecies?(:ORICORIO) || pkmn.form == 0 scene.pbDisplay(_INTL("It had no effect.")) next false elsif pkmn.fainted? @@ -1080,13 +1080,13 @@ ItemHandlers::UseOnPokemon.add(:REDNECTAR,proc { |item, qty, pkmn, scene| end pkmn.setForm(0) { scene.pbRefresh - scene.pbDisplay(_INTL("{1} changed form!",pkmn.name)) + scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) } next true }) -ItemHandlers::UseOnPokemon.add(:YELLOWNECTAR,proc { |item, qty, pkmn, scene| - if !pkmn.isSpecies?(:ORICORIO) || pkmn.form==1 +ItemHandlers::UseOnPokemon.add(:YELLOWNECTAR, proc { |item, qty, pkmn, scene| + if !pkmn.isSpecies?(:ORICORIO) || pkmn.form == 1 scene.pbDisplay(_INTL("It had no effect.")) next false elsif pkmn.fainted? @@ -1095,13 +1095,13 @@ ItemHandlers::UseOnPokemon.add(:YELLOWNECTAR,proc { |item, qty, pkmn, scene| end pkmn.setForm(1) { scene.pbRefresh - scene.pbDisplay(_INTL("{1} changed form!",pkmn.name)) + scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) } next true }) -ItemHandlers::UseOnPokemon.add(:PINKNECTAR,proc { |item, qty, pkmn, scene| - if !pkmn.isSpecies?(:ORICORIO) || pkmn.form==2 +ItemHandlers::UseOnPokemon.add(:PINKNECTAR, proc { |item, qty, pkmn, scene| + if !pkmn.isSpecies?(:ORICORIO) || pkmn.form == 2 scene.pbDisplay(_INTL("It had no effect.")) next false elsif pkmn.fainted? @@ -1110,13 +1110,13 @@ ItemHandlers::UseOnPokemon.add(:PINKNECTAR,proc { |item, qty, pkmn, scene| end pkmn.setForm(2) { scene.pbRefresh - scene.pbDisplay(_INTL("{1} changed form!",pkmn.name)) + scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) } next true }) -ItemHandlers::UseOnPokemon.add(:PURPLENECTAR,proc { |item, qty, pkmn, scene| - if !pkmn.isSpecies?(:ORICORIO) || pkmn.form==3 +ItemHandlers::UseOnPokemon.add(:PURPLENECTAR, proc { |item, qty, pkmn, scene| + if !pkmn.isSpecies?(:ORICORIO) || pkmn.form == 3 scene.pbDisplay(_INTL("It had no effect.")) next false elsif pkmn.fainted? @@ -1125,12 +1125,12 @@ ItemHandlers::UseOnPokemon.add(:PURPLENECTAR,proc { |item, qty, pkmn, scene| end pkmn.setForm(3) { scene.pbRefresh - scene.pbDisplay(_INTL("{1} changed form!",pkmn.name)) + scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) } next true }) -ItemHandlers::UseOnPokemon.add(:REVEALGLASS,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:REVEALGLASS, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:TORNADUS) && !pkmn.isSpecies?(:THUNDURUS) && !pkmn.isSpecies?(:LANDORUS) @@ -1140,15 +1140,15 @@ ItemHandlers::UseOnPokemon.add(:REVEALGLASS,proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) next false end - newForm = (pkmn.form==0) ? 1 : 0 + newForm = (pkmn.form == 0) ? 1 : 0 pkmn.setForm(newForm) { scene.pbRefresh - scene.pbDisplay(_INTL("{1} changed Forme!",pkmn.name)) + scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) } next true }) -ItemHandlers::UseOnPokemon.add(:PRISONBOTTLE,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:PRISONBOTTLE, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:HOOPA) scene.pbDisplay(_INTL("It had no effect.")) next false @@ -1156,10 +1156,10 @@ ItemHandlers::UseOnPokemon.add(:PRISONBOTTLE,proc { |item, qty, pkmn, scene| scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) next false end - newForm = (pkmn.form==0) ? 1 : 0 + newForm = (pkmn.form == 0) ? 1 : 0 pkmn.setForm(newForm) { scene.pbRefresh - scene.pbDisplay(_INTL("{1} changed Forme!",pkmn.name)) + scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) } next true }) @@ -1224,7 +1224,7 @@ ItemHandlers::UseOnPokemon.add(:ZYGARDECUBE, proc { |item, qty, pkmn, scene| next false }) -ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:DNASPLICERS, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:KYUREM) || !pkmn.fused.nil? scene.pbDisplay(_INTL("It had no effect.")) next false @@ -1262,7 +1262,7 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:DNASPLICERSUSED,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:DNASPLICERSUSED, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:KYUREM) || pkmn.fused.nil? scene.pbDisplay(_INTL("It had no effect.")) next false @@ -1284,7 +1284,7 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERSUSED,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:NSOLARIZER, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:NECROZMA) || !pkmn.fused.nil? scene.pbDisplay(_INTL("It had no effect.")) next false @@ -1319,7 +1319,7 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:NSOLARIZERUSED,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:NSOLARIZERUSED, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:NECROZMA) || pkmn.form != 1 || pkmn.fused.nil? scene.pbDisplay(_INTL("It had no effect.")) next false @@ -1341,7 +1341,7 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZERUSED,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:NLUNARIZER, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:NECROZMA) || !pkmn.fused.nil? scene.pbDisplay(_INTL("It had no effect.")) next false @@ -1376,7 +1376,7 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item, qty, pkmn, scene| next true }) -ItemHandlers::UseOnPokemon.add(:NLUNARIZERUSED,proc { |item, qty, pkmn, scene| +ItemHandlers::UseOnPokemon.add(:NLUNARIZERUSED, proc { |item, qty, pkmn, scene| if !pkmn.isSpecies?(:NECROZMA) || pkmn.form != 2 || pkmn.fused.nil? scene.pbDisplay(_INTL("It had no effect.")) next false diff --git a/Data/Scripts/013_Items/003_Item_BattleEffects.rb b/Data/Scripts/013_Items/003_Item_BattleEffects.rb index 1051becc8..b9a891723 100644 --- a/Data/Scripts/013_Items/003_Item_BattleEffects.rb +++ b/Data/Scripts/013_Items/003_Item_BattleEffects.rb @@ -1,15 +1,15 @@ #=============================================================================== # CanUseInBattle handlers #=============================================================================== -ItemHandlers::CanUseInBattle.add(:GUARDSPEC,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !battler || battler.pbOwnSide.effects[PBEffects::Mist]>0 +ItemHandlers::CanUseInBattle.add(:GUARDSPEC, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !battler || battler.pbOwnSide.effects[PBEffects::Mist] > 0 scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end next true }) -ItemHandlers::CanUseInBattle.add(:POKEDOLL,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:POKEDOLL, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if !battle.wildBattle? if showMessages scene.pbDisplay(_INTL("Oak's words echoed... There's a time and place for everything! But not now.")) @@ -23,10 +23,10 @@ ItemHandlers::CanUseInBattle.add(:POKEDOLL,proc { |item,pokemon,battler,move,fir next true }) -ItemHandlers::CanUseInBattle.copy(:POKEDOLL,:FLUFFYTAIL,:POKETOY) +ItemHandlers::CanUseInBattle.copy(:POKEDOLL, :FLUFFYTAIL, :POKETOY) ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls - proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| + proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if battle.pbPlayer.party_full? && $PokemonStorage.full? scene.pbDisplay(_INTL("There is no room left in the PC!")) if showMessages next false @@ -46,8 +46,8 @@ ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_pok # than one unfainted opposing Pokémon. (Snag Balls can be thrown in # this case, but only in trainer battles, and the trainer will deflect # them if they are trying to catch a non-Shadow Pokémon.) - if battle.pbOpposingBattlerCount>1 && !(GameData::Item.get(item).is_snag_ball? && battle.trainerBattle?) - if battle.pbOpposingBattlerCount==2 + if battle.pbOpposingBattlerCount > 1 && !(GameData::Item.get(item).is_snag_ball? && battle.trainerBattle?) + if battle.pbOpposingBattlerCount == 2 scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are two Pokémon!")) if showMessages else scene.pbDisplay(_INTL("It's no good! It's impossible to aim when there are more than one Pokémon!")) if showMessages @@ -58,8 +58,8 @@ ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_pok } ) -ItemHandlers::CanUseInBattle.add(:POTION,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !pokemon.able? || pokemon.hp==pokemon.totalhp +ItemHandlers::CanUseInBattle.add(:POTION, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !pokemon.able? || pokemon.hp == pokemon.totalhp scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end @@ -67,18 +67,18 @@ ItemHandlers::CanUseInBattle.add(:POTION,proc { |item,pokemon,battler,move,first }) ItemHandlers::CanUseInBattle.copy(:POTION, - :SUPERPOTION,:HYPERPOTION,:MAXPOTION,:BERRYJUICE,:SWEETHEART,:FRESHWATER, - :SODAPOP,:LEMONADE,:MOOMOOMILK,:ORANBERRY,:SITRUSBERRY,:ENERGYPOWDER, + :SUPERPOTION, :HYPERPOTION, :MAXPOTION, :BERRYJUICE, :SWEETHEART, :FRESHWATER, + :SODAPOP, :LEMONADE, :MOOMOOMILK, :ORANBERRY, :SITRUSBERRY, :ENERGYPOWDER, :ENERGYROOT) -ItemHandlers::CanUseInBattle.copy(:POTION,:RAGECANDYBAR) if !Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS +ItemHandlers::CanUseInBattle.copy(:POTION, :RAGECANDYBAR) if !Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS -ItemHandlers::CanUseInBattle.add(:AWAKENING,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:AWAKENING, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| next pbBattleItemCanCureStatus?(:SLEEP, pokemon, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:AWAKENING,:CHESTOBERRY) +ItemHandlers::CanUseInBattle.copy(:AWAKENING, :CHESTOBERRY) -ItemHandlers::CanUseInBattle.add(:BLUEFLUTE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:BLUEFLUTE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if battler && battler.hasActiveAbility?(:SOUNDPROOF) scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false @@ -86,34 +86,34 @@ ItemHandlers::CanUseInBattle.add(:BLUEFLUTE,proc { |item,pokemon,battler,move,fi next pbBattleItemCanCureStatus?(:SLEEP, pokemon, scene, showMessages) }) -ItemHandlers::CanUseInBattle.add(:ANTIDOTE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:ANTIDOTE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| next pbBattleItemCanCureStatus?(:POISON, pokemon, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:ANTIDOTE,:PECHABERRY) +ItemHandlers::CanUseInBattle.copy(:ANTIDOTE, :PECHABERRY) -ItemHandlers::CanUseInBattle.add(:BURNHEAL,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:BURNHEAL, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| next pbBattleItemCanCureStatus?(:BURN, pokemon, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:BURNHEAL,:RAWSTBERRY) +ItemHandlers::CanUseInBattle.copy(:BURNHEAL, :RAWSTBERRY) -ItemHandlers::CanUseInBattle.add(:PARALYZEHEAL,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:PARALYZEHEAL, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| next pbBattleItemCanCureStatus?(:PARALYSIS, pokemon, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:PARALYZEHEAL,:PARLYZHEAL,:CHERIBERRY) +ItemHandlers::CanUseInBattle.copy(:PARALYZEHEAL, :PARLYZHEAL, :CHERIBERRY) -ItemHandlers::CanUseInBattle.add(:ICEHEAL,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:ICEHEAL, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| next pbBattleItemCanCureStatus?(:FROZEN, pokemon, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:ICEHEAL,:ASPEARBERRY) +ItemHandlers::CanUseInBattle.copy(:ICEHEAL, :ASPEARBERRY) -ItemHandlers::CanUseInBattle.add(:FULLHEAL,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:FULLHEAL, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if !pokemon.able? || (pokemon.status == :NONE && - (!battler || battler.effects[PBEffects::Confusion]==0)) + (!battler || battler.effects[PBEffects::Confusion] == 0)) scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end @@ -121,21 +121,21 @@ ItemHandlers::CanUseInBattle.add(:FULLHEAL,proc { |item,pokemon,battler,move,fir }) ItemHandlers::CanUseInBattle.copy(:FULLHEAL, - :LAVACOOKIE,:OLDGATEAU,:CASTELIACONE,:LUMIOSEGALETTE,:SHALOURSABLE, - :BIGMALASADA,:PEWTERCRUNCHIES,:LUMBERRY,:HEALPOWDER) -ItemHandlers::CanUseInBattle.copy(:FULLHEAL,:RAGECANDYBAR) if Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS + :LAVACOOKIE, :OLDGATEAU, :CASTELIACONE, :LUMIOSEGALETTE, :SHALOURSABLE, + :BIGMALASADA, :PEWTERCRUNCHIES, :LUMBERRY, :HEALPOWDER) +ItemHandlers::CanUseInBattle.copy(:FULLHEAL, :RAGECANDYBAR) if Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS -ItemHandlers::CanUseInBattle.add(:FULLRESTORE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:FULLRESTORE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if !pokemon.able? || (pokemon.hp == pokemon.totalhp && pokemon.status == :NONE && - (!battler || battler.effects[PBEffects::Confusion]==0)) + (!battler || battler.effects[PBEffects::Confusion] == 0)) scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end next true }) -ItemHandlers::CanUseInBattle.add(:REVIVE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:REVIVE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if pokemon.able? || pokemon.egg? scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false @@ -145,27 +145,27 @@ ItemHandlers::CanUseInBattle.add(:REVIVE,proc { |item,pokemon,battler,move,first ItemHandlers::CanUseInBattle.copy(:REVIVE, :MAXREVIVE, :REVIVALHERB, :MAXHONEY) -ItemHandlers::CanUseInBattle.add(:ETHER,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !pokemon.able? || move<0 || - pokemon.moves[move].total_pp<=0 || - pokemon.moves[move].pp==pokemon.moves[move].total_pp +ItemHandlers::CanUseInBattle.add(:ETHER, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !pokemon.able? || move < 0 || + pokemon.moves[move].total_pp <= 0 || + pokemon.moves[move].pp == pokemon.moves[move].total_pp scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end next true }) -ItemHandlers::CanUseInBattle.copy(:ETHER,:MAXETHER,:LEPPABERRY) +ItemHandlers::CanUseInBattle.copy(:ETHER, :MAXETHER, :LEPPABERRY) -ItemHandlers::CanUseInBattle.add(:ELIXIR,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:ELIXIR, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if !pokemon.able? scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end canRestore = false for m in pokemon.moves - next if m.id==0 - next if m.total_pp<=0 || m.pp==m.total_pp + next if m.id == 0 + next if m.total_pp <= 0 || m.pp == m.total_pp canRestore = true break end @@ -176,10 +176,10 @@ ItemHandlers::CanUseInBattle.add(:ELIXIR,proc { |item,pokemon,battler,move,first next true }) -ItemHandlers::CanUseInBattle.copy(:ELIXIR,:MAXELIXIR) +ItemHandlers::CanUseInBattle.copy(:ELIXIR, :MAXELIXIR) -ItemHandlers::CanUseInBattle.add(:REDFLUTE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !battler || battler.effects[PBEffects::Attract]<0 || +ItemHandlers::CanUseInBattle.add(:REDFLUTE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !battler || battler.effects[PBEffects::Attract] < 0 || battler.hasActiveAbility?(:SOUNDPROOF) scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false @@ -187,16 +187,16 @@ ItemHandlers::CanUseInBattle.add(:REDFLUTE,proc { |item,pokemon,battler,move,fir next true }) -ItemHandlers::CanUseInBattle.add(:PERSIMBERRY,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !battler || battler.effects[PBEffects::Confusion]==0 +ItemHandlers::CanUseInBattle.add(:PERSIMBERRY, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !battler || battler.effects[PBEffects::Confusion] == 0 scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end next true }) -ItemHandlers::CanUseInBattle.add(:YELLOWFLUTE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !battler || battler.effects[PBEffects::Confusion]==0 || +ItemHandlers::CanUseInBattle.add(:YELLOWFLUTE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !battler || battler.effects[PBEffects::Confusion] == 0 || battler.hasActiveAbility?(:SOUNDPROOF) scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false @@ -204,43 +204,43 @@ ItemHandlers::CanUseInBattle.add(:YELLOWFLUTE,proc { |item,pokemon,battler,move, next true }) -ItemHandlers::CanUseInBattle.add(:XATTACK,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - next pbBattleItemCanRaiseStat?(:ATTACK,battler,scene,showMessages) +ItemHandlers::CanUseInBattle.add(:XATTACK, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + next pbBattleItemCanRaiseStat?(:ATTACK, battler, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:XATTACK,:XATTACK2,:XATTACK3,:XATTACK6) +ItemHandlers::CanUseInBattle.copy(:XATTACK, :XATTACK2, :XATTACK3, :XATTACK6) -ItemHandlers::CanUseInBattle.add(:XDEFENSE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - next pbBattleItemCanRaiseStat?(:DEFENSE,battler,scene,showMessages) +ItemHandlers::CanUseInBattle.add(:XDEFENSE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + next pbBattleItemCanRaiseStat?(:DEFENSE, battler, scene, showMessages) }) ItemHandlers::CanUseInBattle.copy(:XDEFENSE, - :XDEFENSE2,:XDEFENSE3,:XDEFENSE6,:XDEFEND,:XDEFEND2,:XDEFEND3,:XDEFEND6) + :XDEFENSE2, :XDEFENSE3, :XDEFENSE6, :XDEFEND, :XDEFEND2, :XDEFEND3, :XDEFEND6) -ItemHandlers::CanUseInBattle.add(:XSPATK,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - next pbBattleItemCanRaiseStat?(:SPECIAL_ATTACK,battler,scene,showMessages) +ItemHandlers::CanUseInBattle.add(:XSPATK, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + next pbBattleItemCanRaiseStat?(:SPECIAL_ATTACK, battler, scene, showMessages) }) ItemHandlers::CanUseInBattle.copy(:XSPATK, - :XSPATK2,:XSPATK3,:XSPATK6,:XSPECIAL,:XSPECIAL2,:XSPECIAL3,:XSPECIAL6) + :XSPATK2, :XSPATK3, :XSPATK6, :XSPECIAL, :XSPECIAL2, :XSPECIAL3, :XSPECIAL6) -ItemHandlers::CanUseInBattle.add(:XSPDEF,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - next pbBattleItemCanRaiseStat?(:SPECIAL_DEFENSE,battler,scene,showMessages) +ItemHandlers::CanUseInBattle.add(:XSPDEF, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + next pbBattleItemCanRaiseStat?(:SPECIAL_DEFENSE, battler, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:XSPDEF,:XSPDEF2,:XSPDEF3,:XSPDEF6) +ItemHandlers::CanUseInBattle.copy(:XSPDEF, :XSPDEF2, :XSPDEF3, :XSPDEF6) -ItemHandlers::CanUseInBattle.add(:XSPEED,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - next pbBattleItemCanRaiseStat?(:SPEED,battler,scene,showMessages) +ItemHandlers::CanUseInBattle.add(:XSPEED, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + next pbBattleItemCanRaiseStat?(:SPEED, battler, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:XSPEED,:XSPEED2,:XSPEED3,:XSPEED6) +ItemHandlers::CanUseInBattle.copy(:XSPEED, :XSPEED2, :XSPEED3, :XSPEED6) -ItemHandlers::CanUseInBattle.add(:XACCURACY,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - next pbBattleItemCanRaiseStat?(:ACCURACY,battler,scene,showMessages) +ItemHandlers::CanUseInBattle.add(:XACCURACY, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + next pbBattleItemCanRaiseStat?(:ACCURACY, battler, scene, showMessages) }) -ItemHandlers::CanUseInBattle.copy(:XACCURACY,:XACCURACY2,:XACCURACY3,:XACCURACY6) +ItemHandlers::CanUseInBattle.copy(:XACCURACY, :XACCURACY2, :XACCURACY3, :XACCURACY6) ItemHandlers::CanUseInBattle.add(:MAXMUSHROOMS, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if !pbBattleItemCanRaiseStat?(:ATTACK, battler, scene, false) && @@ -254,31 +254,31 @@ ItemHandlers::CanUseInBattle.add(:MAXMUSHROOMS, proc { |item, pokemon, battler, next true }) -ItemHandlers::CanUseInBattle.add(:DIREHIT,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !battler || battler.effects[PBEffects::FocusEnergy]>=1 +ItemHandlers::CanUseInBattle.add(:DIREHIT, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !battler || battler.effects[PBEffects::FocusEnergy] >= 1 scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end next true }) -ItemHandlers::CanUseInBattle.add(:DIREHIT2,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !battler || battler.effects[PBEffects::FocusEnergy]>=2 +ItemHandlers::CanUseInBattle.add(:DIREHIT2, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !battler || battler.effects[PBEffects::FocusEnergy] >= 2 scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end next true }) -ItemHandlers::CanUseInBattle.add(:DIREHIT3,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if !battler || battler.effects[PBEffects::FocusEnergy]>=3 +ItemHandlers::CanUseInBattle.add(:DIREHIT3, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| + if !battler || battler.effects[PBEffects::FocusEnergy] >= 3 scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false end next true }) -ItemHandlers::CanUseInBattle.add(:POKEFLUTE,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:POKEFLUTE, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if battle.allBattlers.none? { |b| b.status == :SLEEP && !b.hasActiveAbility?(:SOUNDPROOF) } scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false @@ -290,20 +290,20 @@ ItemHandlers::CanUseInBattle.add(:POKEFLUTE,proc { |item,pokemon,battler,move,fi # UseInBattle handlers # For items used directly or on an opposing battler #=============================================================================== -ItemHandlers::UseInBattle.add(:GUARDSPEC,proc { |item,battler,battle| +ItemHandlers::UseInBattle.add(:GUARDSPEC, proc { |item, battler, battle| battler.pbOwnSide.effects[PBEffects::Mist] = 5 - battle.pbDisplay(_INTL("{1} became shrouded in mist!",battler.pbTeam)) + battle.pbDisplay(_INTL("{1} became shrouded in mist!", battler.pbTeam)) battler.pokemon.changeHappiness("battleitem") }) -ItemHandlers::UseInBattle.add(:POKEDOLL,proc { |item,battler,battle| +ItemHandlers::UseInBattle.add(:POKEDOLL, proc { |item, battler, battle| battle.decision = 3 battle.pbDisplayPaused(_INTL("You got away safely!")) }) -ItemHandlers::UseInBattle.copy(:POKEDOLL,:FLUFFYTAIL,:POKETOY) +ItemHandlers::UseInBattle.copy(:POKEDOLL, :FLUFFYTAIL, :POKETOY) -ItemHandlers::UseInBattle.add(:POKEFLUTE,proc { |item,battler,battle| +ItemHandlers::UseInBattle.add(:POKEFLUTE, proc { |item, battler, battle| battle.allBattlers.each do |b| b.pbCureStatus(false) if b.status == :SLEEP && !b.hasActiveAbility?(:SOUNDPROOF) end @@ -311,8 +311,8 @@ ItemHandlers::UseInBattle.add(:POKEFLUTE,proc { |item,battler,battle| }) ItemHandlers::UseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls - proc { |item,battler,battle| - battle.pbThrowPokeBall(battler.index,item) + proc { |item, battler, battle| + battle.pbThrowPokeBall(battler.index, item) } ) @@ -320,197 +320,197 @@ ItemHandlers::UseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_b # BattleUseOnPokemon handlers # For items used on Pokémon or on a Pokémon's move #=============================================================================== -ItemHandlers::BattleUseOnPokemon.add(:POTION,proc { |item,pokemon,battler,choices,scene| - pbBattleHPItem(pokemon,battler,20,scene) +ItemHandlers::BattleUseOnPokemon.add(:POTION, proc { |item, pokemon, battler, choices, scene| + pbBattleHPItem(pokemon, battler, 20, scene) }) -ItemHandlers::BattleUseOnPokemon.copy(:POTION,:BERRYJUICE,:SWEETHEART) -ItemHandlers::BattleUseOnPokemon.copy(:POTION,:RAGECANDYBAR) if !Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS +ItemHandlers::BattleUseOnPokemon.copy(:POTION, :BERRYJUICE, :SWEETHEART) +ItemHandlers::BattleUseOnPokemon.copy(:POTION, :RAGECANDYBAR) if !Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS -ItemHandlers::BattleUseOnPokemon.add(:SUPERPOTION,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:SUPERPOTION, proc { |item, pokemon, battler, choices, scene| pbBattleHPItem(pokemon, battler, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 60 : 50, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:HYPERPOTION,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:HYPERPOTION, proc { |item, pokemon, battler, choices, scene| pbBattleHPItem(pokemon, battler, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 120 : 200, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:MAXPOTION,proc { |item,pokemon,battler,choices,scene| - pbBattleHPItem(pokemon,battler,pokemon.totalhp-pokemon.hp,scene) +ItemHandlers::BattleUseOnPokemon.add(:MAXPOTION, proc { |item, pokemon, battler, choices, scene| + pbBattleHPItem(pokemon, battler, pokemon.totalhp - pokemon.hp, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:FRESHWATER,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:FRESHWATER, proc { |item, pokemon, battler, choices, scene| pbBattleHPItem(pokemon, battler, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 30 : 50, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:SODAPOP,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:SODAPOP, proc { |item, pokemon, battler, choices, scene| pbBattleHPItem(pokemon, battler, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 50 : 60, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:LEMONADE,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:LEMONADE, proc { |item, pokemon, battler, choices, scene| pbBattleHPItem(pokemon, battler, (Settings::REBALANCED_HEALING_ITEM_AMOUNTS) ? 70 : 80, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:MOOMOOMILK,proc { |item,pokemon,battler,choices,scene| - pbBattleHPItem(pokemon,battler,100,scene) +ItemHandlers::BattleUseOnPokemon.add(:MOOMOOMILK, proc { |item, pokemon, battler, choices, scene| + pbBattleHPItem(pokemon, battler, 100, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:ORANBERRY,proc { |item,pokemon,battler,choices,scene| - pbBattleHPItem(pokemon,battler,10,scene) +ItemHandlers::BattleUseOnPokemon.add(:ORANBERRY, proc { |item, pokemon, battler, choices, scene| + pbBattleHPItem(pokemon, battler, 10, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:SITRUSBERRY,proc { |item,pokemon,battler,choices,scene| - pbBattleHPItem(pokemon,battler,pokemon.totalhp/4,scene) +ItemHandlers::BattleUseOnPokemon.add(:SITRUSBERRY, proc { |item, pokemon, battler, choices, scene| + pbBattleHPItem(pokemon, battler, pokemon.totalhp / 4, scene) }) -ItemHandlers::BattleUseOnPokemon.add(:AWAKENING,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:AWAKENING, proc { |item, pokemon, battler, choices, scene| pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh - scene.pbDisplay(_INTL("{1} woke up.",name)) + scene.pbDisplay(_INTL("{1} woke up.", name)) }) -ItemHandlers::BattleUseOnPokemon.copy(:AWAKENING,:CHESTOBERRY,:BLUEFLUTE) +ItemHandlers::BattleUseOnPokemon.copy(:AWAKENING, :CHESTOBERRY, :BLUEFLUTE) -ItemHandlers::BattleUseOnPokemon.add(:ANTIDOTE,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:ANTIDOTE, proc { |item, pokemon, battler, choices, scene| pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh - scene.pbDisplay(_INTL("{1} was cured of its poisoning.",name)) + scene.pbDisplay(_INTL("{1} was cured of its poisoning.", name)) }) -ItemHandlers::BattleUseOnPokemon.copy(:ANTIDOTE,:PECHABERRY) +ItemHandlers::BattleUseOnPokemon.copy(:ANTIDOTE, :PECHABERRY) -ItemHandlers::BattleUseOnPokemon.add(:BURNHEAL,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:BURNHEAL, proc { |item, pokemon, battler, choices, scene| pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh - scene.pbDisplay(_INTL("{1}'s burn was healed.",name)) + scene.pbDisplay(_INTL("{1}'s burn was healed.", name)) }) -ItemHandlers::BattleUseOnPokemon.copy(:BURNHEAL,:RAWSTBERRY) +ItemHandlers::BattleUseOnPokemon.copy(:BURNHEAL, :RAWSTBERRY) -ItemHandlers::BattleUseOnPokemon.add(:PARALYZEHEAL,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:PARALYZEHEAL, proc { |item, pokemon, battler, choices, scene| pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh - scene.pbDisplay(_INTL("{1} was cured of paralysis.",name)) + scene.pbDisplay(_INTL("{1} was cured of paralysis.", name)) }) -ItemHandlers::BattleUseOnPokemon.copy(:PARALYZEHEAL,:PARLYZHEAL,:CHERIBERRY) +ItemHandlers::BattleUseOnPokemon.copy(:PARALYZEHEAL, :PARLYZHEAL, :CHERIBERRY) -ItemHandlers::BattleUseOnPokemon.add(:ICEHEAL,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:ICEHEAL, proc { |item, pokemon, battler, choices, scene| pokemon.heal_status battler.pbCureStatus(false) if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh - scene.pbDisplay(_INTL("{1} was thawed out.",name)) + scene.pbDisplay(_INTL("{1} was thawed out.", name)) }) -ItemHandlers::BattleUseOnPokemon.copy(:ICEHEAL,:ASPEARBERRY) +ItemHandlers::BattleUseOnPokemon.copy(:ICEHEAL, :ASPEARBERRY) -ItemHandlers::BattleUseOnPokemon.add(:FULLHEAL,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:FULLHEAL, proc { |item, pokemon, battler, choices, scene| pokemon.heal_status battler.pbCureStatus(false) if battler battler.pbCureConfusion if battler name = (battler) ? battler.pbThis : pokemon.name scene.pbRefresh - scene.pbDisplay(_INTL("{1} became healthy.",name)) + scene.pbDisplay(_INTL("{1} became healthy.", name)) }) ItemHandlers::BattleUseOnPokemon.copy(:FULLHEAL, - :LAVACOOKIE,:OLDGATEAU,:CASTELIACONE,:LUMIOSEGALETTE,:SHALOURSABLE, - :BIGMALASADA,:PEWTERCRUNCHIES,:LUMBERRY) -ItemHandlers::BattleUseOnPokemon.copy(:FULLHEAL,:RAGECANDYBAR) if Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS + :LAVACOOKIE, :OLDGATEAU, :CASTELIACONE, :LUMIOSEGALETTE, :SHALOURSABLE, + :BIGMALASADA, :PEWTERCRUNCHIES, :LUMBERRY) +ItemHandlers::BattleUseOnPokemon.copy(:FULLHEAL, :RAGECANDYBAR) if Settings::RAGE_CANDY_BAR_CURES_STATUS_PROBLEMS -ItemHandlers::BattleUseOnPokemon.add(:FULLRESTORE,proc { |item,pokemon,battler,choices,scene| +ItemHandlers::BattleUseOnPokemon.add(:FULLRESTORE, proc { |item, pokemon, battler, choices, scene| pokemon.heal_status battler.pbCureStatus(false) if battler battler.pbCureConfusion if battler name = (battler) ? battler.pbThis : pokemon.name - if pokemon.hp=2) + return (trainer && trainer[4] >= 2) end #=============================================================================== @@ -108,7 +108,7 @@ end def pbPhoneIncrement(tr_type, tr_name, maxbattles) trainer = pbFindPhoneTrainer(tr_type, tr_name) return if !trainer - trainer[5] += 1 if trainer[5]0 + if $PokemonGlobal.pokeradarBattery && $PokemonGlobal.pokeradarBattery > 0 pbMessage(_INTL("The battery has run dry!\nFor it to recharge, you need to walk another {1} steps.", $PokemonGlobal.pokeradarBattery)) return false @@ -59,23 +59,23 @@ def pbPokeRadarHighlightGrass(showmessage = true) grasses = [] # x, y, ring (0-3 inner to outer), rarity # Choose 1 random tile from each ring around the player for i in 0...4 - r = rand((i+1)*8) + r = rand((i + 1) * 8) # Get coordinates of randomly chosen tile x = $game_player.x y = $game_player.y - if r<=(i+1)*2 - x = $game_player.x-i-1+r - y = $game_player.y-i-1 - elsif r<=(i+1)*6-2 - x = [$game_player.x+i+1,$game_player.x-i-1][r%2] - y = $game_player.y-i+((r-1-(i+1)*2)/2).floor + if r <= (i + 1) * 2 + x = $game_player.x - i - 1 + r + y = $game_player.y - i - 1 + elsif r <= (i + 1) * 6 - 2 + x = [$game_player.x + i + 1, $game_player.x - i - 1][r % 2] + y = $game_player.y - i + ((r - 1 - (i + 1) * 2) / 2).floor else - x = $game_player.x-i+r-(i+1)*6 - y = $game_player.y+i+1 + x = $game_player.x - i + r - (i + 1) * 6 + y = $game_player.y + i + 1 end # Add tile to grasses array if it's a valid grass tile - if x>=0 && x<$game_map.width && - y>=0 && y<$game_map.height + if x >= 0 && x < $game_map.width && + y >= 0 && y < $game_map.height terrain = $game_map.terrain_tag(x, y) if terrain.land_wild_encounters && terrain.shows_grass_rustle # Choose a rarity for the grass (0=normal, 1=rare, 2=shiny) @@ -85,11 +85,11 @@ def pbPokeRadarHighlightGrass(showmessage = true) v = (65536 / v.to_f).ceil s = 2 if rand(65536) < v end - grasses.push([x,y,i,s]) + grasses.push([x, y, i, s]) end end end - if grasses.length==0 + if grasses.length == 0 # No shaking grass found, break the chain pbMessage(_INTL("The grassy patch remained quiet...")) if showmessage pbPokeRadarCancel @@ -98,15 +98,15 @@ def pbPokeRadarHighlightGrass(showmessage = true) for grass in grasses case grass[3] when 0 # Normal rustle - $scene.spriteset.addUserAnimation(Settings::RUSTLE_NORMAL_ANIMATION_ID,grass[0],grass[1],true,1) + $scene.spriteset.addUserAnimation(Settings::RUSTLE_NORMAL_ANIMATION_ID, grass[0], grass[1], true, 1) when 1 # Vigorous rustle - $scene.spriteset.addUserAnimation(Settings::RUSTLE_VIGOROUS_ANIMATION_ID,grass[0],grass[1],true,1) + $scene.spriteset.addUserAnimation(Settings::RUSTLE_VIGOROUS_ANIMATION_ID, grass[0], grass[1], true, 1) when 2 # Shiny rustle - $scene.spriteset.addUserAnimation(Settings::RUSTLE_SHINY_ANIMATION_ID,grass[0],grass[1],true,1) + $scene.spriteset.addUserAnimation(Settings::RUSTLE_SHINY_ANIMATION_ID, grass[0], grass[1], true, 1) end end $game_temp.poke_radar_data[3] = grasses if $game_temp.poke_radar_data - pbWait(Graphics.frame_rate/2) + pbWait(Graphics.frame_rate / 2) end end @@ -192,23 +192,23 @@ EncounterModifier.register(proc { |encounter| next encounter }) -Events.onWildPokemonCreate += proc { |_sender,e| +Events.onWildPokemonCreate += proc { |_sender, e| pokemon = e[0] next if !$game_temp.poke_radar_data grasses = $game_temp.poke_radar_data[3] next if !grasses for grass in grasses - next if $game_player.x!=grass[0] || $game_player.y!=grass[1] - pokemon.shiny = true if grass[3]==2 + next if $game_player.x != grass[0] || $game_player.y != grass[1] + pokemon.shiny = true if grass[3] == 2 break end } -Events.onWildBattleEnd += proc { |_sender,e| +Events.onWildBattleEnd += proc { |_sender, e| species = e[0] level = e[1] decision = e[2] - if $game_temp.poke_radar_data && (decision==1 || decision==4) # Defeated/caught + if $game_temp.poke_radar_data && (decision == 1 || decision == 4) # Defeated/caught $game_temp.poke_radar_data[0] = species $game_temp.poke_radar_data[1] = level $game_temp.poke_radar_data[2] += 1 @@ -221,28 +221,28 @@ Events.onWildBattleEnd += proc { |_sender,e| end } -Events.onStepTaken += proc { |_sender,_e| +Events.onStepTaken += proc { |_sender, _e| if $PokemonGlobal.pokeradarBattery && $PokemonGlobal.pokeradarBattery > 0 && !$game_temp.poke_radar_data $PokemonGlobal.pokeradarBattery -= 1 end - terrain = $game_map.terrain_tag($game_player.x,$game_player.y) + terrain = $game_map.terrain_tag($game_player.x, $game_player.y) if !terrain.land_wild_encounters || !terrain.shows_grass_rustle pbPokeRadarCancel end } -Events.onMapChange += proc { |_sender,_e| +Events.onMapChange += proc { |_sender, _e| pbPokeRadarCancel } ################################################################################ # Item handlers ################################################################################ -ItemHandlers::UseInField.add(:POKERADAR,proc { |item| +ItemHandlers::UseInField.add(:POKERADAR, proc { |item| next pbUsePokeRadar }) -ItemHandlers::UseFromBag.add(:POKERADAR,proc { |item| +ItemHandlers::UseFromBag.add(:POKERADAR, proc { |item| next (pbCanUsePokeRadar?) ? 2 : 0 }) diff --git a/Data/Scripts/013_Items/006_Item_Mail.rb b/Data/Scripts/013_Items/006_Item_Mail.rb index f438c9fba..523cf5542 100644 --- a/Data/Scripts/013_Items/006_Item_Mail.rb +++ b/Data/Scripts/013_Items/006_Item_Mail.rb @@ -16,64 +16,64 @@ end def pbMoveToMailbox(pokemon) $PokemonGlobal.mailbox = [] if !$PokemonGlobal.mailbox - return false if $PokemonGlobal.mailbox.length>=10 + return false if $PokemonGlobal.mailbox.length >= 10 return false if !pokemon.mail $PokemonGlobal.mailbox.push(pokemon.mail) pokemon.mail = nil return true end -def pbStoreMail(pkmn,item,message,poke1 = nil,poke2 = nil,poke3 = nil) +def pbStoreMail(pkmn, item, message, poke1 = nil, poke2 = nil, poke3 = nil) raise _INTL("Pokémon already has mail") if pkmn.mail pkmn.mail = Mail.new(item, message, $player.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 = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 - addBackgroundPlane(sprites,"background","mailbg",viewport) - sprites["card"] = IconSprite.new(0,0,viewport) + addBackgroundPlane(sprites, "background", "mailbg", viewport) + sprites["card"] = IconSprite.new(0, 0, viewport) sprites["card"].setBitmap(GameData::Item.mail_filename(mail.item)) - sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,viewport) + sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, viewport) overlay = sprites["overlay"].bitmap pbSetSystemFont(overlay) if GameData::Item.get(mail.item).is_icon_mail? if mail.poke1 - sprites["bearer"] = IconSprite.new(64,288,viewport) + sprites["bearer"] = IconSprite.new(64, 288, viewport) bitmapFileName = GameData::Species.icon_filename(mail.poke1[0], mail.poke1[3], mail.poke1[1], mail.poke1[2], mail.poke1[4], mail.poke1[5]) sprites["bearer"].setBitmap(bitmapFileName) - sprites["bearer"].src_rect.set(0,0,64,64) + sprites["bearer"].src_rect.set(0, 0, 64, 64) end if mail.poke2 - sprites["bearer2"] = IconSprite.new(144,288,viewport) + sprites["bearer2"] = IconSprite.new(144, 288, viewport) bitmapFileName = GameData::Species.icon_filename(mail.poke2[0], mail.poke2[3], mail.poke2[1], mail.poke2[2], mail.poke2[4], mail.poke2[5]) sprites["bearer2"].setBitmap(bitmapFileName) - sprites["bearer2"].src_rect.set(0,0,64,64) + sprites["bearer2"].src_rect.set(0, 0, 64, 64) end if mail.poke3 - sprites["bearer3"] = IconSprite.new(224,288,viewport) + sprites["bearer3"] = IconSprite.new(224, 288, viewport) bitmapFileName = GameData::Species.icon_filename(mail.poke3[0], mail.poke3[3], mail.poke3[1], mail.poke3[2], mail.poke3[4], mail.poke3[5]) sprites["bearer3"].setBitmap(bitmapFileName) - sprites["bearer3"].src_rect.set(0,0,64,64) + sprites["bearer3"].src_rect.set(0, 0, 64, 64) end end - baseForDarkBG = Color.new(248,248,248) - shadowForDarkBG = Color.new(72,80,88) - baseForLightBG = Color.new(80,80,88) - shadowForLightBG = Color.new(168,168,176) - if mail.message && mail.message!="" - isDark = isDarkBackground(sprites["card"].bitmap,Rect.new(48,48,Graphics.width-96,32*7)) - drawTextEx(overlay,48,52,Graphics.width-(48*2),7,mail.message, + baseForDarkBG = Color.new(248, 248, 248) + shadowForDarkBG = Color.new(72, 80, 88) + baseForLightBG = Color.new(80, 80, 88) + shadowForLightBG = Color.new(168, 168, 176) + if mail.message && mail.message != "" + isDark = isDarkBackground(sprites["card"].bitmap, Rect.new(48, 48, Graphics.width - 96, 32 * 7)) + drawTextEx(overlay, 48, 52, Graphics.width - (48 * 2), 7, mail.message, (isDark) ? baseForDarkBG : baseForLightBG, (isDark) ? shadowForDarkBG : shadowForLightBG) end - if mail.sender && mail.sender!="" - isDark = isDarkBackground(sprites["card"].bitmap,Rect.new(336,322,144,32*1)) - drawTextEx(overlay,336,326,144,1,mail.sender, + if mail.sender && mail.sender != "" + isDark = isDarkBackground(sprites["card"].bitmap, Rect.new(336, 322, 144, 32 * 1)) + drawTextEx(overlay, 336, 326, 144, 1, mail.sender, (isDark) ? baseForDarkBG : baseForLightBG, (isDark) ? shadowForDarkBG : shadowForLightBG) end @@ -91,27 +91,27 @@ def pbDisplayMail(mail,_bearer = nil) viewport.dispose end -def pbWriteMail(item,pkmn,pkmnid,scene) +def pbWriteMail(item, pkmn, pkmnid, scene) message = "" loop do message = pbMessageFreeText(_INTL("Please enter a message (max. 250 characters)."), - "",false,250,Graphics.width) { scene.pbUpdate } - if message!="" + "", false, 250, Graphics.width) { scene.pbUpdate } + if message != "" # Store mail if a message was written poke1 = poke2 = nil - if $player.party[pkmnid+2] - p = $player.party[pkmnid+2] - poke1 = [p.species,p.gender,p.shiny?,p.form,p.shadowPokemon?] + if $player.party[pkmnid + 2] + p = $player.party[pkmnid + 2] + poke1 = [p.species, p.gender, p.shiny?, p.form, p.shadowPokemon?] poke1.push(true) if p.egg? end - if $player.party[pkmnid+1] - p = $player.party[pkmnid+1] - poke2 = [p.species,p.gender,p.shiny?,p.form,p.shadowPokemon?] + if $player.party[pkmnid + 1] + p = $player.party[pkmnid + 1] + poke2 = [p.species, p.gender, p.shiny?, p.form, p.shadowPokemon?] poke2.push(true) if p.egg? end - poke3 = [pkmn.species,pkmn.gender,pkmn.shiny?,pkmn.form,pkmn.shadowPokemon?] + poke3 = [pkmn.species, pkmn.gender, pkmn.shiny?, pkmn.form, pkmn.shadowPokemon?] poke3.push(true) if pkmn.egg? - pbStoreMail(pkmn,item,message,poke1,poke2,poke3) + pbStoreMail(pkmn, item, message, poke1, poke2, poke3) return true end return false if scene.pbConfirm(_INTL("Stop giving the Pokémon Mail?")) diff --git a/Data/Scripts/013_Items/007_Item_Sprites.rb b/Data/Scripts/013_Items/007_Item_Sprites.rb index df8d2a534..b38456b84 100644 --- a/Data/Scripts/013_Items/007_Item_Sprites.rb +++ b/Data/Scripts/013_Items/007_Item_Sprites.rb @@ -7,7 +7,7 @@ class ItemIconSprite < SpriteWrapper ANIM_ICON_SIZE = 48 FRAMES_PER_CYCLE = Graphics.frame_rate - def initialize(x,y,item,viewport = nil) + def initialize(x, y, item, viewport = nil) super(viewport) @animbitmap = nil @animframe = 0 @@ -28,7 +28,7 @@ class ItemIconSprite < SpriteWrapper def width return 0 if !self.bitmap || self.bitmap.disposed? - return (@numframes==1) ? self.bitmap.width : ANIM_ICON_SIZE + return (@numframes == 1) ? self.bitmap.width : ANIM_ICON_SIZE end def height @@ -53,7 +53,7 @@ class ItemIconSprite < SpriteWrapper when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight self.oy = 0 when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right - self.oy = self.height/2 + self.oy = self.height / 2 when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight self.oy = self.height end @@ -61,26 +61,26 @@ class ItemIconSprite < SpriteWrapper when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft self.ox = 0 when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom - self.ox = self.width/2 + self.ox = self.width / 2 when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight self.ox = self.width end end def item=(value) - return if @item==value && !@forceitemchange + return if @item == value && !@forceitemchange @item = value @animbitmap.dispose if @animbitmap @animbitmap = nil if @item || !@blankzero @animbitmap = AnimatedBitmap.new(GameData::Item.icon_filename(@item)) self.bitmap = @animbitmap.bitmap - if self.bitmap.height==ANIM_ICON_SIZE - @numframes = [(self.bitmap.width/ANIM_ICON_SIZE).floor,1].max - self.src_rect = Rect.new(0,0,ANIM_ICON_SIZE,ANIM_ICON_SIZE) + if self.bitmap.height == ANIM_ICON_SIZE + @numframes = [(self.bitmap.width / ANIM_ICON_SIZE).floor, 1].max + self.src_rect = Rect.new(0, 0, ANIM_ICON_SIZE, ANIM_ICON_SIZE) else @numframes = 1 - self.src_rect = Rect.new(0,0,self.bitmap.width,self.bitmap.height) + self.src_rect = Rect.new(0, 0, self.bitmap.width, self.bitmap.height) end @animframe = 0 @frame = 0 @@ -96,12 +96,12 @@ class ItemIconSprite < SpriteWrapper if @animbitmap @animbitmap.update self.bitmap = @animbitmap.bitmap - if @numframes>1 - frameskip = (FRAMES_PER_CYCLE/@numframes).floor - @frame = (@frame+1)%FRAMES_PER_CYCLE - if @frame>=frameskip - @animframe = (@animframe+1)%@numframes - self.src_rect.x = @animframe*ANIM_ICON_SIZE + if @numframes > 1 + frameskip = (FRAMES_PER_CYCLE / @numframes).floor + @frame = (@frame + 1) % FRAMES_PER_CYCLE + if @frame >= frameskip + @animframe = (@animframe + 1) % @numframes + self.src_rect.x = @animframe * ANIM_ICON_SIZE @frame = 0 end end @@ -116,7 +116,7 @@ end # Item held icon (used in the party screen) #=============================================================================== class HeldItemIconSprite < SpriteWrapper - def initialize(x,y,pokemon,viewport = nil) + def initialize(x, y, pokemon, viewport = nil) super(viewport) self.x = x self.y = y @@ -136,7 +136,7 @@ class HeldItemIconSprite < SpriteWrapper end def item=(value) - return if @item==value + return if @item == value @item = value @animbitmap.dispose if @animbitmap @animbitmap = nil diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb index 856e76bce..b81069fa5 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/001_FormHandlers.rb @@ -1,135 +1,135 @@ module MultipleForms @@formSpecies = SpeciesHandlerHash.new - def self.copy(sym,*syms) - @@formSpecies.copy(sym,*syms) + def self.copy(sym, *syms) + @@formSpecies.copy(sym, *syms) end - def self.register(sym,hash) - @@formSpecies.add(sym,hash) + def self.register(sym, hash) + @@formSpecies.add(sym, hash) end - def self.registerIf(cond,hash) - @@formSpecies.addIf(cond,hash) + def self.registerIf(cond, hash) + @@formSpecies.addIf(cond, hash) end - def self.hasFunction?(pkmn,func) + def self.hasFunction?(pkmn, func) spec = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn sp = @@formSpecies[spec] return sp && sp[func] end - def self.getFunction(pkmn,func) + def self.getFunction(pkmn, func) spec = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn sp = @@formSpecies[spec] return (sp && sp[func]) ? sp[func] : nil end - def self.call(func,pkmn,*args) + def self.call(func, pkmn, *args) sp = @@formSpecies[pkmn.species] return nil if !sp || !sp[func] - return sp[func].call(pkmn,*args) + return sp[func].call(pkmn, *args) end end -def drawSpot(bitmap,spotpattern,x,y,red,green,blue) +def drawSpot(bitmap, spotpattern, x, y, red, green, blue) height = spotpattern.length width = spotpattern[0].length for yy in 0...height spot = spotpattern[yy] for xx in 0...width - if spot[xx]==1 - xOrg = (x+xx)<<1 - yOrg = (y+yy)<<1 - color = bitmap.get_pixel(xOrg,yOrg) - r = color.red+red - g = color.green+green - b = color.blue+blue - color.red = [[r,0].max,255].min - color.green = [[g,0].max,255].min - color.blue = [[b,0].max,255].min - bitmap.set_pixel(xOrg,yOrg,color) - bitmap.set_pixel(xOrg+1,yOrg,color) - bitmap.set_pixel(xOrg,yOrg+1,color) - bitmap.set_pixel(xOrg+1,yOrg+1,color) + if spot[xx] == 1 + xOrg = (x + xx) << 1 + yOrg = (y + yy) << 1 + color = bitmap.get_pixel(xOrg, yOrg) + r = color.red + red + g = color.green + green + b = color.blue + blue + color.red = [[r, 0].max, 255].min + color.green = [[g, 0].max, 255].min + color.blue = [[b, 0].max, 255].min + bitmap.set_pixel(xOrg, yOrg, color) + bitmap.set_pixel(xOrg + 1, yOrg, color) + bitmap.set_pixel(xOrg, yOrg + 1, color) + bitmap.set_pixel(xOrg + 1, yOrg + 1, color) end end end end -def pbSpindaSpots(pkmn,bitmap) +def pbSpindaSpots(pkmn, bitmap) spot1 = [ - [0,0,1,1,1,1,0,0], - [0,1,1,1,1,1,1,0], - [1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1], - [0,1,1,1,1,1,1,0], - [0,0,1,1,1,1,0,0] + [0, 0, 1, 1, 1, 1, 0, 0], + [0, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1], + [0, 1, 1, 1, 1, 1, 1, 0], + [0, 0, 1, 1, 1, 1, 0, 0] ] spot2 = [ - [0,0,1,1,1,0,0], - [0,1,1,1,1,1,0], - [1,1,1,1,1,1,1], - [1,1,1,1,1,1,1], - [1,1,1,1,1,1,1], - [1,1,1,1,1,1,1], - [1,1,1,1,1,1,1], - [0,1,1,1,1,1,0], - [0,0,1,1,1,0,0] + [0, 0, 1, 1, 1, 0, 0], + [0, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1], + [0, 1, 1, 1, 1, 1, 0], + [0, 0, 1, 1, 1, 0, 0] ] spot3 = [ - [0,0,0,0,0,1,1,1,1,0,0,0,0], - [0,0,0,1,1,1,1,1,1,1,0,0,0], - [0,0,1,1,1,1,1,1,1,1,1,0,0], - [0,1,1,1,1,1,1,1,1,1,1,1,0], - [0,1,1,1,1,1,1,1,1,1,1,1,0], - [1,1,1,1,1,1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1,1,1,1,1,1], - [0,1,1,1,1,1,1,1,1,1,1,1,0], - [0,1,1,1,1,1,1,1,1,1,1,1,0], - [0,0,1,1,1,1,1,1,1,1,1,0,0], - [0,0,0,1,1,1,1,1,1,1,0,0,0], - [0,0,0,0,0,1,1,1,0,0,0,0,0] + [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0] ] spot4 = [ - [0,0,0,0,1,1,1,0,0,0,0,0], - [0,0,1,1,1,1,1,1,1,0,0,0], - [0,1,1,1,1,1,1,1,1,1,0,0], - [0,1,1,1,1,1,1,1,1,1,1,0], - [1,1,1,1,1,1,1,1,1,1,1,0], - [1,1,1,1,1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1,1,1,1,1], - [1,1,1,1,1,1,1,1,1,1,1,0], - [0,1,1,1,1,1,1,1,1,1,1,0], - [0,0,1,1,1,1,1,1,1,1,0,0], - [0,0,0,0,1,1,1,1,1,0,0,0] + [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0] ] id = pkmn.personalID - h = (id>>28)&15 - g = (id>>24)&15 - f = (id>>20)&15 - e = (id>>16)&15 - d = (id>>12)&15 - c = (id>>8)&15 - b = (id>>4)&15 - a = (id)&15 + h = (id >> 28) & 15 + g = (id >> 24) & 15 + f = (id >> 20) & 15 + e = (id >> 16) & 15 + d = (id >> 12) & 15 + c = (id >> 8) & 15 + b = (id >> 4) & 15 + a = (id) & 15 if pkmn.shiny? - drawSpot(bitmap,spot1,b+33,a+25,-75,-10,-150) - drawSpot(bitmap,spot2,d+21,c+24,-75,-10,-150) - drawSpot(bitmap,spot3,f+39,e+7,-75,-10,-150) - drawSpot(bitmap,spot4,h+15,g+6,-75,-10,-150) + drawSpot(bitmap, spot1, b + 33, a + 25, -75, -10, -150) + drawSpot(bitmap, spot2, d + 21, c + 24, -75, -10, -150) + drawSpot(bitmap, spot3, f + 39, e + 7, -75, -10, -150) + drawSpot(bitmap, spot4, h + 15, g + 6, -75, -10, -150) else - drawSpot(bitmap,spot1,b+33,a+25,0,-115,-75) - drawSpot(bitmap,spot2,d+21,c+24,0,-115,-75) - drawSpot(bitmap,spot3,f+39,e+7,0,-115,-75) - drawSpot(bitmap,spot4,h+15,g+6,0,-115,-75) + drawSpot(bitmap, spot1, b + 33, a + 25, 0, -115, -75) + drawSpot(bitmap, spot2, d + 21, c + 24, 0, -115, -75) + drawSpot(bitmap, spot3, f + 39, e + 7, 0, -115, -75) + drawSpot(bitmap, spot4, h + 15, g + 6, 0, -115, -75) end end @@ -137,39 +137,39 @@ end # Regular form differences #=============================================================================== -MultipleForms.register(:UNOWN,{ +MultipleForms.register(:UNOWN, { "getFormOnCreation" => proc { |pkmn| next rand(28) } }) -MultipleForms.register(:SPINDA,{ - "alterBitmap" => proc { |pkmn,bitmap| - pbSpindaSpots(pkmn,bitmap) +MultipleForms.register(:SPINDA, { + "alterBitmap" => proc { |pkmn, bitmap| + pbSpindaSpots(pkmn, bitmap) } }) -MultipleForms.register(:CASTFORM,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:CASTFORM, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 0 } }) -MultipleForms.register(:GROUDON,{ +MultipleForms.register(:GROUDON, { "getPrimalForm" => proc { |pkmn| next 1 if pkmn.hasItem?(:REDORB) next } }) -MultipleForms.register(:KYOGRE,{ +MultipleForms.register(:KYOGRE, { "getPrimalForm" => proc { |pkmn| next 1 if pkmn.hasItem?(:BLUEORB) next } }) -MultipleForms.register(:BURMY,{ +MultipleForms.register(:BURMY, { "getFormOnCreation" => proc { |pkmn| case pbGetEnvironment when :Rock, :Sand, :Cave @@ -180,7 +180,7 @@ MultipleForms.register(:BURMY,{ next 0 # Plant Cloak end }, - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next if !endBattle || !usedInBattle case battle.environment when :Rock, :Sand, :Cave @@ -193,7 +193,7 @@ MultipleForms.register(:BURMY,{ } }) -MultipleForms.register(:WORMADAM,{ +MultipleForms.register(:WORMADAM, { "getFormOnCreation" => proc { |pkmn| case pbGetEnvironment when :Rock, :Sand, :Cave @@ -206,8 +206,8 @@ MultipleForms.register(:WORMADAM,{ } }) -MultipleForms.register(:CHERRIM,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:CHERRIM, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 0 } }) @@ -257,9 +257,9 @@ MultipleForms.register(:ROTOM, { } }) -MultipleForms.register(:GIRATINA,{ +MultipleForms.register(:GIRATINA, { "getForm" => proc { |pkmn| - maps = [49,50,51,72,73] # Map IDs for Origin Forme + maps = [49, 50, 51, 72, 73] # Map IDs for Origin Forme if pkmn.hasItem?(:GRISEOUSORB) || ($game_map && maps.include?($game_map.map_id)) next 1 end @@ -267,13 +267,13 @@ MultipleForms.register(:GIRATINA,{ } }) -MultipleForms.register(:SHAYMIN,{ +MultipleForms.register(:SHAYMIN, { "getForm" => proc { |pkmn| next 0 if pkmn.fainted? || pkmn.status == :FROZEN || PBDayNight.isNight? } }) -MultipleForms.register(:ARCEUS,{ +MultipleForms.register(:ARCEUS, { "getForm" => proc { |pkmn| next nil if !pkmn.hasAbility?(:MULTITYPE) typeArray = { @@ -308,26 +308,26 @@ MultipleForms.register(:ARCEUS,{ } }) -MultipleForms.register(:DARMANITAN,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:DARMANITAN, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 2 * (pkmn.form / 2) } }) -MultipleForms.register(:DEERLING,{ +MultipleForms.register(:DEERLING, { "getForm" => proc { |pkmn| next pbGetSeason } }) -MultipleForms.copy(:DEERLING,:SAWSBUCK) +MultipleForms.copy(:DEERLING, :SAWSBUCK) -MultipleForms.register(:KYUREM,{ - "getFormOnEnteringBattle" => proc { |pkmn,wild| - next pkmn.form+2 if pkmn.form==1 || pkmn.form==2 +MultipleForms.register(:KYUREM, { + "getFormOnEnteringBattle" => proc { |pkmn, wild| + next pkmn.form + 2 if pkmn.form == 1 || pkmn.form == 2 }, - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| - next pkmn.form-2 if pkmn.form>=3 # Fused forms stop glowing + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| + next pkmn.form - 2 if pkmn.form >= 3 # Fused forms stop glowing }, "onSetForm" => proc { |pkmn, form, oldForm| case form @@ -354,20 +354,20 @@ MultipleForms.register(:KYUREM,{ } }) -MultipleForms.register(:KELDEO,{ +MultipleForms.register(:KELDEO, { "getForm" => proc { |pkmn| next 1 if pkmn.hasMove?(:SECRETSWORD) # Resolute Form next 0 # Ordinary Form } }) -MultipleForms.register(:MELOETTA,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:MELOETTA, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 0 } }) -MultipleForms.register(:GENESECT,{ +MultipleForms.register(:GENESECT, { "getForm" => proc { |pkmn| next 1 if pkmn.hasItem?(:SHOCKDRIVE) next 2 if pkmn.hasItem?(:BURNDRIVE) @@ -377,47 +377,47 @@ MultipleForms.register(:GENESECT,{ } }) -MultipleForms.register(:GRENINJA,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:GRENINJA, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 1 if pkmn.form == 2 && (pkmn.fainted? || endBattle) } }) -MultipleForms.register(:SCATTERBUG,{ +MultipleForms.register(:SCATTERBUG, { "getFormOnCreation" => proc { |pkmn| next $player.secret_ID % 18 } }) -MultipleForms.copy(:SCATTERBUG,:SPEWPA,:VIVILLON) +MultipleForms.copy(:SCATTERBUG, :SPEWPA, :VIVILLON) -MultipleForms.register(:FURFROU,{ +MultipleForms.register(:FURFROU, { "getForm" => proc { |pkmn| if !pkmn.time_form_set || pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 5 # 5 days next 0 end }, - "onSetForm" => proc { |pkmn,form,oldForm| + "onSetForm" => proc { |pkmn, form, oldForm| pkmn.time_form_set = (form > 0) ? pbGetTimeNow.to_i : nil } }) -MultipleForms.register(:ESPURR,{ +MultipleForms.register(:ESPURR, { "getForm" => proc { |pkmn| next pkmn.gender } }) -MultipleForms.copy(:ESPURR,:MEOWSTIC) +MultipleForms.copy(:ESPURR, :MEOWSTIC) -MultipleForms.register(:AEGISLASH,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:AEGISLASH, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 0 } }) -MultipleForms.register(:PUMPKABOO,{ +MultipleForms.register(:PUMPKABOO, { "getFormOnCreation" => proc { |pkmn| r = rand(100) next 3 if r < 5 # Super Size (5%) @@ -427,36 +427,36 @@ MultipleForms.register(:PUMPKABOO,{ } }) -MultipleForms.copy(:PUMPKABOO,:GOURGEIST) +MultipleForms.copy(:PUMPKABOO, :GOURGEIST) -MultipleForms.register(:XERNEAS,{ - "getFormOnEnteringBattle" => proc { |pkmn,wild| +MultipleForms.register(:XERNEAS, { + "getFormOnEnteringBattle" => proc { |pkmn, wild| next 1 }, - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 0 } }) -MultipleForms.register(:ZYGARDE,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| - next pkmn.form-2 if pkmn.form>=2 && (pkmn.fainted? || endBattle) +MultipleForms.register(:ZYGARDE, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| + next pkmn.form - 2 if pkmn.form >= 2 && (pkmn.fainted? || endBattle) } }) -MultipleForms.register(:HOOPA,{ +MultipleForms.register(:HOOPA, { "getForm" => proc { |pkmn| if !pkmn.time_form_set || pbGetTimeNow.to_i > pkmn.time_form_set.to_i + 60 * 60 * 24 * 3 # 3 days next 0 end }, - "onSetForm" => proc { |pkmn,form,oldForm| - pkmn.time_form_set = (form>0) ? pbGetTimeNow.to_i : nil + "onSetForm" => proc { |pkmn, form, oldForm| + pkmn.time_form_set = (form > 0) ? pbGetTimeNow.to_i : nil } }) -MultipleForms.register(:ROCKRUFF,{ +MultipleForms.register(:ROCKRUFF, { "getForm" => proc { |pkmn| next if pkmn.form_simple >= 2 # Own Tempo Rockruff cannot become another form next 1 if PBDayNight.isNight? @@ -464,7 +464,7 @@ MultipleForms.register(:ROCKRUFF,{ } }) -MultipleForms.register(:LYCANROC,{ +MultipleForms.register(:LYCANROC, { "getFormOnCreation" => proc { |pkmn| next 2 if PBDayNight.isEvening? # Dusk next 1 if PBDayNight.isNight? # Midnight @@ -472,13 +472,13 @@ MultipleForms.register(:LYCANROC,{ } }) -MultipleForms.register(:WISHIWASHI,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:WISHIWASHI, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 0 } }) -MultipleForms.register(:SILVALLY,{ +MultipleForms.register(:SILVALLY, { "getForm" => proc { |pkmn| next nil if !pkmn.hasAbility?(:RKSSYSTEM) typeArray = { @@ -507,34 +507,34 @@ MultipleForms.register(:SILVALLY,{ ret = f break end - break if ret>0 + break if ret > 0 end next ret } }) -MultipleForms.register(:MINIOR,{ +MultipleForms.register(:MINIOR, { "getFormOnCreation" => proc { |pkmn| - next 7+rand(7) # Meteor forms are 0-6, Core forms are 7-13 + next 7 + rand(7) # Meteor forms are 0-6, Core forms are 7-13 }, - "getFormOnEnteringBattle" => proc { |pkmn,wild| - next pkmn.form-7 if pkmn.form>=7 && wild # Wild Minior always appear in Meteor form + "getFormOnEnteringBattle" => proc { |pkmn, wild| + next pkmn.form - 7 if pkmn.form >= 7 && wild # Wild Minior always appear in Meteor form }, - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| - next pkmn.form+7 if pkmn.form<7 + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| + next pkmn.form + 7 if pkmn.form < 7 } }) -MultipleForms.register(:MIMIKYU,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:MIMIKYU, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| next 0 if pkmn.fainted? || endBattle } }) -MultipleForms.register(:NECROZMA,{ - "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| +MultipleForms.register(:NECROZMA, { + "getFormOnLeavingBattle" => proc { |pkmn, battle, usedInBattle, endBattle| # Fused forms are 1 and 2, Ultra form is 3 or 4 depending on which fusion - next pkmn.form-2 if pkmn.form>=3 && (pkmn.fainted? || endBattle) + next pkmn.form - 2 if pkmn.form >= 3 && (pkmn.fainted? || endBattle) }, "onSetForm" => proc { |pkmn, form, oldForm| next if form > 2 || oldForm > 2 # Ultra form changes don't affect moveset diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb index bceb3f3bf..7d858699c 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/002_ShadowPokemon_Other.rb @@ -76,24 +76,24 @@ class RelicStoneScene @viewport.dispose end - def pbDisplay(msg,brief = false) - UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { pbUpdate } + def pbDisplay(msg, brief = false) + UIHelper.pbDisplay(@sprites["msgwindow"], msg, brief) { pbUpdate } end def pbConfirm(msg) - UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate } + UIHelper.pbConfirm(@sprites["msgwindow"], msg) { pbUpdate } end def pbStartScene(pokemon) @sprites = {} - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @pokemon = pokemon - addBackgroundPlane(@sprites,"bg","relicstonebg",@viewport) + addBackgroundPlane(@sprites, "bg", "relicstonebg", @viewport) @sprites["msgwindow"] = Window_AdvancedTextPokemon.new("") @sprites["msgwindow"].viewport = @viewport @sprites["msgwindow"].x = 0 - @sprites["msgwindow"].y = Graphics.height-96 + @sprites["msgwindow"].y = Graphics.height - 96 @sprites["msgwindow"].width = Graphics.width @sprites["msgwindow"].height = 96 @sprites["msgwindow"].text = "" @@ -125,7 +125,7 @@ class RelicStoneScreen def pbStartScreen(pokemon) @scene.pbStartScene(pokemon) @scene.pbPurify - pbPurify(pokemon,self) + pbPurify(pokemon, self) @scene.pbEndScene end end @@ -154,7 +154,7 @@ def pbRelicStone end pbMessage(_INTL("There's a Pokémon that may open the door to its heart!")) # Choose a purifiable Pokemon - pbChoosePokemon(1, 2,proc { |pkmn| + pbChoosePokemon(1, 2, proc { |pkmn| pkmn.able? && pkmn.shadowPokemon? && pkmn.heart_gauge == 0 }) if $game_variables[1] >= 0 @@ -170,8 +170,8 @@ end class Battle alias __shadow__pbCanUseItemOnPokemon? pbCanUseItemOnPokemon? - def pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages = true) - ret = __shadow__pbCanUseItemOnPokemon?(item,pkmn,battler,scene,showMessages) + def pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages = true) + ret = __shadow__pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages) if ret && pkmn.hyper_mode && ![:JOYSCENT, :EXCITESCENT, :VIVIDSCENT].include?(item) scene.pbDisplay(_INTL("This item can't be used on that Pokémon.")) return false @@ -186,7 +186,7 @@ class Battle::Battler alias __shadow__pbInitPokemon pbInitPokemon def pbInitPokemon(*arg) - if self.pokemonIndex>0 && inHyperMode? + if self.pokemonIndex > 0 && inHyperMode? self.pokemon.hyper_mode = false end __shadow__pbInitPokemon(*arg) @@ -213,14 +213,14 @@ class Battle::Battler p = self.pokemon if @battle.pbRandom(p.heart_gauge) <= p.max_gauge_size / 4 p.hyper_mode = true - @battle.pbDisplay(_INTL("{1}'s emotions rose to a fever pitch!\nIt entered Hyper Mode!",self.pbThis)) + @battle.pbDisplay(_INTL("{1}'s emotions rose to a fever pitch!\nIt entered Hyper Mode!", self.pbThis)) end end def pbHyperModeObedience(move) return true if !inHyperMode? return true if !move || move.type == :SHADOW - return rand(100)<20 + return rand(100) < 20 end end @@ -250,19 +250,19 @@ def pbRaiseHappinessAndReduceHeart(pkmn, scene, multiplier) return true end -ItemHandlers::UseOnPokemon.add(:JOYSCENT,proc { |item,pokemon,scene| +ItemHandlers::UseOnPokemon.add(:JOYSCENT, proc { |item, pokemon, scene| pbRaiseHappinessAndReduceHeart(pokemon, scene, 1) }) -ItemHandlers::UseOnPokemon.add(:EXCITESCENT,proc { |item,pokemon,scene| +ItemHandlers::UseOnPokemon.add(:EXCITESCENT, proc { |item, pokemon, scene| pbRaiseHappinessAndReduceHeart(pokemon, scene, 2) }) -ItemHandlers::UseOnPokemon.add(:VIVIDSCENT,proc { |item,pokemon,scene| +ItemHandlers::UseOnPokemon.add(:VIVIDSCENT, proc { |item, pokemon, scene| pbRaiseHappinessAndReduceHeart(pokemon, scene, 3) }) -ItemHandlers::UseOnPokemon.add(:TIMEFLUTE,proc { |item,pokemon,scene| +ItemHandlers::UseOnPokemon.add(:TIMEFLUTE, proc { |item, pokemon, scene| if !pokemon.shadowPokemon? || pokemon.heart_gauge == 0 scene.pbDisplay(_INTL("It won't have any effect.")) next false @@ -272,7 +272,7 @@ ItemHandlers::UseOnPokemon.add(:TIMEFLUTE,proc { |item,pokemon,scene| next true }) -ItemHandlers::CanUseInBattle.add(:JOYSCENT,proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| +ItemHandlers::CanUseInBattle.add(:JOYSCENT, proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages| if !battler || !battler.shadowPokemon? || !battler.inHyperMode? scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages next false @@ -280,26 +280,26 @@ ItemHandlers::CanUseInBattle.add(:JOYSCENT,proc { |item,pokemon,battler,move,fir next true }) -ItemHandlers::CanUseInBattle.copy(:JOYSCENT,:EXCITESCENT,:VIVIDSCENT) +ItemHandlers::CanUseInBattle.copy(:JOYSCENT, :EXCITESCENT, :VIVIDSCENT) -ItemHandlers::BattleUseOnBattler.add(:JOYSCENT,proc { |item,battler,scene| +ItemHandlers::BattleUseOnBattler.add(:JOYSCENT, proc { |item, battler, scene| battler.pokemon.hyper_mode = false battler.pokemon.change_heart_gauge("scent", 1) - scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name)) + scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", battler.pbThis, GameData::Item.get(item).name)) next true }) -ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT,proc { |item,battler,scene| +ItemHandlers::BattleUseOnBattler.add(:EXCITESCENT, proc { |item, battler, scene| battler.pokemon.hyper_mode = false battler.pokemon.change_heart_gauge("scent", 2) - scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name)) + scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", battler.pbThis, GameData::Item.get(item).name)) next true }) -ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene| +ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT, proc { |item, battler, scene| battler.pokemon.hyper_mode = false battler.pokemon.change_heart_gauge("scent", 3) - scene.pbDisplay(_INTL("{1} came to its senses from the {2}!",battler.pbThis,GameData::Item.get(item).name)) + scene.pbDisplay(_INTL("{1} came to its senses from the {2}!", battler.pbThis, GameData::Item.get(item).name)) next true }) @@ -310,7 +310,7 @@ ItemHandlers::BattleUseOnBattler.add(:VIVIDSCENT,proc { |item,battler,scene| # Skips second turn (if successful). (Shadow Half) #=============================================================================== class Battle::Move::AllBattlersLoseHalfHPUserSkipsNextTurn < Battle::Move - def pbMoveFailed?(user,targets) + def pbMoveFailed?(user, targets) if @battle.allBattlers.none? { |b| b.hp > 1 } @battle.pbDisplay(_INTL("But it failed!")) return true @@ -335,17 +335,17 @@ end # User takes recoil damage equal to 1/2 of its current HP. (Shadow End) #=============================================================================== class Battle::Move::UserLosesHalfHP < Battle::Move::RecoilMove - def pbRecoilDamage(user,target) - return (target.damageState.totalHPLost/2.0).round + def pbRecoilDamage(user, target) + return (target.damageState.totalHPLost / 2.0).round end - def pbEffectAfterAllHits(user,target) + def pbEffectAfterAllHits(user, target) return if user.fainted? || target.damageState.unaffected # NOTE: This move's recoil is not prevented by Rock Head/Magic Guard. - amt = pbRecoilDamage(user,target) - amt = 1 if amt<1 - user.pbReduceHP(amt,false) - @battle.pbDisplay(_INTL("{1} is damaged by recoil!",user.pbThis)) + amt = pbRecoilDamage(user, target) + amt = 1 if amt < 1 + user.pbReduceHP(amt, false) + @battle.pbDisplay(_INTL("{1} is damaged by recoil!", user.pbThis)) user.pbItemHPHealCheck end end @@ -356,7 +356,7 @@ end # Starts shadow weather. (Shadow Sky) #=============================================================================== class Battle::Move::StartShadowSkyWeather < Battle::Move::WeatherMove - def initialize(battle,move) + def initialize(battle, move) super @weatherType = :ShadowSky end @@ -400,7 +400,7 @@ Events.onStartBattle += proc { |_sender| end } -Events.onEndBattle += proc { |_sender,_e| +Events.onEndBattle += proc { |_sender, _e| $game_temp.party_heart_gauges_before_battle.each_with_index do |value, i| pkmn = $player.party[i] next if !pkmn || !value || value == 0 diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/003_Pokemon_Sprites.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/003_Pokemon_Sprites.rb index 7ac0cf202..e07405506 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/003_Pokemon_Sprites.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/003_Pokemon_Sprites.rb @@ -32,7 +32,7 @@ class PokemonSprite < SpriteWrapper when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft self.ox = 0 when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom - self.ox = self.bitmap.width/2 + self.ox = self.bitmap.width / 2 when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight self.ox = self.bitmap.width end @@ -40,21 +40,21 @@ class PokemonSprite < SpriteWrapper when PictureOrigin::TopLeft, PictureOrigin::Top, PictureOrigin::TopRight self.oy = 0 when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right - self.oy = self.bitmap.height/2 + self.oy = self.bitmap.height / 2 when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight self.oy = self.bitmap.height end end - def setPokemonBitmap(pokemon,back = false) + def setPokemonBitmap(pokemon, back = false) @_iconbitmap.dispose if @_iconbitmap @_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back) : nil self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil - self.color = Color.new(0,0,0,0) + self.color = Color.new(0, 0, 0, 0) changeOrigin end - def setPokemonBitmapSpecies(pokemon,species,back = false) + def setPokemonBitmapSpecies(pokemon, species, back = false) @_iconbitmap.dispose if @_iconbitmap @_iconbitmap = (pokemon) ? GameData::Species.sprite_bitmap_from_pokemon(pokemon, back, species) : nil self.bitmap = (@_iconbitmap) ? @_iconbitmap.bitmap : nil @@ -87,7 +87,7 @@ class PokemonIconSprite < SpriteWrapper attr_accessor :active attr_reader :pokemon - def initialize(pokemon,viewport = nil) + def initialize(pokemon, viewport = nil) super(viewport) @selected = false @active = false @@ -111,12 +111,12 @@ class PokemonIconSprite < SpriteWrapper def x=(value) @logical_x = value - super(@logical_x+@adjusted_x) + super(@logical_x + @adjusted_x) end def y=(value) @logical_y = value - super(@logical_y+@adjusted_y) + super(@logical_y + @adjusted_y) end def pokemon=(value) @@ -133,8 +133,8 @@ class PokemonIconSprite < SpriteWrapper self.bitmap = @animBitmap.bitmap self.src_rect.width = @animBitmap.height self.src_rect.height = @animBitmap.height - @numFrames = @animBitmap.width/@animBitmap.height - @currentFrame = 0 if @currentFrame>=@numFrames + @numFrames = @animBitmap.width / @animBitmap.height + @currentFrame = 0 if @currentFrame >= @numFrames changeOrigin end @@ -150,7 +150,7 @@ class PokemonIconSprite < SpriteWrapper when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft self.ox = 0 when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom - self.ox = self.src_rect.width/2 + self.ox = self.src_rect.width / 2 when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight self.ox = self.src_rect.width end @@ -160,7 +160,7 @@ class PokemonIconSprite < SpriteWrapper when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right # NOTE: This assumes the top quarter of the icon is blank, so oy is placed # in the middle of the lower three quarters of the image. - self.oy = self.src_rect.height*5/8 + self.oy = self.src_rect.height * 5 / 8 when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight self.oy = self.src_rect.height end @@ -171,14 +171,14 @@ class PokemonIconSprite < SpriteWrapper return 0 if @pokemon.fainted? # Fainted - no animation # ret is initially the time a whole animation cycle lasts. It is divided by # the number of frames in that cycle at the end. - ret = Graphics.frame_rate/4 # Green HP - 0.25 seconds - if @pokemon.hp<=@pokemon.totalhp/4 # Red HP - 1 second + ret = Graphics.frame_rate / 4 # Green HP - 0.25 seconds + if @pokemon.hp <= @pokemon.totalhp / 4 # Red HP - 1 second ret *= 4 - elsif @pokemon.hp<=@pokemon.totalhp/2 # Yellow HP - 0.5 seconds + elsif @pokemon.hp <= @pokemon.totalhp / 2 # Yellow HP - 0.5 seconds ret *= 2 end ret /= @numFrames - ret = 1 if ret<1 + ret = 1 if ret < 1 return ret end @@ -189,20 +189,20 @@ class PokemonIconSprite < SpriteWrapper self.bitmap = @animBitmap.bitmap # Update animation cl = self.counterLimit - if cl==0 + if cl == 0 @currentFrame = 0 else @counter += 1 - if @counter>=cl - @currentFrame = (@currentFrame+1)%@numFrames + if @counter >= cl + @currentFrame = (@currentFrame + 1) % @numFrames @counter = 0 end end - self.src_rect.x = self.src_rect.width*@currentFrame + self.src_rect.x = self.src_rect.width * @currentFrame # Update "jumping" animation (used in party screen) if @selected @adjusted_x = 4 - @adjusted_y = (@currentFrame>=@numFrames/2) ? -2 : 6 + @adjusted_y = (@currentFrame >= @numFrames / 2) ? -2 : 6 else @adjusted_x = 0 @adjusted_y = 0 @@ -223,7 +223,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper attr_reader :form attr_reader :shiny - def initialize(species,viewport = nil) + def initialize(species, viewport = nil) super(viewport) @species = species @gender = 0 @@ -260,7 +260,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper refresh end - def pbSetParams(species,gender,form,shiny = false) + def pbSetParams(species, gender, form, shiny = false) @species = species @gender = gender @form = form @@ -280,7 +280,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper when PictureOrigin::TopLeft, PictureOrigin::Left, PictureOrigin::BottomLeft self.ox = 0 when PictureOrigin::Top, PictureOrigin::Center, PictureOrigin::Bottom - self.ox = self.src_rect.width/2 + self.ox = self.src_rect.width / 2 when PictureOrigin::TopRight, PictureOrigin::Right, PictureOrigin::BottomRight self.ox = self.src_rect.width end @@ -290,7 +290,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper when PictureOrigin::Left, PictureOrigin::Center, PictureOrigin::Right # NOTE: This assumes the top quarter of the icon is blank, so oy is placed # in the middle of the lower three quarters of the image. - self.oy = self.src_rect.height*5/8 + self.oy = self.src_rect.height * 5 / 8 when PictureOrigin::BottomLeft, PictureOrigin::Bottom, PictureOrigin::BottomRight self.oy = self.src_rect.height end @@ -300,9 +300,9 @@ class PokemonSpeciesIconSprite < SpriteWrapper def counterLimit # ret is initially the time a whole animation cycle lasts. It is divided by # the number of frames in that cycle at the end. - ret = Graphics.frame_rate/4 # 0.25 seconds + ret = Graphics.frame_rate / 4 # 0.25 seconds ret /= @numFrames - ret = 1 if ret<1 + ret = 1 if ret < 1 return ret end @@ -316,7 +316,7 @@ class PokemonSpeciesIconSprite < SpriteWrapper self.src_rect.width = @animBitmap.height self.src_rect.height = @animBitmap.height @numFrames = @animBitmap.width / @animBitmap.height - @currentFrame = 0 if @currentFrame>=@numFrames + @currentFrame = 0 if @currentFrame >= @numFrames changeOrigin end @@ -327,10 +327,10 @@ class PokemonSpeciesIconSprite < SpriteWrapper self.bitmap = @animBitmap.bitmap # Update animation @counter += 1 - if @counter>=self.counterLimit - @currentFrame = (@currentFrame+1)%@numFrames + if @counter >= self.counterLimit + @currentFrame = (@currentFrame + 1) % @numFrames @counter = 0 end - self.src_rect.x = self.src_rect.width*@currentFrame + self.src_rect.x = self.src_rect.width * @currentFrame end end diff --git a/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb b/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb index 5aee9a03e..373ab88aa 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon-related/004_PokemonStorage.rb @@ -38,7 +38,7 @@ class PokemonBox return @pokemon[i] end - def []=(i,value) + def []=(i, value) @pokemon[i] = value end @@ -63,7 +63,7 @@ class PokemonStorage def initialize(maxBoxes = Settings::NUM_STORAGE_BOXES, maxPokemon = PokemonBox::BOX_SIZE) @boxes = [] for i in 0...maxBoxes - @boxes[i] = PokemonBox.new(_INTL("Box {1}",i+1),maxPokemon) + @boxes[i] = PokemonBox.new(_INTL("Box {1}", i + 1), maxPokemon) @boxes[i].background = i % BASICWALLPAPERQTY end @currentBox = 0 @@ -77,17 +77,17 @@ class PokemonStorage def allWallpapers return [ # Basic wallpapers - _INTL("Forest"),_INTL("City"),_INTL("Desert"),_INTL("Savanna"), - _INTL("Crag"),_INTL("Volcano"),_INTL("Snow"),_INTL("Cave"), - _INTL("Beach"),_INTL("Seafloor"),_INTL("River"),_INTL("Sky"), - _INTL("Poké Center"),_INTL("Machine"),_INTL("Checks"),_INTL("Simple"), + _INTL("Forest"), _INTL("City"), _INTL("Desert"), _INTL("Savanna"), + _INTL("Crag"), _INTL("Volcano"), _INTL("Snow"), _INTL("Cave"), + _INTL("Beach"), _INTL("Seafloor"), _INTL("River"), _INTL("Sky"), + _INTL("Poké Center"), _INTL("Machine"), _INTL("Checks"), _INTL("Simple"), # Special wallpapers - _INTL("Space"),_INTL("Backyard"),_INTL("Nostalgic 1"),_INTL("Torchic"), - _INTL("Trio 1"),_INTL("PikaPika 1"),_INTL("Legend 1"),_INTL("Team Galactic 1"), - _INTL("Distortion"),_INTL("Contest"),_INTL("Nostalgic 2"),_INTL("Croagunk"), - _INTL("Trio 2"),_INTL("PikaPika 2"),_INTL("Legend 2"),_INTL("Team Galactic 2"), - _INTL("Heart"),_INTL("Soul"),_INTL("Big Brother"),_INTL("Pokéathlon"), - _INTL("Trio 3"),_INTL("Spiky Pika"),_INTL("Kimono Girl"),_INTL("Revival") + _INTL("Space"), _INTL("Backyard"), _INTL("Nostalgic 1"), _INTL("Torchic"), + _INTL("Trio 1"), _INTL("PikaPika 1"), _INTL("Legend 1"), _INTL("Team Galactic 1"), + _INTL("Distortion"), _INTL("Contest"), _INTL("Nostalgic 2"), _INTL("Croagunk"), + _INTL("Trio 2"), _INTL("PikaPika 2"), _INTL("Legend 2"), _INTL("Team Galactic 2"), + _INTL("Heart"), _INTL("Soul"), _INTL("Big Brother"), _INTL("Pokéathlon"), + _INTL("Trio 3"), _INTL("Spiky Pika"), _INTL("Kimono Girl"), _INTL("Revival") ] end @@ -98,13 +98,13 @@ class PokemonStorage def isAvailableWallpaper?(i) @unlockedWallpapers = [] if !@unlockedWallpapers - return true if i= Settings::MAX_PARTY_SIZE) ? -1 : ret end for i in 0...maxPokemon(box) - return i if !self[box,i] + return i if !self[box, i] end return -1 end - def [](x,y = nil) - if y==nil - return (x==-1) ? self.party : @boxes[x] + def [](x, y = nil) + if y == nil + return (x == -1) ? self.party : @boxes[x] else for i in @boxes raise "Box is a Pokémon, not a box" if i.is_a?(Pokemon) end - return (x==-1) ? self.party[y] : @boxes[x][y] + return (x == -1) ? self.party[y] : @boxes[x][y] end end - def []=(x,y,value) - if x==-1 + def []=(x, y, value) + if x == -1 self.party[y] = value else @boxes[x][y] = value end end - def pbCopy(boxDst,indexDst,boxSrc,indexSrc) - if indexDst<0 && boxDst= 0 old_ready_evo = pkmn.ready_to_evolve pkmn.heal pkmn.ready_to_evolve = old_ready_evo end - self[box,i] = pkmn + self[box, i] = pkmn return true end end @@ -234,15 +234,15 @@ class PokemonStorage pkmn.ready_to_evolve = old_ready_evo end for i in 0...maxPokemon(@currentBox) - if self[@currentBox,i]==nil - self[@currentBox,i] = pkmn + if self[@currentBox, i] == nil + self[@currentBox, i] = pkmn return @currentBox end end for j in 0...self.maxBoxes for i in 0...maxPokemon(j) - if self[j,i]==nil - self[j,i] = pkmn + if self[j, i] == nil + self[j, i] = pkmn @currentBox = j return @currentBox end @@ -251,10 +251,10 @@ class PokemonStorage return -1 end - def pbDelete(box,index) - if self[box,index] - self[box,index] = nil - self.party.compact! if box==-1 + def pbDelete(box, index) + if self[box, index] + self[box, index] = nil + self.party.compact! if box == -1 end end @@ -281,11 +281,11 @@ class RegionalStorage if !$game_map raise _INTL("The player is not on a map, so the region could not be determined.") end - if @lastmap!=$game_map.map_id + if @lastmap != $game_map.map_id @rgnmap = pbGetCurrentRegion # may access file IO, so caching result @lastmap = $game_map.map_id end - if @rgnmap<0 + if @rgnmap < 0 raise _INTL("The current map has no region set. Please set the MapPosition metadata setting for this map.") end if !@storages[@rgnmap] @@ -338,39 +338,39 @@ class RegionalStorage getCurrentStorage.currentBox = value end - def [](x,y = nil) - getCurrentStorage[x,y] + def [](x, y = nil) + getCurrentStorage[x, y] end - def []=(x,y,value) - getCurrentStorage[x,y] = value + def []=(x, y, value) + getCurrentStorage[x, y] = value end def pbFirstFreePos(box) getCurrentStorage.pbFirstFreePos(box) end - def pbCopy(boxDst,indexDst,boxSrc,indexSrc) - getCurrentStorage.pbCopy(boxDst,indexDst,boxSrc,indexSrc) + def pbCopy(boxDst, indexDst, boxSrc, indexSrc) + getCurrentStorage.pbCopy(boxDst, indexDst, boxSrc, indexSrc) end - def pbMove(boxDst,indexDst,boxSrc,indexSrc) - getCurrentStorage.pbCopy(boxDst,indexDst,boxSrc,indexSrc) + def pbMove(boxDst, indexDst, boxSrc, indexSrc) + getCurrentStorage.pbCopy(boxDst, indexDst, boxSrc, indexSrc) end def pbMoveCaughtToParty(pkmn) getCurrentStorage.pbMoveCaughtToParty(pkmn) end - def pbMoveCaughtToBox(pkmn,box) - getCurrentStorage.pbMoveCaughtToBox(pkmn,box) + def pbMoveCaughtToBox(pkmn, box) + getCurrentStorage.pbMoveCaughtToBox(pkmn, box) end def pbStoreCaught(pkmn) getCurrentStorage.pbStoreCaught(pkmn) end - def pbDelete(box,index) + def pbDelete(box, index) getCurrentStorage.pbDelete(pkmn) end end @@ -396,12 +396,12 @@ def pbEachPokemon for i in -1...$PokemonStorage.maxBoxes for j in 0...$PokemonStorage.maxPokemon(i) pkmn = $PokemonStorage[i][j] - yield(pkmn,i) if pkmn + yield(pkmn, i) if pkmn end end end # Yields every Pokémon in storage in turn. def pbEachNonEggPokemon - pbEachPokemon { |pkmn,box| yield(pkmn,box) if !pkmn.egg? } + pbEachPokemon { |pkmn, box| yield(pkmn, box) if !pkmn.egg? } end diff --git a/Data/Scripts/014_Pokemon/001_Pokemon.rb b/Data/Scripts/014_Pokemon/001_Pokemon.rb index 280a75c8e..e15123103 100644 --- a/Data/Scripts/014_Pokemon/001_Pokemon.rb +++ b/Data/Scripts/014_Pokemon/001_Pokemon.rb @@ -1195,7 +1195,7 @@ class Pokemon @timeReceived = pbGetTimeNow.to_i @timeEggHatched = nil @fused = nil - @personalID = rand(2 ** 16) | rand(2 ** 16) << 16 + @personalID = rand(2**16) | rand(2**16) << 16 @hp = 1 @totalhp = 1 calc_stats diff --git a/Data/Scripts/015_Trainers and player/001_Trainer.rb b/Data/Scripts/015_Trainers and player/001_Trainer.rb index 035b70dc0..cfaa47427 100644 --- a/Data/Scripts/015_Trainers and player/001_Trainer.rb +++ b/Data/Scripts/015_Trainers and player/001_Trainer.rb @@ -34,7 +34,7 @@ class Trainer # Random ID other than this Trainer's ID def make_foreign_ID loop do - ret = rand(2 ** 16) | rand(2 ** 16) << 16 + ret = rand(2**16) | rand(2**16) << 16 return ret if ret != @id end return 0 @@ -168,7 +168,7 @@ class Trainer def initialize(name, trainer_type) @trainer_type = GameData::TrainerType.get(trainer_type).id @name = name - @id = rand(2 ** 16) | rand(2 ** 16) << 16 + @id = rand(2**16) | rand(2**16) << 16 @language = pbGetLanguage @party = [] end diff --git a/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb b/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb index 178c04d8e..134082db8 100644 --- a/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb +++ b/Data/Scripts/015_Trainers and player/002_Trainer_LoadAndNew.rb @@ -13,7 +13,7 @@ def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true) party = [] for i in 0...Settings::MAX_PARTY_SIZE if i == 0 - pbMessage(_INTL("Please enter the first Pokémon.",i)) + pbMessage(_INTL("Please enter the first Pokémon.", i)) else break if !pbConfirmMessage(_INTL("Add another Pokémon?")) end diff --git a/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb b/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb index 803e822b3..98b34878d 100644 --- a/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb +++ b/Data/Scripts/015_Trainers and player/003_Trainer_Sprites.rb @@ -2,7 +2,7 @@ # Walking charset, for use in text entry screens and load game screen #=============================================================================== class TrainerWalkingCharSprite < SpriteWrapper - def initialize(charset,viewport = nil) + def initialize(charset, viewport = nil) super(viewport) @animbitmap = nil self.charset = charset @@ -14,12 +14,12 @@ class TrainerWalkingCharSprite < SpriteWrapper def charset=(value) @animbitmap.dispose if @animbitmap @animbitmap = nil - bitmapFileName = sprintf("Graphics/Characters/%s",value) + bitmapFileName = sprintf("Graphics/Characters/%s", value) @charset = pbResolveBitmap(bitmapFileName) if @charset @animbitmap = AnimatedBitmap.new(@charset) self.bitmap = @animbitmap.bitmap - self.src_rect.set(0,0,self.bitmap.width/4,self.bitmap.height/4) + self.src_rect.set(0, 0, self.bitmap.width / 4, self.bitmap.height / 4) else self.bitmap = nil end @@ -32,14 +32,14 @@ class TrainerWalkingCharSprite < SpriteWrapper if @charset @animbitmap = AnimatedBitmap.new(@charset) self.bitmap = @animbitmap.bitmap - self.src_rect.set(0,0,self.bitmap.width/4,self.bitmap.height) + self.src_rect.set(0, 0, self.bitmap.width / 4, self.bitmap.height) else self.bitmap = nil end end def animspeed=(value) - @frameskip = value*Graphics.frame_rate/40 + @frameskip = value * Graphics.frame_rate / 40 end def dispose @@ -55,9 +55,9 @@ class TrainerWalkingCharSprite < SpriteWrapper self.bitmap = @animbitmap.bitmap end @frame += 1 - if @frame>=@frameskip - @animframe = (@animframe+1)%4 - self.src_rect.x = @animframe*@animbitmap.bitmap.width/4 + if @frame >= @frameskip + @animframe = (@animframe + 1) % 4 + self.src_rect.x = @animframe * @animbitmap.bitmap.width / 4 @frame -= @frameskip end @updating = false diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb index ece5d7d39..762d50dea 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/003_UI_EggHatching.rb @@ -11,43 +11,43 @@ #=============================================================================== class PokemonEggHatch_Scene def pbStartScene(pokemon) - @sprites={} - @pokemon=pokemon - @nicknamed=false - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 + @sprites = {} + @pokemon = pokemon + @nicknamed = false + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 # Create background image - addBackgroundOrColoredPlane(@sprites,"background","hatchbg", - Color.new(248,248,248),@viewport) + addBackgroundOrColoredPlane(@sprites, "background", "hatchbg", + Color.new(248, 248, 248), @viewport) # Create egg sprite/Pokémon sprite - @sprites["pokemon"]=PokemonSprite.new(@viewport) + @sprites["pokemon"] = PokemonSprite.new(@viewport) @sprites["pokemon"].setOffset(PictureOrigin::Bottom) - @sprites["pokemon"].x = Graphics.width/2 - @sprites["pokemon"].y = 264+56 # 56 to offset the egg sprite + @sprites["pokemon"].x = Graphics.width / 2 + @sprites["pokemon"].y = 264 + 56 # 56 to offset the egg sprite @sprites["pokemon"].setSpeciesBitmap(@pokemon.species, @pokemon.gender, @pokemon.form, @pokemon.shiny?, false, false, true) # Egg sprite # Load egg cracks bitmap crackfilename = sprintf("Graphics/Pokemon/Eggs/%s_cracks", @pokemon.species) crackfilename = sprintf("Graphics/Pokemon/Eggs/000_cracks") if !pbResolveBitmap(crackfilename) - crackfilename=pbResolveBitmap(crackfilename) - @hatchSheet=AnimatedBitmap.new(crackfilename) + crackfilename = pbResolveBitmap(crackfilename) + @hatchSheet = AnimatedBitmap.new(crackfilename) # Create egg cracks sprite - @sprites["hatch"]=SpriteWrapper.new(@viewport) + @sprites["hatch"] = SpriteWrapper.new(@viewport) @sprites["hatch"].x = @sprites["pokemon"].x @sprites["hatch"].y = @sprites["pokemon"].y @sprites["hatch"].ox = @sprites["pokemon"].ox @sprites["hatch"].oy = @sprites["pokemon"].oy @sprites["hatch"].bitmap = @hatchSheet.bitmap - @sprites["hatch"].src_rect = Rect.new(0,0,@hatchSheet.width/5,@hatchSheet.height) + @sprites["hatch"].src_rect = Rect.new(0, 0, @hatchSheet.width / 5, @hatchSheet.height) @sprites["hatch"].visible = false # Create flash overlay - @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport) - @sprites["overlay"].z=200 - @sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height) - @sprites["overlay"].bitmap.fill_rect(0,0,Graphics.width,Graphics.height, - Color.new(255,255,255)) - @sprites["overlay"].opacity=0 + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) + @sprites["overlay"].z = 200 + @sprites["overlay"].bitmap = Bitmap.new(Graphics.width, Graphics.height) + @sprites["overlay"].bitmap.fill_rect(0, 0, Graphics.width, Graphics.height, + Color.new(255, 255, 255)) + @sprites["overlay"].opacity = 0 # Start up scene pbFadeInAndShow(@sprites) end @@ -55,46 +55,46 @@ class PokemonEggHatch_Scene def pbMain pbBGMPlay("Evolution") # Egg animation - updateScene(Graphics.frame_rate*15/10) + updateScene(Graphics.frame_rate * 15 / 10) pbPositionHatchMask(0) pbSEPlay("Battle ball shake") swingEgg(4) - updateScene(Graphics.frame_rate*2/10) + updateScene(Graphics.frame_rate * 2 / 10) pbPositionHatchMask(1) pbSEPlay("Battle ball shake") swingEgg(4) - updateScene(Graphics.frame_rate*4/10) + updateScene(Graphics.frame_rate * 4 / 10) pbPositionHatchMask(2) pbSEPlay("Battle ball shake") - swingEgg(8,2) - updateScene(Graphics.frame_rate*4/10) + swingEgg(8, 2) + updateScene(Graphics.frame_rate * 4 / 10) pbPositionHatchMask(3) pbSEPlay("Battle ball shake") - swingEgg(16,4) - updateScene(Graphics.frame_rate*2/10) + swingEgg(16, 4) + updateScene(Graphics.frame_rate * 2 / 10) pbPositionHatchMask(4) pbSEPlay("Battle recall") # Fade and change the sprite - fadeTime = Graphics.frame_rate*4/10 - toneDiff = (255.0/fadeTime).ceil + fadeTime = Graphics.frame_rate * 4 / 10 + toneDiff = (255.0 / fadeTime).ceil for i in 1..fadeTime - @sprites["pokemon"].tone=Tone.new(i*toneDiff,i*toneDiff,i*toneDiff) - @sprites["overlay"].opacity=i*toneDiff + @sprites["pokemon"].tone = Tone.new(i * toneDiff, i * toneDiff, i * toneDiff) + @sprites["overlay"].opacity = i * toneDiff updateScene end - updateScene(Graphics.frame_rate*3/4) + updateScene(Graphics.frame_rate * 3 / 4) @sprites["pokemon"].setPokemonBitmap(@pokemon) # Pokémon sprite - @sprites["pokemon"].x = Graphics.width/2 + @sprites["pokemon"].x = Graphics.width / 2 @sprites["pokemon"].y = 264 @pokemon.species_data.apply_metrics_to_sprite(@sprites["pokemon"], 1) - @sprites["hatch"].visible=false + @sprites["hatch"].visible = false for i in 1..fadeTime - @sprites["pokemon"].tone=Tone.new(255-i*toneDiff,255-i*toneDiff,255-i*toneDiff) - @sprites["overlay"].opacity=255-i*toneDiff + @sprites["pokemon"].tone = Tone.new(255 - i * toneDiff, 255 - i * toneDiff, 255 - i * toneDiff) + @sprites["overlay"].opacity = 255 - i * toneDiff updateScene end - @sprites["pokemon"].tone=Tone.new(0,0,0) - @sprites["overlay"].opacity=0 + @sprites["pokemon"].tone = Tone.new(0, 0, 0) + @sprites["overlay"].opacity = 0 # Finish scene frames = (GameData::Species.cry_length(@pokemon) * Graphics.frame_rate).ceil @pokemon.play_cry @@ -120,30 +120,30 @@ class PokemonEggHatch_Scene end def pbPositionHatchMask(index) - @sprites["hatch"].src_rect.x = index*@sprites["hatch"].src_rect.width + @sprites["hatch"].src_rect.x = index * @sprites["hatch"].src_rect.width end - def swingEgg(speed,swingTimes = 1) + def swingEgg(speed, swingTimes = 1) @sprites["hatch"].visible = true - speed = speed.to_f*20/Graphics.frame_rate + speed = speed.to_f * 20 / Graphics.frame_rate amplitude = 8 targets = [] swingTimes.times do - targets.push(@sprites["pokemon"].x+amplitude) - targets.push(@sprites["pokemon"].x-amplitude) + targets.push(@sprites["pokemon"].x + amplitude) + targets.push(@sprites["pokemon"].x - amplitude) end targets.push(@sprites["pokemon"].x) - targets.each_with_index do |target,i| + targets.each_with_index do |target, i| loop do - break if i%2==0 && @sprites["pokemon"].x>=target - break if i%2==1 && @sprites["pokemon"].x<=target + break if i % 2 == 0 && @sprites["pokemon"].x >= target + break if i % 2 == 1 && @sprites["pokemon"].x <= target @sprites["pokemon"].x += speed @sprites["hatch"].x = @sprites["pokemon"].x updateScene end speed *= -1 end - @sprites["pokemon"].x = targets[targets.length-1] + @sprites["pokemon"].x = targets[targets.length - 1] @sprites["hatch"].x = @sprites["pokemon"].x end @@ -165,7 +165,7 @@ end #=============================================================================== class PokemonEggHatchScreen def initialize(scene) - @scene=scene + @scene = scene end def pbStartScreen(pokemon) @@ -181,8 +181,8 @@ end def pbHatchAnimation(pokemon) pbMessage(_INTL("Huh?\1")) pbFadeOutInWithMusic { - scene=PokemonEggHatch_Scene.new - screen=PokemonEggHatchScreen.new(scene) + scene = PokemonEggHatch_Scene.new + screen = PokemonEggHatchScreen.new(scene) screen.pbStartScreen(pokemon) } return true @@ -214,7 +214,7 @@ def pbHatch(pokemon) end end -Events.onStepTaken += proc { |_sender,_e| +Events.onStepTaken += proc { |_sender, _e| for egg in $player.party next if egg.steps_to_hatch <= 0 egg.steps_to_hatch -= 1 diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb index f4f8e95af..f0da60788 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/004_UI_Evolution.rb @@ -32,14 +32,14 @@ class SpriteMetafile end def initialize(viewport = nil) - @metafile=[] - @values=[ + @metafile = [] + @values = [ viewport, - Tone.new(0,0,0,0),Rect.new(0,0,0,0), + Tone.new(0, 0, 0, 0), Rect.new(0, 0, 0, 0), true, - 0,0,0,0,0,100,100, - 0,false,0,255,0, - Color.new(0,0,0,0),Color.new(0,0,0,0), + 0, 0, 0, 0, 0, 100, 100, + 0, false, 0, 255, 0, + Color.new(0, 0, 0, 0), Color.new(0, 0, 0, 0), 0 ] end @@ -50,12 +50,12 @@ class SpriteMetafile def dispose; end - def flash(color,duration) - if duration>0 - @values[FLASHCOLOR]=color.clone - @values[FLASHDURATION]=duration - @metafile.push([FLASHCOLOR,color]) - @metafile.push([FLASHDURATION,duration]) + def flash(color, duration) + if duration > 0 + @values[FLASHCOLOR] = color.clone + @values[FLASHDURATION] = duration + @metafile.push([FLASHCOLOR, color]) + @metafile.push([FLASHDURATION, duration]) end end @@ -64,8 +64,8 @@ class SpriteMetafile end def x=(value) - @values[X]=value - @metafile.push([X,value]) + @values[X] = value + @metafile.push([X, value]) end def y @@ -73,8 +73,8 @@ class SpriteMetafile end def y=(value) - @values[Y]=value - @metafile.push([Y,value]) + @values[Y] = value + @metafile.push([Y, value]) end def bitmap @@ -83,8 +83,8 @@ class SpriteMetafile def bitmap=(value) if value && !value.disposed? - @values[SRC_RECT].set(0,0,value.width,value.height) - @metafile.push([SRC_RECT,@values[SRC_RECT].clone]) + @values[SRC_RECT].set(0, 0, value.width, value.height) + @metafile.push([SRC_RECT, @values[SRC_RECT].clone]) end end @@ -93,8 +93,8 @@ class SpriteMetafile end def src_rect=(value) - @values[SRC_RECT]=value - @metafile.push([SRC_RECT,value]) + @values[SRC_RECT] = value + @metafile.push([SRC_RECT, value]) end def visible @@ -102,8 +102,8 @@ class SpriteMetafile end def visible=(value) - @values[VISIBLE]=value - @metafile.push([VISIBLE,value]) + @values[VISIBLE] = value + @metafile.push([VISIBLE, value]) end def z @@ -111,8 +111,8 @@ class SpriteMetafile end def z=(value) - @values[Z]=value - @metafile.push([Z,value]) + @values[Z] = value + @metafile.push([Z, value]) end def ox @@ -120,8 +120,8 @@ class SpriteMetafile end def ox=(value) - @values[OX]=value - @metafile.push([OX,value]) + @values[OX] = value + @metafile.push([OX, value]) end def oy @@ -129,8 +129,8 @@ class SpriteMetafile end def oy=(value) - @values[OY]=value - @metafile.push([OY,value]) + @values[OY] = value + @metafile.push([OY, value]) end def zoom_x @@ -138,8 +138,8 @@ class SpriteMetafile end def zoom_x=(value) - @values[ZOOM_X]=value - @metafile.push([ZOOM_X,value]) + @values[ZOOM_X] = value + @metafile.push([ZOOM_X, value]) end def zoom_y @@ -147,15 +147,15 @@ class SpriteMetafile end def zoom_y=(value) - @values[ZOOM_Y]=value - @metafile.push([ZOOM_Y,value]) + @values[ZOOM_Y] = value + @metafile.push([ZOOM_Y, value]) end def zoom=(value) - @values[ZOOM_X]=value - @metafile.push([ZOOM_X,value]) - @values[ZOOM_Y]=value - @metafile.push([ZOOM_Y,value]) + @values[ZOOM_X] = value + @metafile.push([ZOOM_X, value]) + @values[ZOOM_Y] = value + @metafile.push([ZOOM_Y, value]) end def angle @@ -163,8 +163,8 @@ class SpriteMetafile end def angle=(value) - @values[ANGLE]=value - @metafile.push([ANGLE,value]) + @values[ANGLE] = value + @metafile.push([ANGLE, value]) end def mirror @@ -172,8 +172,8 @@ class SpriteMetafile end def mirror=(value) - @values[MIRROR]=value - @metafile.push([MIRROR,value]) + @values[MIRROR] = value + @metafile.push([MIRROR, value]) end def bush_depth @@ -181,8 +181,8 @@ class SpriteMetafile end def bush_depth=(value) - @values[BUSH_DEPTH]=value - @metafile.push([BUSH_DEPTH,value]) + @values[BUSH_DEPTH] = value + @metafile.push([BUSH_DEPTH, value]) end def opacity @@ -190,8 +190,8 @@ class SpriteMetafile end def opacity=(value) - @values[OPACITY]=value - @metafile.push([OPACITY,value]) + @values[OPACITY] = value + @metafile.push([OPACITY, value]) end def blend_type @@ -199,8 +199,8 @@ class SpriteMetafile end def blend_type=(value) - @values[BLEND_TYPE]=value - @metafile.push([BLEND_TYPE,value]) + @values[BLEND_TYPE] = value + @metafile.push([BLEND_TYPE, value]) end def color @@ -208,8 +208,8 @@ class SpriteMetafile end def color=(value) - @values[COLOR]=value.clone - @metafile.push([COLOR,@values[COLOR]]) + @values[COLOR] = value.clone + @metafile.push([COLOR, @values[COLOR]]) end def tone @@ -217,12 +217,12 @@ class SpriteMetafile end def tone=(value) - @values[TONE]=value.clone - @metafile.push([TONE,@values[TONE]]) + @values[TONE] = value.clone + @metafile.push([TONE, @values[TONE]]) end def update - @metafile.push([-1,nil]) + @metafile.push([-1, nil]) end end @@ -230,11 +230,11 @@ end # #=============================================================================== class SpriteMetafilePlayer - def initialize(metafile,sprite = nil) - @metafile=metafile - @sprites=[] - @playing=false - @index=0 + def initialize(metafile, sprite = nil) + @metafile = metafile + @sprites = [] + @playing = false + @index = 0 @sprites.push(sprite) if sprite end @@ -247,17 +247,17 @@ class SpriteMetafilePlayer end def play - @playing=true - @index=0 + @playing = true + @index = 0 end def update if @playing for j in @index...@metafile.length - @index=j+1 - break if @metafile[j][0]<0 - code=@metafile[j][0] - value=@metafile[j][1] + @index = j + 1 + break if @metafile[j][0] < 0 + code = @metafile[j][0] + value = @metafile[j][1] for sprite in @sprites case code when SpriteMetafile::X then sprite.x = value @@ -279,7 +279,7 @@ class SpriteMetafilePlayer end end end - @playing=false if @index==@metafile.length + @playing = false if @index == @metafile.length end end end @@ -288,7 +288,7 @@ end # #=============================================================================== def pbSaveSpriteState(sprite) - state=[] + state = [] return state if !sprite || sprite.disposed? state[SpriteMetafile::BITMAP] = sprite.x state[SpriteMetafile::X] = sprite.x @@ -310,7 +310,7 @@ def pbSaveSpriteState(sprite) return state end -def pbRestoreSpriteState(sprite,state) +def pbRestoreSpriteState(sprite, state) return if !state || !sprite || sprite.disposed? sprite.x = state[SpriteMetafile::X] sprite.y = state[SpriteMetafile::Y] @@ -332,15 +332,15 @@ end def pbSaveSpriteStateAndBitmap(sprite) return [] if !sprite || sprite.disposed? - state=pbSaveSpriteState(sprite) - state[SpriteMetafile::BITMAP]=sprite.bitmap + state = pbSaveSpriteState(sprite) + state[SpriteMetafile::BITMAP] = sprite.bitmap return state end -def pbRestoreSpriteStateAndBitmap(sprite,state) +def pbRestoreSpriteStateAndBitmap(sprite, state) return if !state || !sprite || sprite.disposed? - sprite.bitmap=state[SpriteMetafile::BITMAP] - pbRestoreSpriteState(sprite,state) + sprite.bitmap = state[SpriteMetafile::BITMAP] + pbRestoreSpriteState(sprite, state) return state end @@ -350,8 +350,8 @@ end class PokemonEvolutionScene private - def pbGenerateMetafiles(s1x,s1y,s2x,s2y) - sprite = SpriteMetafile.new + def pbGenerateMetafiles(s1x, s1y, s2x, s2y) + sprite = SpriteMetafile.new sprite.ox = s1x sprite.oy = s1y sprite.opacity = 255 @@ -361,7 +361,7 @@ class PokemonEvolutionScene sprite2.zoom = 0.0 sprite2.opacity = 255 alpha = 0 - alphaDiff = 10*20/Graphics.frame_rate + alphaDiff = 10 * 20 / Graphics.frame_rate loop do sprite.color.red = 255 sprite.color.green = 255 @@ -372,15 +372,15 @@ class PokemonEvolutionScene sprite2.color.alpha = 255 sprite.update sprite2.update - break if alpha>=255 + break if alpha >= 255 alpha += alphaDiff end totaltempo = 0 currenttempo = 25 - maxtempo = 7*Graphics.frame_rate - while totaltempo0 + halfResizeDiff = 8 * 20 / Graphics.frame_rate + if @bgviewport.rect.y > 0 @bgviewport.rect.y -= halfResizeDiff @sprites["background"].oy = @bgviewport.rect.y end - if @bgviewport.rect.height=255 + @viewport.tone.set(tone, tone, tone, 0) + break if tone >= 255 end @bgviewport.rect.y = 0 @bgviewport.rect.height = Graphics.height @sprites["background"].oy = 0 if canceled - pbRestoreSpriteState(@sprites["rsprite1"],oldstate) - pbRestoreSpriteState(@sprites["rsprite2"],oldstate2) + pbRestoreSpriteState(@sprites["rsprite1"], oldstate) + pbRestoreSpriteState(@sprites["rsprite2"], oldstate2) @sprites["rsprite1"].zoom_x = 1.0 @sprites["rsprite1"].zoom_y = 1.0 @sprites["rsprite1"].color.alpha = 0 @@ -470,47 +470,47 @@ class PokemonEvolutionScene @sprites["rsprite2"].zoom_y = 1.0 @sprites["rsprite2"].color.alpha = 0 end - (Graphics.frame_rate/4).times do + (Graphics.frame_rate / 4).times do Graphics.update pbUpdate(true) end tone = 255 - toneDiff = 40*20/Graphics.frame_rate + toneDiff = 40 * 20 / Graphics.frame_rate loop do Graphics.update pbUpdate tone -= toneDiff - @viewport.tone.set(tone,tone,tone,0) - break if tone<=0 + @viewport.tone.set(tone, tone, tone, 0) + break if tone <= 0 end end - def pbStartScreen(pokemon,newspecies) + def pbStartScreen(pokemon, newspecies) @pokemon = pokemon @newspecies = newspecies @sprites = {} - @bgviewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @bgviewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @bgviewport.z = 99999 - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 - @msgviewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @msgviewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @msgviewport.z = 99999 - addBackgroundOrColoredPlane(@sprites,"background","evolutionbg", - Color.new(248,248,248),@bgviewport) + addBackgroundOrColoredPlane(@sprites, "background", "evolutionbg", + Color.new(248, 248, 248), @bgviewport) rsprite1 = PokemonSprite.new(@viewport) rsprite1.setOffset(PictureOrigin::Center) - rsprite1.setPokemonBitmap(@pokemon,false) - rsprite1.x = Graphics.width/2 - rsprite1.y = (Graphics.height-64)/2 + rsprite1.setPokemonBitmap(@pokemon, false) + rsprite1.x = Graphics.width / 2 + rsprite1.y = (Graphics.height - 64) / 2 rsprite2 = PokemonSprite.new(@viewport) rsprite2.setOffset(PictureOrigin::Center) - rsprite2.setPokemonBitmapSpecies(@pokemon,@newspecies,false) + rsprite2.setPokemonBitmapSpecies(@pokemon, @newspecies, false) rsprite2.x = rsprite1.x rsprite2.y = rsprite1.y rsprite2.opacity = 0 @sprites["rsprite1"] = rsprite1 @sprites["rsprite2"] = rsprite2 - pbGenerateMetafiles(rsprite1.ox,rsprite1.oy,rsprite2.ox,rsprite2.oy) + pbGenerateMetafiles(rsprite1.ox, rsprite1.oy, rsprite2.ox, rsprite2.oy) @sprites["msgwindow"] = pbCreateMessageWindow(@msgviewport) pbFadeInAndShow(@sprites) { pbUpdate } end @@ -527,15 +527,15 @@ class PokemonEvolutionScene # Opens the evolution screen def pbEvolution(cancancel = true) - metaplayer1 = SpriteMetafilePlayer.new(@metafile1,@sprites["rsprite1"]) - metaplayer2 = SpriteMetafilePlayer.new(@metafile2,@sprites["rsprite2"]) + metaplayer1 = SpriteMetafilePlayer.new(@metafile1, @sprites["rsprite1"]) + metaplayer2 = SpriteMetafilePlayer.new(@metafile2, @sprites["rsprite2"]) metaplayer1.play metaplayer2.play pbBGMStop @pokemon.play_cry pbMessageDisplay(@sprites["msgwindow"], - _INTL("\\se[]What? {1} is evolving!\\^",@pokemon.name)) { pbUpdate } - pbMessageWaitForInput(@sprites["msgwindow"],50,true) { pbUpdate } + _INTL("\\se[]What? {1} is evolving!\\^", @pokemon.name)) { pbUpdate } + pbMessageWaitForInput(@sprites["msgwindow"], 50, true) { pbUpdate } pbPlayDecisionSE oldstate = pbSaveSpriteState(@sprites["rsprite1"]) oldstate2 = pbSaveSpriteState(@sprites["rsprite2"]) @@ -556,11 +556,11 @@ class PokemonEvolutionScene break end end while metaplayer1.playing? && metaplayer2.playing? - pbFlashInOut(canceled,oldstate,oldstate2) + pbFlashInOut(canceled, oldstate, oldstate2) if canceled $stats.evolutions_cancelled += 1 pbMessageDisplay(@sprites["msgwindow"], - _INTL("Huh? {1} stopped evolving!",@pokemon.name)) { pbUpdate } + _INTL("Huh? {1} stopped evolving!", @pokemon.name)) { pbUpdate } else pbEvolutionSuccess end @@ -581,7 +581,7 @@ class PokemonEvolutionScene newspeciesname = GameData::Species.get(@newspecies).name pbMessageDisplay(@sprites["msgwindow"], _INTL("\\se[]Congratulations! Your {1} evolved into {2}!\\wt[80]", - @pokemon.name,newspeciesname)) { pbUpdate } + @pokemon.name, newspeciesname)) { pbUpdate } @sprites["msgwindow"].text = "" # Check for consumed item and check if Pokémon should be duplicated pbEvolutionMethodAfterEvolution @@ -596,8 +596,8 @@ class PokemonEvolutionScene # Learn moves upon evolution for evolved species movelist = @pokemon.getMoveList for i in movelist - next if i[0]!=0 && i[0]!=@pokemon.level # 0 is "learn upon evolution" - pbLearnMove(@pokemon,i[1],true) { pbUpdate } + next if i[0] != 0 && i[0] != @pokemon.level # 0 is "learn upon evolution" + pbLearnMove(@pokemon, i[1], true) { pbUpdate } end end diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb index 337236ab1..b2da85fdd 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/005_UI_Trading.rb @@ -6,16 +6,16 @@ class PokemonTrade_Scene pbUpdateSpriteHash(@sprites) end - def pbRunPictures(pictures,sprites) + def pbRunPictures(pictures, sprites) loop do for i in 0...pictures.length pictures[i].update end for i in 0...sprites.length if sprites[i].is_a?(IconSprite) - setPictureIconSprite(sprites[i],pictures[i]) + setPictureIconSprite(sprites[i], pictures[i]) else - setPictureSprite(sprites[i],pictures[i]) + setPictureSprite(sprites[i], pictures[i]) end end Graphics.update @@ -28,27 +28,27 @@ class PokemonTrade_Scene end end - def pbStartScreen(pokemon,pokemon2,trader1,trader2) + def pbStartScreen(pokemon, pokemon2, trader1, trader2) @sprites = {} - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @pokemon = pokemon @pokemon2 = pokemon2 @trader1 = trader1 @trader2 = trader2 - addBackgroundOrColoredPlane(@sprites,"background","tradebg", - Color.new(248,248,248),@viewport) + addBackgroundOrColoredPlane(@sprites, "background", "tradebg", + Color.new(248, 248, 248), @viewport) @sprites["rsprite1"] = PokemonSprite.new(@viewport) - @sprites["rsprite1"].setPokemonBitmap(@pokemon,false) + @sprites["rsprite1"].setPokemonBitmap(@pokemon, false) @sprites["rsprite1"].setOffset(PictureOrigin::Bottom) - @sprites["rsprite1"].x = Graphics.width/2 + @sprites["rsprite1"].x = Graphics.width / 2 @sprites["rsprite1"].y = 264 @sprites["rsprite1"].z = 10 @pokemon.species_data.apply_metrics_to_sprite(@sprites["rsprite1"], 1) @sprites["rsprite2"] = PokemonSprite.new(@viewport) - @sprites["rsprite2"].setPokemonBitmap(@pokemon2,false) + @sprites["rsprite2"].setPokemonBitmap(@pokemon2, false) @sprites["rsprite2"].setOffset(PictureOrigin::Bottom) - @sprites["rsprite2"].x = Graphics.width/2 + @sprites["rsprite2"].x = Graphics.width / 2 @sprites["rsprite2"].y = 264 @sprites["rsprite2"].z = 10 @pokemon2.species_data.apply_metrics_to_sprite(@sprites["rsprite2"], 1) @@ -58,100 +58,100 @@ class PokemonTrade_Scene end def pbScene1 - spriteBall = IconSprite.new(0,0,@viewport) + spriteBall = IconSprite.new(0, 0, @viewport) pictureBall = PictureEx.new(0) picturePoke = PictureEx.new(0) ballimage = sprintf("Graphics/Battle animations/ball_%s", @pokemon.poke_ball) ballopenimage = sprintf("Graphics/Battle animations/ball_%s_open", @pokemon.poke_ball) # Starting position of ball - pictureBall.setXY(0,Graphics.width/2,48) - pictureBall.setName(0,ballimage) - pictureBall.setSrcSize(0,32,64) - pictureBall.setOrigin(0,PictureOrigin::Center) - pictureBall.setVisible(0,true) + pictureBall.setXY(0, Graphics.width / 2, 48) + pictureBall.setName(0, ballimage) + pictureBall.setSrcSize(0, 32, 64) + pictureBall.setOrigin(0, PictureOrigin::Center) + pictureBall.setVisible(0, true) # Starting position of sprite - picturePoke.setXY(0,@sprites["rsprite1"].x,@sprites["rsprite1"].y) - picturePoke.setOrigin(0,PictureOrigin::Bottom) - picturePoke.setVisible(0,true) + picturePoke.setXY(0, @sprites["rsprite1"].x, @sprites["rsprite1"].y) + picturePoke.setOrigin(0, PictureOrigin::Bottom) + picturePoke.setVisible(0, true) # Change Pokémon color - picturePoke.moveColor(2,5,Color.new(31*8,22*8,30*8,255)) + picturePoke.moveColor(2, 5, Color.new(31 * 8, 22 * 8, 30 * 8, 255)) # Recall delay = picturePoke.totalDuration - picturePoke.setSE(delay,"Battle recall") - pictureBall.setName(delay,ballopenimage) - pictureBall.setSrcSize(delay,32,64) + picturePoke.setSE(delay, "Battle recall") + pictureBall.setName(delay, ballopenimage) + pictureBall.setSrcSize(delay, 32, 64) # Move sprite to ball - picturePoke.moveZoom(delay,8,0) - picturePoke.moveXY(delay,8,Graphics.width/2,48) - picturePoke.setSE(delay+5,"Battle jump to ball") - picturePoke.setVisible(delay+8,false) - delay = picturePoke.totalDuration+1 - pictureBall.setName(delay,ballimage) - pictureBall.setSrcSize(delay,32,64) + picturePoke.moveZoom(delay, 8, 0) + picturePoke.moveXY(delay, 8, Graphics.width / 2, 48) + picturePoke.setSE(delay + 5, "Battle jump to ball") + picturePoke.setVisible(delay + 8, false) + delay = picturePoke.totalDuration + 1 + pictureBall.setName(delay, ballimage) + pictureBall.setSrcSize(delay, 32, 64) # Make Poké Ball go off the top of the screen - delay = picturePoke.totalDuration+10 - pictureBall.moveXY(delay,6,Graphics.width/2,-32) + delay = picturePoke.totalDuration + 10 + pictureBall.moveXY(delay, 6, Graphics.width / 2, -32) # Play animation pbRunPictures( - [picturePoke,pictureBall], - [@sprites["rsprite1"],spriteBall] + [picturePoke, pictureBall], + [@sprites["rsprite1"], spriteBall] ) spriteBall.dispose end def pbScene2 - spriteBall = IconSprite.new(0,0,@viewport) + spriteBall = IconSprite.new(0, 0, @viewport) pictureBall = PictureEx.new(0) picturePoke = PictureEx.new(0) ballimage = sprintf("Graphics/Battle animations/ball_%s", @pokemon2.poke_ball) ballopenimage = sprintf("Graphics/Battle animations/ball_%s_open", @pokemon2.poke_ball) # Starting position of ball - pictureBall.setXY(0,Graphics.width/2,-32) - pictureBall.setName(0,ballimage) - pictureBall.setSrcSize(0,32,64) - pictureBall.setOrigin(0,PictureOrigin::Center) - pictureBall.setVisible(0,true) + pictureBall.setXY(0, Graphics.width / 2, -32) + pictureBall.setName(0, ballimage) + pictureBall.setSrcSize(0, 32, 64) + pictureBall.setOrigin(0, PictureOrigin::Center) + pictureBall.setVisible(0, true) # Starting position of sprite - picturePoke.setOrigin(0,PictureOrigin::Bottom) - picturePoke.setZoom(0,0) - picturePoke.setColor(0,Color.new(31*8,22*8,30*8,255)) - picturePoke.setVisible(0,false) + picturePoke.setOrigin(0, PictureOrigin::Bottom) + picturePoke.setZoom(0, 0) + picturePoke.setColor(0, Color.new(31 * 8, 22 * 8, 30 * 8, 255)) + picturePoke.setVisible(0, false) # Dropping ball - y = Graphics.height-96-16-16 # end point of Poké Ball - delay = picturePoke.totalDuration+2 + y = Graphics.height - 96 - 16 - 16 # end point of Poké Ball + delay = picturePoke.totalDuration + 2 for i in 0...4 - t = [4,4,3,2][i] # Time taken to rise or fall for each bounce - d = [1,2,4,8][i] # Fraction of the starting height each bounce rises to - delay -= t if i==0 - if i>0 - pictureBall.setZoomXY(delay,100+5*(5-i),100-5*(5-i)) # Squish - pictureBall.moveZoom(delay,2,100) # Unsquish - pictureBall.moveXY(delay,t,Graphics.width/2,y-100/d) + t = [4, 4, 3, 2][i] # Time taken to rise or fall for each bounce + d = [1, 2, 4, 8][i] # Fraction of the starting height each bounce rises to + delay -= t if i == 0 + if i > 0 + pictureBall.setZoomXY(delay, 100 + 5 * (5 - i), 100 - 5 * (5 - i)) # Squish + pictureBall.moveZoom(delay, 2, 100) # Unsquish + pictureBall.moveXY(delay, t, Graphics.width / 2, y - 100 / d) end - pictureBall.moveXY(delay+t,t,Graphics.width/2,y) - pictureBall.setSE(delay+2*t,"Battle ball drop") + pictureBall.moveXY(delay + t, t, Graphics.width / 2, y) + pictureBall.setSE(delay + 2 * t, "Battle ball drop") delay = pictureBall.totalDuration end - picturePoke.setXY(delay,Graphics.width/2,y) + picturePoke.setXY(delay, Graphics.width / 2, y) # Open Poké Ball - delay = pictureBall.totalDuration+15 - pictureBall.setSE(delay,"Battle recall") - pictureBall.setName(delay,ballopenimage) - pictureBall.setSrcSize(delay,32,64) - pictureBall.setVisible(delay+5,false) + delay = pictureBall.totalDuration + 15 + pictureBall.setSE(delay, "Battle recall") + pictureBall.setName(delay, ballopenimage) + pictureBall.setSrcSize(delay, 32, 64) + pictureBall.setVisible(delay + 5, false) # Pokémon appears and enlarges - picturePoke.setVisible(delay,true) - picturePoke.moveZoom(delay,8,100) - picturePoke.moveXY(delay,8,Graphics.width/2,@sprites["rsprite2"].y) + picturePoke.setVisible(delay, true) + picturePoke.moveZoom(delay, 8, 100) + picturePoke.moveXY(delay, 8, Graphics.width / 2, @sprites["rsprite2"].y) # Return Pokémon's color to normal and play cry delay = picturePoke.totalDuration - picturePoke.moveColor(delay,5,Color.new(31*8,22*8,30*8,0)) + picturePoke.moveColor(delay, 5, Color.new(31 * 8, 22 * 8, 30 * 8, 0)) cry = GameData::Species.cry_filename_from_pokemon(@pokemon2) - picturePoke.setSE(delay,cry) if cry + picturePoke.setSE(delay, cry) if cry # Play animation pbRunPictures( - [picturePoke,pictureBall], - [@sprites["rsprite2"],spriteBall] + [picturePoke, pictureBall], + [@sprites["rsprite2"], spriteBall] ) spriteBall.dispose end @@ -164,7 +164,7 @@ class PokemonTrade_Scene newspecies = @pokemon2.check_evolution_on_trade(@pokemon) if newspecies evo = PokemonEvolutionScene.new - evo.pbStartScreen(@pokemon2,newspecies) + evo.pbStartScreen(@pokemon2, newspecies) evo.pbEvolution(false) evo.pbEndScreen end @@ -173,31 +173,31 @@ class PokemonTrade_Scene def pbTrade pbBGMStop @pokemon.play_cry - speciesname1=GameData::Species.get(@pokemon.species).name - speciesname2=GameData::Species.get(@pokemon2.species).name + speciesname1 = GameData::Species.get(@pokemon.species).name + speciesname2 = GameData::Species.get(@pokemon2.species).name pbMessageDisplay(@sprites["msgwindow"], _ISPRINTF("{1:s}\r\nID: {2:05d} OT: {3:s}\\wtnp[0]", - @pokemon.name,@pokemon.owner.public_id,@pokemon.owner.name)) { pbUpdate } - pbMessageWaitForInput(@sprites["msgwindow"],50,true) { pbUpdate } + @pokemon.name, @pokemon.owner.public_id, @pokemon.owner.name)) { pbUpdate } + pbMessageWaitForInput(@sprites["msgwindow"], 50, true) { pbUpdate } pbPlayDecisionSE pbScene1 pbMessageDisplay(@sprites["msgwindow"], - _INTL("For {1}'s {2},\r\n{3} sends {4}.\1",@trader1,speciesname1,@trader2,speciesname2)) { pbUpdate } + _INTL("For {1}'s {2},\r\n{3} sends {4}.\1", @trader1, speciesname1, @trader2, speciesname2)) { pbUpdate } pbMessageDisplay(@sprites["msgwindow"], - _INTL("{1} bids farewell to {2}.",@trader2,speciesname2)) { pbUpdate } + _INTL("{1} bids farewell to {2}.", @trader2, speciesname2)) { pbUpdate } pbScene2 pbMessageDisplay(@sprites["msgwindow"], _ISPRINTF("{1:s}\r\nID: {2:05d} OT: {3:s}\1", - @pokemon2.name,@pokemon2.owner.public_id,@pokemon2.owner.name)) { pbUpdate } + @pokemon2.name, @pokemon2.owner.public_id, @pokemon2.owner.name)) { pbUpdate } pbMessageDisplay(@sprites["msgwindow"], - _INTL("Take good care of {1}.",speciesname2)) { pbUpdate } + _INTL("Take good care of {1}.", speciesname2)) { pbUpdate } end end #=============================================================================== # #=============================================================================== -def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender = 0) +def pbStartTrade(pokemonIndex, newpoke, nickname, trainerName, trainerGender = 0) $stats.trade_count += 1 myPokemon = $player.party[pokemonIndex] yourPokemon = nil diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb index 23cdc7d4e..9adb798f4 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb @@ -39,44 +39,44 @@ class HallOfFame_Scene FINALFADESPEED = 16 # Sprites opacity value when them aren't selected OPACITY = 64 - BASECOLOR = Color.new(248,248,248) - SHADOWCOLOR = Color.new(0,0,0) + BASECOLOR = Color.new(248, 248, 248) + SHADOWCOLOR = Color.new(0, 0, 0) # Placement for pokemon icons def pbStartScene - @sprites={} - @viewport=Viewport.new(0,0,Graphics.width, Graphics.height) - @viewport.z=99999 + @sprites = {} + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 # Comment the below line to doesn't use a background - addBackgroundPlane(@sprites,"bg","hallfamebg",@viewport) - @sprites["hallbars"]=IconSprite.new(@viewport) + addBackgroundPlane(@sprites, "bg", "hallfamebg", @viewport) + @sprites["hallbars"] = IconSprite.new(@viewport) @sprites["hallbars"].setBitmap("Graphics/Pictures/hallfamebars") - @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport) - @sprites["overlay"].z=10 + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) + @sprites["overlay"].z = 10 pbSetSystemFont(@sprites["overlay"].bitmap) - @alreadyFadedInEnd=false - @useMusic=false - @battlerIndex=0 - @hallEntry=[] + @alreadyFadedInEnd = false + @useMusic = false + @battlerIndex = 0 + @hallEntry = [] @nationalDexList = [:NONE] GameData::Species.each_species { |s| @nationalDexList.push(s.species) } end def pbStartSceneEntry pbStartScene - @useMusic=(ENTRYMUSIC && ENTRYMUSIC!="") + @useMusic = (ENTRYMUSIC && ENTRYMUSIC != "") pbBGMPlay(ENTRYMUSIC) if @useMusic saveHallEntry - @xmovement=[] - @ymovement=[] + @xmovement = [] + @ymovement = [] createBattlers pbFadeInAndShow(@sprites) { pbUpdate } end def pbStartScenePC pbStartScene - @hallIndex=$PokemonGlobal.hallOfFame.size-1 - @hallEntry=$PokemonGlobal.hallOfFame[-1] + @hallIndex = $PokemonGlobal.hallOfFame.size - 1 + @hallEntry = $PokemonGlobal.hallOfFame[-1] createBattlers(false) pbFadeInAndShow(@sprites) { pbUpdate } pbUpdatePC @@ -90,35 +90,35 @@ class HallOfFame_Scene @viewport.dispose end - def slowFadeOut(sprites,exponent) # 2 exponent + def slowFadeOut(sprites, exponent) # 2 exponent # To handle values above 8 - extraWaitExponent=exponent-9 - exponent=8 if exponent > 8 - max=2**exponent - speed=(2**8)/max + extraWaitExponent = exponent - 9 + exponent = 8 if exponent > 8 + max = 2**exponent + speed = (2**8) / max for j in 0..max - if extraWaitExponent>-1 + if extraWaitExponent > -1 (2**extraWaitExponent).times do Graphics.update Input.update pbUpdate end end - pbSetSpritesToColor(sprites,Color.new(0,0,0,j*speed)) + pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * speed)) block_given? ? yield : pbUpdateSpriteHash(sprites) end end # Dispose the sprite if the sprite exists and make it null - def restartSpritePosition(sprites,spritename) + def restartSpritePosition(sprites, spritename) sprites[spritename].dispose if sprites.include?(spritename) && sprites[spritename] - sprites[spritename]=nil + sprites[spritename] = nil end # Change the pokémon sprites opacity except the index one - def setPokemonSpritesOpacity(index,opacity = 255) + def setPokemonSpritesOpacity(index, opacity = 255) for n in 0...@hallEntry.size - @sprites["pokemon#{n}"].opacity=(n==index) ? 255 : opacity if @sprites["pokemon#{n}"] + @sprites["pokemon#{n}"].opacity = (n == index) ? 255 : opacity if @sprites["pokemon#{n}"] end end @@ -129,73 +129,73 @@ class HallOfFame_Scene end # Update the global variables $PokemonGlobal.hallOfFame.push(@hallEntry) - $PokemonGlobal.hallOfFameLastNumber+=1 - $PokemonGlobal.hallOfFame.delete_at(0) if HALLLIMIT>-1 && - $PokemonGlobal.hallOfFame.size>HALLLIMIT + $PokemonGlobal.hallOfFameLastNumber += 1 + $PokemonGlobal.hallOfFame.delete_at(0) if HALLLIMIT > -1 && + $PokemonGlobal.hallOfFame.size > HALLLIMIT end # Return the x/y point position in screen for battler index number # Don't use odd numbers! def xpointformula(battlernumber) - ret=0 + ret = 0 if !SINGLEROW - ret=32+160*xpositionformula(battlernumber) + ret = 32 + 160 * xpositionformula(battlernumber) else - ret=(60*(battlernumber/2)+48)*(xpositionformula(battlernumber)-1) - ret+=Graphics.width/2-56 + ret = (60 * (battlernumber / 2) + 48) * (xpositionformula(battlernumber) - 1) + ret += Graphics.width / 2 - 56 end return ret end def ypointformula(battlernumber) - ret=0 + ret = 0 if !SINGLEROW - ret=32+128*ypositionformula(battlernumber)/2 + ret = 32 + 128 * ypositionformula(battlernumber) / 2 else - ret=96-8*(battlernumber/2) + ret = 96 - 8 * (battlernumber / 2) end return ret end # Returns 0, 1 or 2 as the x/y column value def xpositionformula(battlernumber) - ret=0 + ret = 0 if !SINGLEROW - ret=(battlernumber/3%2==0) ? (19-battlernumber)%3 : (19+battlernumber)%3 + ret = (battlernumber / 3 % 2 == 0) ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3 else - ret=battlernumber%2*2 + ret = battlernumber % 2 * 2 end return ret end def ypositionformula(battlernumber) - ret=0 + ret = 0 if !SINGLEROW - ret=(battlernumber/3)%2*2 + ret = (battlernumber / 3) % 2 * 2 else - ret=1 + ret = 1 end return ret end def moveSprite(i) - spritename=(i>-1) ? "pokemon#{i}" : "trainer" - speed = (i>-1) ? ANIMATIONSPEED : 2 + spritename = (i > -1) ? "pokemon#{i}" : "trainer" + speed = (i > -1) ? ANIMATIONSPEED : 2 if !ANIMATION # Skips animation - @sprites[spritename].x-=speed*@xmovement[i] - @xmovement[i]=0 - @sprites[spritename].y-=speed*@ymovement[i] - @ymovement[i]=0 + @sprites[spritename].x -= speed * @xmovement[i] + @xmovement[i] = 0 + @sprites[spritename].y -= speed * @ymovement[i] + @ymovement[i] = 0 end if @xmovement[i] != 0 - direction = (@xmovement[i]>0) ? -1 : 1 - @sprites[spritename].x+=speed*direction - @xmovement[i]+=direction + direction = (@xmovement[i] > 0) ? -1 : 1 + @sprites[spritename].x += speed * direction + @xmovement[i] += direction end if @ymovement[i] != 0 - direction = (@ymovement[i]>0) ? -1 : 1 - @sprites[spritename].y+=speed*direction - @ymovement[i]+=direction + direction = (@ymovement[i] > 0) ? -1 : 1 + @sprites[spritename].y += speed * direction + @ymovement[i] += direction end end @@ -204,67 +204,67 @@ class HallOfFame_Scene for i in 0...6 # Clear all 6 pokémon sprites and dispose the ones that exists every time # that this method is call - restartSpritePosition(@sprites,"pokemon#{i}") - next if i>=@hallEntry.size - xpoint=xpointformula(i) - ypoint=ypointformula(i) - pok=@hallEntry[i] - @sprites["pokemon#{i}"]=PokemonSprite.new(@viewport) + restartSpritePosition(@sprites, "pokemon#{i}") + next if i >= @hallEntry.size + xpoint = xpointformula(i) + ypoint = ypointformula(i) + pok = @hallEntry[i] + @sprites["pokemon#{i}"] = PokemonSprite.new(@viewport) @sprites["pokemon#{i}"].setOffset(PictureOrigin::TopLeft) @sprites["pokemon#{i}"].setPokemonBitmap(pok) # This method doesn't put the exact coordinates @sprites["pokemon#{i}"].x = xpoint @sprites["pokemon#{i}"].y = ypoint if @sprites["pokemon#{i}"].bitmap && !@sprites["pokemon#{i}"].disposed? - @sprites["pokemon#{i}"].x += (128-@sprites["pokemon#{i}"].bitmap.width)/2 - @sprites["pokemon#{i}"].y += (128-@sprites["pokemon#{i}"].bitmap.height)/2 + @sprites["pokemon#{i}"].x += (128 - @sprites["pokemon#{i}"].bitmap.width) / 2 + @sprites["pokemon#{i}"].y += (128 - @sprites["pokemon#{i}"].bitmap.height) / 2 end - @sprites["pokemon#{i}"].z=7-i if SINGLEROW + @sprites["pokemon#{i}"].z = 7 - i if SINGLEROW next if !hide # Animation distance calculation - horizontal=1-xpositionformula(i) - vertical=1-ypositionformula(i) - xdistance=(horizontal==-1) ? -@sprites["pokemon#{i}"].bitmap.width : Graphics.width - ydistance=(vertical==-1) ? -@sprites["pokemon#{i}"].bitmap.height : Graphics.height - xdistance=((xdistance-@sprites["pokemon#{i}"].x)/ANIMATIONSPEED).abs+1 - ydistance=((ydistance-@sprites["pokemon#{i}"].y)/ANIMATIONSPEED).abs+1 - biggerdistance=(xdistance>ydistance) ? xdistance : ydistance - @xmovement[i]=biggerdistance - @xmovement[i]*=-1 if horizontal==-1 - @xmovement[i]=0 if horizontal== 0 - @ymovement[i]=biggerdistance - @ymovement[i]*=-1 if vertical==-1 - @ymovement[i]=0 if vertical== 0 + horizontal = 1 - xpositionformula(i) + vertical = 1 - ypositionformula(i) + xdistance = (horizontal == -1) ? -@sprites["pokemon#{i}"].bitmap.width : Graphics.width + ydistance = (vertical == -1) ? -@sprites["pokemon#{i}"].bitmap.height : Graphics.height + xdistance = ((xdistance - @sprites["pokemon#{i}"].x) / ANIMATIONSPEED).abs + 1 + ydistance = ((ydistance - @sprites["pokemon#{i}"].y) / ANIMATIONSPEED).abs + 1 + biggerdistance = (xdistance > ydistance) ? xdistance : ydistance + @xmovement[i] = biggerdistance + @xmovement[i] *= -1 if horizontal == -1 + @xmovement[i] = 0 if horizontal == 0 + @ymovement[i] = biggerdistance + @ymovement[i] *= -1 if vertical == -1 + @ymovement[i] = 0 if vertical == 0 # Hide the battlers - @sprites["pokemon#{i}"].x+=@xmovement[i]*ANIMATIONSPEED - @sprites["pokemon#{i}"].y+=@ymovement[i]*ANIMATIONSPEED + @sprites["pokemon#{i}"].x += @xmovement[i] * ANIMATIONSPEED + @sprites["pokemon#{i}"].y += @ymovement[i] * ANIMATIONSPEED end end def createTrainerBattler - @sprites["trainer"]=IconSprite.new(@viewport) + @sprites["trainer"] = IconSprite.new(@viewport) @sprites["trainer"].setBitmap(GameData::TrainerType.front_sprite_filename($player.trainer_type)) if !SINGLEROW - @sprites["trainer"].x=Graphics.width-96 - @sprites["trainer"].y=160 + @sprites["trainer"].x = Graphics.width - 96 + @sprites["trainer"].y = 160 else - @sprites["trainer"].x=Graphics.width/2 - @sprites["trainer"].y=178 + @sprites["trainer"].x = Graphics.width / 2 + @sprites["trainer"].y = 178 end - @sprites["trainer"].z=9 - @sprites["trainer"].ox=@sprites["trainer"].bitmap.width/2 - @sprites["trainer"].oy=@sprites["trainer"].bitmap.height/2 + @sprites["trainer"].z = 9 + @sprites["trainer"].ox = @sprites["trainer"].bitmap.width / 2 + @sprites["trainer"].oy = @sprites["trainer"].bitmap.height / 2 if REMOVEBARS @sprites["overlay"].bitmap.clear - @sprites["hallbars"].visible=false + @sprites["hallbars"].visible = false end - @xmovement[@battlerIndex]=0 - @ymovement[@battlerIndex]=0 + @xmovement[@battlerIndex] = 0 + @ymovement[@battlerIndex] = 0 if ANIMATION && !SINGLEROW # Trainer Animation - startpoint=Graphics.width/2 + startpoint = Graphics.width / 2 # 2 is the trainer speed - @xmovement[@battlerIndex]=(startpoint-@sprites["trainer"].x)/2 - @sprites["trainer"].x=startpoint + @xmovement[@battlerIndex] = (startpoint - @sprites["trainer"].x) / 2 + @sprites["trainer"].x = startpoint else ENTRYWAITTIME.times do Graphics.update @@ -278,58 +278,58 @@ class HallOfFame_Scene totalsec = Graphics.frame_count / Graphics.frame_rate hour = totalsec / 60 / 60 min = totalsec / 60 % 60 - pubid=sprintf("%05d", $player.public_ID) - lefttext= _INTL("Name{1}
", $player.name) - lefttext+=_INTL("IDNo.{1}
",pubid) - lefttext+=_ISPRINTF("Time{1:02d}:{2:02d}
",hour,min) - lefttext+=_INTL("Pokédex{1}/{2}
", + pubid = sprintf("%05d", $player.public_ID) + lefttext = _INTL("Name{1}
", $player.name) + lefttext += _INTL("IDNo.{1}
", pubid) + lefttext += _ISPRINTF("Time{1:02d}:{2:02d}
", hour, min) + lefttext += _INTL("Pokédex{1}/{2}
", $player.pokedex.owned_count, $player.pokedex.seen_count) - @sprites["messagebox"]=Window_AdvancedTextPokemon.new(lefttext) - @sprites["messagebox"].viewport=@viewport - @sprites["messagebox"].width=192 if @sprites["messagebox"].width<192 - @sprites["msgwindow"]=pbCreateMessageWindow(@viewport) + @sprites["messagebox"] = Window_AdvancedTextPokemon.new(lefttext) + @sprites["messagebox"].viewport = @viewport + @sprites["messagebox"].width = 192 if @sprites["messagebox"].width < 192 + @sprites["msgwindow"] = pbCreateMessageWindow(@viewport) pbMessageDisplay(@sprites["msgwindow"], _INTL("League champion!\nCongratulations!\\^")) end - def writePokemonData(pokemon,hallNumber = -1) - overlay=@sprites["overlay"].bitmap + def writePokemonData(pokemon, hallNumber = -1) + overlay = @sprites["overlay"].bitmap overlay.clear - pokename=pokemon.name - speciesname=pokemon.speciesName + pokename = pokemon.name + speciesname = pokemon.speciesName if pokemon.male? - speciesname+="♂" + speciesname += "♂" elsif pokemon.female? - speciesname+="♀" + speciesname += "♀" end - pokename+="/"+speciesname - pokename=_INTL("Egg")+"/"+_INTL("Egg") if pokemon.egg? - idno=(pokemon.owner.name.empty? || pokemon.egg?) ? "?????" : sprintf("%05d",pokemon.owner.public_id) + pokename += "/" + speciesname + pokename = _INTL("Egg") + "/" + _INTL("Egg") if pokemon.egg? + idno = (pokemon.owner.name.empty? || pokemon.egg?) ? "?????" : sprintf("%05d", pokemon.owner.public_id) dexnumber = _INTL("No. ???") if !pokemon.egg? number = @nationalDexList.index(pokemon.species) || 0 dexnumber = _ISPRINTF("No. {1:03d}", number) end - textPositions=[ - [dexnumber,32,Graphics.height-86,0,BASECOLOR,SHADOWCOLOR], - [pokename,Graphics.width-192,Graphics.height-86,2,BASECOLOR,SHADOWCOLOR], - [_INTL("Lv. {1}",pokemon.egg? ? "?" : pokemon.level), - 64,Graphics.height-54,0,BASECOLOR,SHADOWCOLOR], - [_INTL("IDNo.{1}",pokemon.egg? ? "?????" : idno), - Graphics.width-192,Graphics.height-54,2,BASECOLOR,SHADOWCOLOR] + textPositions = [ + [dexnumber, 32, Graphics.height - 86, 0, BASECOLOR, SHADOWCOLOR], + [pokename, Graphics.width - 192, Graphics.height - 86, 2, BASECOLOR, SHADOWCOLOR], + [_INTL("Lv. {1}", pokemon.egg? ? "?" : pokemon.level), + 64, Graphics.height - 54, 0, BASECOLOR, SHADOWCOLOR], + [_INTL("IDNo.{1}", pokemon.egg? ? "?????" : idno), + Graphics.width - 192, Graphics.height - 54, 2, BASECOLOR, SHADOWCOLOR] ] - if (hallNumber>-1) - textPositions.push([_INTL("Hall of Fame No."),Graphics.width/2-104,-6,0,BASECOLOR,SHADOWCOLOR]) - textPositions.push([hallNumber.to_s,Graphics.width/2+104,-6,1,BASECOLOR,SHADOWCOLOR]) + if (hallNumber > -1) + textPositions.push([_INTL("Hall of Fame No."), Graphics.width / 2 - 104, -6, 0, BASECOLOR, SHADOWCOLOR]) + textPositions.push([hallNumber.to_s, Graphics.width / 2 + 104, -6, 1, BASECOLOR, SHADOWCOLOR]) end - pbDrawTextPositions(overlay,textPositions) + pbDrawTextPositions(overlay, textPositions) end def writeWelcome - overlay=@sprites["overlay"].bitmap + overlay = @sprites["overlay"].bitmap overlay.clear - pbDrawTextPositions(overlay,[[_INTL("Welcome to the Hall of Fame!"), - Graphics.width/2,Graphics.height-80,2,BASECOLOR,SHADOWCOLOR]]) + pbDrawTextPositions(overlay, [[_INTL("Welcome to the Hall of Fame!"), + Graphics.width / 2, Graphics.height - 80, 2, BASECOLOR, SHADOWCOLOR]]) end def pbAnimationLoop @@ -338,7 +338,7 @@ class HallOfFame_Scene Input.update pbUpdate pbUpdateAnimation - break if @battlerIndex==@hallEntry.size+2 + break if @battlerIndex == @hallEntry.size + 2 end end @@ -347,19 +347,19 @@ class HallOfFame_Scene Graphics.update Input.update pbUpdate - continueScene=true + continueScene = true break if Input.trigger?(Input::BACK) # Exits if Input.trigger?(Input::USE) # Moves the selection one entry backward - @battlerIndex+=10 - continueScene=pbUpdatePC + @battlerIndex += 10 + continueScene = pbUpdatePC end if Input.trigger?(Input::LEFT) # Moves the selection one pokémon forward - @battlerIndex-=1 - continueScene=pbUpdatePC + @battlerIndex -= 1 + continueScene = pbUpdatePC end if Input.trigger?(Input::RIGHT) # Moves the selection one pokémon backward - @battlerIndex+=1 - continueScene=pbUpdatePC + @battlerIndex += 1 + continueScene = pbUpdatePC end break if !continueScene end @@ -370,75 +370,75 @@ class HallOfFame_Scene end def pbUpdateAnimation - if @battlerIndex<=@hallEntry.size - if @xmovement[@battlerIndex]!=0 || @ymovement[@battlerIndex]!=0 - spriteIndex=(@battlerIndex<@hallEntry.size) ? @battlerIndex : -1 + if @battlerIndex <= @hallEntry.size + if @xmovement[@battlerIndex] != 0 || @ymovement[@battlerIndex] != 0 + spriteIndex = (@battlerIndex < @hallEntry.size) ? @battlerIndex : -1 moveSprite(spriteIndex) else - @battlerIndex+=1 - if @battlerIndex<=@hallEntry.size + @battlerIndex += 1 + if @battlerIndex <= @hallEntry.size # If it is a pokémon, write the pokémon text, wait the # ENTRYWAITTIME and goes to the next battler @hallEntry[@battlerIndex - 1].play_cry - writePokemonData(@hallEntry[@battlerIndex-1]) - (ENTRYWAITTIME*Graphics.frame_rate/20).times do + writePokemonData(@hallEntry[@battlerIndex - 1]) + (ENTRYWAITTIME * Graphics.frame_rate / 20).times do Graphics.update Input.update pbUpdate end - if @battlerIndex<@hallEntry.size # Preparates the next battler - setPokemonSpritesOpacity(@battlerIndex,OPACITY) + if @battlerIndex < @hallEntry.size # Preparates the next battler + setPokemonSpritesOpacity(@battlerIndex, OPACITY) @sprites["overlay"].bitmap.clear else # Show the welcome message and preparates the trainer setPokemonSpritesOpacity(-1) writeWelcome - (ENTRYWAITTIME*2*Graphics.frame_rate/20).times do + (ENTRYWAITTIME * 2 * Graphics.frame_rate / 20).times do Graphics.update Input.update pbUpdate end - setPokemonSpritesOpacity(-1,OPACITY) if !SINGLEROW + setPokemonSpritesOpacity(-1, OPACITY) if !SINGLEROW createTrainerBattler end end end - elsif @battlerIndex>@hallEntry.size + elsif @battlerIndex > @hallEntry.size # Write the trainer data and fade writeTrainerData - (ENTRYWAITTIME*Graphics.frame_rate/20).times do + (ENTRYWAITTIME * Graphics.frame_rate / 20).times do Graphics.update Input.update pbUpdate end - fadeSpeed=((Math.log(2**12)-Math.log(FINALFADESPEED))/Math.log(2)).floor - pbBGMFade((2**fadeSpeed).to_f/20) if @useMusic - slowFadeOut(@sprites,fadeSpeed) { pbUpdate } - @alreadyFadedInEnd=true - @battlerIndex+=1 + fadeSpeed = ((Math.log(2**12) - Math.log(FINALFADESPEED)) / Math.log(2)).floor + pbBGMFade((2**fadeSpeed).to_f / 20) if @useMusic + slowFadeOut(@sprites, fadeSpeed) { pbUpdate } + @alreadyFadedInEnd = true + @battlerIndex += 1 end end def pbUpdatePC # Change the team - if @battlerIndex>=@hallEntry.size - @hallIndex-=1 - return false if @hallIndex==-1 - @hallEntry=$PokemonGlobal.hallOfFame[@hallIndex] - @battlerIndex=0 + if @battlerIndex >= @hallEntry.size + @hallIndex -= 1 + return false if @hallIndex == -1 + @hallEntry = $PokemonGlobal.hallOfFame[@hallIndex] + @battlerIndex = 0 createBattlers(false) - elsif @battlerIndex<0 - @hallIndex+=1 - return false if @hallIndex>=$PokemonGlobal.hallOfFame.size - @hallEntry=$PokemonGlobal.hallOfFame[@hallIndex] - @battlerIndex=@hallEntry.size-1 + elsif @battlerIndex < 0 + @hallIndex += 1 + return false if @hallIndex >= $PokemonGlobal.hallOfFame.size + @hallEntry = $PokemonGlobal.hallOfFame[@hallIndex] + @battlerIndex = @hallEntry.size - 1 createBattlers(false) end # Change the pokemon @hallEntry[@battlerIndex].play_cry - setPokemonSpritesOpacity(@battlerIndex,OPACITY) - hallNumber=$PokemonGlobal.hallOfFameLastNumber + @hallIndex - - $PokemonGlobal.hallOfFame.size + 1 - writePokemonData(@hallEntry[@battlerIndex],hallNumber) + setPokemonSpritesOpacity(@battlerIndex, OPACITY) + hallNumber = $PokemonGlobal.hallOfFameLastNumber + @hallIndex - + $PokemonGlobal.hallOfFame.size + 1 + writePokemonData(@hallEntry[@battlerIndex], hallNumber) return true end end @@ -469,7 +469,7 @@ end #=============================================================================== class HallOfFamePC def shouldShow? - return $PokemonGlobal.hallOfFameLastNumber>0 + return $PokemonGlobal.hallOfFameLastNumber > 0 end def name @@ -509,13 +509,13 @@ end # #=============================================================================== def pbHallOfFameEntry - scene=HallOfFame_Scene.new - screen=HallOfFameScreen.new(scene) + scene = HallOfFame_Scene.new + screen = HallOfFameScreen.new(scene) screen.pbStartScreenEntry end def pbHallOfFamePC - scene=HallOfFame_Scene.new - screen=HallOfFameScreen.new(scene) + scene = HallOfFame_Scene.new + screen = HallOfFameScreen.new(scene) screen.pbStartScreenPC end diff --git a/Data/Scripts/016_UI/001_UI_PauseMenu.rb b/Data/Scripts/016_UI/001_UI_PauseMenu.rb index 39761150d..181c0d3ea 100644 --- a/Data/Scripts/016_UI/001_UI_PauseMenu.rb +++ b/Data/Scripts/016_UI/001_UI_PauseMenu.rb @@ -3,15 +3,15 @@ #=============================================================================== class PokemonPauseMenu_Scene def pbStartScene - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites = {} @sprites["cmdwindow"] = Window_CommandPokemon.new([]) @sprites["cmdwindow"].visible = false @sprites["cmdwindow"].viewport = @viewport - @sprites["infowindow"] = Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport) + @sprites["infowindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 32, 32, @viewport) @sprites["infowindow"].visible = false - @sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport) + @sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 32, 32, @viewport) @sprites["helpwindow"].visible = false @infostate = false @helpstate = false @@ -19,14 +19,14 @@ class PokemonPauseMenu_Scene end def pbShowInfo(text) - @sprites["infowindow"].resizeToFit(text,Graphics.height) + @sprites["infowindow"].resizeToFit(text, Graphics.height) @sprites["infowindow"].text = text @sprites["infowindow"].visible = true @infostate = true end def pbShowHelp(text) - @sprites["helpwindow"].resizeToFit(text,Graphics.height) + @sprites["helpwindow"].resizeToFit(text, Graphics.height) @sprites["helpwindow"].text = text @sprites["helpwindow"].visible = true pbBottomLeft(@sprites["helpwindow"]) @@ -51,7 +51,7 @@ class PokemonPauseMenu_Scene cmdwindow.commands = commands cmdwindow.index = $game_temp.menu_last_choice cmdwindow.resizeToFit(commands) - cmdwindow.x = Graphics.width-cmdwindow.width + cmdwindow.x = Graphics.width - cmdwindow.width cmdwindow.y = 0 cmdwindow.visible = true loop do @@ -127,7 +127,7 @@ class PokemonPauseMenu commands[cmdTrainer = commands.length] = $player.name if pbInSafari? if Settings::SAFARI_STEPS <= 0 - @scene.pbShowInfo(_INTL("Balls: {1}",pbSafariState.ballcount)) + @scene.pbShowInfo(_INTL("Balls: {1}", pbSafariState.ballcount)) else @scene.pbShowInfo(_INTL("Steps: {1}/{2}\nBalls: {3}", pbSafariState.steps, Settings::SAFARI_STEPS, pbSafariState.ballcount)) @@ -140,7 +140,7 @@ class PokemonPauseMenu pbBugContestState.lastPokemon.level, pbBugContestState.ballcount)) else - @scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}",pbBugContestState.ballcount)) + @scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}", pbBugContestState.ballcount)) end commands[cmdQuit = commands.length] = _INTL("Quit Contest") else @@ -151,7 +151,7 @@ class PokemonPauseMenu commands[cmdEndGame = commands.length] = _INTL("Quit Game") loop do command = @scene.pbShowCommands(commands) - if cmdPokedex>=0 && command==cmdPokedex + if cmdPokedex >= 0 && command == cmdPokedex pbPlayDecisionSE if Settings::USE_CURRENT_REGION_DEX pbFadeOutIn { @@ -178,7 +178,7 @@ class PokemonPauseMenu } end end - elsif cmdPokemon>=0 && command==cmdPokemon + elsif cmdPokemon >= 0 && command == cmdPokemon pbPlayDecisionSE hiddenmove = nil pbFadeOutIn { @@ -189,10 +189,10 @@ class PokemonPauseMenu } if hiddenmove $game_temp.in_menu = false - pbUseHiddenMove(hiddenmove[0],hiddenmove[1]) + pbUseHiddenMove(hiddenmove[0], hiddenmove[1]) return end - elsif cmdBag>=0 && command==cmdBag + elsif cmdBag >= 0 && command == cmdBag pbPlayDecisionSE item = nil pbFadeOutIn { @@ -206,7 +206,7 @@ class PokemonPauseMenu pbUseKeyItemInField(item) return end - elsif cmdPokegear>=0 && command==cmdPokegear + elsif cmdPokegear >= 0 && command == cmdPokegear pbPlayDecisionSE pbFadeOutIn { scene = PokemonPokegear_Scene.new @@ -215,7 +215,7 @@ class PokemonPauseMenu ($game_temp.fly_destination) ? @scene.pbEndScene : @scene.pbRefresh } return if pbFlyToNewLocation - elsif cmdTownMap>=0 && command==cmdTownMap + elsif cmdTownMap >= 0 && command == cmdTownMap pbFadeOutIn { scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) @@ -224,7 +224,7 @@ class PokemonPauseMenu ($game_temp.fly_destination) ? @scene.pbEndScene : @scene.pbRefresh } return if pbFlyToNewLocation - elsif cmdTrainer>=0 && command==cmdTrainer + elsif cmdTrainer >= 0 && command == cmdTrainer pbPlayDecisionSE pbFadeOutIn { scene = PokemonTrainerCard_Scene.new @@ -232,7 +232,7 @@ class PokemonPauseMenu screen.pbStartScreen @scene.pbRefresh } - elsif cmdQuit>=0 && command==cmdQuit + elsif cmdQuit >= 0 && command == cmdQuit @scene.pbHideMenu if pbInSafari? if pbConfirmMessage(_INTL("Would you like to leave the Safari Game right now?")) @@ -252,7 +252,7 @@ class PokemonPauseMenu pbShowMenu end end - elsif cmdSave>=0 && command==cmdSave + elsif cmdSave >= 0 && command == cmdSave @scene.pbHideMenu scene = PokemonSave_Scene.new screen = PokemonSaveScreen.new(scene) @@ -263,7 +263,7 @@ class PokemonPauseMenu else pbShowMenu end - elsif cmdOption>=0 && command==cmdOption + elsif cmdOption >= 0 && command == cmdOption pbPlayDecisionSE pbFadeOutIn { scene = PokemonOption_Scene.new @@ -272,13 +272,13 @@ class PokemonPauseMenu pbUpdateSceneMap @scene.pbRefresh } - elsif cmdDebug>=0 && command==cmdDebug + elsif cmdDebug >= 0 && command == cmdDebug pbPlayDecisionSE pbFadeOutIn { pbDebugMenu @scene.pbRefresh } - elsif cmdEndGame>=0 && command==cmdEndGame + elsif cmdEndGame >= 0 && command == cmdEndGame @scene.pbHideMenu if pbConfirmMessage(_INTL("Are you sure you want to quit the game?")) scene = PokemonSave_Scene.new diff --git a/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb b/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb index 9731983c3..c725ced43 100644 --- a/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb +++ b/Data/Scripts/016_UI/002_UI_Pokedex_Menu.rb @@ -5,27 +5,27 @@ # Settings::USE_CURRENT_REGION_DEX is false. #=============================================================================== class Window_DexesList < Window_CommandPokemon - def initialize(commands,commands2,width) + def initialize(commands, commands2, width) @commands2 = commands2 - super(commands,width) + super(commands, width) @selarrow = AnimatedBitmap.new("Graphics/Pictures/selarrow_white") - self.baseColor = Color.new(248,248,248) - self.shadowColor = Color.new(0,0,0) + self.baseColor = Color.new(248, 248, 248) + self.shadowColor = Color.new(0, 0, 0) self.windowskin = nil end - def drawItem(index,count,rect) - super(index,count,rect) - if index>=0 && index<@commands2.length - pbDrawShadowText(self.contents,rect.x+254,rect.y,64,rect.height, - sprintf("%d",@commands2[index][0]),self.baseColor,self.shadowColor,1) - pbDrawShadowText(self.contents,rect.x+350,rect.y,64,rect.height, - sprintf("%d",@commands2[index][1]),self.baseColor,self.shadowColor,1) - allseen = (@commands2[index][0]>=@commands2[index][2]) - allown = (@commands2[index][1]>=@commands2[index][2]) - pbDrawImagePositions(self.contents,[ - ["Graphics/Pictures/Pokedex/icon_menuseenown",rect.x+236,rect.y+2,(allseen) ? 24 : 0,0,24,24], - ["Graphics/Pictures/Pokedex/icon_menuseenown",rect.x+332,rect.y+2,(allown) ? 24 : 0,24,24,24] + def drawItem(index, count, rect) + super(index, count, rect) + if index >= 0 && index < @commands2.length + pbDrawShadowText(self.contents, rect.x + 254, rect.y, 64, rect.height, + sprintf("%d", @commands2[index][0]), self.baseColor, self.shadowColor, 1) + pbDrawShadowText(self.contents, rect.x + 350, rect.y, 64, rect.height, + sprintf("%d", @commands2[index][1]), self.baseColor, self.shadowColor, 1) + allseen = (@commands2[index][0] >= @commands2[index][2]) + allown = (@commands2[index][1] >= @commands2[index][2]) + pbDrawImagePositions(self.contents, [ + ["Graphics/Pictures/Pokedex/icon_menuseenown", rect.x + 236, rect.y + 2, (allseen) ? 24 : 0, 0, 24, 24], + ["Graphics/Pictures/Pokedex/icon_menuseenown", rect.x + 332, rect.y + 2, (allown) ? 24 : 0, 24, 24, 24] ]) end end @@ -39,17 +39,17 @@ class PokemonPokedexMenu_Scene pbUpdateSpriteHash(@sprites) end - def pbStartScene(commands,commands2) + def pbStartScene(commands, commands2) @commands = commands - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) @sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_menu")) - @sprites["headings"]=Window_AdvancedTextPokemon.newWithSize( - _INTL("SEENOBTAINED"),286,136,208,64,@viewport) - @sprites["headings"].windowskin = nil - @sprites["commands"] = Window_DexesList.new(commands,commands2,Graphics.width-84) + @sprites["headings"] = Window_AdvancedTextPokemon.newWithSize( + _INTL("SEENOBTAINED"), 286, 136, 208, 64, @viewport) + @sprites["headings"].windowskin = nil + @sprites["commands"] = Window_DexesList.new(commands, commands2, Graphics.width - 84) @sprites["commands"].x = 40 @sprites["commands"].y = 192 @sprites["commands"].height = 192 @@ -68,7 +68,7 @@ class PokemonPokedexMenu_Scene break elsif Input.trigger?(Input::USE) ret = @sprites["commands"].index - (ret==@commands.length-1) ? pbPlayCloseMenuSE : pbPlayDecisionSE + (ret == @commands.length - 1) ? pbPlayCloseMenuSE : pbPlayDecisionSE break end end @@ -107,10 +107,10 @@ class PokemonPokedexMenuScreen pbGetRegionalDexLength(dex)]) end commands.push(_INTL("Exit")) - @scene.pbStartScene(commands,commands2) + @scene.pbStartScene(commands, commands2) loop do cmd = @scene.pbScene - break if cmd<0 || cmd>=commands2.length # Cancel/Exit + break if cmd < 0 || cmd >= commands2.length # Cancel/Exit $PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[cmd] pbFadeOutIn { scene = PokemonPokedex_Scene.new diff --git a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb index 7db75dff8..6d6817b71 100644 --- a/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb +++ b/Data/Scripts/016_UI/003_UI_Pokedex_Main.rb @@ -2,14 +2,14 @@ # #=============================================================================== class Window_Pokedex < Window_DrawableCommand - def initialize(x,y,width,height,viewport) + def initialize(x, y, width, height, viewport) @commands = [] - super(x,y,width,height,viewport) + super(x, y, width, height, viewport) @selarrow = AnimatedBitmap.new("Graphics/Pictures/Pokedex/cursor_list") @pokeballOwn = AnimatedBitmap.new("Graphics/Pictures/Pokedex/icon_own") @pokeballSeen = AnimatedBitmap.new("Graphics/Pictures/Pokedex/icon_seen") - self.baseColor = Color.new(88,88,80) - self.shadowColor = Color.new(168,184,184) + self.baseColor = Color.new(88, 88, 80) + self.shadowColor = Color.new(168, 184, 184) self.windowskin = nil end @@ -25,44 +25,44 @@ class Window_Pokedex < Window_DrawableCommand end def species - return (@commands.length==0) ? 0 : @commands[self.index][0] + return (@commands.length == 0) ? 0 : @commands[self.index][0] end def itemCount return @commands.length end - 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) + 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] indexNumber = @commands[index][4] indexNumber -= 1 if @commands[index][5] if $player.seen?(species) if $player.owned?(species) - pbCopyBitmap(self.contents,@pokeballOwn.bitmap,rect.x-6,rect.y+8) + pbCopyBitmap(self.contents, @pokeballOwn.bitmap, rect.x - 6, rect.y + 8) else - pbCopyBitmap(self.contents,@pokeballSeen.bitmap,rect.x-6,rect.y+8) + pbCopyBitmap(self.contents, @pokeballSeen.bitmap, rect.x - 6, rect.y + 8) end - text = sprintf("%03d%s %s",indexNumber," ",@commands[index][1]) + text = sprintf("%03d%s %s", indexNumber, " ", @commands[index][1]) else - text = sprintf("%03d ----------",indexNumber) + text = sprintf("%03d ----------", indexNumber) end - pbDrawShadowText(self.contents,rect.x+36,rect.y+6,rect.width,rect.height, - text,self.baseColor,self.shadowColor) + pbDrawShadowText(self.contents, rect.x + 36, rect.y + 6, rect.width, rect.height, + text, self.baseColor, self.shadowColor) end def refresh @item_max = itemCount - dwidth = self.width-self.borderX - dheight = self.height-self.borderY - self.contents = pbDoEnsureBitmap(self.contents,dwidth,dheight) + dwidth = self.width - self.borderX + dheight = self.height - self.borderY + self.contents = pbDoEnsureBitmap(self.contents, dwidth, dheight) self.contents.clear for i in 0...@item_max - next if iself.top_item+self.page_item_max - drawItem(i,@item_max,itemRect(i)) + next if i < self.top_item || i > self.top_item + self.page_item_max + drawItem(i, @item_max, itemRect(i)) end - drawCursor(self.index,itemRect(self.index)) + drawCursor(self.index, itemRect(self.index)) end def update @@ -120,7 +120,7 @@ class PokedexSearchSelectionSprite < SpriteWrapper @xgap = 124 @ygap = 44 @cols = 4 - when 3,4 # Height, weight + when 3, 4 # Height, weight @xstart = 44 @ystart = 110 @xgap = 8 @@ -142,18 +142,18 @@ class PokedexSearchSelectionSprite < SpriteWrapper def refresh # Size and position cursor - if @mode==-1 # Main search screen + if @mode == -1 # Main search screen case @index when 0 # Order self.src_rect.y = 0 self.src_rect.height = 44 - when 1,5 # Name, color + when 1, 5 # Name, color self.src_rect.y = 44 self.src_rect.height = 44 when 2 # Type self.src_rect.y = 88 self.src_rect.height = 44 - when 3,4 # Height, weight + when 3, 4 # Height, weight self.src_rect.y = 132 self.src_rect.height = 44 when 6 # Shape @@ -167,7 +167,7 @@ class PokedexSearchSelectionSprite < SpriteWrapper when 0 # Order self.x = 252 self.y = 52 - when 1,2,3,4 # Name, type, height, weight + when 1, 2, 3, 4 # Name, type, height, weight self.x = 114 self.y = 110 + (@index - 1) * 52 when 5 # Color @@ -176,13 +176,13 @@ class PokedexSearchSelectionSprite < SpriteWrapper when 6 # Shape self.x = 420 self.y = 214 - when 7,8,9 # Reset, start, cancel + when 7, 8, 9 # Reset, start, cancel self.x = 4 + (@index - 7) * 176 self.y = 334 end else # Parameter screen case @index - when -2,-3 # OK, Cancel + when -2, -3 # OK, Cancel self.src_rect.y = 244 self.src_rect.height = 40 else @@ -193,10 +193,10 @@ class PokedexSearchSelectionSprite < SpriteWrapper when 1 # Name self.src_rect.y = 284 self.src_rect.height = 44 - when 2,5 # Type, color + when 2, 5 # Type, color self.src_rect.y = 44 self.src_rect.height = 44 - when 3,4 # Height, weight + when 3, 4 # Height, weight self.src_rect.y = (@minmax == 1) ? 328 : 424 self.src_rect.height = 96 when 6 # Shape @@ -206,12 +206,12 @@ class PokedexSearchSelectionSprite < SpriteWrapper end case @index when -1 # Blank option - if @mode==3 || @mode==4 # Height/weight range - self.x = @xstart+(@cmds+1)*@xgap*(@minmax%2) - self.y = @ystart+@ygap*((@minmax+1)%2) + if @mode == 3 || @mode == 4 # Height/weight range + self.x = @xstart + (@cmds + 1) * @xgap * (@minmax % 2) + self.y = @ystart + @ygap * ((@minmax + 1) % 2) else - self.x = @xstart+(@cols-1)*@xgap - self.y = @ystart+(@cmds/@cols).floor*@ygap + self.x = @xstart + (@cols - 1) * @xgap + self.y = @ystart + (@cmds / @cols).floor * @ygap end when -2 # OK self.x = 4 @@ -221,21 +221,21 @@ class PokedexSearchSelectionSprite < SpriteWrapper self.y = 334 else case @mode - when 0,1,2,5,6 # Order, name, type, color, shape - if @index>=@cmds - self.x = @xstart+(@cols-1)*@xgap - self.y = @ystart+(@cmds/@cols).floor*@ygap + when 0, 1, 2, 5, 6 # Order, name, type, color, shape + if @index >= @cmds + self.x = @xstart + (@cols - 1) * @xgap + self.y = @ystart + (@cmds / @cols).floor * @ygap else - self.x = @xstart+(@index%@cols)*@xgap - self.y = @ystart+(@index/@cols).floor*@ygap + self.x = @xstart + (@index % @cols) * @xgap + self.y = @ystart + (@index / @cols).floor * @ygap end - when 3,4 # Height, weight - if @index>=@cmds - self.x = @xstart+(@cmds+1)*@xgap*((@minmax+1)%2) + when 3, 4 # Height, weight + if @index >= @cmds + self.x = @xstart + (@cmds + 1) * @xgap * ((@minmax + 1) % 2) else - self.x = @xstart+(@index+1)*@xgap + self.x = @xstart + (@index + 1) * @xgap end - self.y = @ystart+@ygap*((@minmax+1)%2) + self.y = @ystart + @ygap * ((@minmax + 1) % 2) end end end @@ -265,9 +265,9 @@ class PokemonPokedex_Scene @selbitmap = AnimatedBitmap.new("Graphics/Pictures/Pokedex/icon_searchsel") @searchsliderbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Pokedex/icon_searchslider")) @sprites = {} - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 - addBackgroundPlane(@sprites,"background","Pokedex/bg_list",@viewport) + addBackgroundPlane(@sprites, "background", "Pokedex/bg_list", @viewport) =begin # Suggestion for changing the background depending on region. You can change # the line above with the following: @@ -277,19 +277,19 @@ class PokemonPokedex_Scene addBackgroundPlane(@sprites,"background","Pokedex/bg_regional",@viewport) end =end - addBackgroundPlane(@sprites,"searchbg","Pokedex/bg_search",@viewport) + addBackgroundPlane(@sprites, "searchbg", "Pokedex/bg_search", @viewport) @sprites["searchbg"].visible = false - @sprites["pokedex"] = Window_Pokedex.new(206,30,276,364,@viewport) + @sprites["pokedex"] = Window_Pokedex.new(206, 30, 276, 364, @viewport) @sprites["icon"] = PokemonSprite.new(@viewport) @sprites["icon"].setOffset(PictureOrigin::Center) @sprites["icon"].x = 112 @sprites["icon"].y = 196 - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) @sprites["searchcursor"] = PokedexSearchSelectionSprite.new(@viewport) @sprites["searchcursor"].visible = false @searchResults = false - @searchParams = [$PokemonGlobal.pokedexMode,-1,-1,-1,-1,-1,-1,-1,-1,-1] + @searchParams = [$PokemonGlobal.pokedexMode, -1, -1, -1, -1, -1, -1, -1, -1, -1] pbRefreshDexList($PokemonGlobal.pokedexIndex[pbGetSavePositionIndex]) pbDeactivateWindows(@sprites) pbFadeInAndShow(@sprites) @@ -327,7 +327,7 @@ class PokemonPokedex_Scene # National Dex at the end. def pbGetSavePositionIndex index = pbGetPokedexRegion - if index==-1 # National Dex (comes after regional Dex indices) + if index == -1 # National Dex (comes after regional Dex indices) index = $player.pokedex.dexes_count - 1 end return index @@ -376,7 +376,7 @@ class PokemonPokedex_Scene # Hide the Dex number 0 species if unseen dexlist[0] = nil if dexlist[0][5] && !$player.seen?(dexlist[0][0]) # Remove unseen species from the end of the list - i = dexlist.length-1 + i = dexlist.length - 1 loop do break if i < 0 || !dexlist[i] || $player.seen?(dexlist[i][0]) dexlist[i] = nil @@ -384,17 +384,17 @@ class PokemonPokedex_Scene end dexlist.compact! # Sort species in ascending order by Regional Dex number - dexlist.sort! { |a,b| a[4]<=>b[4] } + dexlist.sort! { |a, b| a[4] <=> b[4] } when MODEATOZ - dexlist.sort! { |a,b| (a[1]==b[1]) ? a[4]<=>b[4] : a[1]<=>b[1] } + dexlist.sort! { |a, b| (a[1] == b[1]) ? a[4] <=> b[4] : a[1] <=> b[1] } when MODEHEAVIEST - dexlist.sort! { |a,b| (a[3]==b[3]) ? a[4]<=>b[4] : b[3]<=>a[3] } + dexlist.sort! { |a, b| (a[3] == b[3]) ? a[4] <=> b[4] : b[3] <=> a[3] } when MODELIGHTEST - dexlist.sort! { |a,b| (a[3]==b[3]) ? a[4]<=>b[4] : a[3]<=>b[3] } + dexlist.sort! { |a, b| (a[3] == b[3]) ? a[4] <=> b[4] : a[3] <=> b[3] } when MODETALLEST - dexlist.sort! { |a,b| (a[2]==b[2]) ? a[4]<=>b[4] : b[2]<=>a[2] } + dexlist.sort! { |a, b| (a[2] == b[2]) ? a[4] <=> b[4] : b[2] <=> a[2] } when MODESMALLEST - dexlist.sort! { |a,b| (a[2]==b[2]) ? a[4]<=>b[4] : a[2]<=>b[2] } + dexlist.sort! { |a, b| (a[2] == b[2]) ? a[4] <=> b[4] : a[2] <=> b[2] } end @dexlist = dexlist @sprites["pokedex"].commands = @dexlist @@ -411,127 +411,127 @@ class PokemonPokedex_Scene def pbRefresh overlay = @sprites["overlay"].bitmap overlay.clear - base = Color.new(88,88,80) - shadow = Color.new(168,184,184) + base = Color.new(88, 88, 80) + shadow = Color.new(168, 184, 184) iconspecies = @sprites["pokedex"].species iconspecies = nil if !$player.seen?(iconspecies) # Write various bits of text dexname = _INTL("Pokédex") if $player.pokedex.dexes_count > 1 thisdex = Settings.pokedex_names[pbGetSavePositionIndex] - if thisdex!=nil + if thisdex != nil dexname = (thisdex.is_a?(Array)) ? thisdex[0] : thisdex end end textpos = [ - [dexname,Graphics.width/2,-2,2,Color.new(248,248,248),Color.new(0,0,0)] + [dexname, Graphics.width / 2, -2, 2, Color.new(248, 248, 248), Color.new(0, 0, 0)] ] - textpos.push([GameData::Species.get(iconspecies).name,112,46,2,base,shadow]) if iconspecies + textpos.push([GameData::Species.get(iconspecies).name, 112, 46, 2, base, shadow]) if iconspecies if @searchResults - textpos.push([_INTL("Search results"),112,302,2,base,shadow]) - textpos.push([@dexlist.length.to_s,112,334,2,base,shadow]) + textpos.push([_INTL("Search results"), 112, 302, 2, base, shadow]) + textpos.push([@dexlist.length.to_s, 112, 334, 2, base, shadow]) else - textpos.push([_INTL("Seen:"),42,302,0,base,shadow]) - textpos.push([$player.pokedex.seen_count(pbGetPokedexRegion).to_s,182,302,1,base,shadow]) - textpos.push([_INTL("Owned:"),42,334,0,base,shadow]) - textpos.push([$player.pokedex.owned_count(pbGetPokedexRegion).to_s,182,334,1,base,shadow]) + textpos.push([_INTL("Seen:"), 42, 302, 0, base, shadow]) + textpos.push([$player.pokedex.seen_count(pbGetPokedexRegion).to_s, 182, 302, 1, base, shadow]) + textpos.push([_INTL("Owned:"), 42, 334, 0, base, shadow]) + textpos.push([$player.pokedex.owned_count(pbGetPokedexRegion).to_s, 182, 334, 1, base, shadow]) end # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) # Set Pokémon sprite setIconBitmap(iconspecies) # Draw slider arrows itemlist = @sprites["pokedex"] showslider = false - if itemlist.top_row>0 - overlay.blt(468,48,@sliderbitmap.bitmap,Rect.new(0,0,40,30)) + if itemlist.top_row > 0 + overlay.blt(468, 48, @sliderbitmap.bitmap, Rect.new(0, 0, 40, 30)) showslider = true end - if itemlist.top_item+itemlist.page_item_max=0 + if params[2] >= 0 type_number = @typeCommands[params[2]].icon_position - typerect = Rect.new(0,type_number*32,96,32) - overlay.blt(128,168,@typebitmap.bitmap,typerect) + typerect = Rect.new(0, type_number * 32, 96, 32) + overlay.blt(128, 168, @typebitmap.bitmap, typerect) else - textpos.push(["----",176,168,2,base,shadow,1]) + textpos.push(["----", 176, 168, 2, base, shadow, 1]) end - if params[3]>=0 + if params[3] >= 0 type_number = @typeCommands[params[3]].icon_position - typerect = Rect.new(0,type_number*32,96,32) - overlay.blt(256,168,@typebitmap.bitmap,typerect) + typerect = Rect.new(0, type_number * 32, 96, 32) + overlay.blt(256, 168, @typebitmap.bitmap, typerect) else - textpos.push(["----",304,168,2,base,shadow,1]) + textpos.push(["----", 304, 168, 2, base, shadow, 1]) end # Write height and weight limits - ht1 = (params[4]<0) ? 0 : (params[4]>=@heightCommands.length) ? 999 : @heightCommands[params[4]] - ht2 = (params[5]<0) ? 999 : (params[5]>=@heightCommands.length) ? 0 : @heightCommands[params[5]] - wt1 = (params[6]<0) ? 0 : (params[6]>=@weightCommands.length) ? 9999 : @weightCommands[params[6]] - wt2 = (params[7]<0) ? 9999 : (params[7]>=@weightCommands.length) ? 0 : @weightCommands[params[7]] + ht1 = (params[4] < 0) ? 0 : (params[4] >= @heightCommands.length) ? 999 : @heightCommands[params[4]] + ht2 = (params[5] < 0) ? 999 : (params[5] >= @heightCommands.length) ? 0 : @heightCommands[params[5]] + wt1 = (params[6] < 0) ? 0 : (params[6] >= @weightCommands.length) ? 9999 : @weightCommands[params[6]] + wt2 = (params[7] < 0) ? 9999 : (params[7] >= @weightCommands.length) ? 0 : @weightCommands[params[7]] hwoffset = false - if System.user_language[3..4]=="US" # If the user is in the United States - ht1 = (params[4]>=@heightCommands.length) ? 99*12 : (ht1/0.254).round - ht2 = (params[5]<0) ? 99*12 : (ht2/0.254).round - wt1 = (params[6]>=@weightCommands.length) ? 99990 : (wt1/0.254).round - wt2 = (params[7]<0) ? 99990 : (wt2/0.254).round - textpos.push([sprintf("%d'%02d''",ht1/12,ht1%12),166,220,2,base,shadow,1]) - textpos.push([sprintf("%d'%02d''",ht2/12,ht2%12),294,220,2,base,shadow,1]) - textpos.push([sprintf("%.1f",wt1/10.0),166,272,2,base,shadow,1]) - textpos.push([sprintf("%.1f",wt2/10.0),294,272,2,base,shadow,1]) + if System.user_language[3..4] == "US" # If the user is in the United States + ht1 = (params[4] >= @heightCommands.length) ? 99 * 12 : (ht1 / 0.254).round + ht2 = (params[5] < 0) ? 99 * 12 : (ht2 / 0.254).round + wt1 = (params[6] >= @weightCommands.length) ? 99990 : (wt1 / 0.254).round + wt2 = (params[7] < 0) ? 99990 : (wt2 / 0.254).round + textpos.push([sprintf("%d'%02d''", ht1 / 12, ht1 % 12), 166, 220, 2, base, shadow, 1]) + textpos.push([sprintf("%d'%02d''", ht2 / 12, ht2 % 12), 294, 220, 2, base, shadow, 1]) + textpos.push([sprintf("%.1f", wt1 / 10.0), 166, 272, 2, base, shadow, 1]) + textpos.push([sprintf("%.1f", wt2 / 10.0), 294, 272, 2, base, shadow, 1]) hwoffset = true else - textpos.push([sprintf("%.1f",ht1/10.0),166,220,2,base,shadow,1]) - textpos.push([sprintf("%.1f",ht2/10.0),294,220,2,base,shadow,1]) - textpos.push([sprintf("%.1f",wt1/10.0),166,272,2,base,shadow,1]) - textpos.push([sprintf("%.1f",wt2/10.0),294,272,2,base,shadow,1]) + textpos.push([sprintf("%.1f", ht1 / 10.0), 166, 220, 2, base, shadow, 1]) + textpos.push([sprintf("%.1f", ht2 / 10.0), 294, 220, 2, base, shadow, 1]) + textpos.push([sprintf("%.1f", wt1 / 10.0), 166, 272, 2, base, shadow, 1]) + textpos.push([sprintf("%.1f", wt2 / 10.0), 294, 272, 2, base, shadow, 1]) end - overlay.blt(344,214,@hwbitmap.bitmap,Rect.new(0,(hwoffset) ? 44 : 0,32,44)) - overlay.blt(344,266,@hwbitmap.bitmap,Rect.new(32,(hwoffset) ? 44 : 0,32,44)) + overlay.blt(344, 214, @hwbitmap.bitmap, Rect.new(0, (hwoffset) ? 44 : 0, 32, 44)) + overlay.blt(344, 266, @hwbitmap.bitmap, Rect.new(32, (hwoffset) ? 44 : 0, 32, 44)) # Draw shape icon if params[9] >= 0 shape_number = @shapeCommands[params[9]].icon_position @@ -539,23 +539,23 @@ class PokemonPokedex_Scene overlay.blt(424, 218, @shapebitmap.bitmap, shaperect) end # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) end - def pbRefreshDexSearchParam(mode,cmds,sel,_index) + def pbRefreshDexSearchParam(mode, cmds, sel, _index) overlay = @sprites["overlay"].bitmap overlay.clear - base = Color.new(248,248,248) - shadow = Color.new(72,72,72) + base = Color.new(248, 248, 248) + shadow = Color.new(72, 72, 72) # Write various bits of text textpos = [ - [_INTL("Search Mode"),Graphics.width/2,-2,2,base,shadow], - [_INTL("OK"),80,338,2,base,shadow,1], - [_INTL("Cancel"),Graphics.width-80,338,2,base,shadow,1] + [_INTL("Search Mode"), Graphics.width / 2, -2, 2, base, shadow], + [_INTL("OK"), 80, 338, 2, base, shadow, 1], + [_INTL("Cancel"), Graphics.width - 80, 338, 2, base, shadow, 1] ] - title = [_INTL("Order"),_INTL("Name"),_INTL("Type"),_INTL("Height"), - _INTL("Weight"),_INTL("Color"),_INTL("Shape")][mode] - textpos.push([title,102,(mode==6) ? 58 : 52,0,base,shadow]) + title = [_INTL("Order"), _INTL("Name"), _INTL("Type"), _INTL("Height"), + _INTL("Weight"), _INTL("Color"), _INTL("Shape")][mode] + textpos.push([title, 102, (mode == 6) ? 58 : 52, 0, base, shadow]) case mode when 0 # Order xstart = 46 @@ -584,7 +584,7 @@ class PokemonPokedex_Scene cols = 4 selbuttony = 44 selbuttonheight = 44 - when 3,4 # Height, weight + when 3, 4 # Height, weight xstart = 44 ystart = 110 xgap = 304 / (cmds.length + 1) @@ -614,53 +614,53 @@ class PokemonPokedex_Scene case mode when 2 # Type icons for i in 0...2 - if !sel[i] || sel[i]<0 - textpos.push(["----",298+128*i,58,2,base,shadow,1]) + if !sel[i] || sel[i] < 0 + textpos.push(["----", 298 + 128 * i, 58, 2, base, shadow, 1]) else type_number = @typeCommands[sel[i]].icon_position - typerect = Rect.new(0,type_number*32,96,32) - overlay.blt(250+128*i,58,@typebitmap.bitmap,typerect) + typerect = Rect.new(0, type_number * 32, 96, 32) + overlay.blt(250 + 128 * i, 58, @typebitmap.bitmap, typerect) end end when 3 # Height range - ht1 = (sel[0]<0) ? 0 : (sel[0]>=@heightCommands.length) ? 999 : @heightCommands[sel[0]] - ht2 = (sel[1]<0) ? 999 : (sel[1]>=@heightCommands.length) ? 0 : @heightCommands[sel[1]] + ht1 = (sel[0] < 0) ? 0 : (sel[0] >= @heightCommands.length) ? 999 : @heightCommands[sel[0]] + ht2 = (sel[1] < 0) ? 999 : (sel[1] >= @heightCommands.length) ? 0 : @heightCommands[sel[1]] hwoffset = false - if System.user_language[3..4]=="US" # If the user is in the United States - ht1 = (sel[0]>=@heightCommands.length) ? 99*12 : (ht1/0.254).round - ht2 = (sel[1]<0) ? 99*12 : (ht2/0.254).round - txt1 = sprintf("%d'%02d''",ht1/12,ht1%12) - txt2 = sprintf("%d'%02d''",ht2/12,ht2%12) + if System.user_language[3..4] == "US" # If the user is in the United States + ht1 = (sel[0] >= @heightCommands.length) ? 99 * 12 : (ht1 / 0.254).round + ht2 = (sel[1] < 0) ? 99 * 12 : (ht2 / 0.254).round + txt1 = sprintf("%d'%02d''", ht1 / 12, ht1 % 12) + txt2 = sprintf("%d'%02d''", ht2 / 12, ht2 % 12) hwoffset = true else - txt1 = sprintf("%.1f",ht1/10.0) - txt2 = sprintf("%.1f",ht2/10.0) + txt1 = sprintf("%.1f", ht1 / 10.0) + txt2 = sprintf("%.1f", ht2 / 10.0) end - textpos.push([txt1,286,58,2,base,shadow,1]) - textpos.push([txt2,414,58,2,base,shadow,1]) - overlay.blt(462,52,@hwbitmap.bitmap,Rect.new(0,(hwoffset) ? 44 : 0,32,44)) + textpos.push([txt1, 286, 58, 2, base, shadow, 1]) + textpos.push([txt2, 414, 58, 2, base, shadow, 1]) + overlay.blt(462, 52, @hwbitmap.bitmap, Rect.new(0, (hwoffset) ? 44 : 0, 32, 44)) when 4 # Weight range - wt1 = (sel[0]<0) ? 0 : (sel[0]>=@weightCommands.length) ? 9999 : @weightCommands[sel[0]] - wt2 = (sel[1]<0) ? 9999 : (sel[1]>=@weightCommands.length) ? 0 : @weightCommands[sel[1]] + wt1 = (sel[0] < 0) ? 0 : (sel[0] >= @weightCommands.length) ? 9999 : @weightCommands[sel[0]] + wt2 = (sel[1] < 0) ? 9999 : (sel[1] >= @weightCommands.length) ? 0 : @weightCommands[sel[1]] hwoffset = false - if System.user_language[3..4]=="US" # If the user is in the United States - wt1 = (sel[0]>=@weightCommands.length) ? 99990 : (wt1/0.254).round - wt2 = (sel[1]<0) ? 99990 : (wt2/0.254).round - txt1 = sprintf("%.1f",wt1/10.0) - txt2 = sprintf("%.1f",wt2/10.0) + if System.user_language[3..4] == "US" # If the user is in the United States + wt1 = (sel[0] >= @weightCommands.length) ? 99990 : (wt1 / 0.254).round + wt2 = (sel[1] < 0) ? 99990 : (wt2 / 0.254).round + txt1 = sprintf("%.1f", wt1 / 10.0) + txt2 = sprintf("%.1f", wt2 / 10.0) hwoffset = true else - txt1 = sprintf("%.1f",wt1/10.0) - txt2 = sprintf("%.1f",wt2/10.0) + txt1 = sprintf("%.1f", wt1 / 10.0) + txt2 = sprintf("%.1f", wt2 / 10.0) end - textpos.push([txt1,286,58,2,base,shadow,1]) - textpos.push([txt2,414,58,2,base,shadow,1]) - overlay.blt(462,52,@hwbitmap.bitmap,Rect.new(32,(hwoffset) ? 44 : 0,32,44)) + textpos.push([txt1, 286, 58, 2, base, shadow, 1]) + textpos.push([txt2, 414, 58, 2, base, shadow, 1]) + overlay.blt(462, 52, @hwbitmap.bitmap, Rect.new(32, (hwoffset) ? 44 : 0, 32, 44)) when 5 # Color - if sel[0]<0 - textpos.push(["----",362,58,2,base,shadow,1]) + if sel[0] < 0 + textpos.push(["----", 362, 58, 2, base, shadow, 1]) else - textpos.push([cmds[sel[0]].name,362,58,2,base,shadow,1]) + textpos.push([cmds[sel[0]].name, 362, 58, 2, base, shadow, 1]) end when 6 # Shape icon if sel[0] >= 0 @@ -668,71 +668,71 @@ class PokemonPokedex_Scene overlay.blt(332, 50, @shapebitmap.bitmap, shaperect) end else - if sel[0]<0 - text = ["----","-","----","","","----",""][mode] - textpos.push([text,362,58,2,base,shadow,1]) + if sel[0] < 0 + text = ["----", "-", "----", "", "", "----", ""][mode] + textpos.push([text, 362, 58, 2, base, shadow, 1]) else - textpos.push([cmds[sel[0]],362,58,2,base,shadow,1]) + textpos.push([cmds[sel[0]], 362, 58, 2, base, shadow, 1]) end end # Draw selected option(s) button graphic - if mode==3 || mode==4 # Height, weight - xpos1 = xstart+(sel[0]+1)*xgap - xpos1 = xstart if sel[0]<-1 - xpos2 = xstart+(sel[1]+1)*xgap - xpos2 = xstart+cols*xgap if sel[1]<0 - xpos2 = xstart if sel[1]>=cols-1 - ypos1 = ystart+172 - ypos2 = ystart+28 - overlay.blt(16,120,@searchsliderbitmap.bitmap,Rect.new(0,192,32,44)) if sel[1]=0 - overlay.blt(16,264,@searchsliderbitmap.bitmap,Rect.new(0,192,32,44)) if sel[0]>=0 - overlay.blt(464,264,@searchsliderbitmap.bitmap,Rect.new(32,192,32,44)) if sel[0]= cols - 1 + ypos1 = ystart + 172 + ypos2 = ystart + 28 + overlay.blt(16, 120, @searchsliderbitmap.bitmap, Rect.new(0, 192, 32, 44)) if sel[1] < cols - 1 + overlay.blt(464, 120, @searchsliderbitmap.bitmap, Rect.new(32, 192, 32, 44)) if sel[1] >= 0 + overlay.blt(16, 264, @searchsliderbitmap.bitmap, Rect.new(0, 192, 32, 44)) if sel[0] >= 0 + overlay.blt(464, 264, @searchsliderbitmap.bitmap, Rect.new(32, 192, 32, 44)) if sel[0] < cols - 1 + hwrect = Rect.new(0, 0, 120, 96) + overlay.blt(xpos2, ystart, @searchsliderbitmap.bitmap, hwrect) hwrect.y = 96 - overlay.blt(xpos1,ystart+ygap,@searchsliderbitmap.bitmap,hwrect) - textpos.push([txt1,xpos1+halfwidth,ypos1,2,base,nil,1]) - textpos.push([txt2,xpos2+halfwidth,ypos2,2,base,nil,1]) + overlay.blt(xpos1, ystart + ygap, @searchsliderbitmap.bitmap, hwrect) + textpos.push([txt1, xpos1 + halfwidth, ypos1, 2, base, nil, 1]) + textpos.push([txt2, xpos2 + halfwidth, ypos2, 2, base, nil, 1]) else for i in 0...sel.length - if sel[i]>=0 - selrect = Rect.new(0,selbuttony,@selbitmap.bitmap.width,selbuttonheight) - overlay.blt(xstart+(sel[i]%cols)*xgap,ystart+(sel[i]/cols).floor*ygap,@selbitmap.bitmap,selrect) + if sel[i] >= 0 + selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight) + overlay.blt(xstart + (sel[i] % cols) * xgap, ystart + (sel[i] / cols).floor * ygap, @selbitmap.bitmap, selrect) else - selrect = Rect.new(0,selbuttony,@selbitmap.bitmap.width,selbuttonheight) - overlay.blt(xstart+(cols-1)*xgap,ystart+(cmds.length/cols).floor*ygap,@selbitmap.bitmap,selrect) + selrect = Rect.new(0, selbuttony, @selbitmap.bitmap.width, selbuttonheight) + overlay.blt(xstart + (cols - 1) * xgap, ystart + (cmds.length / cols).floor * ygap, @selbitmap.bitmap, selrect) end end end # Draw options case mode - when 0,1 # Order, name + when 0, 1 # Order, name for i in 0...cmds.length - x = xstart+halfwidth+(i%cols)*xgap - y = ystart+6+(i/cols).floor*ygap - textpos.push([cmds[i],x,y,2,base,shadow,1]) + x = xstart + halfwidth + (i % cols) * xgap + y = ystart + 6 + (i / cols).floor * ygap + textpos.push([cmds[i], x, y, 2, base, shadow, 1]) end - if mode!=0 - textpos.push([(mode==1) ? "-" : "----", - xstart+halfwidth+(cols-1)*xgap,ystart+6+(cmds.length/cols).floor*ygap,2,base,shadow,1]) + if mode != 0 + textpos.push([(mode == 1) ? "-" : "----", + xstart + halfwidth + (cols - 1) * xgap, ystart + 6 + (cmds.length / cols).floor * ygap, 2, base, shadow, 1]) end when 2 # Type - typerect = Rect.new(0,0,96,32) + typerect = Rect.new(0, 0, 96, 32) for i in 0...cmds.length - typerect.y = @typeCommands[i].icon_position*32 - overlay.blt(xstart+14+(i%cols)*xgap,ystart+6+(i/cols).floor*ygap,@typebitmap.bitmap,typerect) + typerect.y = @typeCommands[i].icon_position * 32 + overlay.blt(xstart + 14 + (i % cols) * xgap, ystart + 6 + (i / cols).floor * ygap, @typebitmap.bitmap, typerect) end textpos.push(["----", - xstart+halfwidth+(cols-1)*xgap,ystart+6+(cmds.length/cols).floor*ygap,2,base,shadow,1]) + xstart + halfwidth + (cols - 1) * xgap, ystart + 6 + (cmds.length / cols).floor * ygap, 2, base, shadow, 1]) when 5 # Color for i in 0...cmds.length - x = xstart+halfwidth+(i%cols)*xgap - y = ystart+6+(i/cols).floor*ygap - textpos.push([cmds[i].name,x,y,2,base,shadow,1]) + x = xstart + halfwidth + (i % cols) * xgap + y = ystart + 6 + (i / cols).floor * ygap + textpos.push([cmds[i].name, x, y, 2, base, shadow, 1]) end textpos.push(["----", - xstart+halfwidth+(cols-1)*xgap,ystart+6+(cmds.length/cols).floor*ygap,2,base,shadow,1]) + xstart + halfwidth + (cols - 1) * xgap, ystart + 6 + (cmds.length / cols).floor * ygap, 2, base, shadow, 1]) when 6 # Shape shaperect = Rect.new(0, 0, 60, 60) for i in 0...cmds.length @@ -741,7 +741,7 @@ class PokemonPokedex_Scene end end # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) end def setIconBitmap(species) @@ -753,58 +753,58 @@ class PokemonPokedex_Scene $PokemonGlobal.pokedexMode = params[0] dexlist = pbGetDexList # Filter by name - if params[1]>=0 + if params[1] >= 0 scanNameCommand = @nameCommands[params[1]].scan(/./) dexlist = dexlist.find_all { |item| next false if !$player.seen?(item[0]) - firstChar = item[1][0,1] - next scanNameCommand.any? { |v| v==firstChar } + firstChar = item[1][0, 1] + next scanNameCommand.any? { |v| v == firstChar } } end # Filter by type - if params[2]>=0 || params[3]>=0 - stype1 = (params[2]>=0) ? @typeCommands[params[2]].id : nil - stype2 = (params[3]>=0) ? @typeCommands[params[3]].id : nil + if params[2] >= 0 || params[3] >= 0 + stype1 = (params[2] >= 0) ? @typeCommands[params[2]].id : nil + stype2 = (params[3] >= 0) ? @typeCommands[params[3]].id : nil dexlist = dexlist.find_all { |item| next false if !$player.owned?(item[0]) type1 = item[6] type2 = item[7] if stype1 && stype2 # Find species that match both types - next (type1==stype1 && type2==stype2) || (type1==stype2 && type2==stype1) + next (type1 == stype1 && type2 == stype2) || (type1 == stype2 && type2 == stype1) elsif stype1 # Find species that match first type entered - next type1==stype1 || type2==stype1 + next type1 == stype1 || type2 == stype1 elsif stype2 # Find species that match second type entered - next type1==stype2 || type2==stype2 + next type1 == stype2 || type2 == stype2 else next false end } end # Filter by height range - if params[4]>=0 || params[5]>=0 - minh = (params[4]<0) ? 0 : (params[4]>=@heightCommands.length) ? 999 : @heightCommands[params[4]] - maxh = (params[5]<0) ? 999 : (params[5]>=@heightCommands.length) ? 0 : @heightCommands[params[5]] + if params[4] >= 0 || params[5] >= 0 + minh = (params[4] < 0) ? 0 : (params[4] >= @heightCommands.length) ? 999 : @heightCommands[params[4]] + maxh = (params[5] < 0) ? 999 : (params[5] >= @heightCommands.length) ? 0 : @heightCommands[params[5]] dexlist = dexlist.find_all { |item| next false if !$player.owned?(item[0]) height = item[2] - next height>=minh && height<=maxh + next height >= minh && height <= maxh } end # Filter by weight range - if params[6]>=0 || params[7]>=0 - minw = (params[6]<0) ? 0 : (params[6]>=@weightCommands.length) ? 9999 : @weightCommands[params[6]] - maxw = (params[7]<0) ? 9999 : (params[7]>=@weightCommands.length) ? 0 : @weightCommands[params[7]] + if params[6] >= 0 || params[7] >= 0 + minw = (params[6] < 0) ? 0 : (params[6] >= @weightCommands.length) ? 9999 : @weightCommands[params[6]] + maxw = (params[7] < 0) ? 9999 : (params[7] >= @weightCommands.length) ? 0 : @weightCommands[params[7]] dexlist = dexlist.find_all { |item| next false if !$player.owned?(item[0]) weight = item[3] - next weight>=minw && weight<=maxw + next weight >= minw && weight <= maxw } end # Filter by color - if params[8]>=0 + if params[8] >= 0 scolor = @colorCommands[params[8]].id dexlist = dexlist.find_all { |item| next false if !$player.seen?(item[0]) @@ -812,7 +812,7 @@ class PokemonPokedex_Scene } end # Filter by shape - if params[9]>=0 + if params[9] >= 0 sshape = @shapeCommands[params[9]].id dexlist = dexlist.find_all { |item| next false if !$player.seen?(item[0]) @@ -822,12 +822,12 @@ class PokemonPokedex_Scene # Remove all unseen species from the results dexlist = dexlist.find_all { |item| next $player.seen?(item[0]) } case $PokemonGlobal.pokedexMode - when MODENUMERICAL then dexlist.sort! { |a,b| a[4]<=>b[4] } - when MODEATOZ then dexlist.sort! { |a,b| a[1]<=>b[1] } - when MODEHEAVIEST then dexlist.sort! { |a,b| b[3]<=>a[3] } - when MODELIGHTEST then dexlist.sort! { |a,b| a[3]<=>b[3] } - when MODETALLEST then dexlist.sort! { |a,b| b[2]<=>a[2] } - when MODESMALLEST then dexlist.sort! { |a,b| a[2]<=>b[2] } + when MODENUMERICAL then dexlist.sort! { |a, b| a[4] <=> b[4] } + when MODEATOZ then dexlist.sort! { |a, b| a[1] <=> b[1] } + when MODEHEAVIEST then dexlist.sort! { |a, b| b[3] <=> a[3] } + when MODELIGHTEST then dexlist.sort! { |a, b| a[3] <=> b[3] } + when MODETALLEST then dexlist.sort! { |a, b| b[2] <=> a[2] } + when MODESMALLEST then dexlist.sort! { |a, b| a[2] <=> b[2] } end return dexlist end @@ -837,16 +837,16 @@ class PokemonPokedex_Scene oldspecies = @sprites["pokedex"].species @searchResults = false $PokemonGlobal.pokedexMode = MODENUMERICAL - @searchParams = [$PokemonGlobal.pokedexMode,-1,-1,-1,-1,-1,-1,-1,-1,-1] + @searchParams = [$PokemonGlobal.pokedexMode, -1, -1, -1, -1, -1, -1, -1, -1, -1] pbRefreshDexList($PokemonGlobal.pokedexIndex[pbGetSavePositionIndex]) for i in 0...@dexlist.length - next if @dexlist[i][0]!=oldspecies + next if @dexlist[i][0] != oldspecies @sprites["pokedex"].index = i pbRefresh break end $PokemonGlobal.pokedexIndex[pbGetSavePositionIndex] = @sprites["pokedex"].index - pbFadeInAndShow(@sprites,oldsprites) + pbFadeInAndShow(@sprites, oldsprites) end def pbDexEntry(index) @@ -860,13 +860,13 @@ class PokemonPokedex_Scene end scene = PokemonPokedexInfo_Scene.new screen = PokemonPokedexInfoScreen.new(scene) - ret = screen.pbStartScreen(@dexlist,index,region) + ret = screen.pbStartScreen(@dexlist, index, region) if @searchResults dexlist = pbSearchDexList(@searchParams) @dexlist = dexlist @sprites["pokedex"].commands = @dexlist - ret = @dexlist.length-1 if ret>=@dexlist.length - ret = 0 if ret<0 + ret = @dexlist.length - 1 if ret >= @dexlist.length + ret = 0 if ret < 0 else pbRefreshDexList($PokemonGlobal.pokedexIndex[pbGetSavePositionIndex]) $PokemonGlobal.pokedexIndex[pbGetSavePositionIndex] = ret @@ -874,13 +874,13 @@ class PokemonPokedex_Scene @sprites["pokedex"].index = ret @sprites["pokedex"].refresh pbRefresh - pbFadeInAndShow(@sprites,oldsprites) + pbFadeInAndShow(@sprites, oldsprites) end - def pbDexSearchCommands(mode,selitems,mainindex) - cmds = [@orderCommands,@nameCommands,@typeCommands,@heightCommands, - @weightCommands,@colorCommands,@shapeCommands][mode] - cols = [2,7,4,1,1,3,5][mode] + def pbDexSearchCommands(mode, selitems, mainindex) + cmds = [@orderCommands, @nameCommands, @typeCommands, @heightCommands, + @weightCommands, @colorCommands, @shapeCommands][mode] + cols = [2, 7, 4, 1, 1, 3, 5][mode] ret = nil # Set background case mode @@ -903,18 +903,18 @@ class PokemonPokedex_Scene oldindex = index minmax = 1 oldminmax = minmax - if mode==3 || mode==4 + if mode == 3 || mode == 4 index = oldindex = selindex[minmax] end @sprites["searchcursor"].mode = mode @sprites["searchcursor"].cmds = cmds.length @sprites["searchcursor"].minmax = minmax @sprites["searchcursor"].index = index - nextparam = cmds.length%2 - pbRefreshDexSearchParam(mode,cmds,selindex,index) + nextparam = cmds.length % 2 + pbRefreshDexSearchParam(mode, cmds, selindex, index) loop do pbUpdate - if index!=oldindex || minmax!=oldminmax + if index != oldindex || minmax != oldminmax @sprites["searchcursor"].minmax = minmax @sprites["searchcursor"].index = index oldindex = index @@ -922,147 +922,147 @@ class PokemonPokedex_Scene end Graphics.update Input.update - if mode==3 || mode==4 + if mode == 3 || mode == 4 if Input.trigger?(Input::UP) - if index<-1 # From OK/Cancel + if index < -1 # From OK/Cancel minmax = 0 index = selindex[minmax] - elsif minmax==0 + elsif minmax == 0 minmax = 1 index = selindex[minmax] end - if index!=oldindex || minmax!=oldminmax + if index != oldindex || minmax != oldminmax pbPlayCursorSE - pbRefreshDexSearchParam(mode,cmds,selindex,index) + pbRefreshDexSearchParam(mode, cmds, selindex, index) end elsif Input.trigger?(Input::DOWN) - if minmax==1 + if minmax == 1 minmax = 0 index = selindex[minmax] - elsif minmax==0 + elsif minmax == 0 minmax = -1 index = -2 end - if index!=oldindex || minmax!=oldminmax + if index != oldindex || minmax != oldminmax pbPlayCursorSE - pbRefreshDexSearchParam(mode,cmds,selindex,index) + pbRefreshDexSearchParam(mode, cmds, selindex, index) end elsif Input.repeat?(Input::LEFT) - if index==-3 + if index == -3 index = -2 - elsif index>=-1 - if minmax==1 && index==-1 - index = cmds.length-1 if selindex[0]-1 && !(minmax==1 && index>=cmds.length) - index -= 1 if minmax==0 || selindex[0]<=index-1 + elsif index >= -1 + if minmax == 1 && index == -1 + index = cmds.length - 1 if selindex[0] < cmds.length - 1 + elsif minmax == 1 && index == 0 + index = cmds.length if selindex[0] < 0 + elsif index > -1 && !(minmax == 1 && index >= cmds.length) + index -= 1 if minmax == 0 || selindex[0] <= index - 1 end end - if index!=oldindex - selindex[minmax] = index if minmax>=0 + if index != oldindex + selindex[minmax] = index if minmax >= 0 pbPlayCursorSE - pbRefreshDexSearchParam(mode,cmds,selindex,index) + pbRefreshDexSearchParam(mode, cmds, selindex, index) end elsif Input.repeat?(Input::RIGHT) - if index==-2 + if index == -2 index = -3 - elsif index>=-1 - if minmax==1 && index>=cmds.length + elsif index >= -1 + if minmax == 1 && index >= cmds.length index = 0 - elsif minmax==1 && index==cmds.length-1 + elsif minmax == 1 && index == cmds.length - 1 index = -1 - elsif index=index+1) + elsif index < cmds.length && !(minmax == 1 && index < 0) + index += 1 if minmax == 1 || selindex[1] == -1 || + (selindex[1] < cmds.length && selindex[1] >= index + 1) end end - if index!=oldindex - selindex[minmax] = index if minmax>=0 + if index != oldindex + selindex[minmax] = index if minmax >= 0 pbPlayCursorSE - pbRefreshDexSearchParam(mode,cmds,selindex,index) + pbRefreshDexSearchParam(mode, cmds, selindex, index) end end else if Input.trigger?(Input::UP) - if index==-1 # From blank - index = cmds.length-1-(cmds.length-1)%cols-1 - elsif index==-2 # From OK - index = ((cmds.length-1)/cols).floor*cols - elsif index==-3 && mode==0 # From Cancel - index = cmds.length-1 - elsif index==-3 # From Cancel + if index == -1 # From blank + index = cmds.length - 1 - (cmds.length - 1) % cols - 1 + elsif index == -2 # From OK + index = ((cmds.length - 1) / cols).floor * cols + elsif index == -3 && mode == 0 # From Cancel + index = cmds.length - 1 + elsif index == -3 # From Cancel index = -1 - elsif index>=cols + elsif index >= cols index -= cols end - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::DOWN) - if index==-1 # From blank + if index == -1 # From blank index = -3 - elsif index>=0 - if index+cols= 0 + if index + cols < cmds.length index += cols - elsif (index/cols).floor<((cmds.length-1)/cols).floor - index = (index%cols0 && index%cols!=0 + elsif index == -1 + index = cmds.length - 1 + elsif index > 0 && index % cols != 0 index -= 1 end - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::RIGHT) - if index==-2 + if index == -2 index = -3 - elsif index==cmds.length-1 && mode!=0 + elsif index == cmds.length - 1 && mode != 0 index = -1 - elsif index>=0 && index%cols!=cols-1 + elsif index >= 0 && index % cols != cols - 1 index += 1 end - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex end end if Input.trigger?(Input::ACTION) index = -2 - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::BACK) pbPlayCloseMenuSE ret = nil break elsif Input.trigger?(Input::USE) - if index==-2 # OK + if index == -2 # OK pbPlayDecisionSE ret = selindex break - elsif index==-3 # Cancel + elsif index == -3 # Cancel pbPlayCloseMenuSE ret = nil break - elsif selindex!=index && mode!=3 && mode!=4 - if mode==2 - if index==-1 - nextparam = (selindex[1]>=0) ? 1 : 0 - elsif index>=0 - nextparam = (selindex[0]<0) ? 0 : (selindex[1]<0) ? 1 : nextparam + elsif selindex != index && mode != 3 && mode != 4 + if mode == 2 + if index == -1 + nextparam = (selindex[1] >= 0) ? 1 : 0 + elsif index >= 0 + nextparam = (selindex[0] < 0) ? 0 : (selindex[1] < 0) ? 1 : nextparam end - if index<0 || selindex[(nextparam+1)%2]!=index + if index < 0 || selindex[(nextparam + 1) % 2] != index pbPlayDecisionSE selindex[nextparam] = index - nextparam = (nextparam+1)%2 + nextparam = (nextparam + 1) % 2 end else pbPlayDecisionSE selindex[0] = index end - pbRefreshDexSearchParam(mode,cmds,selindex,index) + pbRefreshDexSearchParam(mode, cmds, selindex, index) end end end @@ -1084,22 +1084,22 @@ class PokemonPokedex_Scene @orderCommands[MODELIGHTEST] = _INTL("Lightest") @orderCommands[MODETALLEST] = _INTL("Tallest") @orderCommands[MODESMALLEST] = _INTL("Smallest") - @nameCommands = [_INTL("A"),_INTL("B"),_INTL("C"),_INTL("D"),_INTL("E"), - _INTL("F"),_INTL("G"),_INTL("H"),_INTL("I"),_INTL("J"), - _INTL("K"),_INTL("L"),_INTL("M"),_INTL("N"),_INTL("O"), - _INTL("P"),_INTL("Q"),_INTL("R"),_INTL("S"),_INTL("T"), - _INTL("U"),_INTL("V"),_INTL("W"),_INTL("X"),_INTL("Y"), + @nameCommands = [_INTL("A"), _INTL("B"), _INTL("C"), _INTL("D"), _INTL("E"), + _INTL("F"), _INTL("G"), _INTL("H"), _INTL("I"), _INTL("J"), + _INTL("K"), _INTL("L"), _INTL("M"), _INTL("N"), _INTL("O"), + _INTL("P"), _INTL("Q"), _INTL("R"), _INTL("S"), _INTL("T"), + _INTL("U"), _INTL("V"), _INTL("W"), _INTL("X"), _INTL("Y"), _INTL("Z")] @typeCommands = [] GameData::Type.each { |t| @typeCommands.push(t) if !t.pseudo_type } - @heightCommands = [1,2,3,4,5,6,7,8,9,10, - 11,12,13,14,15,16,17,18,19,20, - 21,22,23,24,25,30,35,40,45,50, - 55,60,65,70,80,90,100] - @weightCommands = [5,10,15,20,25,30,35,40,45,50, - 55,60,70,80,90,100,110,120,140,160, - 180,200,250,300,350,400,500,600,700,800, - 900,1000,1250,1500,2000,3000,5000] + @heightCommands = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 30, 35, 40, 45, 50, + 55, 60, 65, 70, 80, 90, 100] + @weightCommands = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, + 55, 60, 70, 80, 90, 100, 110, 120, 140, 160, + 180, 200, 250, 300, 350, 400, 500, 600, 700, 800, + 900, 1000, 1250, 1500, 2000, 3000, 5000] @colorCommands = [] GameData::BodyColor.each { |c| @colorCommands.push(c) if c.id != :None } @shapeCommands = [] @@ -1111,104 +1111,104 @@ class PokemonPokedex_Scene oldindex = index @sprites["searchcursor"].mode = -1 @sprites["searchcursor"].index = index - pbRefreshDexSearch(params,index) + pbRefreshDexSearch(params, index) pbFadeInAndShow(@sprites) loop do Graphics.update Input.update pbUpdate - if index!=oldindex + if index != oldindex @sprites["searchcursor"].index = index oldindex = index end if Input.trigger?(Input::UP) - if index>=7 + if index >= 7 index = 4 - elsif index==5 + elsif index == 5 index = 0 - elsif index>0 + elsif index > 0 index -= 1 end - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::DOWN) - if index==4 || index==6 + if index == 4 || index == 6 index = 8 - elsif index<7 + elsif index < 7 index += 1 end - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::LEFT) - if index==5 + if index == 5 index = 1 - elsif index==6 + elsif index == 6 index = 3 - elsif index>7 + elsif index > 7 index -= 1 end - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::RIGHT) - if index==1 + if index == 1 index = 5 - elsif index>=2 && index<=4 + elsif index >= 2 && index <= 4 index = 6 - elsif index==7 || index==8 + elsif index == 7 || index == 8 index += 1 end - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::ACTION) index = 8 - pbPlayCursorSE if index!=oldindex + pbPlayCursorSE if index != oldindex elsif Input.trigger?(Input::BACK) pbPlayCloseMenuSE break elsif Input.trigger?(Input::USE) - pbPlayDecisionSE if index!=9 + pbPlayDecisionSE if index != 9 case index when 0 # Choose sort order - newparam = pbDexSearchCommands(0,[params[0]],index) - params[0] = newparam[0] if newparam!=nil - pbRefreshDexSearch(params,index) + newparam = pbDexSearchCommands(0, [params[0]], index) + params[0] = newparam[0] if newparam != nil + pbRefreshDexSearch(params, index) when 1 # Filter by name - newparam = pbDexSearchCommands(1,[params[1]],index) - params[1] = newparam[0] if newparam!=nil - pbRefreshDexSearch(params,index) + newparam = pbDexSearchCommands(1, [params[1]], index) + params[1] = newparam[0] if newparam != nil + pbRefreshDexSearch(params, index) when 2 # Filter by type - newparam = pbDexSearchCommands(2,[params[2],params[3]],index) - if newparam!=nil + newparam = pbDexSearchCommands(2, [params[2], params[3]], index) + if newparam != nil params[2] = newparam[0] params[3] = newparam[1] end - pbRefreshDexSearch(params,index) + pbRefreshDexSearch(params, index) when 3 # Filter by height range - newparam = pbDexSearchCommands(3,[params[4],params[5]],index) - if newparam!=nil + newparam = pbDexSearchCommands(3, [params[4], params[5]], index) + if newparam != nil params[4] = newparam[0] params[5] = newparam[1] end - pbRefreshDexSearch(params,index) + pbRefreshDexSearch(params, index) when 4 # Filter by weight range - newparam = pbDexSearchCommands(4,[params[6],params[7]],index) - if newparam!=nil + newparam = pbDexSearchCommands(4, [params[6], params[7]], index) + if newparam != nil params[6] = newparam[0] params[7] = newparam[1] end - pbRefreshDexSearch(params,index) + pbRefreshDexSearch(params, index) when 5 # Filter by color filter - newparam = pbDexSearchCommands(5,[params[8]],index) - params[8] = newparam[0] if newparam!=nil - pbRefreshDexSearch(params,index) + newparam = pbDexSearchCommands(5, [params[8]], index) + params[8] = newparam[0] if newparam != nil + pbRefreshDexSearch(params, index) when 6 # Filter by shape - newparam = pbDexSearchCommands(6,[params[9]],index) - params[9] = newparam[0] if newparam!=nil - pbRefreshDexSearch(params,index) + newparam = pbDexSearchCommands(6, [params[9]], index) + params[9] = newparam[0] if newparam != nil + pbRefreshDexSearch(params, index) when 7 # Clear filters for i in 0...10 - params[i] = (i==0) ? MODENUMERICAL : -1 + params[i] = (i == 0) ? MODENUMERICAL : -1 end - pbRefreshDexSearch(params,index) + pbRefreshDexSearch(params, index) when 8 # Start search (filter) dexlist = pbSearchDexList(params) - if dexlist.length==0 + if dexlist.length == 0 pbMessage(_INTL("No matching Pokémon were found.")) else @dexlist = dexlist @@ -1232,19 +1232,19 @@ class PokemonPokedex_Scene @sprites["background"].setBitmap("Graphics/Pictures/Pokedex/bg_list") end pbRefresh - pbFadeInAndShow(@sprites,oldsprites) + pbFadeInAndShow(@sprites, oldsprites) Input.update return 0 end def pbPokedex - pbActivateWindow(@sprites,"pokedex") { + pbActivateWindow(@sprites, "pokedex") { loop do Graphics.update Input.update oldindex = @sprites["pokedex"].index pbUpdate - if oldindex!=@sprites["pokedex"].index + if oldindex != @sprites["pokedex"].index $PokemonGlobal.pokedexIndex[pbGetSavePositionIndex] = @sprites["pokedex"].index if !@searchResults pbRefresh end diff --git a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb index f418675be..6fb255ce0 100644 --- a/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb +++ b/Data/Scripts/016_UI/004_UI_Pokedex_Entry.rb @@ -2,8 +2,8 @@ # #=============================================================================== class PokemonPokedexInfo_Scene - def pbStartScene(dexlist,index,region) - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + def pbStartScene(dexlist, index, region) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @dexlist = dexlist @index = index @@ -12,7 +12,7 @@ class PokemonPokedexInfo_Scene @show_battled_count = false @typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Pokedex/icon_types")) @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) @sprites["infosprite"] = PokemonSprite.new(@viewport) @sprites["infosprite"].setOffset(PictureOrigin::Center) @sprites["infosprite"].x = 104 @@ -22,21 +22,21 @@ class PokemonPokedexInfo_Scene if @region < 0 # Use player's current region @region = (mappos) ? mappos[0] : 0 # Region 0 default end - @sprites["areamap"] = IconSprite.new(0,0,@viewport) + @sprites["areamap"] = IconSprite.new(0, 0, @viewport) @sprites["areamap"].setBitmap("Graphics/Pictures/#{@mapdata[@region][1]}") - @sprites["areamap"].x += (Graphics.width-@sprites["areamap"].bitmap.width)/2 - @sprites["areamap"].y += (Graphics.height+32-@sprites["areamap"].bitmap.height)/2 + @sprites["areamap"].x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2 + @sprites["areamap"].y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2 for hidden in Settings::REGION_MAP_EXTRAS - if hidden[0]==@region && hidden[1]>0 && $game_switches[hidden[1]] - pbDrawImagePositions(@sprites["areamap"].bitmap,[ + if hidden[0] == @region && hidden[1] > 0 && $game_switches[hidden[1]] + pbDrawImagePositions(@sprites["areamap"].bitmap, [ ["Graphics/Pictures/#{hidden[4]}", - hidden[2]*PokemonRegionMap_Scene::SQUARE_WIDTH, - hidden[3]*PokemonRegionMap_Scene::SQUARE_HEIGHT] + hidden[2] * PokemonRegionMap_Scene::SQUARE_WIDTH, + hidden[3] * PokemonRegionMap_Scene::SQUARE_HEIGHT] ]) end end - @sprites["areahighlight"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) - @sprites["areaoverlay"] = IconSprite.new(0,0,@viewport) + @sprites["areahighlight"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) + @sprites["areaoverlay"] = IconSprite.new(0, 0, @viewport) @sprites["areaoverlay"].setBitmap("Graphics/Pictures/Pokedex/overlay_area") @sprites["formfront"] = PokemonSprite.new(@viewport) @sprites["formfront"].setOffset(PictureOrigin::Center) @@ -49,17 +49,17 @@ class PokemonPokedexInfo_Scene @sprites["formicon"].setOffset(PictureOrigin::Center) @sprites["formicon"].x = 82 @sprites["formicon"].y = 328 - @sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow",8,28,40,2,@viewport) + @sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow", 8, 28, 40, 2, @viewport) @sprites["uparrow"].x = 242 @sprites["uparrow"].y = 268 @sprites["uparrow"].play @sprites["uparrow"].visible = false - @sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow",8,28,40,2,@viewport) + @sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow", 8, 28, 40, 2, @viewport) @sprites["downarrow"].x = 242 @sprites["downarrow"].y = 348 @sprites["downarrow"].play @sprites["downarrow"].visible = false - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) pbUpdateDummyPokemon @available = pbGetAvailableForms @@ -68,7 +68,7 @@ class PokemonPokedexInfo_Scene end def pbStartSceneBrief(species) # For standalone access, shows first page only - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 dexnum = 0 dexnumshift = false @@ -83,25 +83,25 @@ class PokemonPokedexInfo_Scene else for i in 0...$player.pokedex.dexes_count - 1 # Regional Dexes next if !$player.pokedex.unlocked?(i) - num = pbGetRegionalNumber(i,species) + num = pbGetRegionalNumber(i, species) next if num <= 0 dexnum = num dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(i) break end end - @dexlist = [[species,"",0,0,dexnum,dexnumshift]] + @dexlist = [[species, "", 0, 0, dexnum, dexnumshift]] @index = 0 @page = 1 @brief = true @typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Pokedex/icon_types")) @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) @sprites["infosprite"] = PokemonSprite.new(@viewport) @sprites["infosprite"].setOffset(PictureOrigin::Center) @sprites["infosprite"].x = 104 @sprites["infosprite"].y = 136 - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) pbUpdateDummyPokemon drawPage(@page) @@ -116,9 +116,9 @@ class PokemonPokedexInfo_Scene end def pbUpdate - if @page==2 - intensity = (Graphics.frame_count%40)*12 - intensity = 480-intensity if intensity>240 + if @page == 2 + intensity = (Graphics.frame_count % 40) * 12 + intensity = 480 - intensity if intensity > 240 @sprites["areahighlight"].opacity = intensity end pbUpdateSpriteHash(@sprites) @@ -128,17 +128,17 @@ class PokemonPokedexInfo_Scene @species = @dexlist[@index][0] @gender, @form = $player.pokedex.last_form_seen(@species) metrics_data = GameData::SpeciesMetrics.get_species_form(@species, @form) - @sprites["infosprite"].setSpeciesBitmap(@species,@gender,@form) + @sprites["infosprite"].setSpeciesBitmap(@species, @gender, @form) if @sprites["formfront"] - @sprites["formfront"].setSpeciesBitmap(@species,@gender,@form) + @sprites["formfront"].setSpeciesBitmap(@species, @gender, @form) end if @sprites["formback"] - @sprites["formback"].setSpeciesBitmap(@species,@gender,@form,false,false,true) + @sprites["formback"].setSpeciesBitmap(@species, @gender, @form, false, false, true) @sprites["formback"].y = 256 @sprites["formback"].y += metrics_data.back_sprite[1] * 2 end if @sprites["formicon"] - @sprites["formicon"].pbSetParams(@species,@gender,@form) + @sprites["formicon"].pbSetParams(@species, @gender, @form) end end @@ -185,13 +185,13 @@ class PokemonPokedexInfo_Scene overlay = @sprites["overlay"].bitmap overlay.clear # Make certain sprites visible - @sprites["infosprite"].visible = (@page==1) - @sprites["areamap"].visible = (@page==2) if @sprites["areamap"] - @sprites["areahighlight"].visible = (@page==2) if @sprites["areahighlight"] - @sprites["areaoverlay"].visible = (@page==2) if @sprites["areaoverlay"] - @sprites["formfront"].visible = (@page==3) if @sprites["formfront"] - @sprites["formback"].visible = (@page==3) if @sprites["formback"] - @sprites["formicon"].visible = (@page==3) if @sprites["formicon"] + @sprites["infosprite"].visible = (@page == 1) + @sprites["areamap"].visible = (@page == 2) if @sprites["areamap"] + @sprites["areahighlight"].visible = (@page == 2) if @sprites["areahighlight"] + @sprites["areaoverlay"].visible = (@page == 2) if @sprites["areaoverlay"] + @sprites["formfront"].visible = (@page == 3) if @sprites["formfront"] + @sprites["formback"].visible = (@page == 3) if @sprites["formback"] + @sprites["formicon"].visible = (@page == 3) if @sprites["formicon"] # Draw page-specific information case page when 1 then drawPageInfo @@ -251,7 +251,7 @@ class PokemonPokedexInfo_Scene # Draw the footprint footprintfile = GameData::Species.footprint_filename(@species, @form) if footprintfile - footprint = RPG::Cache.load_bitmap("",footprintfile) + footprint = RPG::Cache.load_bitmap("", footprintfile) overlay.blt(226, 138, footprint, footprint.rect) footprint.dispose end @@ -295,13 +295,13 @@ class PokemonPokedexInfo_Scene def drawPageArea @sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_area")) overlay = @sprites["overlay"].bitmap - base = Color.new(88,88,80) - shadow = Color.new(168,184,184) + base = Color.new(88, 88, 80) + shadow = Color.new(168, 184, 184) @sprites["areahighlight"].bitmap.clear # Fill the array "points" with all squares of the region map in which the # species can be found points = [] - mapwidth = 1+PokemonRegionMap_Scene::RIGHT-PokemonRegionMap_Scene::LEFT + mapwidth = 1 + PokemonRegionMap_Scene::RIGHT - PokemonRegionMap_Scene::LEFT GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data| next if !pbFindEncounter(enc_data.types, @species) map_metadata = GameData::MapMetadata.try_get(enc_data.map) @@ -309,89 +309,89 @@ class PokemonPokedexInfo_Scene next if !mappos || mappos[0] != @region showpoint = true for loc in @mapdata[@region][2] - showpoint = false if loc[0]==mappos[1] && loc[1]==mappos[2] && + showpoint = false if loc[0] == mappos[1] && loc[1] == mappos[2] && loc[7] && !$game_switches[loc[7]] end next if !showpoint mapsize = map_metadata.town_map_size - if mapsize && mapsize[0] && mapsize[0]>0 + if mapsize && mapsize[0] && mapsize[0] > 0 sqwidth = mapsize[0] - sqheight = (mapsize[1].length*1.0/mapsize[0]).ceil + sqheight = (mapsize[1].length * 1.0 / mapsize[0]).ceil for i in 0...sqwidth for j in 0...sqheight - if mapsize[1][i+j*sqwidth,1].to_i>0 - points[mappos[1]+i+(mappos[2]+j)*mapwidth] = true + if mapsize[1][i + j * sqwidth, 1].to_i > 0 + points[mappos[1] + i + (mappos[2] + j) * mapwidth] = true end end end else - points[mappos[1]+mappos[2]*mapwidth] = true + points[mappos[1] + mappos[2] * mapwidth] = true end end # Draw coloured squares on each square of the region map with a nest - pointcolor = Color.new(0,248,248) - pointcolorhl = Color.new(192,248,248) + pointcolor = Color.new(0, 248, 248) + pointcolorhl = Color.new(192, 248, 248) sqwidth = PokemonRegionMap_Scene::SQUARE_WIDTH sqheight = PokemonRegionMap_Scene::SQUARE_HEIGHT for j in 0...points.length if points[j] - x = (j%mapwidth)*sqwidth - x += (Graphics.width-@sprites["areamap"].bitmap.width)/2 - y = (j/mapwidth)*sqheight - y += (Graphics.height+32-@sprites["areamap"].bitmap.height)/2 - @sprites["areahighlight"].bitmap.fill_rect(x,y,sqwidth,sqheight,pointcolor) - if j-mapwidth<0 || !points[j-mapwidth] - @sprites["areahighlight"].bitmap.fill_rect(x,y-2,sqwidth,2,pointcolorhl) + x = (j % mapwidth) * sqwidth + x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2 + y = (j / mapwidth) * sqheight + y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2 + @sprites["areahighlight"].bitmap.fill_rect(x, y, sqwidth, sqheight, pointcolor) + if j - mapwidth < 0 || !points[j - mapwidth] + @sprites["areahighlight"].bitmap.fill_rect(x, y - 2, sqwidth, 2, pointcolorhl) end - if j+mapwidth>=points.length || !points[j+mapwidth] - @sprites["areahighlight"].bitmap.fill_rect(x,y+sqheight,sqwidth,2,pointcolorhl) + if j + mapwidth >= points.length || !points[j + mapwidth] + @sprites["areahighlight"].bitmap.fill_rect(x, y + sqheight, sqwidth, 2, pointcolorhl) end - if j%mapwidth==0 || !points[j-1] - @sprites["areahighlight"].bitmap.fill_rect(x-2,y,2,sqheight,pointcolorhl) + if j % mapwidth == 0 || !points[j - 1] + @sprites["areahighlight"].bitmap.fill_rect(x - 2, y, 2, sqheight, pointcolorhl) end - if (j+1)%mapwidth==0 || !points[j+1] - @sprites["areahighlight"].bitmap.fill_rect(x+sqwidth,y,2,sqheight,pointcolorhl) + if (j + 1) % mapwidth == 0 || !points[j + 1] + @sprites["areahighlight"].bitmap.fill_rect(x + sqwidth, y, 2, sqheight, pointcolorhl) end end end # Set the text textpos = [] - if points.length==0 - pbDrawImagePositions(overlay,[ - [sprintf("Graphics/Pictures/Pokedex/overlay_areanone"),108,188] + if points.length == 0 + pbDrawImagePositions(overlay, [ + [sprintf("Graphics/Pictures/Pokedex/overlay_areanone"), 108, 188] ]) - textpos.push([_INTL("Area unknown"),Graphics.width/2,Graphics.height/2 - 6,2,base,shadow]) + textpos.push([_INTL("Area unknown"), Graphics.width / 2, Graphics.height / 2 - 6, 2, base, shadow]) end - textpos.push([pbGetMessage(MessageTypes::RegionNames,@region),414,38,2,base,shadow]) - textpos.push([_INTL("{1}'s area",GameData::Species.get(@species).name), - Graphics.width/2,346,2,base,shadow]) - pbDrawTextPositions(overlay,textpos) + textpos.push([pbGetMessage(MessageTypes::RegionNames, @region), 414, 38, 2, base, shadow]) + textpos.push([_INTL("{1}'s area", GameData::Species.get(@species).name), + Graphics.width / 2, 346, 2, base, shadow]) + pbDrawTextPositions(overlay, textpos) end def drawPageForms @sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_forms")) overlay = @sprites["overlay"].bitmap - base = Color.new(88,88,80) - shadow = Color.new(168,184,184) + base = Color.new(88, 88, 80) + shadow = Color.new(168, 184, 184) # Write species and form name formname = "" for i in @available - if i[1]==@gender && i[2]==@form + if i[1] == @gender && i[2] == @form formname = i[0] break end end textpos = [ - [GameData::Species.get(@species).name,Graphics.width/2,Graphics.height-94,2,base,shadow], - [formname,Graphics.width/2,Graphics.height-62,2,base,shadow], + [GameData::Species.get(@species).name, Graphics.width / 2, Graphics.height - 94, 2, base, shadow], + [formname, Graphics.width / 2, Graphics.height - 62, 2, base, shadow], ] # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) end def pbGoToPrevious newindex = @index - while newindex>0 + while newindex > 0 newindex -= 1 if $player.seen?(@dexlist[newindex][0]) @index = newindex @@ -402,7 +402,7 @@ class PokemonPokedexInfo_Scene def pbGoToNext newindex = @index - while newindex<@dexlist.length-1 + while newindex < @dexlist.length - 1 newindex += 1 if $player.seen?(@dexlist[newindex][0]) @index = newindex @@ -414,19 +414,19 @@ class PokemonPokedexInfo_Scene def pbChooseForm index = 0 for i in 0...@available.length - if @available[i][1]==@gender && @available[i][2]==@form + if @available[i][1] == @gender && @available[i][2] == @form index = i break end end oldindex = -1 loop do - if oldindex!=index + if oldindex != index $player.pokedex.set_last_form_seen(@species, @available[index][1], @available[index][2]) pbUpdateDummyPokemon drawPage(@page) - @sprites["uparrow"].visible = (index>0) - @sprites["downarrow"].visible = (index<@available.length-1) + @sprites["uparrow"].visible = (index > 0) + @sprites["downarrow"].visible = (index < @available.length - 1) oldindex = index end Graphics.update @@ -434,10 +434,10 @@ class PokemonPokedexInfo_Scene pbUpdate if Input.trigger?(Input::UP) pbPlayCursorSE - index = (index+@available.length-1)%@available.length + index = (index + @available.length - 1) % @available.length elsif Input.trigger?(Input::DOWN) pbPlayCursorSE - index = (index+1)%@available.length + index = (index + 1) % @available.length elsif Input.trigger?(Input::BACK) pbPlayCancelSE break @@ -470,7 +470,7 @@ class PokemonPokedexInfo_Scene elsif @page == 2 # Area # dorefresh = true elsif @page == 3 # Forms - if @available.length>1 + if @available.length > 1 pbPlayDecisionSE pbChooseForm dorefresh = true @@ -479,38 +479,38 @@ class PokemonPokedexInfo_Scene elsif Input.trigger?(Input::UP) oldindex = @index pbGoToPrevious - if @index!=oldindex + if @index != oldindex pbUpdateDummyPokemon @available = pbGetAvailableForms pbSEStop - (@page==1) ? Pokemon.play_cry(@species, @form) : pbPlayCursorSE + (@page == 1) ? Pokemon.play_cry(@species, @form) : pbPlayCursorSE dorefresh = true end elsif Input.trigger?(Input::DOWN) oldindex = @index pbGoToNext - if @index!=oldindex + if @index != oldindex pbUpdateDummyPokemon @available = pbGetAvailableForms pbSEStop - (@page==1) ? Pokemon.play_cry(@species, @form) : pbPlayCursorSE + (@page == 1) ? Pokemon.play_cry(@species, @form) : pbPlayCursorSE dorefresh = true end elsif Input.trigger?(Input::LEFT) oldpage = @page @page -= 1 - @page = 1 if @page<1 - @page = 3 if @page>3 - if @page!=oldpage + @page = 1 if @page < 1 + @page = 3 if @page > 3 + if @page != oldpage pbPlayCursorSE dorefresh = true end elsif Input.trigger?(Input::RIGHT) oldpage = @page @page += 1 - @page = 1 if @page<1 - @page = 3 if @page>3 - if @page!=oldpage + @page = 1 if @page < 1 + @page = 3 if @page > 3 + if @page != oldpage pbPlayCursorSE dorefresh = true end @@ -550,8 +550,8 @@ class PokemonPokedexInfoScreen @scene = scene end - def pbStartScreen(dexlist,index,region) - @scene.pbStartScene(dexlist,index,region) + def pbStartScreen(dexlist, index, region) + @scene.pbStartScene(dexlist, index, region) ret = @scene.pbScene @scene.pbEndScene return ret # Index of last species viewed in dexlist @@ -565,10 +565,10 @@ class PokemonPokedexInfoScreen else region = $PokemonGlobal.pokedexDex # National Dex -1, regional Dexes 0, 1, etc. end - dexnum = pbGetRegionalNumber(region,species) + dexnum = pbGetRegionalNumber(region, species) dexnumshift = Settings::DEXES_WITH_OFFSETS.include?(region) - dexlist = [[species,GameData::Species.get(species).name,0,0,dexnum,dexnumshift]] - @scene.pbStartScene(dexlist,0,region) + dexlist = [[species, GameData::Species.get(species).name, 0, 0, dexnum, dexnumshift]] + @scene.pbStartScene(dexlist, 0, region) @scene.pbScene @scene.pbEndScene end diff --git a/Data/Scripts/016_UI/005_UI_Party.rb b/Data/Scripts/016_UI/005_UI_Party.rb index 7b2929a7e..9ad97d443 100644 --- a/Data/Scripts/016_UI/005_UI_Party.rb +++ b/Data/Scripts/016_UI/005_UI_Party.rb @@ -4,24 +4,24 @@ class PokemonPartyConfirmCancelSprite < SpriteWrapper attr_reader :selected - def initialize(text,x,y,narrowbox = false,viewport = nil) + def initialize(text, x, y, narrowbox = false, viewport = nil) super(viewport) @refreshBitmap = true - @bgsprite = ChangelingSprite.new(0,0,viewport) + @bgsprite = ChangelingSprite.new(0, 0, viewport) if narrowbox - @bgsprite.addBitmap("desel","Graphics/Pictures/Party/icon_cancel_narrow") - @bgsprite.addBitmap("sel","Graphics/Pictures/Party/icon_cancel_narrow_sel") + @bgsprite.addBitmap("desel", "Graphics/Pictures/Party/icon_cancel_narrow") + @bgsprite.addBitmap("sel", "Graphics/Pictures/Party/icon_cancel_narrow_sel") else - @bgsprite.addBitmap("desel","Graphics/Pictures/Party/icon_cancel") - @bgsprite.addBitmap("sel","Graphics/Pictures/Party/icon_cancel_sel") + @bgsprite.addBitmap("desel", "Graphics/Pictures/Party/icon_cancel") + @bgsprite.addBitmap("sel", "Graphics/Pictures/Party/icon_cancel_sel") end @bgsprite.changeBitmap("desel") - @overlaysprite = BitmapSprite.new(@bgsprite.bitmap.width,@bgsprite.bitmap.height,viewport) - @overlaysprite.z = self.z+1 + @overlaysprite = BitmapSprite.new(@bgsprite.bitmap.width, @bgsprite.bitmap.height, viewport) + @overlaysprite.z = self.z + 1 pbSetSystemFont(@overlaysprite.bitmap) @yoffset = 8 - textpos = [[text,56,(narrowbox) ? -4 : 2,2,Color.new(248,248,248),Color.new(40,40,40)]] - pbDrawTextPositions(@overlaysprite.bitmap,textpos) + textpos = [[text, 56, (narrowbox) ? -4 : 2, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)]] + pbDrawTextPositions(@overlaysprite.bitmap, textpos) self.x = x self.y = y end @@ -54,7 +54,7 @@ class PokemonPartyConfirmCancelSprite < SpriteWrapper end def selected=(value) - if @selected!=value + if @selected != value @selected = value refresh end @@ -80,7 +80,7 @@ end #=============================================================================== class PokemonPartyCancelSprite < PokemonPartyConfirmCancelSprite def initialize(viewport = nil) - super(_INTL("CANCEL"),398,328,false,viewport) + super(_INTL("CANCEL"), 398, 328, false, viewport) end end @@ -89,7 +89,7 @@ end #=============================================================================== class PokemonPartyConfirmSprite < PokemonPartyConfirmCancelSprite def initialize(viewport = nil) - super(_INTL("CONFIRM"),398,308,true,viewport) + super(_INTL("CONFIRM"), 398, 308, true, viewport) end end @@ -98,7 +98,7 @@ end #=============================================================================== class PokemonPartyCancelSprite2 < PokemonPartyConfirmCancelSprite def initialize(viewport = nil) - super(_INTL("CANCEL"),398,346,true,viewport) + super(_INTL("CANCEL"), 398, 346, true, viewport) end end @@ -106,7 +106,7 @@ end # #=============================================================================== class Window_CommandPokemonColor < Window_CommandPokemon - def initialize(commands,width = nil) + def initialize(commands, width = nil) @colorKey = [] for i in 0...commands.length if commands[i].is_a?(Array) @@ -114,20 +114,20 @@ class Window_CommandPokemonColor < Window_CommandPokemon commands[i] = commands[i][0] end end - super(commands,width) + super(commands, width) end - def drawItem(index,_count,rect) + def drawItem(index, _count, rect) pbSetSystemFont(self.contents) if @starting - rect = drawCursor(index,rect) + rect = drawCursor(index, rect) base = self.baseColor shadow = self.shadowColor - if @colorKey[index] && @colorKey[index]==1 - base = Color.new(0,80,160) - shadow = Color.new(128,192,240) + if @colorKey[index] && @colorKey[index] == 1 + base = Color.new(0, 80, 160) + shadow = Color.new(128, 192, 240) end - pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height, - @commands[index],base,shadow) + pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height, + @commands[index], base, shadow) end end @@ -137,7 +137,7 @@ end class PokemonPartyBlankPanel < SpriteWrapper attr_accessor :text - def initialize(_pokemon,index,viewport = nil) + def initialize(_pokemon, index, viewport = nil) super(viewport) self.x = (index % 2) * Graphics.width / 2 self.y = 16 * (index % 2) + 96 * (index / 2) @@ -171,49 +171,49 @@ class PokemonPartyPanel < SpriteWrapper attr_reader :switching attr_reader :text - def initialize(pokemon,index,viewport = nil) + def initialize(pokemon, index, viewport = nil) super(viewport) @pokemon = pokemon - @active = (index==0) # true = rounded panel, false = rectangular panel + @active = (index == 0) # true = rounded panel, false = rectangular panel @refreshing = true self.x = (index % 2) * Graphics.width / 2 self.y = 16 * (index % 2) + 96 * (index / 2) - @panelbgsprite = ChangelingSprite.new(0,0,viewport) + @panelbgsprite = ChangelingSprite.new(0, 0, viewport) @panelbgsprite.z = self.z if @active # Rounded panel - @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_round") - @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_round_sel") - @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_round_faint") - @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_round_faint_sel") - @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_round_swap") - @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_round_swap_sel") - @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_round_swap_sel2") + @panelbgsprite.addBitmap("able", "Graphics/Pictures/Party/panel_round") + @panelbgsprite.addBitmap("ablesel", "Graphics/Pictures/Party/panel_round_sel") + @panelbgsprite.addBitmap("fainted", "Graphics/Pictures/Party/panel_round_faint") + @panelbgsprite.addBitmap("faintedsel", "Graphics/Pictures/Party/panel_round_faint_sel") + @panelbgsprite.addBitmap("swap", "Graphics/Pictures/Party/panel_round_swap") + @panelbgsprite.addBitmap("swapsel", "Graphics/Pictures/Party/panel_round_swap_sel") + @panelbgsprite.addBitmap("swapsel2", "Graphics/Pictures/Party/panel_round_swap_sel2") else # Rectangular panel - @panelbgsprite.addBitmap("able","Graphics/Pictures/Party/panel_rect") - @panelbgsprite.addBitmap("ablesel","Graphics/Pictures/Party/panel_rect_sel") - @panelbgsprite.addBitmap("fainted","Graphics/Pictures/Party/panel_rect_faint") - @panelbgsprite.addBitmap("faintedsel","Graphics/Pictures/Party/panel_rect_faint_sel") - @panelbgsprite.addBitmap("swap","Graphics/Pictures/Party/panel_rect_swap") - @panelbgsprite.addBitmap("swapsel","Graphics/Pictures/Party/panel_rect_swap_sel") - @panelbgsprite.addBitmap("swapsel2","Graphics/Pictures/Party/panel_rect_swap_sel2") + @panelbgsprite.addBitmap("able", "Graphics/Pictures/Party/panel_rect") + @panelbgsprite.addBitmap("ablesel", "Graphics/Pictures/Party/panel_rect_sel") + @panelbgsprite.addBitmap("fainted", "Graphics/Pictures/Party/panel_rect_faint") + @panelbgsprite.addBitmap("faintedsel", "Graphics/Pictures/Party/panel_rect_faint_sel") + @panelbgsprite.addBitmap("swap", "Graphics/Pictures/Party/panel_rect_swap") + @panelbgsprite.addBitmap("swapsel", "Graphics/Pictures/Party/panel_rect_swap_sel") + @panelbgsprite.addBitmap("swapsel2", "Graphics/Pictures/Party/panel_rect_swap_sel2") end - @hpbgsprite = ChangelingSprite.new(0,0,viewport) - @hpbgsprite.z = self.z+1 - @hpbgsprite.addBitmap("able","Graphics/Pictures/Party/overlay_hp_back") - @hpbgsprite.addBitmap("fainted","Graphics/Pictures/Party/overlay_hp_back_faint") - @hpbgsprite.addBitmap("swap","Graphics/Pictures/Party/overlay_hp_back_swap") - @ballsprite = ChangelingSprite.new(0,0,viewport) - @ballsprite.z = self.z+1 - @ballsprite.addBitmap("desel","Graphics/Pictures/Party/icon_ball") - @ballsprite.addBitmap("sel","Graphics/Pictures/Party/icon_ball_sel") - @pkmnsprite = PokemonIconSprite.new(pokemon,viewport) + @hpbgsprite = ChangelingSprite.new(0, 0, viewport) + @hpbgsprite.z = self.z + 1 + @hpbgsprite.addBitmap("able", "Graphics/Pictures/Party/overlay_hp_back") + @hpbgsprite.addBitmap("fainted", "Graphics/Pictures/Party/overlay_hp_back_faint") + @hpbgsprite.addBitmap("swap", "Graphics/Pictures/Party/overlay_hp_back_swap") + @ballsprite = ChangelingSprite.new(0, 0, viewport) + @ballsprite.z = self.z + 1 + @ballsprite.addBitmap("desel", "Graphics/Pictures/Party/icon_ball") + @ballsprite.addBitmap("sel", "Graphics/Pictures/Party/icon_ball_sel") + @pkmnsprite = PokemonIconSprite.new(pokemon, viewport) @pkmnsprite.setOffset(PictureOrigin::Center) @pkmnsprite.active = @active - @pkmnsprite.z = self.z+2 - @helditemsprite = HeldItemIconSprite.new(0,0,@pokemon,viewport) - @helditemsprite.z = self.z+3 - @overlaysprite = BitmapSprite.new(Graphics.width,Graphics.height,viewport) - @overlaysprite.z = self.z+4 + @pkmnsprite.z = self.z + 2 + @helditemsprite = HeldItemIconSprite.new(0, 0, @pokemon, viewport) + @helditemsprite.z = self.z + 3 + @overlaysprite = BitmapSprite.new(Graphics.width, Graphics.height, viewport) + @overlaysprite.z = self.z + 4 @hpbar = AnimatedBitmap.new("Graphics/Pictures/Party/overlay_hp") @statuses = AnimatedBitmap.new(_INTL("Graphics/Pictures/statuses")) @selected = false @@ -254,7 +254,7 @@ class PokemonPartyPanel < SpriteWrapper end def text=(value) - if @text!=value + if @text != value @text = value @refreshBitmap = true refresh @@ -270,21 +270,21 @@ class PokemonPartyPanel < SpriteWrapper end def selected=(value) - if @selected!=value + if @selected != value @selected = value refresh end end def preselected=(value) - if @preselected!=value + if @preselected != value @preselected = value refresh end end def switching=(value) - if @switching!=value + if @switching != value @switching = value refresh end @@ -321,7 +321,7 @@ class PokemonPartyPanel < SpriteWrapper @panelbgsprite.color = self.color end if @hpbgsprite && !@hpbgsprite.disposed? - @hpbgsprite.visible = (!@pokemon.egg? && !(@text && @text.length>0)) + @hpbgsprite.visible = (!@pokemon.egg? && !(@text && @text.length > 0)) if @hpbgsprite.visible if self.preselected || (self.selected && @switching) @hpbgsprite.changeBitmap("swap") @@ -330,27 +330,27 @@ class PokemonPartyPanel < SpriteWrapper else @hpbgsprite.changeBitmap("able") end - @hpbgsprite.x = self.x+96 - @hpbgsprite.y = self.y+50 + @hpbgsprite.x = self.x + 96 + @hpbgsprite.y = self.y + 50 @hpbgsprite.color = self.color end end if @ballsprite && !@ballsprite.disposed? @ballsprite.changeBitmap((self.selected) ? "sel" : "desel") - @ballsprite.x = self.x+10 + @ballsprite.x = self.x + 10 @ballsprite.y = self.y @ballsprite.color = self.color end if @pkmnsprite && !@pkmnsprite.disposed? - @pkmnsprite.x = self.x+60 - @pkmnsprite.y = self.y+40 + @pkmnsprite.x = self.x + 60 + @pkmnsprite.y = self.y + 40 @pkmnsprite.color = self.color @pkmnsprite.selected = self.selected end if @helditemsprite && !@helditemsprite.disposed? if @helditemsprite.visible - @helditemsprite.x = self.x+62 - @helditemsprite.y = self.y+48 + @helditemsprite.x = self.x + 62 + @helditemsprite.y = self.y + 48 @helditemsprite.color = self.color end end @@ -362,26 +362,26 @@ class PokemonPartyPanel < SpriteWrapper if @refreshBitmap @refreshBitmap = false @overlaysprite.bitmap.clear if @overlaysprite.bitmap - basecolor = Color.new(248,248,248) - shadowcolor = Color.new(40,40,40) + basecolor = Color.new(248, 248, 248) + shadowcolor = Color.new(40, 40, 40) pbSetSystemFont(@overlaysprite.bitmap) textpos = [] # Draw Pokémon name - textpos.push([@pokemon.name,96,10,0,basecolor,shadowcolor]) + textpos.push([@pokemon.name, 96, 10, 0, basecolor, shadowcolor]) if !@pokemon.egg? - if !@text || @text.length==0 + if !@text || @text.length == 0 # Draw HP numbers - textpos.push([sprintf("% 3d /% 3d",@pokemon.hp,@pokemon.totalhp),224,54,1,basecolor,shadowcolor]) + textpos.push([sprintf("% 3d /% 3d", @pokemon.hp, @pokemon.totalhp), 224, 54, 1, basecolor, shadowcolor]) # Draw HP bar - if @pokemon.hp>0 - w = @pokemon.hp*96*1.0/@pokemon.totalhp - w = 1 if w<1 - w = ((w/2).round)*2 + if @pokemon.hp > 0 + w = @pokemon.hp * 96 * 1.0 / @pokemon.totalhp + w = 1 if w < 1 + w = ((w / 2).round) * 2 hpzone = 0 - hpzone = 1 if @pokemon.hp<=(@pokemon.totalhp/2).floor - hpzone = 2 if @pokemon.hp<=(@pokemon.totalhp/4).floor - hprect = Rect.new(0,hpzone*8,w,8) - @overlaysprite.bitmap.blt(128,52,@hpbar.bitmap,hprect) + hpzone = 1 if @pokemon.hp <= (@pokemon.totalhp / 2).floor + hpzone = 2 if @pokemon.hp <= (@pokemon.totalhp / 4).floor + hprect = Rect.new(0, hpzone * 8, w, 8) + @overlaysprite.bitmap.blt(128, 52, @hpbar.bitmap, hprect) end # Draw status status = -1 @@ -393,15 +393,15 @@ class PokemonPartyPanel < SpriteWrapper status = GameData::Status.count + 1 end if status >= 0 - statusrect = Rect.new(0,16*status,44,16) - @overlaysprite.bitmap.blt(78,68,@statuses.bitmap,statusrect) + statusrect = Rect.new(0, 16 * status, 44, 16) + @overlaysprite.bitmap.blt(78, 68, @statuses.bitmap, statusrect) end end # Draw gender symbol if @pokemon.male? - textpos.push([_INTL("♂"),224,10,0,Color.new(0,112,248),Color.new(120,184,232)]) + textpos.push([_INTL("♂"), 224, 10, 0, Color.new(0, 112, 248), Color.new(120, 184, 232)]) elsif @pokemon.female? - textpos.push([_INTL("♀"),224,10,0,Color.new(232,32,16),Color.new(248,168,184)]) + textpos.push([_INTL("♀"), 224, 10, 0, Color.new(232, 32, 16), Color.new(248, 168, 184)]) end # Draw shiny icon if @pokemon.shiny? @@ -410,22 +410,22 @@ class PokemonPartyPanel < SpriteWrapper ) end end - pbDrawTextPositions(@overlaysprite.bitmap,textpos) + pbDrawTextPositions(@overlaysprite.bitmap, textpos) # Draw level text if !@pokemon.egg? pbDrawImagePositions(@overlaysprite.bitmap, [["Graphics/Pictures/Party/overlay_lv", 20, 70, 0, 0, 22, 14]] ) pbSetSmallFont(@overlaysprite.bitmap) - pbDrawTextPositions(@overlaysprite.bitmap,[ - [@pokemon.level.to_s,42,57,0,basecolor,shadowcolor] + pbDrawTextPositions(@overlaysprite.bitmap, [ + [@pokemon.level.to_s, 42, 57, 0, basecolor, shadowcolor] ]) end # Draw annotation text - if @text && @text.length>0 + if @text && @text.length > 0 pbSetSystemFont(@overlaysprite.bitmap) - pbDrawTextPositions(@overlaysprite.bitmap,[ - [@text,96,52,0,basecolor,shadowcolor] + pbDrawTextPositions(@overlaysprite.bitmap, [ + [@text, 96, 52, 0, basecolor, shadowcolor] ]) end end @@ -449,17 +449,17 @@ class PokemonParty_Scene def pbStartScene(party, starthelptext, annotations = nil, multiselect = false, can_access_storage = false) @sprites = {} @party = party - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @multiselect = multiselect @can_access_storage = can_access_storage - addBackgroundPlane(@sprites,"partybg","Party/bg",@viewport) + addBackgroundPlane(@sprites, "partybg", "Party/bg", @viewport) @sprites["messagebox"] = Window_AdvancedTextPokemon.new("") @sprites["messagebox"].z = 50 @sprites["messagebox"].viewport = @viewport @sprites["messagebox"].visible = false @sprites["messagebox"].letterbyletter = true - pbBottomLeftLines(@sprites["messagebox"],2) + pbBottomLeftLines(@sprites["messagebox"], 2) @sprites["storagetext"] = Window_UnformattedTextPokemon.new( @can_access_storage ? _INTL("[Special]: To Boxes") : "") @sprites["storagetext"].x = 32 @@ -472,14 +472,14 @@ class PokemonParty_Scene @sprites["helpwindow"] = Window_UnformattedTextPokemon.new(starthelptext) @sprites["helpwindow"].viewport = @viewport @sprites["helpwindow"].visible = true - pbBottomLeftLines(@sprites["helpwindow"],1) + pbBottomLeftLines(@sprites["helpwindow"], 1) pbSetHelpText(starthelptext) # Add party Pokémon sprites for i in 0...Settings::MAX_PARTY_SIZE if @party[i] - @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport) + @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i], i, @viewport) else - @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport) + @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i], i, @viewport) end @sprites["pokemon#{i}"].text = annotations[i] if annotations end @@ -530,11 +530,11 @@ class PokemonParty_Scene @sprites["messagebox"].text = text @sprites["messagebox"].visible = true @sprites["helpwindow"].visible = false - using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])) { + using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { cmdwindow.visible = false pbBottomRight(cmdwindow) cmdwindow.y -= @sprites["messagebox"].height - cmdwindow.z = @viewport.z+1 + cmdwindow.z = @viewport.z + 1 loop do Graphics.update Input.update @@ -546,7 +546,7 @@ class PokemonParty_Scene ret = false break elsif Input.trigger?(Input::USE) && @sprites["messagebox"].resume - ret = (cmdwindow.index==0) + ret = (cmdwindow.index == 0) break end end @@ -557,15 +557,15 @@ class PokemonParty_Scene return ret end - def pbShowCommands(helptext,commands,index = 0) + def pbShowCommands(helptext, commands, index = 0) ret = -1 helpwindow = @sprites["helpwindow"] helpwindow.visible = true using(cmdwindow = Window_CommandPokemonColor.new(commands)) { - cmdwindow.z = @viewport.z+1 + cmdwindow.z = @viewport.z + 1 cmdwindow.index = index pbBottomRight(cmdwindow) - helpwindow.resizeHeightToFit(helptext,Graphics.width-cmdwindow.width) + helpwindow.resizeHeightToFit(helptext, Graphics.width - cmdwindow.width) helpwindow.text = helptext pbBottomLeft(helpwindow) loop do @@ -593,14 +593,14 @@ class PokemonParty_Scene def pbSetHelpText(helptext) helpwindow = @sprites["helpwindow"] - pbBottomLeftLines(helpwindow,1) + pbBottomLeftLines(helpwindow, 1) helpwindow.text = helptext helpwindow.width = 398 helpwindow.visible = true end def pbHasAnnotations? - return @sprites["pokemon0"].text!=nil + return @sprites["pokemon0"].text != nil end def pbAnnotate(annot) @@ -613,7 +613,7 @@ class PokemonParty_Scene @activecmd = item numsprites = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 2 : 1) for i in 0...numsprites - @sprites["pokemon#{i}"].selected = (i==@activecmd) + @sprites["pokemon#{i}"].selected = (i == @activecmd) end end @@ -621,32 +621,32 @@ class PokemonParty_Scene @activecmd = item end - def pbSwitchBegin(oldid,newid) + def pbSwitchBegin(oldid, newid) pbSEPlay("GUI party switch") oldsprite = @sprites["pokemon#{oldid}"] newsprite = @sprites["pokemon#{newid}"] - timeTaken = Graphics.frame_rate*4/10 - distancePerFrame = (Graphics.width/(2.0*timeTaken)).ceil + timeTaken = Graphics.frame_rate * 4 / 10 + distancePerFrame = (Graphics.width / (2.0 * timeTaken)).ceil timeTaken.times do - oldsprite.x += (oldid&1)==0 ? -distancePerFrame : distancePerFrame - newsprite.x += (newid&1)==0 ? -distancePerFrame : distancePerFrame + oldsprite.x += (oldid & 1) == 0 ? -distancePerFrame : distancePerFrame + newsprite.x += (newid & 1) == 0 ? -distancePerFrame : distancePerFrame Graphics.update Input.update self.update end end - def pbSwitchEnd(oldid,newid) + def pbSwitchEnd(oldid, newid) pbSEPlay("GUI party switch") oldsprite = @sprites["pokemon#{oldid}"] newsprite = @sprites["pokemon#{newid}"] oldsprite.pokemon = @party[oldid] newsprite.pokemon = @party[newid] - timeTaken = Graphics.frame_rate*4/10 - distancePerFrame = (Graphics.width/(2.0*timeTaken)).ceil + timeTaken = Graphics.frame_rate * 4 / 10 + distancePerFrame = (Graphics.width / (2.0 * timeTaken)).ceil timeTaken.times do - oldsprite.x -= (oldid&1)==0 ? -distancePerFrame : distancePerFrame - newsprite.x -= (newid&1)==0 ? -distancePerFrame : distancePerFrame + oldsprite.x -= (oldid & 1) == 0 ? -distancePerFrame : distancePerFrame + newsprite.x -= (newid & 1) == 0 ? -distancePerFrame : distancePerFrame Graphics.update Input.update self.update @@ -665,31 +665,31 @@ class PokemonParty_Scene end end - def pbSummary(pkmnid,inbattle = false) + def pbSummary(pkmnid, inbattle = false) oldsprites = pbFadeOutAndHide(@sprites) scene = PokemonSummary_Scene.new - screen = PokemonSummaryScreen.new(scene,inbattle) - screen.pbStartScreen(@party,pkmnid) + screen = PokemonSummaryScreen.new(scene, inbattle) + screen.pbStartScreen(@party, pkmnid) yield if block_given? - pbFadeInAndShow(@sprites,oldsprites) + pbFadeInAndShow(@sprites, oldsprites) end def pbChooseItem(bag) ret = nil pbFadeOutIn { scene = PokemonBag_Scene.new - screen = PokemonBagScreen.new(scene,bag) + screen = PokemonBagScreen.new(scene, bag) ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? }) yield if block_given? } return ret end - def pbUseItem(bag,pokemon) + def pbUseItem(bag, pokemon) ret = nil pbFadeOutIn { scene = PokemonBag_Scene.new - screen = PokemonBagScreen.new(scene,bag) + screen = PokemonBagScreen.new(scene, bag) ret = screen.pbChooseItemScreen(Proc.new { |item| itm = GameData::Item.get(item) next false if !pbCanUseOnPokemon?(itm) @@ -704,12 +704,12 @@ class PokemonParty_Scene return ret end - def pbChoosePokemon(switching = false,initialsel = -1,canswitch = 0) + def pbChoosePokemon(switching = false, initialsel = -1, canswitch = 0) for i in 0...Settings::MAX_PARTY_SIZE - @sprites["pokemon#{i}"].preselected = (switching && i==@activecmd) + @sprites["pokemon#{i}"].preselected = (switching && i == @activecmd) @sprites["pokemon#{i}"].switching = switching end - @activecmd = initialsel if initialsel>=0 + @activecmd = initialsel if initialsel >= 0 pbRefresh loop do Graphics.update @@ -721,14 +721,14 @@ class PokemonParty_Scene key = Input::RIGHT if Input.repeat?(Input::RIGHT) key = Input::LEFT if Input.repeat?(Input::LEFT) key = Input::UP if Input.repeat?(Input::UP) - if key>=0 - @activecmd = pbChangeSelection(key,@activecmd) + if key >= 0 + @activecmd = pbChangeSelection(key, @activecmd) end - if @activecmd!=oldsel # Changing selection + if @activecmd != oldsel # Changing selection pbPlayCursorSE numsprites = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 2 : 1) for i in 0...numsprites - @sprites["pokemon#{i}"].selected = (i==@activecmd) + @sprites["pokemon#{i}"].selected = (i == @activecmd) end end cancelsprite = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 1 : 0) @@ -740,16 +740,16 @@ class PokemonParty_Scene screen.pbStartScreen(0) pbHardRefresh } - elsif Input.trigger?(Input::ACTION) && canswitch==1 && @activecmd!=cancelsprite + elsif Input.trigger?(Input::ACTION) && canswitch == 1 && @activecmd != cancelsprite pbPlayDecisionSE - return [1,@activecmd] - elsif Input.trigger?(Input::ACTION) && canswitch==2 + return [1, @activecmd] + elsif Input.trigger?(Input::ACTION) && canswitch == 2 return -1 elsif Input.trigger?(Input::BACK) pbPlayCloseMenuSE if !switching return -1 elsif Input.trigger?(Input::USE) - if @activecmd==cancelsprite + if @activecmd == cancelsprite (switching) ? pbPlayDecisionSE : pbPlayCloseMenuSE return -1 else @@ -760,7 +760,7 @@ class PokemonParty_Scene end end - def pbChangeSelection(key,currentsel) + def pbChangeSelection(key, currentsel) numsprites = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 2 : 1) case key when Input::LEFT @@ -792,7 +792,7 @@ class PokemonParty_Scene end while currentsel > 0 && !@party[currentsel] end if currentsel >= @party.length && currentsel < Settings::MAX_PARTY_SIZE - currentsel = @party.length-1 + currentsel = @party.length - 1 end currentsel = numsprites - 1 if currentsel < 0 when Input::DOWN @@ -819,13 +819,13 @@ class PokemonParty_Scene lastselected = i if @sprites["pokemon#{i}"].selected @sprites["pokemon#{i}"].dispose end - lastselected = @party.length-1 if lastselected>=@party.length - lastselected = 0 if lastselected<0 + lastselected = @party.length - 1 if lastselected >= @party.length + lastselected = 0 if lastselected < 0 for i in 0...Settings::MAX_PARTY_SIZE if @party[i] - @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i],i,@viewport) + @sprites["pokemon#{i}"] = PokemonPartyPanel.new(@party[i], i, @viewport) else - @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i],i,@viewport) + @sprites["pokemon#{i}"] = PokemonPartyBlankPanel.new(@party[i], i, @viewport) end @sprites["pokemon#{i}"].text = oldtext[i] end @@ -868,13 +868,13 @@ class PokemonPartyScreen attr_reader :scene attr_reader :party - def initialize(scene,party) + def initialize(scene, party) @scene = scene @party = party end - def pbStartScene(helptext,_numBattlersOut,annotations = nil) - @scene.pbStartScene(@party,helptext,annotations) + def pbStartScene(helptext, _numBattlersOut, annotations = nil) + @scene.pbStartScene(@party, helptext, annotations) end def pbChoosePokemon(helptext = nil) @@ -883,11 +883,11 @@ class PokemonPartyScreen end def pbPokemonGiveScreen(item) - @scene.pbStartScene(@party,_INTL("Give to which Pokémon?")) + @scene.pbStartScene(@party, _INTL("Give to which Pokémon?")) pkmnid = @scene.pbChoosePokemon ret = false - if pkmnid>=0 - ret = pbGiveItemToPokemon(item,@party[pkmnid],self,pkmnid) + if pkmnid >= 0 + ret = pbGiveItemToPokemon(item, @party[pkmnid], self, pkmnid) end pbRefreshSingle(pkmnid) @scene.pbEndScene @@ -895,9 +895,9 @@ class PokemonPartyScreen end def pbPokemonGiveMailScreen(mailIndex) - @scene.pbStartScene(@party,_INTL("Give to which Pokémon?")) + @scene.pbStartScene(@party, _INTL("Give to which Pokémon?")) pkmnid = @scene.pbChoosePokemon - if pkmnid>=0 + if pkmnid >= 0 pkmn = @party[pkmnid] if pkmn.hasItem? || pkmn.mail pbDisplay(_INTL("This Pokémon is holding an item. It can't hold mail.")) @@ -942,15 +942,15 @@ class PokemonPartyScreen return @scene.pbDisplayConfirm(text) end - def pbShowCommands(helptext,commands,index = 0) - return @scene.pbShowCommands(helptext,commands,index) + def pbShowCommands(helptext, commands, index = 0) + return @scene.pbShowCommands(helptext, commands, index) end # Checks for identical species def pbCheckSpecies(array) # Unused for i in 0...array.length - for j in i+1...array.length - return false if array[i].species==array[j].species + for j in i + 1...array.length + return false if array[i].species == array[j].species end end return true @@ -960,34 +960,34 @@ class PokemonPartyScreen def pbCheckItems(array) # Unused for i in 0...array.length next if !array[i].hasItem? - for j in i+1...array.length - return false if array[i].item==array[j].item + for j in i + 1...array.length + return false if array[i].item == array[j].item end end return true end - def pbSwitch(oldid,newid) - if oldid!=newid - @scene.pbSwitchBegin(oldid,newid) + def pbSwitch(oldid, newid) + if oldid != newid + @scene.pbSwitchBegin(oldid, newid) tmp = @party[oldid] @party[oldid] = @party[newid] @party[newid] = tmp - @scene.pbSwitchEnd(oldid,newid) + @scene.pbSwitchEnd(oldid, newid) end end - def pbChooseMove(pokemon,helptext,index = 0) + def pbChooseMove(pokemon, helptext, index = 0) movenames = [] for i in pokemon.moves next if !i || !i.id - if i.total_pp<=0 - movenames.push(_INTL("{1} (PP: ---)",i.name)) + if i.total_pp <= 0 + movenames.push(_INTL("{1} (PP: ---)", i.name)) else - movenames.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp)) + movenames.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp)) end end - return @scene.pbShowCommands(helptext,movenames,index) + return @scene.pbShowCommands(helptext, movenames, index) end def pbRefreshAnnotations(ableProc) # For after using an evolution stone @@ -1027,25 +1027,25 @@ class PokemonPartyScreen for i in 0...@party.length annot[i] = ordinals[statuses[i]] end - @scene.pbStartScene(@party,_INTL("Choose Pokémon and confirm."),annot,true) + @scene.pbStartScene(@party, _INTL("Choose Pokémon and confirm."), annot, true) loop do realorder = [] for i in 0...@party.length for j in 0...@party.length - if statuses[j]==i+3 + if statuses[j] == i + 3 realorder.push(j) break end end end for i in 0...realorder.length - statuses[realorder[i]] = i+3 + statuses[realorder[i]] = i + 3 end for i in 0...@party.length annot[i] = ordinals[statuses[i]] end @scene.pbAnnotate(annot) - if realorder.length==ruleset.number && addedEntry + if realorder.length == ruleset.number && addedEntry @scene.pbSelect(Settings::MAX_PARTY_SIZE) end @scene.pbSetHelpText(_INTL("Choose Pokémon and confirm.")) @@ -1057,11 +1057,11 @@ class PokemonPartyScreen ret.push(@party[i]) end error = [] - break if ruleset.isValid?(ret,error) + break if ruleset.isValid?(ret, error) pbDisplay(error[0]) ret = nil end - break if pkmnid<0 # Cancelled + break if pkmnid < 0 # Cancelled cmdEntry = -1 cmdNoEntry = -1 cmdSummary = -1 @@ -1074,21 +1074,21 @@ class PokemonPartyScreen pkmn = @party[pkmnid] commands[cmdSummary = commands.length] = _INTL("Summary") commands[commands.length] = _INTL("Cancel") - command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands) if pkmn - if cmdEntry>=0 && command==cmdEntry - if realorder.length>=ruleset.number && ruleset.number>0 - pbDisplay(_INTL("No more than {1} Pokémon may enter.",ruleset.number)) + command = @scene.pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands) if pkmn + if cmdEntry >= 0 && command == cmdEntry + if realorder.length >= ruleset.number && ruleset.number > 0 + pbDisplay(_INTL("No more than {1} Pokémon may enter.", ruleset.number)) else - statuses[pkmnid] = realorder.length+3 + statuses[pkmnid] = realorder.length + 3 addedEntry = true pbRefreshSingle(pkmnid) end - elsif cmdNoEntry>=0 && command==cmdNoEntry + elsif cmdNoEntry >= 0 && command == cmdNoEntry statuses[pkmnid] = 1 pbRefreshSingle(pkmnid) - elsif cmdSummary>=0 && command==cmdSummary + elsif cmdSummary >= 0 && command == cmdSummary @scene.pbSummary(pkmnid) { - @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) } end end @@ -1096,7 +1096,7 @@ class PokemonPartyScreen return ret end - def pbChooseAblePokemon(ableProc,allowIneligible = false) + def pbChooseAblePokemon(ableProc, allowIneligible = false) annot = [] eligibility = [] for pkmn in @party @@ -1106,12 +1106,12 @@ class PokemonPartyScreen end ret = -1 @scene.pbStartScene(@party, - (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),annot) + (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."), annot) loop do @scene.pbSetHelpText( - (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) pkmnid = @scene.pbChoosePokemon - break if pkmnid<0 + break if pkmnid < 0 if !eligibility[pkmnid] && !allowIneligible pbDisplay(_INTL("This Pokémon can't be chosen.")) else @@ -1123,7 +1123,7 @@ class PokemonPartyScreen return ret end - def pbChooseTradablePokemon(ableProc,allowIneligible = false) + def pbChooseTradablePokemon(ableProc, allowIneligible = false) annot = [] eligibility = [] for pkmn in @party @@ -1134,12 +1134,12 @@ class PokemonPartyScreen end ret = -1 @scene.pbStartScene(@party, - (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."),annot) + (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."), annot) loop do @scene.pbSetHelpText( - (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) pkmnid = @scene.pbChoosePokemon - break if pkmnid<0 + break if pkmnid < 0 if !eligibility[pkmnid] && !allowIneligible pbDisplay(_INTL("This Pokémon can't be chosen.")) else @@ -1163,15 +1163,15 @@ class PokemonPartyScreen (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."), nil, false, can_access_storage) loop do - @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) - pkmnid = @scene.pbChoosePokemon(false,-1,1) - break if (pkmnid.is_a?(Numeric) && pkmnid<0) || (pkmnid.is_a?(Array) && pkmnid[1]<0) - if pkmnid.is_a?(Array) && pkmnid[0]==1 # Switch + @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + pkmnid = @scene.pbChoosePokemon(false, -1, 1) + break if (pkmnid.is_a?(Numeric) && pkmnid < 0) || (pkmnid.is_a?(Array) && pkmnid[1] < 0) + if pkmnid.is_a?(Array) && pkmnid[0] == 1 # Switch @scene.pbSetHelpText(_INTL("Move to where?")) oldpkmnid = pkmnid[1] - pkmnid = @scene.pbChoosePokemon(true,-1,2) - if pkmnid>=0 && pkmnid!=oldpkmnid - pbSwitch(oldpkmnid,pkmnid) + pkmnid = @scene.pbChoosePokemon(true, -1, 2) + if pkmnid >= 0 && pkmnid != oldpkmnid + pbSwitch(oldpkmnid, pkmnid) end next end @@ -1195,7 +1195,7 @@ class PokemonPartyScreen end end end - commands[cmdSwitch = commands.length] = _INTL("Switch") if @party.length>1 + commands[cmdSwitch = commands.length] = _INTL("Switch") if @party.length > 1 if !pkmn.egg? if pkmn.mail commands[cmdMail = commands.length] = _INTL("Mail") @@ -1203,15 +1203,15 @@ class PokemonPartyScreen commands[cmdItem = commands.length] = _INTL("Item") end end - commands[commands.length] = _INTL("Cancel") - command = @scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands) + commands[commands.length] = _INTL("Cancel") + command = @scene.pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands) havecommand = false cmdMoves.each_with_index do |cmd, i| next if cmd < 0 || cmd != command havecommand = true if [:MILKDRINK, :SOFTBOILED].include?(pkmn.moves[i].id) - amt = [(pkmn.totalhp/5).floor,1].max - if pkmn.hp<=amt + amt = [(pkmn.totalhp / 5).floor, 1].max + if pkmn.hp <= amt pbDisplay(_INTL("Not enough HP...")) break end @@ -1219,120 +1219,120 @@ class PokemonPartyScreen oldpkmnid = pkmnid loop do @scene.pbPreSelect(oldpkmnid) - pkmnid = @scene.pbChoosePokemon(true,pkmnid) - break if pkmnid<0 + pkmnid = @scene.pbChoosePokemon(true, pkmnid) + break if pkmnid < 0 newpkmn = @party[pkmnid] movename = pkmn.moves[i].name - if pkmnid==oldpkmnid - pbDisplay(_INTL("{1} can't use {2} on itself!",pkmn.name,movename)) + if pkmnid == oldpkmnid + pbDisplay(_INTL("{1} can't use {2} on itself!", pkmn.name, movename)) elsif newpkmn.egg? - pbDisplay(_INTL("{1} can't be used on an Egg!",movename)) - elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp - pbDisplay(_INTL("{1} can't be used on that Pokémon.",movename)) + pbDisplay(_INTL("{1} can't be used on an Egg!", movename)) + elsif newpkmn.hp == 0 || newpkmn.hp == newpkmn.totalhp + pbDisplay(_INTL("{1} can't be used on that Pokémon.", movename)) else pkmn.hp -= amt - hpgain = pbItemRestoreHP(newpkmn,amt) - @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain)) + hpgain = pbItemRestoreHP(newpkmn, amt) + @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.", newpkmn.name, hpgain)) pbRefresh end - break if pkmn.hp<=amt + break if pkmn.hp <= amt end @scene.pbSelect(oldpkmnid) pbRefresh break - elsif pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id) - if pbConfirmUseHiddenMove(pkmn,pkmn.moves[i].id) + elsif pbCanUseHiddenMove?(pkmn, pkmn.moves[i].id) + if pbConfirmUseHiddenMove(pkmn, pkmn.moves[i].id) @scene.pbEndScene if pkmn.moves[i].id == :FLY - scene = PokemonRegionMap_Scene.new(-1,false) + scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) ret = screen.pbStartFlyScreen if ret $game_temp.fly_destination = ret - return [pkmn,pkmn.moves[i].id] + return [pkmn, pkmn.moves[i].id] end @scene.pbStartScene(@party, - (@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + (@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) break end - return [pkmn,pkmn.moves[i].id] + return [pkmn, pkmn.moves[i].id] end end end next if havecommand - if cmdSummary>=0 && command==cmdSummary + if cmdSummary >= 0 && command == cmdSummary @scene.pbSummary(pkmnid) { - @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) } - elsif cmdDebug>=0 && command==cmdDebug - pbPokemonDebug(pkmn,pkmnid) - elsif cmdSwitch>=0 && command==cmdSwitch + elsif cmdDebug >= 0 && command == cmdDebug + pbPokemonDebug(pkmn, pkmnid) + elsif cmdSwitch >= 0 && command == cmdSwitch @scene.pbSetHelpText(_INTL("Move to where?")) oldpkmnid = pkmnid pkmnid = @scene.pbChoosePokemon(true) - if pkmnid>=0 && pkmnid!=oldpkmnid - pbSwitch(oldpkmnid,pkmnid) + if pkmnid >= 0 && pkmnid != oldpkmnid + pbSwitch(oldpkmnid, pkmnid) end - elsif cmdMail>=0 && command==cmdMail + elsif cmdMail >= 0 && command == cmdMail command = @scene.pbShowCommands(_INTL("Do what with the mail?"), - [_INTL("Read"),_INTL("Take"),_INTL("Cancel")]) + [_INTL("Read"), _INTL("Take"), _INTL("Cancel")]) case command when 0 # Read pbFadeOutIn { - pbDisplayMail(pkmn.mail,pkmn) - @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + pbDisplayMail(pkmn.mail, pkmn) + @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) } when 1 # Take - if pbTakeItemFromPokemon(pkmn,self) + if pbTakeItemFromPokemon(pkmn, self) pbRefreshSingle(pkmnid) end end - elsif cmdItem>=0 && command==cmdItem + elsif cmdItem >= 0 && command == cmdItem itemcommands = [] cmdUseItem = -1 cmdGiveItem = -1 cmdTakeItem = -1 cmdMoveItem = -1 # Build the commands - itemcommands[cmdUseItem=itemcommands.length] = _INTL("Use") - itemcommands[cmdGiveItem=itemcommands.length] = _INTL("Give") - itemcommands[cmdTakeItem=itemcommands.length] = _INTL("Take") if pkmn.hasItem? - itemcommands[cmdMoveItem=itemcommands.length] = _INTL("Move") if pkmn.hasItem? && - !GameData::Item.get(pkmn.item).is_mail? - itemcommands[itemcommands.length] = _INTL("Cancel") - command = @scene.pbShowCommands(_INTL("Do what with an item?"),itemcommands) - if cmdUseItem>=0 && command==cmdUseItem # Use - item = @scene.pbUseItem($bag,pkmn) { - @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + itemcommands[cmdUseItem = itemcommands.length] = _INTL("Use") + itemcommands[cmdGiveItem = itemcommands.length] = _INTL("Give") + itemcommands[cmdTakeItem = itemcommands.length] = _INTL("Take") if pkmn.hasItem? + itemcommands[cmdMoveItem = itemcommands.length] = _INTL("Move") if pkmn.hasItem? && + !GameData::Item.get(pkmn.item).is_mail? + itemcommands[itemcommands.length] = _INTL("Cancel") + command = @scene.pbShowCommands(_INTL("Do what with an item?"), itemcommands) + if cmdUseItem >= 0 && command == cmdUseItem # Use + item = @scene.pbUseItem($bag, pkmn) { + @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) } if item - pbUseItemOnPokemon(item,pkmn,self) + pbUseItemOnPokemon(item, pkmn, self) pbRefreshSingle(pkmnid) end - elsif cmdGiveItem>=0 && command==cmdGiveItem # Give + elsif cmdGiveItem >= 0 && command == cmdGiveItem # Give item = @scene.pbChooseItem($bag) { - @scene.pbSetHelpText((@party.length>1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) + @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) } if item - if pbGiveItemToPokemon(item,pkmn,self,pkmnid) + if pbGiveItemToPokemon(item, pkmn, self, pkmnid) pbRefreshSingle(pkmnid) end end - elsif cmdTakeItem>=0 && command==cmdTakeItem # Take - if pbTakeItemFromPokemon(pkmn,self) + elsif cmdTakeItem >= 0 && command == cmdTakeItem # Take + if pbTakeItemFromPokemon(pkmn, self) pbRefreshSingle(pkmnid) end - elsif cmdMoveItem>=0 && command==cmdMoveItem # Move + elsif cmdMoveItem >= 0 && command == cmdMoveItem # Move item = pkmn.item itemname = item.name - @scene.pbSetHelpText(_INTL("Move {1} to where?",itemname)) + @scene.pbSetHelpText(_INTL("Move {1} to where?", itemname)) oldpkmnid = pkmnid loop do @scene.pbPreSelect(oldpkmnid) - pkmnid = @scene.pbChoosePokemon(true,pkmnid) - break if pkmnid<0 + pkmnid = @scene.pbChoosePokemon(true, pkmnid) + break if pkmnid < 0 newpkmn = @party[pkmnid] - break if pkmnid==oldpkmnid + break if pkmnid == oldpkmnid if newpkmn.egg? pbDisplay(_INTL("Eggs can't hold items.")) elsif !newpkmn.hasItem? @@ -1340,27 +1340,27 @@ class PokemonPartyScreen pkmn.item = nil @scene.pbClearSwitching pbRefresh - pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname)) + pbDisplay(_INTL("{1} was given the {2} to hold.", newpkmn.name, itemname)) break elsif GameData::Item.get(newpkmn.item).is_mail? - pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.",newpkmn.name)) + pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.", newpkmn.name)) else newitem = newpkmn.item newitemname = newitem.name if newitem == :LEFTOVERS - pbDisplay(_INTL("{1} is already holding some {2}.\1",newpkmn.name,newitemname)) + pbDisplay(_INTL("{1} is already holding some {2}.\1", newpkmn.name, newitemname)) elsif newitemname.starts_with_vowel? - pbDisplay(_INTL("{1} is already holding an {2}.\1",newpkmn.name,newitemname)) + pbDisplay(_INTL("{1} is already holding an {2}.\1", newpkmn.name, newitemname)) else - pbDisplay(_INTL("{1} is already holding a {2}.\1",newpkmn.name,newitemname)) + pbDisplay(_INTL("{1} is already holding a {2}.\1", newpkmn.name, newitemname)) end if pbConfirm(_INTL("Would you like to switch the two items?")) newpkmn.item = item pkmn.item = newitem @scene.pbClearSwitching pbRefresh - pbDisplay(_INTL("{1} was given the {2} to hold.",newpkmn.name,itemname)) - pbDisplay(_INTL("{1} was given the {2} to hold.",pkmn.name,newitemname)) + pbDisplay(_INTL("{1} was given the {2} to hold.", newpkmn.name, itemname)) + pbDisplay(_INTL("{1} was given the {2} to hold.", pkmn.name, newitemname)) break end end @@ -1390,60 +1390,60 @@ end # Choose a Pokémon/egg from the party. # Stores result in variable _variableNumber_ and the chosen Pokémon's name in # variable _nameVarNumber_; result is -1 if no Pokémon was chosen -def pbChoosePokemon(variableNumber,nameVarNumber,ableProc = nil,allowIneligible = false) +def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false) chosen = 0 pbFadeOutIn { scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) if ableProc - chosen=screen.pbChooseAblePokemon(ableProc,allowIneligible) + chosen = screen.pbChooseAblePokemon(ableProc, allowIneligible) else - screen.pbStartScene(_INTL("Choose a Pokémon."),false) + screen.pbStartScene(_INTL("Choose a Pokémon."), false) chosen = screen.pbChoosePokemon screen.pbEndScene end } pbSet(variableNumber, chosen) - if chosen>=0 + if chosen >= 0 pbSet(nameVarNumber, $player.party[chosen].name) else pbSet(nameVarNumber, "") end end -def pbChooseNonEggPokemon(variableNumber,nameVarNumber) - pbChoosePokemon(variableNumber,nameVarNumber,proc { |pkmn| !pkmn.egg? }) +def pbChooseNonEggPokemon(variableNumber, nameVarNumber) + pbChoosePokemon(variableNumber, nameVarNumber, proc { |pkmn| !pkmn.egg? }) end -def pbChooseAblePokemon(variableNumber,nameVarNumber) - pbChoosePokemon(variableNumber,nameVarNumber,proc { |pkmn| !pkmn.egg? && pkmn.hp>0 }) +def pbChooseAblePokemon(variableNumber, nameVarNumber) + pbChoosePokemon(variableNumber, nameVarNumber, proc { |pkmn| !pkmn.egg? && pkmn.hp > 0 }) end # Same as pbChoosePokemon, but prevents choosing an egg or a Shadow Pokémon. -def pbChooseTradablePokemon(variableNumber,nameVarNumber,ableProc = nil,allowIneligible = false) +def pbChooseTradablePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false) chosen = 0 pbFadeOutIn { scene = PokemonParty_Scene.new screen = PokemonPartyScreen.new(scene, $player.party) if ableProc - chosen=screen.pbChooseTradablePokemon(ableProc,allowIneligible) + chosen = screen.pbChooseTradablePokemon(ableProc, allowIneligible) else - screen.pbStartScene(_INTL("Choose a Pokémon."),false) + screen.pbStartScene(_INTL("Choose a Pokémon."), false) chosen = screen.pbChoosePokemon screen.pbEndScene end } pbSet(variableNumber, chosen) - if chosen>=0 + if chosen >= 0 pbSet(nameVarNumber, $player.party[chosen].name) else pbSet(nameVarNumber, "") end end -def pbChoosePokemonForTrade(variableNumber,nameVarNumber,wanted) +def pbChoosePokemonForTrade(variableNumber, nameVarNumber, wanted) wanted = GameData::Species.get(wanted).species - pbChooseTradablePokemon(variableNumber,nameVarNumber,proc { |pkmn| - next pkmn.species==wanted + pbChooseTradablePokemon(variableNumber, nameVarNumber, proc { |pkmn| + next pkmn.species == wanted }) end diff --git a/Data/Scripts/016_UI/006_UI_Summary.rb b/Data/Scripts/016_UI/006_UI_Summary.rb index 9d8a482b6..31e513d61 100644 --- a/Data/Scripts/016_UI/006_UI_Summary.rb +++ b/Data/Scripts/016_UI/006_UI_Summary.rb @@ -5,7 +5,7 @@ class MoveSelectionSprite < SpriteWrapper attr_reader :preselected attr_reader :index - def initialize(viewport = nil,fifthmove = false) + def initialize(viewport = nil, fifthmove = false) super(viewport) @movesel = AnimatedBitmap.new("Graphics/Pictures/Summary/cursor_move") @frame = 0 @@ -33,16 +33,16 @@ class MoveSelectionSprite < SpriteWrapper def refresh w = @movesel.width - h = @movesel.height/2 + h = @movesel.height / 2 self.x = 240 - self.y = 92+(self.index*64) + self.y = 92 + (self.index * 64) self.y -= 76 if @fifthmove - self.y += 20 if @fifthmove && self.index==Pokemon::MAX_MOVES # Add a gap + self.y += 20 if @fifthmove && self.index == Pokemon::MAX_MOVES # Add a gap self.bitmap = @movesel.bitmap if self.preselected - self.src_rect.set(0,h,w,h) + self.src_rect.set(0, h, w, h) else - self.src_rect.set(0,0,w,h) + self.src_rect.set(0, 0, w, h) end end @@ -77,21 +77,21 @@ class RibbonSelectionSprite < MoveSelectionSprite def refresh w = @movesel.width - h = @movesel.height/2 - self.x = 228+(self.index%4)*68 - self.y = 76+((self.index/4).floor*68) + h = @movesel.height / 2 + self.x = 228 + (self.index % 4) * 68 + self.y = 76 + ((self.index / 4).floor * 68) self.bitmap = @movesel.bitmap if self.preselected - self.src_rect.set(0,h,w,h) + self.src_rect.set(0, h, w, h) else - self.src_rect.set(0,0,w,h) + self.src_rect.set(0, 0, w, h) end end def update @updating = true super - self.visible = @spriteVisible && @index>=0 && @index<12 + self.visible = @spriteVisible && @index >= 0 && @index < 12 @movesel.update @updating = false refresh @@ -109,8 +109,8 @@ class PokemonSummary_Scene pbUpdateSpriteHash(@sprites) end - def pbStartScene(party,partyindex,inbattle = false) - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + def pbStartScene(party, partyindex, inbattle = false) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @party = party @partyindex = partyindex @@ -120,20 +120,20 @@ class PokemonSummary_Scene @typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) @markingbitmap = AnimatedBitmap.new("Graphics/Pictures/Summary/markings") @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) @sprites["pokemon"] = PokemonSprite.new(@viewport) @sprites["pokemon"].setOffset(PictureOrigin::Center) @sprites["pokemon"].x = 104 @sprites["pokemon"].y = 206 @sprites["pokemon"].setPokemonBitmap(@pokemon) - @sprites["pokeicon"] = PokemonIconSprite.new(@pokemon,@viewport) + @sprites["pokeicon"] = PokemonIconSprite.new(@pokemon, @viewport) @sprites["pokeicon"].setOffset(PictureOrigin::Center) @sprites["pokeicon"].x = 46 @sprites["pokeicon"].y = 92 @sprites["pokeicon"].visible = false - @sprites["itemicon"] = ItemIconSprite.new(30,320,@pokemon.item_id,@viewport) + @sprites["itemicon"] = ItemIconSprite.new(30, 320, @pokemon.item_id, @viewport) @sprites["itemicon"].blankzero = true - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) @sprites["movepresel"] = MoveSelectionSprite.new(@viewport) @sprites["movepresel"].visible = false @@ -145,39 +145,39 @@ class PokemonSummary_Scene @sprites["ribbonpresel"].preselected = true @sprites["ribbonsel"] = RibbonSelectionSprite.new(@viewport) @sprites["ribbonsel"].visible = false - @sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow",8,28,40,2,@viewport) + @sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow", 8, 28, 40, 2, @viewport) @sprites["uparrow"].x = 350 @sprites["uparrow"].y = 56 @sprites["uparrow"].play @sprites["uparrow"].visible = false - @sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow",8,28,40,2,@viewport) + @sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow", 8, 28, 40, 2, @viewport) @sprites["downarrow"].x = 350 @sprites["downarrow"].y = 260 @sprites["downarrow"].play @sprites["downarrow"].visible = false - @sprites["markingbg"] = IconSprite.new(260,88,@viewport) + @sprites["markingbg"] = IconSprite.new(260, 88, @viewport) @sprites["markingbg"].setBitmap("Graphics/Pictures/Summary/overlay_marking") @sprites["markingbg"].visible = false - @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) @sprites["markingoverlay"].visible = false pbSetSystemFont(@sprites["markingoverlay"].bitmap) - @sprites["markingsel"] = IconSprite.new(0,0,@viewport) + @sprites["markingsel"] = IconSprite.new(0, 0, @viewport) @sprites["markingsel"].setBitmap("Graphics/Pictures/Summary/cursor_marking") - @sprites["markingsel"].src_rect.height = @sprites["markingsel"].bitmap.height/2 + @sprites["markingsel"].src_rect.height = @sprites["markingsel"].bitmap.height / 2 @sprites["markingsel"].visible = false @sprites["messagebox"] = Window_AdvancedTextPokemon.new("") @sprites["messagebox"].viewport = @viewport @sprites["messagebox"].visible = false @sprites["messagebox"].letterbyletter = true - pbBottomLeftLines(@sprites["messagebox"],2) + pbBottomLeftLines(@sprites["messagebox"], 2) @nationalDexList = [:NONE] GameData::Species.each_species { |s| @nationalDexList.push(s.species) } drawPage(@page) pbFadeInAndShow(@sprites) { pbUpdate } end - def pbStartForgetScene(party,partyindex,move_to_learn) - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + def pbStartForgetScene(party, partyindex, move_to_learn) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @party = party @partyindex = partyindex @@ -185,19 +185,19 @@ class PokemonSummary_Scene @page = 4 @typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) - @sprites["pokeicon"] = PokemonIconSprite.new(@pokemon,@viewport) + @sprites["pokeicon"] = PokemonIconSprite.new(@pokemon, @viewport) @sprites["pokeicon"].setOffset(PictureOrigin::Center) @sprites["pokeicon"].x = 46 @sprites["pokeicon"].y = 92 - @sprites["movesel"] = MoveSelectionSprite.new(@viewport,!move_to_learn.nil?) + @sprites["movesel"] = MoveSelectionSprite.new(@viewport, !move_to_learn.nil?) @sprites["movesel"].visible = false @sprites["movesel"].visible = true @sprites["movesel"].index = 0 new_move = (move_to_learn) ? Pokemon::Move.new(move_to_learn) : nil - drawSelectedMove(new_move,@pokemon.moves[0]) + drawSelectedMove(new_move, @pokemon.moves[0]) pbFadeInAndShow(@sprites) end @@ -233,8 +233,8 @@ class PokemonSummary_Scene ret = -1 @sprites["messagebox"].text = text @sprites["messagebox"].visible = true - using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])) { - cmdwindow.z = @viewport.z+1 + using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { + cmdwindow.z = @viewport.z + 1 cmdwindow.visible = false pbBottomRight(cmdwindow) cmdwindow.y -= @sprites["messagebox"].height @@ -249,7 +249,7 @@ class PokemonSummary_Scene ret = false break elsif Input.trigger?(Input::USE) && @sprites["messagebox"].resume - ret = (cmdwindow.index==0) + ret = (cmdwindow.index == 0) break end end @@ -259,10 +259,10 @@ class PokemonSummary_Scene return ret end - def pbShowCommands(commands,index = 0) + def pbShowCommands(commands, index = 0) ret = -1 using(cmdwindow = Window_CommandPokemon.new(commands)) { - cmdwindow.z = @viewport.z+1 + cmdwindow.z = @viewport.z + 1 cmdwindow.index = index pbBottomRight(cmdwindow) loop do @@ -284,7 +284,7 @@ class PokemonSummary_Scene return ret end - def drawMarkings(bitmap,x,y) + def drawMarkings(bitmap, x, y) mark_variants = @markingbitmap.bitmap.height / MARK_HEIGHT markings = @pokemon.markings markrect = Rect.new(0, 0, MARK_WIDTH, MARK_HEIGHT) @@ -303,14 +303,14 @@ class PokemonSummary_Scene @sprites["itemicon"].item = @pokemon.item_id overlay = @sprites["overlay"].bitmap overlay.clear - base = Color.new(248,248,248) - shadow = Color.new(104,104,104) + base = Color.new(248, 248, 248) + shadow = Color.new(104, 104, 104) # Set background image @sprites["background"].setBitmap("Graphics/Pictures/Summary/bg_#{page}") - imagepos=[] + imagepos = [] # Show the Poké Ball containing the Pokémon ballimage = sprintf("Graphics/Pictures/Summary/icon_ball_%s", @pokemon.poke_ball) - imagepos.push([ballimage,14,60]) + imagepos.push([ballimage, 14, 60]) # Show status/fainted/Pokérus infected icon status = -1 if @pokemon.fainted? @@ -321,46 +321,46 @@ class PokemonSummary_Scene status = GameData::Status.count + 1 end if status >= 0 - imagepos.push(["Graphics/Pictures/statuses",124,100,0,16*status,44,16]) + imagepos.push(["Graphics/Pictures/statuses", 124, 100, 0, 16 * status, 44, 16]) end # Show Pokérus cured icon - if @pokemon.pokerusStage==2 - imagepos.push([sprintf("Graphics/Pictures/Summary/icon_pokerus"),176,100]) + if @pokemon.pokerusStage == 2 + imagepos.push([sprintf("Graphics/Pictures/Summary/icon_pokerus"), 176, 100]) end # Show shininess star if @pokemon.shiny? - imagepos.push([sprintf("Graphics/Pictures/shiny"),2,134]) + imagepos.push([sprintf("Graphics/Pictures/shiny"), 2, 134]) end # Draw all images - pbDrawImagePositions(overlay,imagepos) + pbDrawImagePositions(overlay, imagepos) # Write various bits of text pagename = [_INTL("INFO"), _INTL("TRAINER MEMO"), _INTL("SKILLS"), _INTL("MOVES"), - _INTL("RIBBONS")][page-1] + _INTL("RIBBONS")][page - 1] textpos = [ - [pagename,26,10,0,base,shadow], - [@pokemon.name,46,56,0,base,shadow], - [@pokemon.level.to_s,46,86,0,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Item"),66,312,0,base,shadow] + [pagename, 26, 10, 0, base, shadow], + [@pokemon.name, 46, 56, 0, base, shadow], + [@pokemon.level.to_s, 46, 86, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Item"), 66, 312, 0, base, shadow] ] # Write the held item's name if @pokemon.hasItem? - textpos.push([@pokemon.item.name,16,346,0,Color.new(64,64,64),Color.new(176,176,176)]) + textpos.push([@pokemon.item.name, 16, 346, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)]) else - textpos.push([_INTL("None"),16,346,0,Color.new(192,200,208),Color.new(208,216,224)]) + textpos.push([_INTL("None"), 16, 346, 0, Color.new(192, 200, 208), Color.new(208, 216, 224)]) end # Write the gender symbol if @pokemon.male? - textpos.push([_INTL("♂"),178,56,0,Color.new(24,112,216),Color.new(136,168,208)]) + textpos.push([_INTL("♂"), 178, 56, 0, Color.new(24, 112, 216), Color.new(136, 168, 208)]) elsif @pokemon.female? - textpos.push([_INTL("♀"),178,56,0,Color.new(248,56,32),Color.new(224,152,144)]) + textpos.push([_INTL("♀"), 178, 56, 0, Color.new(248, 56, 32), Color.new(224, 152, 144)]) end # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) # Draw the Pokémon's markings - drawMarkings(overlay,84,292) + drawMarkings(overlay, 84, 292) # Draw page-specific information case page when 1 then drawPageOne @@ -373,27 +373,27 @@ class PokemonSummary_Scene def drawPageOne overlay = @sprites["overlay"].bitmap - base = Color.new(248,248,248) - shadow = Color.new(104,104,104) - dexNumBase = (@pokemon.shiny?) ? Color.new(248,56,32) : Color.new(64,64,64) - dexNumShadow = (@pokemon.shiny?) ? Color.new(224,152,144) : Color.new(176,176,176) + base = Color.new(248, 248, 248) + shadow = Color.new(104, 104, 104) + dexNumBase = (@pokemon.shiny?) ? Color.new(248, 56, 32) : Color.new(64, 64, 64) + dexNumShadow = (@pokemon.shiny?) ? Color.new(224, 152, 144) : Color.new(176, 176, 176) # If a Shadow Pokémon, draw the heart gauge area and bar if @pokemon.shadowPokemon? shadowfract = @pokemon.heart_gauge.to_f / @pokemon.max_gauge_size imagepos = [ - ["Graphics/Pictures/Summary/overlay_shadow",224,240], - ["Graphics/Pictures/Summary/overlay_shadowbar",242,280,0,0,(shadowfract*248).floor,-1] + ["Graphics/Pictures/Summary/overlay_shadow", 224, 240], + ["Graphics/Pictures/Summary/overlay_shadowbar", 242, 280, 0, 0, (shadowfract * 248).floor, -1] ] - pbDrawImagePositions(overlay,imagepos) + pbDrawImagePositions(overlay, imagepos) end # Write various bits of text textpos = [ - [_INTL("Dex No."),238,74,0,base,shadow], - [_INTL("Species"),238,106,0,base,shadow], - [@pokemon.speciesName,435,106,2,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Type"),238,138,0,base,shadow], - [_INTL("OT"),238,170,0,base,shadow], - [_INTL("ID No."),238,202,0,base,shadow], + [_INTL("Dex No."), 238, 74, 0, base, shadow], + [_INTL("Species"), 238, 106, 0, base, shadow], + [@pokemon.speciesName, 435, 106, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Type"), 238, 138, 0, base, shadow], + [_INTL("OT"), 238, 170, 0, base, shadow], + [_INTL("ID No."), 238, 202, 0, base, shadow], ] # Write the Regional/National Dex number dexnum = 0 @@ -404,26 +404,26 @@ class PokemonSummary_Scene else for i in 0...$player.pokedex.dexes_count - 1 next if !$player.pokedex.unlocked?(i) - num = pbGetRegionalNumber(i,@pokemon.species) - next if num<=0 + num = pbGetRegionalNumber(i, @pokemon.species) + next if num <= 0 dexnum = num dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(i) break end end - if dexnum<=0 - textpos.push(["???",435,74,2,dexNumBase,dexNumShadow]) + if dexnum <= 0 + textpos.push(["???", 435, 74, 2, dexNumBase, dexNumShadow]) else dexnum -= 1 if dexnumshift - textpos.push([sprintf("%03d",dexnum),435,74,2,dexNumBase,dexNumShadow]) + textpos.push([sprintf("%03d", dexnum), 435, 74, 2, dexNumBase, dexNumShadow]) end # Write Original Trainer's name and ID number if @pokemon.owner.name.empty? - textpos.push([_INTL("RENTAL"),435,170,2,Color.new(64,64,64),Color.new(176,176,176)]) - textpos.push(["?????",435,202,2,Color.new(64,64,64),Color.new(176,176,176)]) + textpos.push([_INTL("RENTAL"), 435, 170, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)]) + textpos.push(["?????", 435, 202, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)]) else - ownerbase = Color.new(64,64,64) - ownershadow = Color.new(176,176,176) + ownerbase = Color.new(64, 64, 64) + ownershadow = Color.new(176, 176, 176) case @pokemon.owner.gender when 0 ownerbase = Color.new(24, 112, 216) @@ -432,29 +432,29 @@ class PokemonSummary_Scene ownerbase = Color.new(248, 56, 32) ownershadow = Color.new(224, 152, 144) end - textpos.push([@pokemon.owner.name,435,170,2,ownerbase,ownershadow]) - textpos.push([sprintf("%05d",@pokemon.owner.public_id),435,202,2,Color.new(64,64,64),Color.new(176,176,176)]) + textpos.push([@pokemon.owner.name, 435, 170, 2, ownerbase, ownershadow]) + textpos.push([sprintf("%05d", @pokemon.owner.public_id), 435, 202, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)]) end # Write Exp text OR heart gauge message (if a Shadow Pokémon) if @pokemon.shadowPokemon? - textpos.push([_INTL("Heart Gauge"),238,234,0,base,shadow]) + textpos.push([_INTL("Heart Gauge"), 238, 234, 0, base, shadow]) heartmessage = [_INTL("The door to its heart is open! Undo the final lock!"), _INTL("The door to its heart is almost fully open."), _INTL("The door to its heart is nearly open."), _INTL("The door to its heart is opening wider."), _INTL("The door to its heart is opening up."), _INTL("The door to its heart is tightly shut.")][@pokemon.heartStage] - memo = sprintf("%s\n",heartmessage) - drawFormattedTextEx(overlay,234,304,264,memo) + memo = sprintf("%s\n", heartmessage) + drawFormattedTextEx(overlay, 234, 304, 264, memo) else endexp = @pokemon.growth_rate.minimum_exp_for_level(@pokemon.level + 1) - textpos.push([_INTL("Exp. Points"),238,234,0,base,shadow]) - textpos.push([@pokemon.exp.to_s_formatted,488,266,1,Color.new(64,64,64),Color.new(176,176,176)]) - textpos.push([_INTL("To Next Lv."),238,298,0,base,shadow]) - textpos.push([(endexp-@pokemon.exp).to_s_formatted,488,330,1,Color.new(64,64,64),Color.new(176,176,176)]) + textpos.push([_INTL("Exp. Points"), 238, 234, 0, base, shadow]) + textpos.push([@pokemon.exp.to_s_formatted, 488, 266, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)]) + textpos.push([_INTL("To Next Lv."), 238, 298, 0, base, shadow]) + textpos.push([(endexp - @pokemon.exp).to_s_formatted, 488, 330, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)]) end # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) # Draw Pokémon type(s) @pokemon.types.each_with_index do |type, i| type_number = GameData::Type.get(type).icon_position @@ -463,11 +463,11 @@ class PokemonSummary_Scene overlay.blt(type_x, 146, @typebitmap.bitmap, type_rect) end # Draw Exp bar - if @pokemon.level{1} {2}, {3}\n",date,month,year) + memo += _INTL("{1} {2}, {3}\n", date, month, year) end # Write map name egg was received on mapname = pbGetMapNameFromId(@pokemon.obtain_map) mapname = @pokemon.obtain_text if @pokemon.obtain_text && !@pokemon.obtain_text.empty? if mapname && mapname != "" - memo += _INTL("A mysterious Pokémon Egg received from {1}.\n",mapname) + memo += _INTL("A mysterious Pokémon Egg received from {1}.\n", mapname) else - memo += _INTL("A mysterious Pokémon Egg.\n",mapname) + memo += _INTL("A mysterious Pokémon Egg.\n", mapname) end memo += "\n" # Empty line # Write Egg Watch blurb @@ -523,11 +523,11 @@ class PokemonSummary_Scene eggstate = _INTL("What will hatch from this? It doesn't seem close to hatching.") if @pokemon.steps_to_hatch < 10200 eggstate = _INTL("It appears to move occasionally. It may be close to hatching.") if @pokemon.steps_to_hatch < 2550 eggstate = _INTL("Sounds can be heard coming from inside! It will hatch soon!") if @pokemon.steps_to_hatch < 1275 - memo += sprintf("%s\n",eggstate) + memo += sprintf("%s\n", eggstate) # Draw all text - drawFormattedTextEx(overlay,232,82,268,memo) + drawFormattedTextEx(overlay, 232, 82, 268, memo) # Draw the Pokémon's markings - drawMarkings(overlay,84,292) + drawMarkings(overlay, 84, 292) end def drawPageTwo @@ -537,38 +537,38 @@ class PokemonSummary_Scene showNature = !@pokemon.shadowPokemon? || @pokemon.heartStage <= 3 if showNature natureName = @pokemon.nature.name - memo += _INTL("{1} nature.\n",natureName) + memo += _INTL("{1} nature.\n", natureName) end # Write date received if @pokemon.timeReceived date = @pokemon.timeReceived.day month = pbGetMonthName(@pokemon.timeReceived.mon) year = @pokemon.timeReceived.year - memo += _INTL("{1} {2}, {3}\n",date,month,year) + memo += _INTL("{1} {2}, {3}\n", date, month, year) end # Write map name Pokémon was received on mapname = pbGetMapNameFromId(@pokemon.obtain_map) mapname = @pokemon.obtain_text if @pokemon.obtain_text && !@pokemon.obtain_text.empty? mapname = _INTL("Faraway place") if nil_or_empty?(mapname) - memo += sprintf("%s\n",mapname) + memo += sprintf("%s\n", mapname) # Write how Pokémon was obtained - mettext = [_INTL("Met at Lv. {1}.",@pokemon.obtain_level), + mettext = [_INTL("Met at Lv. {1}.", @pokemon.obtain_level), _INTL("Egg received."), - _INTL("Traded at Lv. {1}.",@pokemon.obtain_level), + _INTL("Traded at Lv. {1}.", @pokemon.obtain_level), "", - _INTL("Had a fateful encounter at Lv. {1}.",@pokemon.obtain_level)][@pokemon.obtain_method] - memo += sprintf("%s\n",mettext) if mettext && mettext!="" + _INTL("Had a fateful encounter at Lv. {1}.", @pokemon.obtain_level)][@pokemon.obtain_method] + memo += sprintf("%s\n", mettext) if mettext && mettext != "" # If Pokémon was hatched, write when and where it hatched if @pokemon.obtain_method == 1 if @pokemon.timeEggHatched date = @pokemon.timeEggHatched.day month = pbGetMonthName(@pokemon.timeEggHatched.mon) year = @pokemon.timeEggHatched.year - memo += _INTL("{1} {2}, {3}\n",date,month,year) + memo += _INTL("{1} {2}, {3}\n", date, month, year) end mapname = pbGetMapNameFromId(@pokemon.hatched_map) mapname = _INTL("Faraway place") if nil_or_empty?(mapname) - memo += sprintf("%s\n",mapname) + memo += sprintf("%s\n", mapname) memo += _INTL("Egg hatched.\n") else memo += "\n" # Empty line @@ -621,73 +621,73 @@ class PokemonSummary_Scene memo += sprintf("%s\n", characteristics[best_stat][best_iv % 5]) end # Write all text - drawFormattedTextEx(overlay,232,82,268,memo) + drawFormattedTextEx(overlay, 232, 82, 268, memo) end def drawPageThree overlay = @sprites["overlay"].bitmap - base = Color.new(248,248,248) - shadow = Color.new(104,104,104) + base = Color.new(248, 248, 248) + shadow = Color.new(104, 104, 104) # Determine which stats are boosted and lowered by the Pokémon's nature statshadows = {} GameData::Stat.each_main { |s| statshadows[s.id] = shadow } if !@pokemon.shadowPokemon? || @pokemon.heartStage <= 3 @pokemon.nature_for_stats.stat_changes.each do |change| - statshadows[change[0]] = Color.new(136,96,72) if change[1] > 0 - statshadows[change[0]] = Color.new(64,120,152) if change[1] < 0 + statshadows[change[0]] = Color.new(136, 96, 72) if change[1] > 0 + statshadows[change[0]] = Color.new(64, 120, 152) if change[1] < 0 end end # Write various bits of text textpos = [ - [_INTL("HP"),292,70,2,base,statshadows[:HP]], - [sprintf("%d/%d",@pokemon.hp,@pokemon.totalhp),462,70,1,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Attack"),248,114,0,base,statshadows[:ATTACK]], - [sprintf("%d",@pokemon.attack),456,114,1,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Defense"),248,146,0,base,statshadows[:DEFENSE]], - [sprintf("%d",@pokemon.defense),456,146,1,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Sp. Atk"),248,178,0,base,statshadows[:SPECIAL_ATTACK]], - [sprintf("%d",@pokemon.spatk),456,178,1,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Sp. Def"),248,210,0,base,statshadows[:SPECIAL_DEFENSE]], - [sprintf("%d",@pokemon.spdef),456,210,1,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Speed"),248,242,0,base,statshadows[:SPEED]], - [sprintf("%d",@pokemon.speed),456,242,1,Color.new(64,64,64),Color.new(176,176,176)], - [_INTL("Ability"),224,278,0,base,shadow] + [_INTL("HP"), 292, 70, 2, base, statshadows[:HP]], + [sprintf("%d/%d", @pokemon.hp, @pokemon.totalhp), 462, 70, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Attack"), 248, 114, 0, base, statshadows[:ATTACK]], + [sprintf("%d", @pokemon.attack), 456, 114, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Defense"), 248, 146, 0, base, statshadows[:DEFENSE]], + [sprintf("%d", @pokemon.defense), 456, 146, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Sp. Atk"), 248, 178, 0, base, statshadows[:SPECIAL_ATTACK]], + [sprintf("%d", @pokemon.spatk), 456, 178, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Sp. Def"), 248, 210, 0, base, statshadows[:SPECIAL_DEFENSE]], + [sprintf("%d", @pokemon.spdef), 456, 210, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Speed"), 248, 242, 0, base, statshadows[:SPEED]], + [sprintf("%d", @pokemon.speed), 456, 242, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [_INTL("Ability"), 224, 278, 0, base, shadow] ] # Draw ability name and description ability = @pokemon.ability if ability - textpos.push([ability.name,362,278,0,Color.new(64,64,64),Color.new(176,176,176)]) - drawTextEx(overlay,224,320,282,2,ability.description,Color.new(64,64,64),Color.new(176,176,176)) + textpos.push([ability.name, 362, 278, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)]) + drawTextEx(overlay, 224, 320, 282, 2, ability.description, Color.new(64, 64, 64), Color.new(176, 176, 176)) end # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) # Draw HP bar - if @pokemon.hp>0 - w = @pokemon.hp*96*1.0/@pokemon.totalhp - w = 1 if w<1 - w = ((w/2).round)*2 + if @pokemon.hp > 0 + w = @pokemon.hp * 96 * 1.0 / @pokemon.totalhp + w = 1 if w < 1 + w = ((w / 2).round) * 2 hpzone = 0 - hpzone = 1 if @pokemon.hp<=(@pokemon.totalhp/2).floor - hpzone = 2 if @pokemon.hp<=(@pokemon.totalhp/4).floor + hpzone = 1 if @pokemon.hp <= (@pokemon.totalhp / 2).floor + hpzone = 2 if @pokemon.hp <= (@pokemon.totalhp / 4).floor imagepos = [ - ["Graphics/Pictures/Summary/overlay_hp",360,110,0,hpzone*6,w,6] + ["Graphics/Pictures/Summary/overlay_hp", 360, 110, 0, hpzone * 6, w, 6] ] - pbDrawImagePositions(overlay,imagepos) + pbDrawImagePositions(overlay, imagepos) end end def drawPageFour overlay = @sprites["overlay"].bitmap - moveBase = Color.new(64,64,64) - moveShadow = Color.new(176,176,176) + moveBase = Color.new(64, 64, 64) + moveShadow = Color.new(176, 176, 176) ppBase = [moveBase, # More than 1/2 of total PP - Color.new(248,192,0), # 1/2 of total PP or less - Color.new(248,136,32), # 1/4 of total PP or less - Color.new(248,72,72)] # Zero PP + Color.new(248, 192, 0), # 1/2 of total PP or less + Color.new(248, 136, 32), # 1/4 of total PP or less + Color.new(248, 72, 72)] # Zero PP ppShadow = [moveShadow, # More than 1/2 of total PP - Color.new(144,104,0), # 1/2 of total PP or less - Color.new(144,72,24), # 1/4 of total PP or less - Color.new(136,48,48)] # Zero PP + Color.new(144, 104, 0), # 1/2 of total PP or less + Color.new(144, 72, 24), # 1/4 of total PP or less + Color.new(136, 48, 48)] # Zero PP @sprites["pokemon"].visible = true @sprites["pokeicon"].visible = false @sprites["itemicon"].visible = true @@ -696,49 +696,49 @@ class PokemonSummary_Scene # Write move names, types and PP amounts for each known move yPos = 92 for i in 0...Pokemon::MAX_MOVES - move=@pokemon.moves[i] + move = @pokemon.moves[i] if move type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position imagepos.push(["Graphics/Pictures/types", 248, yPos + 8, 0, type_number * 28, 64, 28]) - textpos.push([move.name,316,yPos,0,moveBase,moveShadow]) - if move.total_pp>0 - textpos.push([_INTL("PP"),342,yPos+32,0,moveBase,moveShadow]) + textpos.push([move.name, 316, yPos, 0, moveBase, moveShadow]) + if move.total_pp > 0 + textpos.push([_INTL("PP"), 342, yPos + 32, 0, moveBase, moveShadow]) ppfraction = 0 - if move.pp==0 + if move.pp == 0 ppfraction = 3 - elsif move.pp*4<=move.total_pp + elsif move.pp * 4 <= move.total_pp ppfraction = 2 - elsif move.pp*2<=move.total_pp + elsif move.pp * 2 <= move.total_pp ppfraction = 1 end - textpos.push([sprintf("%d/%d",move.pp,move.total_pp),460,yPos+32,1,ppBase[ppfraction],ppShadow[ppfraction]]) + textpos.push([sprintf("%d/%d", move.pp, move.total_pp), 460, yPos + 32, 1, ppBase[ppfraction], ppShadow[ppfraction]]) end else - textpos.push(["-",316,yPos,0,moveBase,moveShadow]) - textpos.push(["--",442,yPos+32,1,moveBase,moveShadow]) + textpos.push(["-", 316, yPos, 0, moveBase, moveShadow]) + textpos.push(["--", 442, yPos + 32, 1, moveBase, moveShadow]) end yPos += 64 end # Draw all text and images - pbDrawTextPositions(overlay,textpos) - pbDrawImagePositions(overlay,imagepos) + pbDrawTextPositions(overlay, textpos) + pbDrawImagePositions(overlay, imagepos) end def drawPageFourSelecting(move_to_learn) overlay = @sprites["overlay"].bitmap overlay.clear - base = Color.new(248,248,248) - shadow = Color.new(104,104,104) - moveBase = Color.new(64,64,64) - moveShadow = Color.new(176,176,176) + base = Color.new(248, 248, 248) + shadow = Color.new(104, 104, 104) + moveBase = Color.new(64, 64, 64) + moveShadow = Color.new(176, 176, 176) ppBase = [moveBase, # More than 1/2 of total PP - Color.new(248,192,0), # 1/2 of total PP or less - Color.new(248,136,32), # 1/4 of total PP or less - Color.new(248,72,72)] # Zero PP + Color.new(248, 192, 0), # 1/2 of total PP or less + Color.new(248, 136, 32), # 1/4 of total PP or less + Color.new(248, 72, 72)] # Zero PP ppShadow = [moveShadow, # More than 1/2 of total PP - Color.new(144,104,0), # 1/2 of total PP or less - Color.new(144,72,24), # 1/4 of total PP or less - Color.new(136,48,48)] # Zero PP + Color.new(144, 104, 0), # 1/2 of total PP or less + Color.new(144, 72, 24), # 1/4 of total PP or less + Color.new(136, 48, 48)] # Zero PP # Set background image if move_to_learn @sprites["background"].setBitmap("Graphics/Pictures/Summary/bg_learnmove") @@ -747,10 +747,10 @@ class PokemonSummary_Scene end # Write various bits of text textpos = [ - [_INTL("MOVES"),26,10,0,base,shadow], - [_INTL("CATEGORY"),20,116,0,base,shadow], - [_INTL("POWER"),20,148,0,base,shadow], - [_INTL("ACCURACY"),20,180,0,base,shadow] + [_INTL("MOVES"), 26, 10, 0, base, shadow], + [_INTL("CATEGORY"), 20, 116, 0, base, shadow], + [_INTL("POWER"), 20, 148, 0, base, shadow], + [_INTL("ACCURACY"), 20, 180, 0, base, shadow] ] imagepos = [] # Write move names, types and PP amounts for each known move @@ -759,35 +759,35 @@ class PokemonSummary_Scene limit = (move_to_learn) ? Pokemon::MAX_MOVES + 1 : Pokemon::MAX_MOVES for i in 0...limit move = @pokemon.moves[i] - if i==Pokemon::MAX_MOVES + if i == Pokemon::MAX_MOVES move = move_to_learn yPos += 20 end if move type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position imagepos.push(["Graphics/Pictures/types", 248, yPos + 8, 0, type_number * 28, 64, 28]) - textpos.push([move.name,316,yPos,0,moveBase,moveShadow]) - if move.total_pp>0 - textpos.push([_INTL("PP"),342,yPos+32,0,moveBase,moveShadow]) + textpos.push([move.name, 316, yPos, 0, moveBase, moveShadow]) + if move.total_pp > 0 + textpos.push([_INTL("PP"), 342, yPos + 32, 0, moveBase, moveShadow]) ppfraction = 0 - if move.pp==0 + if move.pp == 0 ppfraction = 3 - elsif move.pp*4<=move.total_pp + elsif move.pp * 4 <= move.total_pp ppfraction = 2 - elsif move.pp*2<=move.total_pp + elsif move.pp * 2 <= move.total_pp ppfraction = 1 end - textpos.push([sprintf("%d/%d",move.pp,move.total_pp),460,yPos+32,1,ppBase[ppfraction],ppShadow[ppfraction]]) + textpos.push([sprintf("%d/%d", move.pp, move.total_pp), 460, yPos + 32, 1, ppBase[ppfraction], ppShadow[ppfraction]]) end else - textpos.push(["-",316,yPos,0,moveBase,moveShadow]) - textpos.push(["--",442,yPos+32,1,moveBase,moveShadow]) + textpos.push(["-", 316, yPos, 0, moveBase, moveShadow]) + textpos.push(["--", 442, yPos + 32, 1, moveBase, moveShadow]) end yPos += 64 end # Draw all text and images - pbDrawTextPositions(overlay,textpos) - pbDrawImagePositions(overlay,imagepos) + pbDrawTextPositions(overlay, textpos) + pbDrawImagePositions(overlay, imagepos) # Draw Pokémon's type icon(s) @pokemon.types.each_with_index do |type, i| type_number = GameData::Type.get(type).icon_position @@ -835,15 +835,15 @@ class PokemonSummary_Scene @sprites["downarrow"].visible = false # Write various bits of text textpos = [ - [_INTL("No. of Ribbons:"),234,326,0,Color.new(64,64,64),Color.new(176,176,176)], - [@pokemon.numRibbons.to_s,450,326,1,Color.new(64,64,64),Color.new(176,176,176)], + [_INTL("No. of Ribbons:"), 234, 326, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)], + [@pokemon.numRibbons.to_s, 450, 326, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)], ] # Draw all text - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) # Show all ribbons imagepos = [] coord = 0 - for i in @ribbonOffset*4...@ribbonOffset*4+12 + for i in @ribbonOffset * 4...@ribbonOffset * 4 + 12 break if !@pokemon.ribbons[i] ribbon_data = GameData::Ribbon.get(@pokemon.ribbons[i]) ribn = ribbon_data.icon_position @@ -853,7 +853,7 @@ class PokemonSummary_Scene coord += 1 end # Draw all images - pbDrawImagePositions(overlay,imagepos) + pbDrawImagePositions(overlay, imagepos) end def drawSelectedRibbon(ribbonid) @@ -861,32 +861,32 @@ class PokemonSummary_Scene drawPage(5) # Set various values overlay = @sprites["overlay"].bitmap - base = Color.new(64,64,64) - shadow = Color.new(176,176,176) - nameBase = Color.new(248,248,248) - nameShadow = Color.new(104,104,104) + base = Color.new(64, 64, 64) + shadow = Color.new(176, 176, 176) + nameBase = Color.new(248, 248, 248) + nameShadow = Color.new(104, 104, 104) # Get data for selected ribbon name = ribbonid ? GameData::Ribbon.get(ribbonid).name : "" desc = ribbonid ? GameData::Ribbon.get(ribbonid).description : "" # Draw the description box imagepos = [ - ["Graphics/Pictures/Summary/overlay_ribbon",8,280] + ["Graphics/Pictures/Summary/overlay_ribbon", 8, 280] ] - pbDrawImagePositions(overlay,imagepos) + pbDrawImagePositions(overlay, imagepos) # Draw name of selected ribbon textpos = [ - [name,18,280,0,nameBase,nameShadow] + [name, 18, 280, 0, nameBase, nameShadow] ] - pbDrawTextPositions(overlay,textpos) + pbDrawTextPositions(overlay, textpos) # Draw selected ribbon's description - drawTextEx(overlay,18,322,480,2,desc,base,shadow) + drawTextEx(overlay, 18, 322, 480, 2, desc, base, shadow) end def pbGoToPrevious newindex = @partyindex - while newindex>0 + while newindex > 0 newindex -= 1 - if @party[newindex] && (@page==1 || !@party[newindex].egg?) + if @party[newindex] && (@page == 1 || !@party[newindex].egg?) @partyindex = newindex break end @@ -895,9 +895,9 @@ class PokemonSummary_Scene def pbGoToNext newindex = @partyindex - while newindex<@party.length-1 + while newindex < @party.length - 1 newindex += 1 - if @party[newindex] && (@page==1 || !@party[newindex].egg?) + if @party[newindex] && (@page == 1 || !@party[newindex].egg?) @partyindex = newindex break end @@ -918,13 +918,13 @@ class PokemonSummary_Scene selmove = 0 oldselmove = 0 switching = false - drawSelectedMove(nil,@pokemon.moves[selmove]) + drawSelectedMove(nil, @pokemon.moves[selmove]) loop do Graphics.update Input.update pbUpdate - if @sprites["movepresel"].index==@sprites["movesel"].index - @sprites["movepresel"].z = @sprites["movesel"].z+1 + if @sprites["movepresel"].index == @sprites["movesel"].index + @sprites["movepresel"].z = @sprites["movesel"].z + 1 else @sprites["movepresel"].z = @sprites["movesel"].z end @@ -935,7 +935,7 @@ class PokemonSummary_Scene switching = false elsif Input.trigger?(Input::USE) pbPlayDecisionSE - if selmove==Pokemon::MAX_MOVES + if selmove == Pokemon::MAX_MOVES break if !switching @sprites["movepresel"].visible = false switching = false @@ -952,50 +952,50 @@ class PokemonSummary_Scene @pokemon.moves[selmove] = tmpmove @sprites["movepresel"].visible = false switching = false - drawSelectedMove(nil,@pokemon.moves[selmove]) + drawSelectedMove(nil, @pokemon.moves[selmove]) end end end elsif Input.trigger?(Input::UP) selmove -= 1 - if selmove=@pokemon.numMoves - selmove = @pokemon.numMoves-1 + if selmove < Pokemon::MAX_MOVES && selmove >= @pokemon.numMoves + selmove = @pokemon.numMoves - 1 end - selmove = 0 if selmove>=Pokemon::MAX_MOVES - selmove = @pokemon.numMoves-1 if selmove<0 + selmove = 0 if selmove >= Pokemon::MAX_MOVES + selmove = @pokemon.numMoves - 1 if selmove < 0 @sprites["movesel"].index = selmove pbPlayCursorSE - drawSelectedMove(nil,@pokemon.moves[selmove]) + drawSelectedMove(nil, @pokemon.moves[selmove]) elsif Input.trigger?(Input::DOWN) selmove += 1 - selmove = 0 if selmove=@pokemon.numMoves - selmove = 0 if selmove>=Pokemon::MAX_MOVES - selmove = Pokemon::MAX_MOVES if selmove<0 + selmove = 0 if selmove < Pokemon::MAX_MOVES && selmove >= @pokemon.numMoves + selmove = 0 if selmove >= Pokemon::MAX_MOVES + selmove = Pokemon::MAX_MOVES if selmove < 0 @sprites["movesel"].index = selmove pbPlayCursorSE - drawSelectedMove(nil,@pokemon.moves[selmove]) + drawSelectedMove(nil, @pokemon.moves[selmove]) end end - @sprites["movesel"].visible=false + @sprites["movesel"].visible = false end def pbRibbonSelection @sprites["ribbonsel"].visible = true @sprites["ribbonsel"].index = 0 - selribbon = @ribbonOffset*4 + selribbon = @ribbonOffset * 4 oldselribbon = selribbon switching = false numRibbons = @pokemon.ribbons.length - numRows = [((numRibbons+3)/4).floor,3].max + numRows = [((numRibbons + 3) / 4).floor, 3].max drawSelectedRibbon(@pokemon.ribbons[selribbon]) loop do - @sprites["uparrow"].visible = (@ribbonOffset>0) - @sprites["downarrow"].visible = (@ribbonOffset 0) + @sprites["downarrow"].visible = (@ribbonOffset < numRows - 3) Graphics.update Input.update pbUpdate - if @sprites["ribbonpresel"].index==@sprites["ribbonsel"].index - @sprites["ribbonpresel"].z = @sprites["ribbonsel"].z+1 + if @sprites["ribbonpresel"].index == @sprites["ribbonsel"].index + @sprites["ribbonpresel"].z = @sprites["ribbonsel"].z + 1 else @sprites["ribbonpresel"].z = @sprites["ribbonsel"].z end @@ -1009,7 +1009,7 @@ class PokemonSummary_Scene if !switching if @pokemon.ribbons[selribbon] pbPlayDecisionSE - @sprites["ribbonpresel"].index = selribbon-@ribbonOffset*4 + @sprites["ribbonpresel"].index = selribbon - @ribbonOffset * 4 oldselribbon = selribbon @sprites["ribbonpresel"].visible = true switching = true @@ -1021,8 +1021,8 @@ class PokemonSummary_Scene @pokemon.ribbons[selribbon] = tmpribbon if @pokemon.ribbons[oldselribbon] || @pokemon.ribbons[selribbon] @pokemon.ribbons.compact! - if selribbon>=numRibbons - selribbon = numRibbons-1 + if selribbon >= numRibbons + selribbon = numRibbons - 1 hasMovedCursor = true end end @@ -1032,32 +1032,32 @@ class PokemonSummary_Scene end elsif Input.trigger?(Input::UP) selribbon -= 4 - selribbon += numRows*4 if selribbon<0 + selribbon += numRows * 4 if selribbon < 0 hasMovedCursor = true pbPlayCursorSE elsif Input.trigger?(Input::DOWN) selribbon += 4 - selribbon -= numRows*4 if selribbon>=numRows*4 + selribbon -= numRows * 4 if selribbon >= numRows * 4 hasMovedCursor = true pbPlayCursorSE elsif Input.trigger?(Input::LEFT) selribbon -= 1 - selribbon += 4 if selribbon%4==3 + selribbon += 4 if selribbon % 4 == 3 hasMovedCursor = true pbPlayCursorSE elsif Input.trigger?(Input::RIGHT) selribbon += 1 - selribbon -= 4 if selribbon%4==0 + selribbon -= 4 if selribbon % 4 == 0 hasMovedCursor = true pbPlayCursorSE end if hasMovedCursor - @ribbonOffset = (selribbon/4).floor if selribbon<@ribbonOffset*4 - @ribbonOffset = (selribbon/4).floor-2 if selribbon>=(@ribbonOffset+3)*4 - @ribbonOffset = 0 if @ribbonOffset<0 - @ribbonOffset = numRows-3 if @ribbonOffset>numRows-3 - @sprites["ribbonsel"].index = selribbon-@ribbonOffset*4 - @sprites["ribbonpresel"].index = oldselribbon-@ribbonOffset*4 + @ribbonOffset = (selribbon / 4).floor if selribbon < @ribbonOffset * 4 + @ribbonOffset = (selribbon / 4).floor - 2 if selribbon >= (@ribbonOffset + 3) * 4 + @ribbonOffset = 0 if @ribbonOffset < 0 + @ribbonOffset = numRows - 3 if @ribbonOffset > numRows - 3 + @sprites["ribbonsel"].index = selribbon - @ribbonOffset * 4 + @sprites["ribbonpresel"].index = oldselribbon - @ribbonOffset * 4 drawSelectedRibbon(@pokemon.ribbons[selribbon]) end end @@ -1068,8 +1068,8 @@ class PokemonSummary_Scene @sprites["markingbg"].visible = true @sprites["markingoverlay"].visible = true @sprites["markingsel"].visible = true - base = Color.new(248,248,248) - shadow = Color.new(104,104,104) + base = Color.new(248, 248, 248) + shadow = Color.new(104, 104, 104) ret = pokemon.markings.clone markings = pokemon.markings.clone mark_variants = @markingbitmap.bitmap.height / MARK_HEIGHT @@ -1087,24 +1087,24 @@ class PokemonSummary_Scene @markingbitmap.bitmap, markrect) end textpos = [ - [_INTL("Mark {1}",pokemon.name),366,90,2,base,shadow], - [_INTL("OK"),366,242,2,base,shadow], - [_INTL("Cancel"),366,292,2,base,shadow] + [_INTL("Mark {1}", pokemon.name), 366, 90, 2, base, shadow], + [_INTL("OK"), 366, 242, 2, base, shadow], + [_INTL("Cancel"), 366, 292, 2, base, shadow] ] - pbDrawTextPositions(@sprites["markingoverlay"].bitmap,textpos) + pbDrawTextPositions(@sprites["markingoverlay"].bitmap, textpos) redraw = false end # Reposition the cursor - @sprites["markingsel"].x = 284+58*(index%3) - @sprites["markingsel"].y = 144+50*(index/3) - if index==6 # OK + @sprites["markingsel"].x = 284 + 58 * (index % 3) + @sprites["markingsel"].y = 144 + 50 * (index / 3) + if index == 6 # OK @sprites["markingsel"].x = 284 @sprites["markingsel"].y = 244 - @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height/2 - elsif index==7 # Cancel + @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2 + elsif index == 7 # Cancel @sprites["markingsel"].x = 284 @sprites["markingsel"].y = 294 - @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height/2 + @sprites["markingsel"].src_rect.y = @sprites["markingsel"].bitmap.height / 2 else @sprites["markingsel"].src_rect.y = 0 end @@ -1116,10 +1116,10 @@ class PokemonSummary_Scene break elsif Input.trigger?(Input::USE) pbPlayDecisionSE - if index==6 # OK + if index == 6 # OK ret = markings break - elsif index==7 # Cancel + elsif index == 7 # Cancel break else markings[index] = ((markings[index] || 0) + 1) % mark_variants @@ -1132,37 +1132,37 @@ class PokemonSummary_Scene redraw = true end elsif Input.trigger?(Input::UP) - if index==7 + if index == 7 index = 6 - elsif index==6 + elsif index == 6 index = 4 - elsif index<3 + elsif index < 3 index = 7 else index -= 3 end pbPlayCursorSE elsif Input.trigger?(Input::DOWN) - if index==7 + if index == 7 index = 1 - elsif index==6 + elsif index == 6 index = 7 - elsif index>=3 + elsif index >= 3 index = 6 else index += 3 end pbPlayCursorSE elsif Input.trigger?(Input::LEFT) - if index<6 + if index < 6 index -= 1 - index += 3 if index%3==2 + index += 3 if index % 3 == 2 pbPlayCursorSE end elsif Input.trigger?(Input::RIGHT) - if index<6 + if index < 6 index += 1 - index -= 3 if index%3==0 + index -= 3 if index % 3 == 0 pbPlayCursorSE end end @@ -1170,7 +1170,7 @@ class PokemonSummary_Scene @sprites["markingbg"].visible = false @sprites["markingoverlay"].visible = false @sprites["markingsel"].visible = false - if pokemon.markings!=ret + if pokemon.markings != ret pokemon.markings = ret return true end @@ -1179,7 +1179,7 @@ class PokemonSummary_Scene def pbOptions dorefresh = false - commands = [] + commands = [] cmdGiveItem = -1 cmdTakeItem = -1 cmdPokedex = -1 @@ -1192,7 +1192,7 @@ class PokemonSummary_Scene commands[cmdMark = commands.length] = _INTL("Mark") commands[commands.length] = _INTL("Cancel") command = pbShowCommands(commands) - if cmdGiveItem>=0 && command==cmdGiveItem + if cmdGiveItem >= 0 && command == cmdGiveItem item = nil pbFadeOutIn { scene = PokemonBag_Scene.new @@ -1200,11 +1200,11 @@ class PokemonSummary_Scene item = screen.pbChooseItemScreen(Proc.new { |itm| GameData::Item.get(itm).can_hold? }) } if item - dorefresh = pbGiveItemToPokemon(item,@pokemon,self,@partyindex) + dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex) end - elsif cmdTakeItem>=0 && command==cmdTakeItem - dorefresh = pbTakeItemFromPokemon(@pokemon,self) - elsif cmdPokedex>=0 && command==cmdPokedex + elsif cmdTakeItem >= 0 && command == cmdTakeItem + dorefresh = pbTakeItemFromPokemon(@pokemon, self) + elsif cmdPokedex >= 0 && command == cmdPokedex $player.pokedex.register_last_seen(@pokemon) pbFadeOutIn { scene = PokemonPokedexInfo_Scene.new @@ -1212,7 +1212,7 @@ class PokemonSummary_Scene screen.pbStartSceneSingle(@pokemon.species) } dorefresh = true - elsif cmdMark>=0 && command==cmdMark + elsif cmdMark >= 0 && command == cmdMark dorefresh = pbMarking(@pokemon) end return dorefresh @@ -1235,25 +1235,25 @@ class PokemonSummary_Scene break elsif Input.trigger?(Input::UP) selmove -= 1 - selmove = maxmove if selmove<0 - if selmove=@pokemon.numMoves - selmove = @pokemon.numMoves-1 + selmove = maxmove if selmove < 0 + if selmove < Pokemon::MAX_MOVES && selmove >= @pokemon.numMoves + selmove = @pokemon.numMoves - 1 end @sprites["movesel"].index = selmove - selected_move = (selmove==Pokemon::MAX_MOVES) ? new_move : @pokemon.moves[selmove] - drawSelectedMove(new_move,selected_move) + selected_move = (selmove == Pokemon::MAX_MOVES) ? new_move : @pokemon.moves[selmove] + drawSelectedMove(new_move, selected_move) elsif Input.trigger?(Input::DOWN) selmove += 1 - selmove = 0 if selmove>maxmove - if selmove=@pokemon.numMoves + selmove = 0 if selmove > maxmove + if selmove < Pokemon::MAX_MOVES && selmove >= @pokemon.numMoves selmove = (new_move) ? maxmove : 0 end @sprites["movesel"].index = selmove - selected_move = (selmove==Pokemon::MAX_MOVES) ? new_move : @pokemon.moves[selmove] - drawSelectedMove(new_move,selected_move) + selected_move = (selmove == Pokemon::MAX_MOVES) ? new_move : @pokemon.moves[selmove] + drawSelectedMove(new_move, selected_move) end end - return (selmove==Pokemon::MAX_MOVES) ? -1 : selmove + return (selmove == Pokemon::MAX_MOVES) ? -1 : selmove end def pbScene @@ -1270,11 +1270,11 @@ class PokemonSummary_Scene pbPlayCloseMenuSE break elsif Input.trigger?(Input::USE) - if @page==4 + if @page == 4 pbPlayDecisionSE pbMoveSelection dorefresh = true - elsif @page==5 + elsif @page == 5 pbPlayDecisionSE pbRibbonSelection dorefresh = true @@ -1282,18 +1282,18 @@ class PokemonSummary_Scene pbPlayDecisionSE dorefresh = pbOptions end - elsif Input.trigger?(Input::UP) && @partyindex>0 + elsif Input.trigger?(Input::UP) && @partyindex > 0 oldindex = @partyindex pbGoToPrevious - if @partyindex!=oldindex + if @partyindex != oldindex pbChangePokemon @ribbonOffset = 0 dorefresh = true end - elsif Input.trigger?(Input::DOWN) && @partyindex<@party.length-1 + elsif Input.trigger?(Input::DOWN) && @partyindex < @party.length - 1 oldindex = @partyindex pbGoToNext - if @partyindex!=oldindex + if @partyindex != oldindex pbChangePokemon @ribbonOffset = 0 dorefresh = true @@ -1301,9 +1301,9 @@ class PokemonSummary_Scene elsif Input.trigger?(Input::LEFT) && !@pokemon.egg? oldpage = @page @page -= 1 - @page = 1 if @page<1 - @page = 5 if @page>5 - if @page!=oldpage # Move to next page + @page = 1 if @page < 1 + @page = 5 if @page > 5 + if @page != oldpage # Move to next page pbSEPlay("GUI summary change page") @ribbonOffset = 0 dorefresh = true @@ -1311,9 +1311,9 @@ class PokemonSummary_Scene elsif Input.trigger?(Input::RIGHT) && !@pokemon.egg? oldpage = @page @page += 1 - @page = 1 if @page<1 - @page = 5 if @page>5 - if @page!=oldpage # Move to next page + @page = 1 if @page < 1 + @page = 5 if @page > 5 + if @page != oldpage # Move to next page pbSEPlay("GUI summary change page") @ribbonOffset = 0 dorefresh = true @@ -1331,21 +1331,21 @@ end # #=============================================================================== class PokemonSummaryScreen - def initialize(scene,inbattle = false) + def initialize(scene, inbattle = false) @scene = scene @inbattle = inbattle end - def pbStartScreen(party,partyindex) - @scene.pbStartScene(party,partyindex,@inbattle) + def pbStartScreen(party, partyindex) + @scene.pbStartScene(party, partyindex, @inbattle) ret = @scene.pbScene @scene.pbEndScene return ret end - def pbStartForgetScreen(party,partyindex,move_to_learn) + def pbStartForgetScreen(party, partyindex, move_to_learn) ret = -1 - @scene.pbStartForgetScene(party,partyindex,move_to_learn) + @scene.pbStartForgetScene(party, partyindex, move_to_learn) loop do ret = @scene.pbChooseMoveToForget(move_to_learn) break if ret < 0 || !move_to_learn @@ -1356,9 +1356,9 @@ class PokemonSummaryScreen return ret end - def pbStartChooseMoveScreen(party,partyindex,message) + def pbStartChooseMoveScreen(party, partyindex, message) ret = -1 - @scene.pbStartForgetScene(party,partyindex,nil) + @scene.pbStartForgetScene(party, partyindex, nil) pbMessage(message) { @scene.pbUpdate } loop do ret = @scene.pbChooseMoveToForget(nil) @@ -1373,16 +1373,16 @@ end #=============================================================================== # #=============================================================================== -def pbChooseMove(pokemon,variableNumber,nameVarNumber) +def pbChooseMove(pokemon, variableNumber, nameVarNumber) return if !pokemon ret = -1 pbFadeOutIn { scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene) - ret = screen.pbStartForgetScreen([pokemon],0,nil) + ret = screen.pbStartForgetScreen([pokemon], 0, nil) } $game_variables[variableNumber] = ret - if ret>=0 + if ret >= 0 $game_variables[nameVarNumber] = pokemon.moves[ret].name else $game_variables[nameVarNumber] = "" diff --git a/Data/Scripts/016_UI/007_UI_Bag.rb b/Data/Scripts/016_UI/007_UI_Bag.rb index c5ad354d1..7aa6f5370 100644 --- a/Data/Scripts/016_UI/007_UI_Bag.rb +++ b/Data/Scripts/016_UI/007_UI_Bag.rb @@ -5,13 +5,13 @@ class Window_PokemonBag < Window_DrawableCommand attr_reader :pocket attr_accessor :sorting - def initialize(bag,filterlist,pocket,x,y,width,height) + def initialize(bag, filterlist, pocket, x, y, width, height) @bag = bag @filterlist = filterlist @pocket = pocket @sorting = false @adapter = PokemonMartAdapter.new - super(x,y,width,height) + super(x, y, width, height) @selarrow = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor") @swaparrow = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor_swap") self.windowskin = nil @@ -24,7 +24,7 @@ class Window_PokemonBag < Window_DrawableCommand def pocket=(value) @pocket = value - @item_max = (@filterlist) ? @filterlist[@pocket].length+1 : @bag.pockets[@pocket].length+1 + @item_max = (@filterlist) ? @filterlist[@pocket].length + 1 : @bag.pockets[@pocket].length + 1 self.index = @bag.last_viewed_index(@pocket) end @@ -39,77 +39,77 @@ class Window_PokemonBag < Window_DrawableCommand end def itemCount - return (@filterlist) ? @filterlist[@pocket].length+1 : @bag.pockets[@pocket].length+1 + return (@filterlist) ? @filterlist[@pocket].length + 1 : @bag.pockets[@pocket].length + 1 end def itemRect(item) - if item<0 || item>=@item_max || itemself.top_item+self.page_item_max - return Rect.new(0,0,0,0) + if item < 0 || item >= @item_max || item < self.top_item - 1 || + item > self.top_item + self.page_item_max + return Rect.new(0, 0, 0, 0) else - cursor_width = (self.width-self.borderX-(@column_max-1)*@column_spacing) / @column_max + cursor_width = (self.width - self.borderX - (@column_max - 1) * @column_spacing) / @column_max x = item % @column_max * (cursor_width + @column_spacing) y = item / @column_max * @row_height - @virtualOy return Rect.new(x, y, cursor_width, @row_height) end end - def drawCursor(index,rect) - if self.index==index + def drawCursor(index, rect) + if self.index == index bmp = (@sorting) ? @swaparrow.bitmap : @selarrow.bitmap - pbCopyBitmap(self.contents,bmp,rect.x,rect.y+2) + pbCopyBitmap(self.contents, bmp, rect.x, rect.y + 2) 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) + rect = Rect.new(rect.x + 16, rect.y + 16, rect.width - 16, rect.height) thispocket = @bag.pockets[@pocket] - if index==self.itemCount-1 - textpos.push([_INTL("CLOSE BAG"),rect.x,rect.y-2,false,self.baseColor,self.shadowColor]) + if index == self.itemCount - 1 + textpos.push([_INTL("CLOSE BAG"), rect.x, rect.y - 2, false, self.baseColor, self.shadowColor]) else item = (@filterlist) ? thispocket[@filterlist[@pocket][index]][0] : thispocket[index][0] baseColor = self.baseColor shadowColor = self.shadowColor - if @sorting && index==self.index - baseColor = Color.new(224,0,0) - shadowColor = Color.new(248,144,144) + if @sorting && index == self.index + baseColor = Color.new(224, 0, 0) + shadowColor = Color.new(248, 144, 144) end textpos.push( - [@adapter.getDisplayName(item),rect.x,rect.y-2,false,baseColor,shadowColor] + [@adapter.getDisplayName(item), rect.x, rect.y - 2, false, baseColor, shadowColor] ) if GameData::Item.get(item).is_important? if @bag.registered?(item) - pbDrawImagePositions(self.contents,[ - ["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,0,-1,24] + pbDrawImagePositions(self.contents, [ + ["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 0, -1, 24] ]) elsif pbCanRegisterItem?(item) - pbDrawImagePositions(self.contents,[ - ["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,24,-1,24] + pbDrawImagePositions(self.contents, [ + ["Graphics/Pictures/Bag/icon_register", rect.x + rect.width - 72, rect.y + 8, 0, 24, -1, 24] ]) end else qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1] - qtytext = _ISPRINTF("x{1: 3d}",qty) - xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16 - textpos.push([qtytext,xQty,rect.y-2,false,baseColor,shadowColor]) + qtytext = _ISPRINTF("x{1: 3d}", qty) + xQty = rect.x + rect.width - self.contents.text_size(qtytext).width - 16 + textpos.push([qtytext, xQty, rect.y - 2, false, baseColor, shadowColor]) end end - pbDrawTextPositions(self.contents,textpos) + pbDrawTextPositions(self.contents, textpos) end def refresh @item_max = itemCount self.update_cursor_rect - dwidth = self.width-self.borderX - dheight = self.height-self.borderY - self.contents = pbDoEnsureBitmap(self.contents,dwidth,dheight) + dwidth = self.width - self.borderX + dheight = self.height - self.borderY + self.contents = pbDoEnsureBitmap(self.contents, dwidth, dheight) self.contents.clear for i in 0...@item_max - next if iself.top_item+self.page_item_max - drawItem(i,@item_max,itemRect(i)) + next if i < self.top_item - 1 || i > self.top_item + self.page_item_max + drawItem(i, @item_max, itemRect(i)) end - drawCursor(self.index,itemRect(self.index)) + drawCursor(self.index, itemRect(self.index)) end def update @@ -123,46 +123,46 @@ end # Bag visuals #=============================================================================== class PokemonBag_Scene - ITEMLISTBASECOLOR = Color.new(88,88,80) - ITEMLISTSHADOWCOLOR = Color.new(168,184,184) - ITEMTEXTBASECOLOR = Color.new(248,248,248) - ITEMTEXTSHADOWCOLOR = Color.new(0,0,0) - POCKETNAMEBASECOLOR = Color.new(88,88,80) - POCKETNAMESHADOWCOLOR = Color.new(168,184,184) + ITEMLISTBASECOLOR = Color.new(88, 88, 80) + ITEMLISTSHADOWCOLOR = Color.new(168, 184, 184) + ITEMTEXTBASECOLOR = Color.new(248, 248, 248) + ITEMTEXTSHADOWCOLOR = Color.new(0, 0, 0) + POCKETNAMEBASECOLOR = Color.new(88, 88, 80) + POCKETNAMESHADOWCOLOR = Color.new(168, 184, 184) ITEMSVISIBLE = 7 def pbUpdate pbUpdateSpriteHash(@sprites) end - def pbStartScene(bag,choosing = false,filterproc = nil,resetpocket = true) - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + def pbStartScene(bag, choosing = false, filterproc = nil, resetpocket = true) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @bag = bag @choosing = choosing @filterproc = filterproc pbRefreshFilter lastpocket = @bag.last_viewed_pocket - numfilledpockets = @bag.pockets.length-1 + numfilledpockets = @bag.pockets.length - 1 if @choosing numfilledpockets = 0 - if @filterlist!=nil + if @filterlist != nil for i in 1...@bag.pockets.length - numfilledpockets += 1 if @filterlist[i].length>0 + numfilledpockets += 1 if @filterlist[i].length > 0 end else for i in 1...@bag.pockets.length - numfilledpockets += 1 if @bag.pockets[i].length>0 + numfilledpockets += 1 if @bag.pockets[i].length > 0 end end lastpocket = (resetpocket) ? 1 : @bag.last_viewed_pocket - if (@filterlist && @filterlist[lastpocket].length==0) || - (!@filterlist && @bag.pockets[lastpocket].length==0) + if (@filterlist && @filterlist[lastpocket].length == 0) || + (!@filterlist && @bag.pockets[lastpocket].length == 0) for i in 1...@bag.pockets.length - if @filterlist && @filterlist[i].length>0 + if @filterlist && @filterlist[i].length > 0 lastpocket = i break - elsif !@filterlist && @bag.pockets[i].length>0 + elsif !@filterlist && @bag.pockets[i].length > 0 lastpocket = i break end @@ -173,30 +173,30 @@ class PokemonBag_Scene @sliderbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Bag/icon_slider")) @pocketbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Bag/icon_pocket")) @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) - @sprites["bagsprite"] = IconSprite.new(30,20,@viewport) - @sprites["pocketicon"] = BitmapSprite.new(186,32,@viewport) + @sprites["bagsprite"] = IconSprite.new(30, 20, @viewport) + @sprites["pocketicon"] = BitmapSprite.new(186, 32, @viewport) @sprites["pocketicon"].x = 0 @sprites["pocketicon"].y = 224 - @sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow",8,40,28,2,@viewport) + @sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow", 8, 40, 28, 2, @viewport) @sprites["leftarrow"].x = -4 @sprites["leftarrow"].y = 76 - @sprites["leftarrow"].visible = (!@choosing || numfilledpockets>1) + @sprites["leftarrow"].visible = (!@choosing || numfilledpockets > 1) @sprites["leftarrow"].play - @sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow",8,40,28,2,@viewport) + @sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow", 8, 40, 28, 2, @viewport) @sprites["rightarrow"].x = 150 @sprites["rightarrow"].y = 76 - @sprites["rightarrow"].visible = (!@choosing || numfilledpockets>1) + @sprites["rightarrow"].visible = (!@choosing || numfilledpockets > 1) @sprites["rightarrow"].play - @sprites["itemlist"] = Window_PokemonBag.new(@bag,@filterlist,lastpocket,168,-8,314,40+32+ITEMSVISIBLE*32) + @sprites["itemlist"] = Window_PokemonBag.new(@bag, @filterlist, lastpocket, 168, -8, 314, 40 + 32 + ITEMSVISIBLE * 32) @sprites["itemlist"].viewport = @viewport @sprites["itemlist"].pocket = lastpocket @sprites["itemlist"].index = @bag.last_viewed_index(lastpocket) @sprites["itemlist"].baseColor = ITEMLISTBASECOLOR @sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR - @sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,nil,@viewport) + @sprites["itemicon"] = ItemIconSprite.new(48, Graphics.height - 48, nil, @viewport) @sprites["itemtext"] = Window_UnformattedTextPokemon.newWithSize("", 72, 270, Graphics.width - 72 - 24, 128, @viewport) @sprites["itemtext"].baseColor = ITEMTEXTBASECOLOR @@ -209,7 +209,7 @@ class PokemonBag_Scene @sprites["msgwindow"] = Window_AdvancedTextPokemon.new("") @sprites["msgwindow"].visible = false @sprites["msgwindow"].viewport = @viewport - pbBottomLeftLines(@sprites["helpwindow"],1) + pbBottomLeftLines(@sprites["helpwindow"], 1) pbDeactivateWindows(@sprites) pbRefresh pbFadeInAndShow(@sprites) @@ -220,7 +220,7 @@ class PokemonBag_Scene end def pbFadeInScene - pbFadeInAndShow(@sprites,@oldsprites) + pbFadeInAndShow(@sprites, @oldsprites) @oldsprites = nil end @@ -237,20 +237,20 @@ class PokemonBag_Scene @viewport.dispose end - def pbDisplay(msg,brief = false) - UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { pbUpdate } + def pbDisplay(msg, brief = false) + UIHelper.pbDisplay(@sprites["msgwindow"], msg, brief) { pbUpdate } end def pbConfirm(msg) - UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate } + UIHelper.pbConfirm(@sprites["msgwindow"], msg) { pbUpdate } end - def pbChooseNumber(helptext,maximum,initnum = 1) - return UIHelper.pbChooseNumber(@sprites["helpwindow"],helptext,maximum,initnum) { pbUpdate } + def pbChooseNumber(helptext, maximum, initnum = 1) + return UIHelper.pbChooseNumber(@sprites["helpwindow"], helptext, maximum, initnum) { pbUpdate } end - def pbShowCommands(helptext,commands,index = 0) - return UIHelper.pbShowCommands(@sprites["helpwindow"],helptext,commands,index) { pbUpdate } + def pbShowCommands(helptext, commands, index = 0) + return UIHelper.pbShowCommands(@sprites["helpwindow"], helptext, commands, index) { pbUpdate } end def pbRefresh @@ -267,14 +267,14 @@ class PokemonBag_Scene @sprites["pocketicon"].bitmap.clear if @choosing && @filterlist for i in 1...@bag.pockets.length - if @filterlist[i].length==0 - @sprites["pocketicon"].bitmap.blt(6+(i-1)*22,6, - @pocketbitmap.bitmap,Rect.new((i-1)*20,28,20,20)) + if @filterlist[i].length == 0 + @sprites["pocketicon"].bitmap.blt(6 + (i - 1) * 22, 6, + @pocketbitmap.bitmap, Rect.new((i - 1) * 20, 28, 20, 20)) end end end - @sprites["pocketicon"].bitmap.blt(2+(@sprites["itemlist"].pocket-1)*22,2, - @pocketbitmap.bitmap,Rect.new((@sprites["itemlist"].pocket-1)*28,0,28,28)) + @sprites["pocketicon"].bitmap.blt(2 + (@sprites["itemlist"].pocket - 1) * 22, 2, + @pocketbitmap.bitmap, Rect.new((@sprites["itemlist"].pocket - 1) * 28, 0, 28, 28)) # Refresh the item window @sprites["itemlist"].refresh # Refresh more things @@ -286,35 +286,35 @@ class PokemonBag_Scene overlay = @sprites["overlay"].bitmap overlay.clear # Draw the pocket name - pbDrawTextPositions(overlay,[ + pbDrawTextPositions(overlay, [ [PokemonBag.pocket_names[@bag.last_viewed_pocket - 1], 94, 176, 2, POCKETNAMEBASECOLOR, POCKETNAMESHADOWCOLOR] ]) # Draw slider arrows showslider = false - if itemlist.top_row>0 - overlay.blt(470,16,@sliderbitmap.bitmap,Rect.new(0,0,36,38)) + if itemlist.top_row > 0 + overlay.blt(470, 16, @sliderbitmap.bitmap, Rect.new(0, 0, 36, 38)) showslider = true end - if itemlist.top_item+itemlist.page_item_max=thispocket.length - itemwindow.index = (oldindex==thispocket.length-1) ? 0 : thispocket.length-1 + if itemwindow.sorting && itemwindow.index >= thispocket.length + itemwindow.index = (oldindex == thispocket.length - 1) ? 0 : thispocket.length - 1 end - if itemwindow.index!=oldindex + if itemwindow.index != oldindex # Move the item being switched if itemwindow.sorting - thispocket.insert(itemwindow.index,thispocket.delete_at(oldindex)) + thispocket.insert(itemwindow.index, thispocket.delete_at(oldindex)) end # Update selected item for current pocket - @bag.set_last_viewed_index(itemwindow.pocket,itemwindow.index) + @bag.set_last_viewed_index(itemwindow.pocket, itemwindow.index) pbRefresh end if itemwindow.sorting @@ -367,7 +367,7 @@ class PokemonBag_Scene pbPlayDecisionSE pbRefresh elsif Input.trigger?(Input::BACK) - thispocket.insert(swapinitialpos,thispocket.delete_at(itemwindow.index)) + thispocket.insert(swapinitialpos, thispocket.delete_at(itemwindow.index)) itemwindow.index = swapinitialpos itemwindow.sorting = false pbPlayCancelSE @@ -378,15 +378,15 @@ class PokemonBag_Scene if Input.trigger?(Input::LEFT) newpocket = itemwindow.pocket loop do - newpocket = (newpocket==1) ? PokemonBag.pocket_count : newpocket-1 - break if !@choosing || newpocket==itemwindow.pocket + newpocket = (newpocket == 1) ? PokemonBag.pocket_count : newpocket - 1 + break if !@choosing || newpocket == itemwindow.pocket if @filterlist - break if @filterlist[newpocket].length>0 + break if @filterlist[newpocket].length > 0 else - break if @bag.pockets[newpocket].length>0 + break if @bag.pockets[newpocket].length > 0 end end - if itemwindow.pocket!=newpocket + if itemwindow.pocket != newpocket itemwindow.pocket = newpocket @bag.last_viewed_pocket = itemwindow.pocket thispocket = @bag.pockets[itemwindow.pocket] @@ -396,15 +396,15 @@ class PokemonBag_Scene elsif Input.trigger?(Input::RIGHT) newpocket = itemwindow.pocket loop do - newpocket = (newpocket==PokemonBag.pocket_count) ? 1 : newpocket+1 - break if !@choosing || newpocket==itemwindow.pocket + newpocket = (newpocket == PokemonBag.pocket_count) ? 1 : newpocket + 1 + break if !@choosing || newpocket == itemwindow.pocket if @filterlist - break if @filterlist[newpocket].length>0 + break if @filterlist[newpocket].length > 0 else - break if @bag.pockets[newpocket].length>0 + break if @bag.pockets[newpocket].length > 0 end end - if itemwindow.pocket!=newpocket + if itemwindow.pocket != newpocket itemwindow.pocket = newpocket @bag.last_viewed_pocket = itemwindow.pocket thispocket = @bag.pockets[itemwindow.pocket] @@ -423,7 +423,7 @@ class PokemonBag_Scene # end elsif Input.trigger?(Input::ACTION) # Start switching the selected item if !@choosing - if thispocket.length>1 && itemwindow.index 1 && itemwindow.index < thispocket.length && !Settings::BAG_POCKET_AUTO_SORT[itemwindow.pocket - 1] itemwindow.sorting = true swapinitialpos = itemwindow.index @@ -448,7 +448,7 @@ end # Bag mechanics #=============================================================================== class PokemonBagScreen - def initialize(scene,bag) + def initialize(scene, bag) @bag = bag @scene = scene end @@ -468,8 +468,8 @@ class PokemonBagScreen cmdDebug = -1 commands = [] # Generate command list - commands[cmdRead = commands.length] = _INTL("Read") if itm.is_mail? - if ItemHandlers.hasOutHandler(item) || (itm.is_machine? && $player.party.length>0) + commands[cmdRead = commands.length] = _INTL("Read") if itm.is_mail? + if ItemHandlers.hasOutHandler(item) || (itm.is_machine? && $player.party.length > 0) if ItemHandlers.hasUseText(item) commands[cmdUse = commands.length] = ItemHandlers.getUseText(item) else @@ -487,22 +487,22 @@ class PokemonBagScreen commands[commands.length] = _INTL("Cancel") # Show commands generated above itemname = itm.name - command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands) - if cmdRead>=0 && command==cmdRead # Read mail + command = @scene.pbShowCommands(_INTL("{1} is selected.", itemname), commands) + if cmdRead >= 0 && command == cmdRead # Read mail pbFadeOutIn { pbDisplayMail(Mail.new(item, "", "")) } - elsif cmdUse>=0 && command==cmdUse # Use item - ret = pbUseItem(@bag,item,@scene) + elsif cmdUse >= 0 && command == cmdUse # Use item + ret = pbUseItem(@bag, item, @scene) # ret: 0=Item wasn't used; 1=Item used; 2=Close Bag to use in field - break if ret==2 # End screen + break if ret == 2 # End screen @scene.pbRefresh next - elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon + elsif cmdGive >= 0 && command == cmdGive # Give item to Pokémon if $player.pokemon_count == 0 @scene.pbDisplay(_INTL("There is no Pokémon.")) elsif itm.is_important? - @scene.pbDisplay(_INTL("The {1} can't be held.",itemname)) + @scene.pbDisplay(_INTL("The {1} can't be held.", itemname)) else pbFadeOutIn { sscene = PokemonParty_Scene.new @@ -511,35 +511,35 @@ class PokemonBagScreen @scene.pbRefresh } end - elsif cmdToss>=0 && command==cmdToss # Toss item + elsif cmdToss >= 0 && command == cmdToss # Toss item qty = @bag.quantity(item) - if qty>1 - helptext = _INTL("Toss out how many {1}?",itm.name_plural) - qty = @scene.pbChooseNumber(helptext,qty) + if qty > 1 + helptext = _INTL("Toss out how many {1}?", itm.name_plural) + qty = @scene.pbChooseNumber(helptext, qty) end - if qty>0 - itemname = itm.name_plural if qty>1 - if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname)) - pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname)) + if qty > 0 + itemname = itm.name_plural if qty > 1 + if pbConfirm(_INTL("Is it OK to throw away {1} {2}?", qty, itemname)) + pbDisplay(_INTL("Threw away {1} {2}.", qty, itemname)) qty.times { @bag.remove(item) } @scene.pbRefresh end end - elsif cmdRegister>=0 && command==cmdRegister # Register item + elsif cmdRegister >= 0 && command == cmdRegister # Register item if @bag.registered?(item) @bag.unregister(item) else @bag.register(item) end @scene.pbRefresh - elsif cmdDebug>=0 && command==cmdDebug # Debug + elsif cmdDebug >= 0 && command == cmdDebug # Debug command = 0 loop do - command = @scene.pbShowCommands(_INTL("Do what with {1}?",itemname),[ + command = @scene.pbShowCommands(_INTL("Do what with {1}?", itemname), [ _INTL("Change quantity"), _INTL("Make Mystery Gift"), _INTL("Cancel") - ],command) + ], command) case command ### Cancel ### when -1, 2 @@ -552,17 +552,17 @@ class PokemonBagScreen params.setRange(0, Settings::BAG_MAX_PER_SLOT) params.setDefaultValue(qty) newqty = pbMessageChooseNumber( - _INTL("Choose new quantity of {1} (max. #{Settings::BAG_MAX_PER_SLOT}).",itemplural),params) { @scene.pbUpdate } - if newqty>qty + _INTL("Choose new quantity of {1} (max. #{Settings::BAG_MAX_PER_SLOT}).", itemplural), params) { @scene.pbUpdate } + if newqty > qty @bag.add(item, newqty - qty) - elsif newqty1 && !itm.is_important? - qty = @scene.pbChooseNumber(_INTL("How many do you want to withdraw?"),qty) + if qty > 1 && !itm.is_important? + qty = @scene.pbChooseNumber(_INTL("How many do you want to withdraw?"), qty) end - next if qty<=0 - if @bag.can_add?(item,qty) - if !storage.remove(item,qty) + next if qty <= 0 + if @bag.can_add?(item, qty) + if !storage.remove(item, qty) raise "Can't delete items from storage" end - if !@bag.add(item,qty) + if !@bag.add(item, qty) raise "Can't withdraw items from storage" end @scene.pbRefresh dispqty = (itm.is_important?) ? 1 : qty - itemname = (dispqty>1) ? itm.name_plural : itm.name - pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname)) + itemname = (dispqty > 1) ? itm.name_plural : itm.name + pbDisplay(_INTL("Withdrew {1} {2}.", dispqty, itemname)) else pbDisplay(_INTL("There's no more room in the Bag.")) end @@ -637,23 +637,23 @@ class PokemonBagScreen break if !item itm = GameData::Item.get(item) qty = @bag.quantity(item) - if qty>1 && !itm.is_important? - qty = @scene.pbChooseNumber(_INTL("How many do you want to deposit?"),qty) + if qty > 1 && !itm.is_important? + qty = @scene.pbChooseNumber(_INTL("How many do you want to deposit?"), qty) end - if qty>0 - if !storage.can_add?(item,qty) + if qty > 0 + if !storage.can_add?(item, qty) pbDisplay(_INTL("There's no room to store items.")) else - if !@bag.remove(item,qty) + if !@bag.remove(item, qty) raise "Can't delete items from Bag" end - if !storage.add(item,qty) + if !storage.add(item, qty) raise "Can't deposit items to storage" end @scene.pbRefresh dispqty = (itm.is_important?) ? 1 : qty - itemname = (dispqty>1) ? itm.name_plural : itm.name - pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname)) + itemname = (dispqty > 1) ? itm.name_plural : itm.name + pbDisplay(_INTL("Deposited {1} {2}.", dispqty, itemname)) end end end @@ -678,17 +678,17 @@ class PokemonBagScreen qty = storage.quantity(item) itemname = itm.name itemnameplural = itm.name_plural - if qty>1 - qty=@scene.pbChooseNumber(_INTL("Toss out how many {1}?",itemnameplural),qty) + if qty > 1 + qty = @scene.pbChooseNumber(_INTL("Toss out how many {1}?", itemnameplural), qty) end - if qty>0 - itemname = itemnameplural if qty>1 - if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname)) - if !storage.remove(item,qty) + if qty > 0 + itemname = itemnameplural if qty > 1 + if pbConfirm(_INTL("Is it OK to throw away {1} {2}?", qty, itemname)) + if !storage.remove(item, qty) raise "Can't delete items from storage" end @scene.pbRefresh - pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname)) + pbDisplay(_INTL("Threw away {1} {2}.", qty, itemname)) end end end diff --git a/Data/Scripts/016_UI/008_UI_Pokegear.rb b/Data/Scripts/016_UI/008_UI_Pokegear.rb index a32309899..7fb4907bf 100644 --- a/Data/Scripts/016_UI/008_UI_Pokegear.rb +++ b/Data/Scripts/016_UI/008_UI_Pokegear.rb @@ -6,7 +6,7 @@ class PokegearButton < SpriteWrapper attr_reader :name attr_reader :selected - def initialize(command,x,y,viewport = nil) + def initialize(command, x, y, viewport = nil) super(viewport) @image = command[0] @name = command[1] @@ -16,7 +16,7 @@ class PokegearButton < SpriteWrapper else @button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button") end - @contents = BitmapWrapper.new(@button.width,@button.height) + @contents = BitmapWrapper.new(@button.width, @button.height) self.bitmap = @contents self.x = x self.y = y @@ -33,22 +33,22 @@ class PokegearButton < SpriteWrapper def selected=(val) oldsel = @selected @selected = val - refresh if oldsel!=val + refresh if oldsel != val end def refresh self.bitmap.clear - rect = Rect.new(0,0,@button.width,@button.height/2) - rect.y = @button.height/2 if @selected - self.bitmap.blt(0,0,@button.bitmap,rect) + rect = Rect.new(0, 0, @button.width, @button.height / 2) + rect.y = @button.height / 2 if @selected + self.bitmap.blt(0, 0, @button.bitmap, rect) textpos = [ - [@name,self.bitmap.width/2,4,2,Color.new(248,248,248),Color.new(40,40,40)], + [@name, self.bitmap.width / 2, 4, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)], ] - pbDrawTextPositions(self.bitmap,textpos) + pbDrawTextPositions(self.bitmap, textpos) imagepos = [ - [sprintf("Graphics/Pictures/Pokegear/icon_"+@image),18,10] + [sprintf("Graphics/Pictures/Pokegear/icon_" + @image), 18, 10] ] - pbDrawImagePositions(self.bitmap,imagepos) + pbDrawImagePositions(self.bitmap, imagepos) end end @@ -58,7 +58,7 @@ end class PokemonPokegear_Scene def pbUpdate for i in 0...@commands.length - @sprites["button#{i}"].selected = (i==@index) + @sprites["button#{i}"].selected = (i == @index) end pbUpdateSpriteHash(@sprites) end @@ -66,18 +66,18 @@ class PokemonPokegear_Scene def pbStartScene(commands) @commands = commands @index = 0 - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f")) @sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f") else @sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg") end for i in 0...@commands.length - y = 196 - (@commands.length*24) + (i*48) - @sprites["button#{i}"] = PokegearButton.new(@commands[i],118,y,@viewport) + y = 196 - (@commands.length * 24) + (i * 48) + @sprites["button#{i}"] = PokegearButton.new(@commands[i], 118, y, @viewport) end pbFadeInAndShow(@sprites) { pbUpdate } end @@ -96,13 +96,13 @@ class PokemonPokegear_Scene ret = @index break elsif Input.trigger?(Input::UP) - pbPlayCursorSE if @commands.length>1 + pbPlayCursorSE if @commands.length > 1 @index -= 1 - @index = @commands.length-1 if @index<0 + @index = @commands.length - 1 if @index < 0 elsif Input.trigger?(Input::DOWN) - pbPlayCursorSE if @commands.length>1 + pbPlayCursorSE if @commands.length > 1 @index += 1 - @index = 0 if @index>=@commands.length + @index = 0 if @index >= @commands.length end end return ret @@ -132,17 +132,17 @@ class PokemonPokegearScreen cmdMap = -1 cmdPhone = -1 cmdJukebox = -1 - commands[cmdMap = commands.length] = ["map",_INTL("Map")] - if $PokemonGlobal.phoneNumbers && $PokemonGlobal.phoneNumbers.length>0 - commands[cmdPhone = commands.length] = ["phone",_INTL("Phone")] + commands[cmdMap = commands.length] = ["map", _INTL("Map")] + if $PokemonGlobal.phoneNumbers && $PokemonGlobal.phoneNumbers.length > 0 + commands[cmdPhone = commands.length] = ["phone", _INTL("Phone")] end - commands[cmdJukebox = commands.length] = ["jukebox",_INTL("Jukebox")] + commands[cmdJukebox = commands.length] = ["jukebox", _INTL("Jukebox")] @scene.pbStartScene(commands) loop do cmd = @scene.pbScene - if cmd<0 + if cmd < 0 break - elsif cmdMap>=0 && cmd==cmdMap + elsif cmdMap >= 0 && cmd == cmdMap pbFadeOutIn { scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) @@ -153,11 +153,11 @@ class PokemonPokegearScreen end } break if $game_temp.fly_destination - elsif cmdPhone>=0 && cmd==cmdPhone + elsif cmdPhone >= 0 && cmd == cmdPhone pbFadeOutIn { PokemonPhoneScene.new.start } - elsif cmdJukebox>=0 && cmd==cmdJukebox + elsif cmdJukebox >= 0 && cmd == cmdJukebox pbFadeOutIn { scene = PokemonJukebox_Scene.new screen = PokemonJukeboxScreen.new(scene) diff --git a/Data/Scripts/016_UI/009_UI_RegionMap.rb b/Data/Scripts/016_UI/009_UI_RegionMap.rb index b5309f1e9..50a6217e7 100644 --- a/Data/Scripts/016_UI/009_UI_RegionMap.rb +++ b/Data/Scripts/016_UI/009_UI_RegionMap.rb @@ -177,13 +177,13 @@ class PokemonRegionMap_Scene # TODO: Why is this PBS file writer here? def pbSaveMapData - File.open("PBS/town_map.txt","wb") { |f| + File.open("PBS/town_map.txt", "wb") { |f| Compiler.add_PBS_header_to_file(f) for i in 0...@map_data.length map = @map_data[i] next if !map f.write("\#-------------------------------\r\n") - f.write(sprintf("[%d]\r\n",i)) + f.write(sprintf("[%d]\r\n", i)) f.write(sprintf("Name = %s\r\nFilename = %s\r\n", Compiler.csvQuote(map[0]), Compiler.csvQuote(map[1]))) for loc in map[2] diff --git a/Data/Scripts/016_UI/010_UI_Phone.rb b/Data/Scripts/016_UI/010_UI_Phone.rb index f06856185..d55b247ce 100644 --- a/Data/Scripts/016_UI/010_UI_Phone.rb +++ b/Data/Scripts/016_UI/010_UI_Phone.rb @@ -2,18 +2,18 @@ # Phone screen #=============================================================================== class Window_PhoneList < Window_CommandPokemon - def drawCursor(index,rect) + def drawCursor(index, rect) selarrow = AnimatedBitmap.new("Graphics/Pictures/phoneSel") - if self.index==index - pbCopyBitmap(self.contents,selarrow.bitmap,rect.x,rect.y) + if self.index == index + pbCopyBitmap(self.contents, selarrow.bitmap, rect.x, rect.y) end - return Rect.new(rect.x+28,rect.y+8,rect.width-16,rect.height) + return Rect.new(rect.x + 28, rect.y + 8, rect.width - 16, rect.height) end - def drawItem(index,count,rect) - return if index>=self.top_row+self.page_item_max + def drawItem(index, count, rect) + return if index >= self.top_row + self.page_item_max super - drawCursor(index-1,itemRect(index-1)) + drawCursor(index - 1, itemRect(index - 1)) end end @@ -27,48 +27,48 @@ class PokemonPhoneScene if $PokemonGlobal.phoneNumbers for num in $PokemonGlobal.phoneNumbers if num[0] # if visible - if num.length==8 # if trainer - @trainers.push([num[1],num[2],num[6],(num[4]>=2)]) + if num.length == 8 # if trainer + @trainers.push([num[1], num[2], num[6], (num[4] >= 2)]) else # if NPC - @trainers.push([num[1],num[2],num[3]]) + @trainers.push([num[1], num[2], num[3]]) end end end end - if @trainers.length==0 + if @trainers.length == 0 pbMessage(_INTL("There are no phone numbers stored.")) return end @sprites = {} - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 - @sprites["list"] = Window_PhoneList.newEmpty(152,32,Graphics.width-142,Graphics.height-80,@viewport) + @sprites["list"] = Window_PhoneList.newEmpty(152, 32, Graphics.width - 142, Graphics.height - 80, @viewport) @sprites["header"] = Window_UnformattedTextPokemon.newWithSize(_INTL("Phone"), - 2,-18,128,64,@viewport) - @sprites["header"].baseColor = Color.new(248,248,248) - @sprites["header"].shadowColor = Color.new(0,0,0) + 2, -18, 128, 64, @viewport) + @sprites["header"].baseColor = Color.new(248, 248, 248) + @sprites["header"].shadowColor = Color.new(0, 0, 0) mapname = (@trainers[0][2]) ? pbGetMapNameFromId(@trainers[0][2]) : "" @sprites["bottom"] = Window_AdvancedTextPokemon.newWithSize("", - 162,Graphics.height-64,Graphics.width-158,64,@viewport) - @sprites["bottom"].text = ""+mapname - @sprites["info"] = Window_AdvancedTextPokemon.newWithSize("",-8,224,180,160,@viewport) - addBackgroundPlane(@sprites,"bg","phonebg",@viewport) - @sprites["icon"] = IconSprite.new(70,102,@viewport) - if @trainers[0].length==4 + 162, Graphics.height - 64, Graphics.width - 158, 64, @viewport) + @sprites["bottom"].text = "" + mapname + @sprites["info"] = Window_AdvancedTextPokemon.newWithSize("", -8, 224, 180, 160, @viewport) + addBackgroundPlane(@sprites, "bg", "phonebg", @viewport) + @sprites["icon"] = IconSprite.new(70, 102, @viewport) + if @trainers[0].length == 4 filename = GameData::TrainerType.charset_filename(@trainers[0][0]) else - filename = sprintf("Graphics/Characters/phone%03d",@trainers[0][0]) + filename = sprintf("Graphics/Characters/phone%03d", @trainers[0][0]) end @sprites["icon"].setBitmap(filename) charwidth = @sprites["icon"].bitmap.width charheight = @sprites["icon"].bitmap.height - @sprites["icon"].x = 86-charwidth/8 - @sprites["icon"].y = 134-charheight/8 - @sprites["icon"].src_rect = Rect.new(0,0,charwidth/4,charheight/4) + @sprites["icon"].x = 86 - charwidth / 8 + @sprites["icon"].y = 134 - charheight / 8 + @sprites["icon"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4) for trainer in @trainers - if trainer.length==4 + if trainer.length == 4 displayname = _INTL("{1} {2}", GameData::TrainerType.get(trainer[0]).name, - pbGetMessageFromHash(MessageTypes::TrainerNames,trainer[1]) + pbGetMessageFromHash(MessageTypes::TrainerNames, trainer[1]) ) commands.push(displayname) # trainer's display name else @@ -77,11 +77,11 @@ class PokemonPhoneScene end @sprites["list"].commands = commands for i in 0...@sprites["list"].page_item_max - @sprites["rematch[#{i}]"] = IconSprite.new(468,62+i*32,@viewport) - j = i+@sprites["list"].top_item - next if j>=commands.length + @sprites["rematch[#{i}]"] = IconSprite.new(468, 62 + i * 32, @viewport) + j = i + @sprites["list"].top_item + next if j >= commands.length trainer = @trainers[j] - if trainer.length==4 + if trainer.length == 4 if trainer[3] @sprites["rematch[#{i}]"].setBitmap("Graphics/Pictures/phoneRematch") end @@ -89,42 +89,42 @@ class PokemonPhoneScene end rematchcount = 0 for trainer in @trainers - if trainer.length==4 + if trainer.length == 4 rematchcount += 1 if trainer[3] end end infotext = _INTL("Registered
") - infotext += _INTL(" {1}
",@sprites["list"].commands.length) - infotext += _INTL("Waiting for a rematch{1}",rematchcount) + infotext += _INTL(" {1}
", @sprites["list"].commands.length) + infotext += _INTL("Waiting for a rematch{1}", rematchcount) @sprites["info"].text = infotext pbFadeInAndShow(@sprites) - pbActivateWindow(@sprites,"list") { + pbActivateWindow(@sprites, "list") { oldindex = -1 loop do Graphics.update Input.update pbUpdateSpriteHash(@sprites) - if @sprites["list"].index!=oldindex + if @sprites["list"].index != oldindex trainer = @trainers[@sprites["list"].index] - if trainer.length==4 + if trainer.length == 4 filename = GameData::TrainerType.charset_filename(trainer[0]) else - filename = sprintf("Graphics/Characters/phone%03d",trainer[0]) + filename = sprintf("Graphics/Characters/phone%03d", trainer[0]) end @sprites["icon"].setBitmap(filename) charwidth = @sprites["icon"].bitmap.width charheight = @sprites["icon"].bitmap.height - @sprites["icon"].x = 86-charwidth/8 - @sprites["icon"].y = 134-charheight/8 - @sprites["icon"].src_rect = Rect.new(0,0,charwidth/4,charheight/4) + @sprites["icon"].x = 86 - charwidth / 8 + @sprites["icon"].y = 134 - charheight / 8 + @sprites["icon"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4) mapname = (trainer[2]) ? pbGetMapNameFromId(trainer[2]) : "" - @sprites["bottom"].text = ""+mapname + @sprites["bottom"].text = "" + mapname for i in 0...@sprites["list"].page_item_max @sprites["rematch[#{i}]"].clearBitmaps - j = i+@sprites["list"].top_item - next if j>=commands.length + j = i + @sprites["list"].top_item + next if j >= commands.length trainer = @trainers[j] - if trainer.length==4 + if trainer.length == 4 if trainer[3] @sprites["rematch[#{i}]"].setBitmap("Graphics/Pictures/phoneRematch") end @@ -136,8 +136,8 @@ class PokemonPhoneScene break elsif Input.trigger?(Input::USE) index = @sprites["list"].index - if index>=0 - pbCallTrainer(@trainers[index][0],@trainers[index][1]) + if index >= 0 + pbCallTrainer(@trainers[index][0], @trainers[index][1]) end end end diff --git a/Data/Scripts/016_UI/011_UI_Jukebox.rb b/Data/Scripts/016_UI/011_UI_Jukebox.rb index d3badccfe..601efa58e 100644 --- a/Data/Scripts/016_UI/011_UI_Jukebox.rb +++ b/Data/Scripts/016_UI/011_UI_Jukebox.rb @@ -8,18 +8,18 @@ class PokemonJukebox_Scene def pbStartScene(commands) @commands = commands - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) @sprites["background"].setBitmap("Graphics/Pictures/jukeboxbg") @sprites["header"] = Window_UnformattedTextPokemon.newWithSize( - _INTL("Jukebox"),2,-18,128,64,@viewport) - @sprites["header"].baseColor = Color.new(248,248,248) - @sprites["header"].shadowColor = Color.new(0,0,0) + _INTL("Jukebox"), 2, -18, 128, 64, @viewport) + @sprites["header"].baseColor = Color.new(248, 248, 248) + @sprites["header"].shadowColor = Color.new(0, 0, 0) @sprites["header"].windowskin = nil @sprites["commands"] = Window_CommandPokemon.newWithSize(@commands, - 94,92,324,224,@viewport) + 94, 92, 324, 224, @viewport) @sprites["commands"].windowskin = nil pbFadeInAndShow(@sprites) { pbUpdate } end @@ -40,7 +40,7 @@ class PokemonJukebox_Scene return ret end - def pbSetCommands(newcommands,newindex) + def pbSetCommands(newcommands, newindex) @sprites["commands"].commands = (!newcommands) ? @commands : newcommands @sprites["commands"].index = newindex end @@ -74,25 +74,25 @@ class PokemonJukeboxScreen @scene.pbStartScene(commands) loop do cmd = @scene.pbScene - if cmd<0 + if cmd < 0 pbPlayCloseMenuSE break - elsif cmdMarch>=0 && cmd==cmdMarch + elsif cmdMarch >= 0 && cmd == cmdMarch pbPlayDecisionSE pbBGMPlay("Radio - March", 100, 100) $PokemonMap.whiteFluteUsed = true if $PokemonMap $PokemonMap.blackFluteUsed = false if $PokemonMap - elsif cmdLullaby>=0 && cmd==cmdLullaby + elsif cmdLullaby >= 0 && cmd == cmdLullaby pbPlayDecisionSE pbBGMPlay("Radio - Lullaby", 100, 100) $PokemonMap.blackFluteUsed = true if $PokemonMap $PokemonMap.whiteFluteUsed = false if $PokemonMap - elsif cmdOak>=0 && cmd==cmdOak + elsif cmdOak >= 0 && cmd == cmdOak pbPlayDecisionSE pbBGMPlay("Radio - Oak", 100, 100) $PokemonMap.whiteFluteUsed = false if $PokemonMap $PokemonMap.blackFluteUsed = false if $PokemonMap - elsif cmdCustom>=0 && cmd==cmdCustom + elsif cmdCustom >= 0 && cmd == cmdCustom pbPlayDecisionSE files = [_INTL("(Default)")] Dir.chdir("Audio/BGM/") { @@ -107,13 +107,13 @@ class PokemonJukeboxScreen Dir.glob("*.midi") { |f| files.push(f) } Dir.glob("*.MIDI") { |f| files.push(f) } } - @scene.pbSetCommands(files,0) + @scene.pbSetCommands(files, 0) loop do cmd2 = @scene.pbScene - if cmd2<0 + if cmd2 < 0 pbPlayCancelSE break - elsif cmd2==0 + elsif cmd2 == 0 pbPlayDecisionSE $game_system.setDefaultBGM(nil) $PokemonMap.whiteFluteUsed = false if $PokemonMap @@ -125,7 +125,7 @@ class PokemonJukeboxScreen $PokemonMap.blackFluteUsed = false if $PokemonMap end end - @scene.pbSetCommands(nil,cmdCustom) + @scene.pbSetCommands(nil, cmdCustom) else # Exit pbPlayCloseMenuSE break diff --git a/Data/Scripts/016_UI/012_UI_TrainerCard.rb b/Data/Scripts/016_UI/012_UI_TrainerCard.rb index fb0a5f7c6..85c0dc8f5 100644 --- a/Data/Scripts/016_UI/012_UI_TrainerCard.rb +++ b/Data/Scripts/016_UI/012_UI_TrainerCard.rb @@ -7,28 +7,28 @@ class PokemonTrainerCard_Scene end def pbStartScene - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites = {} background = pbResolveBitmap(sprintf("Graphics/Pictures/Trainer Card/bg_f")) if $player.female? && background - addBackgroundPlane(@sprites,"bg","Trainer Card/bg_f",@viewport) + addBackgroundPlane(@sprites, "bg", "Trainer Card/bg_f", @viewport) else - addBackgroundPlane(@sprites,"bg","Trainer Card/bg",@viewport) + addBackgroundPlane(@sprites, "bg", "Trainer Card/bg", @viewport) end cardexists = pbResolveBitmap(sprintf("Graphics/Pictures/Trainer Card/card_f")) - @sprites["card"] = IconSprite.new(0,0,@viewport) + @sprites["card"] = IconSprite.new(0, 0, @viewport) if $player.female? && cardexists @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_f") else @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card") end - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) - @sprites["trainer"] = IconSprite.new(336,112,@viewport) + @sprites["trainer"] = IconSprite.new(336, 112, @viewport) @sprites["trainer"].setBitmap(GameData::TrainerType.player_front_sprite_filename($player.trainer_type)) - @sprites["trainer"].x -= (@sprites["trainer"].bitmap.width-128)/2 - @sprites["trainer"].y -= (@sprites["trainer"].bitmap.height-128) + @sprites["trainer"].x -= (@sprites["trainer"].bitmap.width - 128) / 2 + @sprites["trainer"].y -= (@sprites["trainer"].bitmap.height - 128) @sprites["trainer"].z = 2 pbDrawTrainerCardFront pbFadeInAndShow(@sprites) { pbUpdate } @@ -37,42 +37,42 @@ class PokemonTrainerCard_Scene def pbDrawTrainerCardFront overlay = @sprites["overlay"].bitmap overlay.clear - baseColor = Color.new(72,72,72) - shadowColor = Color.new(160,160,160) + baseColor = Color.new(72, 72, 72) + shadowColor = Color.new(160, 160, 160) totalsec = $stats.play_time.to_i hour = totalsec / 60 / 60 min = totalsec / 60 % 60 - time = (hour>0) ? _INTL("{1}h {2}m",hour,min) : _INTL("{1}m",min) + time = (hour > 0) ? _INTL("{1}h {2}m", hour, min) : _INTL("{1}m", min) $PokemonGlobal.startTime = pbGetTimeNow if !$PokemonGlobal.startTime starttime = _INTL("{1} {2}, {3}", pbGetAbbrevMonthName($PokemonGlobal.startTime.mon), $PokemonGlobal.startTime.day, $PokemonGlobal.startTime.year) textPositions = [ - [_INTL("Name"),34,58,0,baseColor,shadowColor], - [$player.name,302,58,1,baseColor,shadowColor], - [_INTL("ID No."),332,58,0,baseColor,shadowColor], - [sprintf("%05d",$player.public_ID),468,58,1,baseColor,shadowColor], - [_INTL("Money"),34,106,0,baseColor,shadowColor], - [_INTL("${1}",$player.money.to_s_formatted),302,106,1,baseColor,shadowColor], - [_INTL("Pokédex"),34,154,0,baseColor,shadowColor], - [sprintf("%d/%d",$player.pokedex.owned_count,$player.pokedex.seen_count),302,154,1,baseColor,shadowColor], - [_INTL("Time"),34,202,0,baseColor,shadowColor], - [time,302,202,1,baseColor,shadowColor], - [_INTL("Started"),34,250,0,baseColor,shadowColor], - [starttime,302,250,1,baseColor,shadowColor] + [_INTL("Name"), 34, 58, 0, baseColor, shadowColor], + [$player.name, 302, 58, 1, baseColor, shadowColor], + [_INTL("ID No."), 332, 58, 0, baseColor, shadowColor], + [sprintf("%05d", $player.public_ID), 468, 58, 1, baseColor, shadowColor], + [_INTL("Money"), 34, 106, 0, baseColor, shadowColor], + [_INTL("${1}", $player.money.to_s_formatted), 302, 106, 1, baseColor, shadowColor], + [_INTL("Pokédex"), 34, 154, 0, baseColor, shadowColor], + [sprintf("%d/%d", $player.pokedex.owned_count, $player.pokedex.seen_count), 302, 154, 1, baseColor, shadowColor], + [_INTL("Time"), 34, 202, 0, baseColor, shadowColor], + [time, 302, 202, 1, baseColor, shadowColor], + [_INTL("Started"), 34, 250, 0, baseColor, shadowColor], + [starttime, 302, 250, 1, baseColor, shadowColor] ] - pbDrawTextPositions(overlay,textPositions) + pbDrawTextPositions(overlay, textPositions) x = 72 region = pbGetCurrentRegion(0) # Get the current region imagePositions = [] for i in 0...8 - if $player.badges[i+region*8] - imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges",x,310,i*32,region*32,32,32]) + if $player.badges[i + region * 8] + imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges", x, 310, i * 32, region * 32, 32, 32]) end x += 48 end - pbDrawImagePositions(overlay,imagePositions) + pbDrawImagePositions(overlay, imagePositions) end def pbTrainerCard diff --git a/Data/Scripts/016_UI/013_UI_Load.rb b/Data/Scripts/016_UI/013_UI_Load.rb index 149b06ac2..4993c5269 100644 --- a/Data/Scripts/016_UI/013_UI_Load.rb +++ b/Data/Scripts/016_UI/013_UI_Load.rb @@ -4,12 +4,12 @@ class PokemonLoadPanel < SpriteWrapper attr_reader :selected - TEXTCOLOR = Color.new(232,232,232) - TEXTSHADOWCOLOR = Color.new(136,136,136) - MALETEXTCOLOR = Color.new(56,160,248) - MALETEXTSHADOWCOLOR = Color.new(56,104,168) - FEMALETEXTCOLOR = Color.new(240,72,88) - FEMALETEXTSHADOWCOLOR = Color.new(160,64,64) + TEXTCOLOR = Color.new(232, 232, 232) + TEXTSHADOWCOLOR = Color.new(136, 136, 136) + MALETEXTCOLOR = Color.new(56, 160, 248) + MALETEXTSHADOWCOLOR = Color.new(56, 104, 168) + FEMALETEXTCOLOR = Color.new(240, 72, 88) + FEMALETEXTSHADOWCOLOR = Color.new(160, 64, 64) def initialize(index, title, isContinue, trainer, framecount, stats, mapid, viewport = nil) super(viewport) @@ -19,7 +19,7 @@ class PokemonLoadPanel < SpriteWrapper @trainer = trainer @totalsec = (stats) ? stats.play_time.to_i : ((framecount || 0) / Graphics.frame_rate) @mapid = mapid - @selected = (index==0) + @selected = (index == 0) @bgbitmap = AnimatedBitmap.new("Graphics/Pictures/loadPanels") @refreshBitmap = true @refreshing = false @@ -33,7 +33,7 @@ class PokemonLoadPanel < SpriteWrapper end def selected=(value) - return if @selected==value + return if @selected == value @selected = value @refreshBitmap = true refresh @@ -49,46 +49,46 @@ class PokemonLoadPanel < SpriteWrapper return if disposed? @refreshing = true if !self.bitmap || self.bitmap.disposed? - self.bitmap = BitmapWrapper.new(@bgbitmap.width,111*2) + self.bitmap = BitmapWrapper.new(@bgbitmap.width, 111 * 2) pbSetSystemFont(self.bitmap) end if @refreshBitmap @refreshBitmap = false self.bitmap.clear if self.bitmap if @isContinue - self.bitmap.blt(0,0,@bgbitmap.bitmap,Rect.new(0,(@selected) ? 111*2 : 0,@bgbitmap.width,111*2)) + self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, (@selected) ? 111 * 2 : 0, @bgbitmap.width, 111 * 2)) else - self.bitmap.blt(0,0,@bgbitmap.bitmap,Rect.new(0,111*2*2+((@selected) ? 23*2 : 0),@bgbitmap.width,23*2)) + self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, 111 * 2 * 2 + ((@selected) ? 23 * 2 : 0), @bgbitmap.width, 23 * 2)) end textpos = [] if @isContinue - textpos.push([@title,16*2,2*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) - textpos.push([_INTL("Badges:"),16*2,53*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) - textpos.push([@trainer.badge_count.to_s,103*2,53*2,1,TEXTCOLOR,TEXTSHADOWCOLOR]) - textpos.push([_INTL("Pokédex:"),16*2,69*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) - textpos.push([@trainer.pokedex.seen_count.to_s,103*2,69*2,1,TEXTCOLOR,TEXTSHADOWCOLOR]) - textpos.push([_INTL("Time:"),16*2,85*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) + textpos.push([@title, 16 * 2, 2 * 2, 0, TEXTCOLOR, TEXTSHADOWCOLOR]) + textpos.push([_INTL("Badges:"), 16 * 2, 53 * 2, 0, TEXTCOLOR, TEXTSHADOWCOLOR]) + textpos.push([@trainer.badge_count.to_s, 103 * 2, 53 * 2, 1, TEXTCOLOR, TEXTSHADOWCOLOR]) + textpos.push([_INTL("Pokédex:"), 16 * 2, 69 * 2, 0, TEXTCOLOR, TEXTSHADOWCOLOR]) + textpos.push([@trainer.pokedex.seen_count.to_s, 103 * 2, 69 * 2, 1, TEXTCOLOR, TEXTSHADOWCOLOR]) + textpos.push([_INTL("Time:"), 16 * 2, 85 * 2, 0, TEXTCOLOR, TEXTSHADOWCOLOR]) hour = @totalsec / 60 / 60 min = @totalsec / 60 % 60 - if hour>0 - textpos.push([_INTL("{1}h {2}m",hour,min),103*2,85*2,1,TEXTCOLOR,TEXTSHADOWCOLOR]) + if hour > 0 + textpos.push([_INTL("{1}h {2}m", hour, min), 103 * 2, 85 * 2, 1, TEXTCOLOR, TEXTSHADOWCOLOR]) else - textpos.push([_INTL("{1}m",min),103*2,85*2,1,TEXTCOLOR,TEXTSHADOWCOLOR]) + textpos.push([_INTL("{1}m", min), 103 * 2, 85 * 2, 1, TEXTCOLOR, TEXTSHADOWCOLOR]) end if @trainer.male? - textpos.push([@trainer.name,56*2,29*2,0,MALETEXTCOLOR,MALETEXTSHADOWCOLOR]) + textpos.push([@trainer.name, 56 * 2, 29 * 2, 0, MALETEXTCOLOR, MALETEXTSHADOWCOLOR]) elsif @trainer.female? - textpos.push([@trainer.name,56*2,29*2,0,FEMALETEXTCOLOR,FEMALETEXTSHADOWCOLOR]) + textpos.push([@trainer.name, 56 * 2, 29 * 2, 0, FEMALETEXTCOLOR, FEMALETEXTSHADOWCOLOR]) else - textpos.push([@trainer.name,56*2,29*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) + textpos.push([@trainer.name, 56 * 2, 29 * 2, 0, TEXTCOLOR, TEXTSHADOWCOLOR]) end mapname = pbGetMapNameFromId(@mapid) - mapname.gsub!(/\\PN/,@trainer.name) - textpos.push([mapname,193*2,2*2,1,TEXTCOLOR,TEXTSHADOWCOLOR]) + mapname.gsub!(/\\PN/, @trainer.name) + textpos.push([mapname, 193 * 2, 2 * 2, 1, TEXTCOLOR, TEXTSHADOWCOLOR]) else - textpos.push([@title,16*2,1*2,0,TEXTCOLOR,TEXTSHADOWCOLOR]) + textpos.push([@title, 16 * 2, 1 * 2, 0, TEXTCOLOR, TEXTSHADOWCOLOR]) end - pbDrawTextPositions(self.bitmap,textpos) + pbDrawTextPositions(self.bitmap, textpos) end @refreshing = false end @@ -103,15 +103,15 @@ class PokemonLoad_Scene @sprites = {} @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99998 - addBackgroundOrColoredPlane(@sprites,"background","loadbg",Color.new(248,248,248),@viewport) - y = 16*2 + addBackgroundOrColoredPlane(@sprites, "background", "loadbg", Color.new(248, 248, 248), @viewport) + y = 16 * 2 for i in 0...commands.length @sprites["panel#{i}"] = PokemonLoadPanel.new(i, commands[i], (show_continue) ? (i == 0) : false, trainer, frame_count, stats, map_id, @viewport) - @sprites["panel#{i}"].x = 24*2 + @sprites["panel#{i}"].x = 24 * 2 @sprites["panel#{i}"].y = y @sprites["panel#{i}"].pbRefresh - y += (show_continue && i==0) ? 112*2 : 24*2 + y += (show_continue && i == 0) ? 112 * 2 : 24 * 2 end @sprites["cmdwindow"] = Window_CommandPokemon.new([]) @sprites["cmdwindow"].viewport = @viewport @@ -124,39 +124,39 @@ class PokemonLoad_Scene def pbStartDeleteScene @sprites = {} - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99998 - addBackgroundOrColoredPlane(@sprites,"background","loadbg",Color.new(248,248,248),@viewport) + addBackgroundOrColoredPlane(@sprites, "background", "loadbg", Color.new(248, 248, 248), @viewport) end def pbUpdate oldi = @sprites["cmdwindow"].index rescue 0 pbUpdateSpriteHash(@sprites) newi = @sprites["cmdwindow"].index rescue 0 - if oldi!=newi + if oldi != newi @sprites["panel#{oldi}"].selected = false @sprites["panel#{oldi}"].pbRefresh @sprites["panel#{newi}"].selected = true @sprites["panel#{newi}"].pbRefresh - while @sprites["panel#{newi}"].y>Graphics.height-40*2 + while @sprites["panel#{newi}"].y > Graphics.height - 40 * 2 for i in 0...@commands.length - @sprites["panel#{i}"].y -= 24*2 + @sprites["panel#{i}"].y -= 24 * 2 end for i in 0...6 break if !@sprites["party#{i}"] - @sprites["party#{i}"].y -= 24*2 + @sprites["party#{i}"].y -= 24 * 2 end - @sprites["player"].y -= 24*2 if @sprites["player"] + @sprites["player"].y -= 24 * 2 if @sprites["player"] end - while @sprites["panel#{newi}"].y<16*2 + while @sprites["panel#{newi}"].y < 16 * 2 for i in 0...@commands.length - @sprites["panel#{i}"].y += 24*2 + @sprites["panel#{i}"].y += 24 * 2 end for i in 0...6 break if !@sprites["party#{i}"] - @sprites["party#{i}"].y += 24*2 + @sprites["party#{i}"].y += 24 * 2 end - @sprites["player"].y += 24*2 if @sprites["player"] + @sprites["player"].y += 24 * 2 if @sprites["player"] end end end @@ -166,18 +166,18 @@ class PokemonLoad_Scene meta = GameData::PlayerMetadata.get(trainer.character_ID) if meta filename = pbGetPlayerCharset(meta.walk_charset, trainer, true) - @sprites["player"] = TrainerWalkingCharSprite.new(filename,@viewport) + @sprites["player"] = TrainerWalkingCharSprite.new(filename, @viewport) charwidth = @sprites["player"].bitmap.width charheight = @sprites["player"].bitmap.height - @sprites["player"].x = 56*2-charwidth/8 - @sprites["player"].y = 56*2-charheight/8 - @sprites["player"].src_rect = Rect.new(0,0,charwidth/4,charheight/4) + @sprites["player"].x = 56 * 2 - charwidth / 8 + @sprites["player"].y = 56 * 2 - charheight / 8 + @sprites["player"].src_rect = Rect.new(0, 0, charwidth / 4, charheight / 4) end for i in 0...trainer.party.length - @sprites["party#{i}"] = PokemonIconSprite.new(trainer.party[i],@viewport) + @sprites["party#{i}"] = PokemonIconSprite.new(trainer.party[i], @viewport) @sprites["party#{i}"].setOffset(PictureOrigin::Center) - @sprites["party#{i}"].x = (167+33*(i%2))*2 - @sprites["party#{i}"].y = (56+25*(i/2))*2 + @sprites["party#{i}"].x = (167 + 33 * (i % 2)) * 2 + @sprites["party#{i}"].y = (56 + 25 * (i / 2)) * 2 @sprites["party#{i}"].z = 99999 end end diff --git a/Data/Scripts/016_UI/014_UI_Save.rb b/Data/Scripts/016_UI/014_UI_Save.rb index 1ca82f7a5..b9479ef1c 100644 --- a/Data/Scripts/016_UI/014_UI_Save.rb +++ b/Data/Scripts/016_UI/014_UI_Save.rb @@ -25,32 +25,32 @@ end #=============================================================================== class PokemonSave_Scene def pbStartScreen - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 - @sprites={} + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 + @sprites = {} totalsec = $stats.play_time.to_i hour = totalsec / 60 / 60 min = totalsec / 60 % 60 - mapname=$game_map.name - textColor = ["0070F8,78B8E8","E82010,F8A8B8","0070F8,78B8E8"][$player.gender] + mapname = $game_map.name + textColor = ["0070F8,78B8E8", "E82010,F8A8B8", "0070F8,78B8E8"][$player.gender] locationColor = "209808,90F090" # green - loctext=_INTL("{2}",locationColor,mapname) - loctext+=_INTL("Player{2}
",textColor,$player.name) - if hour>0 - loctext+=_INTL("Time{2}h {3}m
",textColor,hour,min) + loctext = _INTL("{2}", locationColor, mapname) + loctext += _INTL("Player{2}
", textColor, $player.name) + if hour > 0 + loctext += _INTL("Time{2}h {3}m
", textColor, hour, min) else - loctext+=_INTL("Time{2}m
",textColor,min) + loctext += _INTL("Time{2}m
", textColor, min) end - loctext+=_INTL("Badges{2}
",textColor,$player.badge_count) + loctext += _INTL("Badges{2}
", textColor, $player.badge_count) if $player.has_pokedex - loctext+=_INTL("Pokédex{2}/{3}",textColor,$player.pokedex.owned_count,$player.pokedex.seen_count) + loctext += _INTL("Pokédex{2}/{3}", textColor, $player.pokedex.owned_count, $player.pokedex.seen_count) end - @sprites["locwindow"]=Window_AdvancedTextPokemon.new(loctext) - @sprites["locwindow"].viewport=@viewport - @sprites["locwindow"].x=0 - @sprites["locwindow"].y=0 - @sprites["locwindow"].width=228 if @sprites["locwindow"].width<228 - @sprites["locwindow"].visible=true + @sprites["locwindow"] = Window_AdvancedTextPokemon.new(loctext) + @sprites["locwindow"].viewport = @viewport + @sprites["locwindow"].x = 0 + @sprites["locwindow"].y = 0 + @sprites["locwindow"].width = 228 if @sprites["locwindow"].width < 228 + @sprites["locwindow"].visible = true end def pbEndScreen @@ -64,11 +64,11 @@ end #=============================================================================== class PokemonSaveScreen def initialize(scene) - @scene=scene + @scene = scene end - def pbDisplay(text,brief = false) - @scene.pbDisplay(text,brief) + def pbDisplay(text, brief = false) + @scene.pbDisplay(text, brief) end def pbDisplayPaused(text) diff --git a/Data/Scripts/016_UI/015_UI_Options.rb b/Data/Scripts/016_UI/015_UI_Options.rb index e200039bf..4f8e35ac9 100644 --- a/Data/Scripts/016_UI/015_UI_Options.rb +++ b/Data/Scripts/016_UI/015_UI_Options.rb @@ -50,7 +50,7 @@ class EnumOption attr_reader :values attr_reader :name - def initialize(name,options,getProc,setProc) + def initialize(name, options, getProc, setProc) @name = name @values = options @getProc = getProc @@ -58,14 +58,14 @@ class EnumOption end def next(current) - index = current+1 - index = @values.length-1 if index>@values.length-1 + index = current + 1 + index = @values.length - 1 if index > @values.length - 1 return index end def prev(current) - index = current-1 - index = 0 if index<0 + index = current - 1 + index = 0 if index < 0 return index end end @@ -78,7 +78,7 @@ class EnumOption2 attr_reader :values attr_reader :name - def initialize(name,options,getProc,setProc) + def initialize(name, options, getProc, setProc) @name = name @values = options @getProc = getProc @@ -86,14 +86,14 @@ class EnumOption2 end def next(current) - index = current+1 - index = @values.length-1 if index>@values.length-1 + index = current + 1 + index = @values.length - 1 if index > @values.length - 1 return index end def prev(current) - index = current-1 - index = 0 if index<0 + index = current - 1 + index = 0 if index < 0 return index end end @@ -107,7 +107,7 @@ class NumberOption attr_reader :optstart attr_reader :optend - def initialize(name,optstart,optend,getProc,setProc) + def initialize(name, optstart, optend, getProc, setProc) @name = name @optstart = optstart @optend = optend @@ -116,17 +116,17 @@ class NumberOption end def next(current) - index = current+@optstart + index = current + @optstart index += 1 - index = @optstart if index>@optend - return index-@optstart + index = @optstart if index > @optend + return index - @optstart end def prev(current) - index = current+@optstart + index = current + @optstart index -= 1 - index = @optend if index<@optstart - return index-@optstart + index = @optend if index < @optstart + return index - @optstart end end @@ -139,7 +139,7 @@ class SliderOption attr_reader :optstart attr_reader :optend - def initialize(name,optstart,optend,optinterval,getProc,setProc) + def initialize(name, optstart, optend, optinterval, getProc, setProc) @name = name @optstart = optstart @optend = optend @@ -149,17 +149,17 @@ class SliderOption end def next(current) - index = current+@optstart + index = current + @optstart index += @optinterval - index = @optend if index>@optend - return index-@optstart + index = @optend if index > @optend + return index - @optstart end def prev(current) - index = current+@optstart + index = current + @optstart index -= @optinterval - index = @optstart if index<@optstart - return index-@optstart + index = @optstart if index < @optstart + return index - @optstart end end @@ -169,92 +169,92 @@ end class Window_PokemonOption < Window_DrawableCommand attr_reader :mustUpdateOptions - def initialize(options,x,y,width,height) + def initialize(options, x, y, width, height) @options = options - @nameBaseColor = Color.new(24*8,15*8,0) - @nameShadowColor = Color.new(31*8,22*8,10*8) - @selBaseColor = Color.new(31*8,6*8,3*8) - @selShadowColor = Color.new(31*8,17*8,16*8) + @nameBaseColor = Color.new(24 * 8, 15 * 8, 0) + @nameShadowColor = Color.new(31 * 8, 22 * 8, 10 * 8) + @selBaseColor = Color.new(31 * 8, 6 * 8, 3 * 8) + @selShadowColor = Color.new(31 * 8, 17 * 8, 16 * 8) @optvalues = [] @mustUpdateOptions = false for i in 0...@options.length @optvalues[i] = 0 end - super(x,y,width,height) + super(x, y, width, height) end def [](i) return @optvalues[i] end - def []=(i,value) + def []=(i, value) @optvalues[i] = value refresh end - def setValueNoRefresh(i,value) + def setValueNoRefresh(i, value) @optvalues[i] = value end def itemCount - return @options.length+1 + return @options.length + 1 end - def drawItem(index,_count,rect) - rect = drawCursor(index,rect) - optionname = (index==@options.length) ? _INTL("Cancel") : @options[index].name - optionwidth = rect.width*9/20 - pbDrawShadowText(self.contents,rect.x,rect.y,optionwidth,rect.height,optionname, - @nameBaseColor,@nameShadowColor) - return if index==@options.length + def drawItem(index, _count, rect) + rect = drawCursor(index, rect) + optionname = (index == @options.length) ? _INTL("Cancel") : @options[index].name + optionwidth = rect.width * 9 / 20 + pbDrawShadowText(self.contents, rect.x, rect.y, optionwidth, rect.height, optionname, + @nameBaseColor, @nameShadowColor) + return if index == @options.length if @options[index].is_a?(EnumOption) - if @options[index].values.length>1 + if @options[index].values.length > 1 totalwidth = 0 for value in @options[index].values totalwidth += self.contents.text_size(value).width end - spacing = (optionwidth-totalwidth)/(@options[index].values.length-1) - spacing = 0 if spacing<0 - xpos = optionwidth+rect.x + spacing = (optionwidth - totalwidth) / (@options[index].values.length - 1) + spacing = 0 if spacing < 0 + xpos = optionwidth + rect.x ivalue = 0 for value in @options[index].values - pbDrawShadowText(self.contents,xpos,rect.y,optionwidth,rect.height,value, - (ivalue==self[index]) ? @selBaseColor : self.baseColor, - (ivalue==self[index]) ? @selShadowColor : self.shadowColor + pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value, + (ivalue == self[index]) ? @selBaseColor : self.baseColor, + (ivalue == self[index]) ? @selShadowColor : self.shadowColor ) xpos += self.contents.text_size(value).width xpos += spacing ivalue += 1 end else - pbDrawShadowText(self.contents,rect.x+optionwidth,rect.y,optionwidth,rect.height, - optionname,self.baseColor,self.shadowColor) + pbDrawShadowText(self.contents, rect.x + optionwidth, rect.y, optionwidth, rect.height, + optionname, self.baseColor, self.shadowColor) end elsif @options[index].is_a?(NumberOption) - value = _INTL("Type {1}/{2}",@options[index].optstart+self[index], - @options[index].optend-@options[index].optstart+1) - xpos = optionwidth+rect.x - pbDrawShadowText(self.contents,xpos,rect.y,optionwidth,rect.height,value, - @selBaseColor,@selShadowColor) + value = _INTL("Type {1}/{2}", @options[index].optstart + self[index], + @options[index].optend - @options[index].optstart + 1) + xpos = optionwidth + rect.x + pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value, + @selBaseColor, @selShadowColor) elsif @options[index].is_a?(SliderOption) - value = sprintf(" %d",@options[index].optend) - sliderlength = optionwidth-self.contents.text_size(value).width - xpos = optionwidth+rect.x - self.contents.fill_rect(xpos,rect.y-2+rect.height/2, - optionwidth-self.contents.text_size(value).width,4,self.baseColor) + value = sprintf(" %d", @options[index].optend) + sliderlength = optionwidth - self.contents.text_size(value).width + xpos = optionwidth + rect.x + self.contents.fill_rect(xpos, rect.y - 2 + rect.height / 2, + optionwidth - self.contents.text_size(value).width, 4, self.baseColor) self.contents.fill_rect( - xpos+(sliderlength-8)*(@options[index].optstart+self[index])/@options[index].optend, - rect.y-8+rect.height/2, - 8,16,@selBaseColor) - value = sprintf("%d",@options[index].optstart+self[index]) - xpos += optionwidth-self.contents.text_size(value).width - pbDrawShadowText(self.contents,xpos,rect.y,optionwidth,rect.height,value, - @selBaseColor,@selShadowColor) + xpos + (sliderlength - 8) * (@options[index].optstart + self[index]) / @options[index].optend, + rect.y - 8 + rect.height / 2, + 8, 16, @selBaseColor) + value = sprintf("%d", @options[index].optstart + self[index]) + xpos += optionwidth - self.contents.text_size(value).width + pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value, + @selBaseColor, @selShadowColor) else value = @options[index].values[self[index]] - xpos = optionwidth+rect.x - pbDrawShadowText(self.contents,xpos,rect.y,optionwidth,rect.height,value, - @selBaseColor,@selShadowColor) + xpos = optionwidth + rect.x + pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value, + @selBaseColor, @selShadowColor) end end @@ -262,8 +262,8 @@ class Window_PokemonOption < Window_DrawableCommand oldindex = self.index @mustUpdateOptions = false super - dorefresh = (self.index!=oldindex) - if self.active && self.index<@options.length + dorefresh = (self.index != oldindex) + if self.active && self.index < @options.length if Input.repeat?(Input::LEFT) self[self.index] = @options[self.index].prev(self[self.index]) dorefresh = true @@ -288,24 +288,24 @@ class PokemonOption_Scene def pbStartScene(inloadscreen = false) @sprites = {} - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites["title"] = Window_UnformattedTextPokemon.newWithSize( - _INTL("Options"),0,0,Graphics.width,64,@viewport) + _INTL("Options"), 0, 0, Graphics.width, 64, @viewport) @sprites["textbox"] = pbCreateMessageWindow - @sprites["textbox"].text = _INTL("Speech frame {1}.",1+$PokemonSystem.textskin) + @sprites["textbox"].text = _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin) @sprites["textbox"].letterbyletter = false pbSetSystemFont(@sprites["textbox"].contents) # These are the different options in the game. To add an option, define a # setter and a getter for that option. To delete an option, comment it out # or delete it. The game's options may be placed in any order. @PokemonOptions = [ - SliderOption.new(_INTL("Music Volume"),0,100,5, + SliderOption.new(_INTL("Music Volume"), 0, 100, 5, proc { $PokemonSystem.bgmvolume }, proc { |value| - if $PokemonSystem.bgmvolume!=value + if $PokemonSystem.bgmvolume != value $PokemonSystem.bgmvolume = value - if $game_system.playing_bgm!=nil && !inloadscreen + if $game_system.playing_bgm != nil && !inloadscreen playingBGM = $game_system.getPlayingBGM $game_system.bgm_pause $game_system.bgm_resume(playingBGM) @@ -313,12 +313,12 @@ class PokemonOption_Scene end } ), - SliderOption.new(_INTL("SE Volume"),0,100,5, + SliderOption.new(_INTL("SE Volume"), 0, 100, 5, proc { $PokemonSystem.sevolume }, proc { |value| - if $PokemonSystem.sevolume!=value + if $PokemonSystem.sevolume != value $PokemonSystem.sevolume = value - if $game_system.playing_bgs!=nil + if $game_system.playing_bgs != nil $game_system.playing_bgs.volume = value playingBGS = $game_system.getPlayingBGS $game_system.bgs_pause @@ -328,44 +328,44 @@ class PokemonOption_Scene end } ), - EnumOption.new(_INTL("Text Speed"),[_INTL("Slow"),_INTL("Normal"),_INTL("Fast")], + EnumOption.new(_INTL("Text Speed"), [_INTL("Slow"), _INTL("Normal"), _INTL("Fast")], proc { $PokemonSystem.textspeed }, proc { |value| $PokemonSystem.textspeed = value MessageConfig.pbSetTextSpeed(MessageConfig.pbSettingToTextSpeed(value)) } ), - EnumOption.new(_INTL("Battle Effects"),[_INTL("On"),_INTL("Off")], + EnumOption.new(_INTL("Battle Effects"), [_INTL("On"), _INTL("Off")], proc { $PokemonSystem.battlescene }, proc { |value| $PokemonSystem.battlescene = value } ), - EnumOption.new(_INTL("Battle Style"),[_INTL("Switch"),_INTL("Set")], + EnumOption.new(_INTL("Battle Style"), [_INTL("Switch"), _INTL("Set")], proc { $PokemonSystem.battlestyle }, proc { |value| $PokemonSystem.battlestyle = value } ), - EnumOption.new(_INTL("Default Movement"),[_INTL("Walking"),_INTL("Running")], + EnumOption.new(_INTL("Default Movement"), [_INTL("Walking"), _INTL("Running")], proc { $PokemonSystem.runstyle }, proc { |value| $PokemonSystem.runstyle = value } ), - NumberOption.new(_INTL("Speech Frame"),1,Settings::SPEECH_WINDOWSKINS.length, + NumberOption.new(_INTL("Speech Frame"), 1, Settings::SPEECH_WINDOWSKINS.length, proc { $PokemonSystem.textskin }, proc { |value| $PokemonSystem.textskin = value MessageConfig.pbSetSpeechFrame("Graphics/Windowskins/" + Settings::SPEECH_WINDOWSKINS[value]) } ), - NumberOption.new(_INTL("Menu Frame"),1,Settings::MENU_WINDOWSKINS.length, + NumberOption.new(_INTL("Menu Frame"), 1, Settings::MENU_WINDOWSKINS.length, proc { $PokemonSystem.frame }, proc { |value| $PokemonSystem.frame = value MessageConfig.pbSetSystemFrame("Graphics/Windowskins/" + Settings::MENU_WINDOWSKINS[value]) } ), - EnumOption.new(_INTL("Text Entry"),[_INTL("Cursor"),_INTL("Keyboard")], + EnumOption.new(_INTL("Text Entry"), [_INTL("Cursor"), _INTL("Keyboard")], proc { $PokemonSystem.textinput }, proc { |value| $PokemonSystem.textinput = value } ), - EnumOption.new(_INTL("Screen Size"),[_INTL("S"),_INTL("M"),_INTL("L"),_INTL("XL"),_INTL("Full")], + EnumOption.new(_INTL("Screen Size"), [_INTL("S"), _INTL("M"), _INTL("L"), _INTL("XL"), _INTL("Full")], proc { [$PokemonSystem.screensize, 4].min }, proc { |value| if $PokemonSystem.screensize != value @@ -376,14 +376,14 @@ class PokemonOption_Scene ) ] @PokemonOptions = pbAddOnOptions(@PokemonOptions) - @sprites["option"] = Window_PokemonOption.new(@PokemonOptions,0, - @sprites["title"].height,Graphics.width, - Graphics.height-@sprites["title"].height-@sprites["textbox"].height) + @sprites["option"] = Window_PokemonOption.new(@PokemonOptions, 0, + @sprites["title"].height, Graphics.width, + Graphics.height - @sprites["title"].height - @sprites["textbox"].height) @sprites["option"].viewport = @viewport @sprites["option"].visible = true # Get the values of each option for i in 0...@PokemonOptions.length - @sprites["option"].setValueNoRefresh(i,(@PokemonOptions[i].get || 0)) + @sprites["option"].setValueNoRefresh(i, (@PokemonOptions[i].get || 0)) end @sprites["option"].refresh pbDeactivateWindows(@sprites) @@ -397,7 +397,7 @@ class PokemonOption_Scene def pbOptions oldSystemSkin = $PokemonSystem.frame # Menu oldTextSkin = $PokemonSystem.textskin # Speech - pbActivateWindow(@sprites,"option") { + pbActivateWindow(@sprites, "option") { loop do Graphics.update Input.update @@ -407,12 +407,12 @@ class PokemonOption_Scene for i in 0...@PokemonOptions.length @PokemonOptions[i].set(@sprites["option"][i]) end - if $PokemonSystem.textskin!=oldTextSkin + if $PokemonSystem.textskin != oldTextSkin @sprites["textbox"].setSkin(MessageConfig.pbGetSpeechFrame()) - @sprites["textbox"].text = _INTL("Speech frame {1}.",1+$PokemonSystem.textskin) + @sprites["textbox"].text = _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin) oldTextSkin = $PokemonSystem.textskin end - if $PokemonSystem.frame!=oldSystemSkin + if $PokemonSystem.frame != oldSystemSkin @sprites["title"].setSkin(MessageConfig.pbGetSystemFrame()) @sprites["option"].setSkin(MessageConfig.pbGetSystemFrame()) oldSystemSkin = $PokemonSystem.frame @@ -421,7 +421,7 @@ class PokemonOption_Scene if Input.trigger?(Input::BACK) break elsif Input.trigger?(Input::USE) - break if @sprites["option"].index==@PokemonOptions.length + break if @sprites["option"].index == @PokemonOptions.length end end } diff --git a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb index 1c8e38749..519f99711 100644 --- a/Data/Scripts/016_UI/016_UI_ReadyMenu.rb +++ b/Data/Scripts/016_UI/016_UI_ReadyMenu.rb @@ -6,7 +6,7 @@ class ReadyMenuButton < SpriteWrapper attr_reader :selected attr_reader :side - def initialize(index,command,selected,side,viewport = nil) + def initialize(index, command, selected, side, viewport = nil) super(viewport) @index = index @command = command # Item/move ID, name, mode (T move/F item), pkmnIndex @@ -17,16 +17,16 @@ class ReadyMenuButton < SpriteWrapper else @button = AnimatedBitmap.new("Graphics/Pictures/Ready Menu/icon_itembutton") end - @contents = BitmapWrapper.new(@button.width,@button.height/2) + @contents = BitmapWrapper.new(@button.width, @button.height / 2) self.bitmap = @contents pbSetSystemFont(self.bitmap) if @command[2] @icon = PokemonIconSprite.new($player.party[@command[3]], viewport) @icon.setOffset(PictureOrigin::Center) else - @icon = ItemIconSprite.new(0,0,@command[0],viewport) + @icon = ItemIconSprite.new(0, 0, @command[0], viewport) end - @icon.z = self.z+1 + @icon.z = self.z + 1 refresh end @@ -45,47 +45,47 @@ class ReadyMenuButton < SpriteWrapper def selected=(val) oldsel = @selected @selected = val - refresh if oldsel!=val + refresh if oldsel != val end def side=(val) oldsel = @side @side = val - refresh if oldsel!=val + refresh if oldsel != val end def refresh - sel = (@selected==@index && (@side==0)==@command[2]) - self.y = (Graphics.height-@button.height/2)/2 - (@selected-@index)*(@button.height/2+4) + sel = (@selected == @index && (@side == 0) == @command[2]) + self.y = (Graphics.height - @button.height / 2) / 2 - (@selected - @index) * (@button.height / 2 + 4) if @command[2] # Pokémon self.x = (sel) ? 0 : -16 - @icon.x = self.x+52 - @icon.y = self.y+32 + @icon.x = self.x + 52 + @icon.y = self.y + 32 else # Item - self.x = (sel) ? Graphics.width-@button.width : Graphics.width+16-@button.width - @icon.x = self.x+32 - @icon.y = self.y+@button.height/4 + self.x = (sel) ? Graphics.width - @button.width : Graphics.width + 16 - @button.width + @icon.x = self.x + 32 + @icon.y = self.y + @button.height / 4 end self.bitmap.clear - rect = Rect.new(0,(sel) ? @button.height/2 : 0,@button.width,@button.height/2) - self.bitmap.blt(0,0,@button.bitmap,rect) + rect = Rect.new(0, (sel) ? @button.height / 2 : 0, @button.width, @button.height / 2) + self.bitmap.blt(0, 0, @button.bitmap, rect) textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124 textpos = [ - [@command[1],textx,16,2,Color.new(248,248,248),Color.new(40,40,40),1], + [@command[1], textx, 16, 2, Color.new(248, 248, 248), Color.new(40, 40, 40), 1], ] if !@command[2] if !GameData::Item.get(@command[0]).is_important? qty = $bag.quantity(@command[0]) - if qty>99 - textpos.push([_INTL(">99"),230,16,1, - Color.new(248,248,248),Color.new(40,40,40),1]) + if qty > 99 + textpos.push([_INTL(">99"), 230, 16, 1, + Color.new(248, 248, 248), Color.new(40, 40, 40), 1]) else - textpos.push([_INTL("x{1}",qty),230,16,1, - Color.new(248,248,248),Color.new(40,40,40),1]) + textpos.push([_INTL("x{1}", qty), 230, 16, 1, + Color.new(248, 248, 248), Color.new(40, 40, 40), 1]) end end end - pbDrawTextPositions(self.bitmap,textpos) + pbDrawTextPositions(self.bitmap, textpos) end def update @@ -111,29 +111,29 @@ class PokemonReadyMenu_Scene @itemcommands.push(@commands[1][i][1]) end @index = $bag.ready_menu_selection - if @index[0]>=@movecommands.length && @movecommands.length>0 - @index[0] = @movecommands.length-1 + if @index[0] >= @movecommands.length && @movecommands.length > 0 + @index[0] = @movecommands.length - 1 end - if @index[1]>=@itemcommands.length && @itemcommands.length>0 - @index[1] = @itemcommands.length-1 + if @index[1] >= @itemcommands.length && @itemcommands.length > 0 + @index[1] = @itemcommands.length - 1 end - if @index[2]==0 && @movecommands.length==0 + if @index[2] == 0 && @movecommands.length == 0 @index[2] = 1 - elsif @index[2]==1 && @itemcommands.length==0 + elsif @index[2] == 1 && @itemcommands.length == 0 @index[2] = 0 end - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites = {} - @sprites["cmdwindow"] = Window_CommandPokemon.new((@index[2]==0) ? @movecommands : @itemcommands) - @sprites["cmdwindow"].height = 6*32 + @sprites["cmdwindow"] = Window_CommandPokemon.new((@index[2] == 0) ? @movecommands : @itemcommands) + @sprites["cmdwindow"].height = 6 * 32 @sprites["cmdwindow"].visible = false @sprites["cmdwindow"].viewport = @viewport for i in 0...@commands[0].length - @sprites["movebutton#{i}"] = ReadyMenuButton.new(i,@commands[0][i],@index[0],@index[2],@viewport) + @sprites["movebutton#{i}"] = ReadyMenuButton.new(i, @commands[0][i], @index[0], @index[2], @viewport) end for i in 0...@commands[1].length - @sprites["itembutton#{i}"] = ReadyMenuButton.new(i,@commands[1][i],@index[1],@index[2],@viewport) + @sprites["itembutton#{i}"] = ReadyMenuButton.new(i, @commands[1][i], @index[1], @index[2], @viewport) end pbSEPlay("GUI menu open") end @@ -161,15 +161,15 @@ class PokemonReadyMenu_Scene def pbShowCommands ret = -1 cmdwindow = @sprites["cmdwindow"] - cmdwindow.commands = (@index[2]==0) ? @movecommands : @itemcommands + cmdwindow.commands = (@index[2] == 0) ? @movecommands : @itemcommands cmdwindow.index = @index[@index[2]] cmdwindow.visible = false loop do pbUpdate - if Input.trigger?(Input::LEFT) && @index[2]==1 && @movecommands.length>0 + if Input.trigger?(Input::LEFT) && @index[2] == 1 && @movecommands.length > 0 @index[2] = 0 pbChangeSide - elsif Input.trigger?(Input::RIGHT) && @index[2]==0 && @itemcommands.length>0 + elsif Input.trigger?(Input::RIGHT) && @index[2] == 0 && @itemcommands.length > 0 @index[2] = 1 pbChangeSide elsif Input.trigger?(Input::BACK) @@ -177,7 +177,7 @@ class PokemonReadyMenu_Scene ret = -1 break elsif Input.trigger?(Input::USE) - ret = [@index[2],cmdwindow.index] + ret = [@index[2], cmdwindow.index] break end end @@ -196,7 +196,7 @@ class PokemonReadyMenu_Scene for i in 0...@commands[1].length @sprites["itembutton#{i}"].side = @index[2] end - @sprites["cmdwindow"].commands = (@index[2]==0) ? @movecommands : @itemcommands + @sprites["cmdwindow"].commands = (@index[2] == 0) ? @movecommands : @itemcommands @sprites["cmdwindow"].index = @index[@index[2]] end @@ -205,12 +205,12 @@ class PokemonReadyMenu_Scene def pbUpdate oldindex = @index[@index[2]] @index[@index[2]] = @sprites["cmdwindow"].index - if @index[@index[2]]!=oldindex - if @index[2]==0 + if @index[@index[2]] != oldindex + if @index[2] == 0 for i in 0...@commands[0].length @sprites["movebutton#{i}"].selected = @index[@index[2]] end - elsif @index[2]==1 + elsif @index[2] == 1 for i in 0...@commands[1].length @sprites["itembutton#{i}"].selected = @index[@index[2]] end @@ -240,28 +240,28 @@ class PokemonReadyMenu @scene.pbShowMenu end - def pbStartReadyMenu(moves,items) - commands = [[],[]] # Moves, items + def pbStartReadyMenu(moves, items) + commands = [[], []] # Moves, items for i in moves commands[0].push([i[0], GameData::Move.get(i[0]).name, true, i[1]]) end - commands[0].sort! { |a,b| a[1]<=>b[1] } + commands[0].sort! { |a, b| a[1] <=> b[1] } for i in items commands[1].push([i, GameData::Item.get(i).name, false]) end - commands[1].sort! { |a,b| a[1]<=>b[1] } + commands[1].sort! { |a, b| a[1] <=> b[1] } @scene.pbStartScene(commands) loop do command = @scene.pbShowCommands - break if command==-1 - if command[0]==0 # Use a move + break if command == -1 + if command[0] == 0 # Use a move move = commands[0][command[1]][0] user = $player.party[commands[0][command[1]][3]] if move == :FLY ret = nil - pbFadeOutInWithUpdate(99999,@scene.sprites) { + pbFadeOutInWithUpdate(99999, @scene.sprites) { pbHideMenu - scene = PokemonRegionMap_Scene.new(-1,false) + scene = PokemonRegionMap_Scene.new(-1, false) screen = PokemonRegionMapScreen.new(scene) ret = screen.pbStartFlyScreen pbShowMenu if !ret @@ -269,14 +269,14 @@ class PokemonReadyMenu if ret $game_temp.fly_destination = ret $game_temp.in_menu = false - pbUseHiddenMove(user,move) + pbUseHiddenMove(user, move) break end else pbHideMenu - if pbConfirmUseHiddenMove(user,move) + if pbConfirmUseHiddenMove(user, move) $game_temp.in_menu = false - pbUseHiddenMove(user,move) + pbUseHiddenMove(user, move) break else pbShowMenu diff --git a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb index 1a2ea87b3..5fedffdbc 100644 --- a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb +++ b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb @@ -2,8 +2,8 @@ # Pokémon icons #=============================================================================== class PokemonBoxIcon < IconSprite - def initialize(pokemon,viewport = nil) - super(0,0,viewport) + def initialize(pokemon, viewport = nil) + super(0, 0, viewport) @pokemon = pokemon @release = Interpolator.new @startRelease = false @@ -15,28 +15,28 @@ class PokemonBoxIcon < IconSprite end def release - self.ox = self.src_rect.width/2 # 32 - self.oy = self.src_rect.height/2 # 32 - self.x += self.src_rect.width/2 # 32 - self.y += self.src_rect.height/2 # 32 - @release.tween(self,[ - [Interpolator::ZOOM_X,0], - [Interpolator::ZOOM_Y,0], - [Interpolator::OPACITY,0] - ],100) + self.ox = self.src_rect.width / 2 # 32 + self.oy = self.src_rect.height / 2 # 32 + self.x += self.src_rect.width / 2 # 32 + self.y += self.src_rect.height / 2 # 32 + @release.tween(self, [ + [Interpolator::ZOOM_X, 0], + [Interpolator::ZOOM_Y, 0], + [Interpolator::OPACITY, 0] + ], 100) @startRelease = true end def refresh return if !@pokemon self.setBitmap(GameData::Species.icon_filename_from_pokemon(@pokemon)) - self.src_rect = Rect.new(0,0,self.bitmap.height,self.bitmap.height) + self.src_rect = Rect.new(0, 0, self.bitmap.height, self.bitmap.height) end def update super @release.update - self.color = Color.new(0,0,0,0) + self.color = Color.new(0, 0, 0, 0) dispose if @startRelease && !releasing? end end @@ -71,7 +71,7 @@ class MosaicPokemonSprite < PokemonSprite def mosaic=(value) @mosaic = value - @mosaic = 0 if @mosaic<0 + @mosaic = 0 if @mosaic < 0 mosaicRefresh(@oldbitmap) end @@ -79,25 +79,25 @@ class MosaicPokemonSprite < PokemonSprite return if @inrefresh @inrefresh = true @oldbitmap = bitmap - if @mosaic<=0 || !@oldbitmap + if @mosaic <= 0 || !@oldbitmap @mosaicbitmap.dispose if @mosaicbitmap @mosaicbitmap = nil @mosaicbitmap2.dispose if @mosaicbitmap2 @mosaicbitmap2 = nil self.bitmap = @oldbitmap else - newWidth = [(@oldbitmap.width/@mosaic),1].max - newHeight = [(@oldbitmap.height/@mosaic),1].max + newWidth = [(@oldbitmap.width / @mosaic), 1].max + newHeight = [(@oldbitmap.height / @mosaic), 1].max @mosaicbitmap2.dispose if @mosaicbitmap2 - @mosaicbitmap = pbDoEnsureBitmap(@mosaicbitmap,newWidth,newHeight) + @mosaicbitmap = pbDoEnsureBitmap(@mosaicbitmap, newWidth, newHeight) @mosaicbitmap.clear - @mosaicbitmap2 = pbDoEnsureBitmap(@mosaicbitmap2,@oldbitmap.width,@oldbitmap.height) + @mosaicbitmap2 = pbDoEnsureBitmap(@mosaicbitmap2, @oldbitmap.width, @oldbitmap.height) @mosaicbitmap2.clear - @mosaicbitmap.stretch_blt(Rect.new(0,0,newWidth,newHeight),@oldbitmap,@oldbitmap.rect) + @mosaicbitmap.stretch_blt(Rect.new(0, 0, newWidth, newHeight), @oldbitmap, @oldbitmap.rect) @mosaicbitmap2.stretch_blt( - Rect.new(-@mosaic/2+1,-@mosaic/2+1, - @mosaicbitmap2.width,@mosaicbitmap2.height), - @mosaicbitmap,Rect.new(0,0,newWidth,newHeight)) + Rect.new(-@mosaic / 2 + 1, -@mosaic / 2 + 1, + @mosaicbitmap2.width, @mosaicbitmap2.height), + @mosaicbitmap, Rect.new(0, 0, newWidth, newHeight)) self.bitmap = @mosaicbitmap2 end @inrefresh = false @@ -129,15 +129,15 @@ class PokemonBoxArrow < SpriteWrapper @grabbingState = 0 @placingState = 0 @heldpkmn = nil - @handsprite = ChangelingSprite.new(0,0,viewport) - @handsprite.addBitmap("point1","Graphics/Pictures/Storage/cursor_point_1") - @handsprite.addBitmap("point2","Graphics/Pictures/Storage/cursor_point_2") - @handsprite.addBitmap("grab","Graphics/Pictures/Storage/cursor_grab") - @handsprite.addBitmap("fist","Graphics/Pictures/Storage/cursor_fist") - @handsprite.addBitmap("point1q","Graphics/Pictures/Storage/cursor_point_1_q") - @handsprite.addBitmap("point2q","Graphics/Pictures/Storage/cursor_point_2_q") - @handsprite.addBitmap("grabq","Graphics/Pictures/Storage/cursor_grab_q") - @handsprite.addBitmap("fistq","Graphics/Pictures/Storage/cursor_fist_q") + @handsprite = ChangelingSprite.new(0, 0, viewport) + @handsprite.addBitmap("point1", "Graphics/Pictures/Storage/cursor_point_1") + @handsprite.addBitmap("point2", "Graphics/Pictures/Storage/cursor_point_2") + @handsprite.addBitmap("grab", "Graphics/Pictures/Storage/cursor_grab") + @handsprite.addBitmap("fist", "Graphics/Pictures/Storage/cursor_fist") + @handsprite.addBitmap("point1q", "Graphics/Pictures/Storage/cursor_point_1_q") + @handsprite.addBitmap("point2q", "Graphics/Pictures/Storage/cursor_point_2_q") + @handsprite.addBitmap("grabq", "Graphics/Pictures/Storage/cursor_grab_q") + @handsprite.addBitmap("fistq", "Graphics/Pictures/Storage/cursor_fist_q") @handsprite.changeBitmap("fist") @spriteX = self.x @spriteY = self.y @@ -174,11 +174,11 @@ class PokemonBoxArrow < SpriteWrapper end def grabbing? - return @grabbingState>0 + return @grabbingState > 0 end def placing? - return @placingState>0 + return @placingState > 0 end def x=(value) @@ -192,7 +192,7 @@ class PokemonBoxArrow < SpriteWrapper super @handsprite.y = self.y @spriteY = y if !@updating - heldPokemon.y = self.y+16 if holding? + heldPokemon.y = self.y + 16 if holding? end def z=(value) @@ -241,29 +241,29 @@ class PokemonBoxArrow < SpriteWrapper heldpkmn.update if heldpkmn @handsprite.update @holding = false if !heldpkmn - if @grabbingState>0 - if @grabbingState<=4*Graphics.frame_rate/20 + if @grabbingState > 0 + if @grabbingState <= 4 * Graphics.frame_rate / 20 @handsprite.changeBitmap((@quickswap) ? "grabq" : "grab") - self.y = @spriteY+4.0*@grabbingState*20/Graphics.frame_rate + self.y = @spriteY + 4.0 * @grabbingState * 20 / Graphics.frame_rate @grabbingState += 1 - elsif @grabbingState<=8*Graphics.frame_rate/20 + elsif @grabbingState <= 8 * Graphics.frame_rate / 20 @holding = true @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist") - self.y = @spriteY+4*(8*Graphics.frame_rate/20-@grabbingState)*20/Graphics.frame_rate + self.y = @spriteY + 4 * (8 * Graphics.frame_rate / 20 - @grabbingState) * 20 / Graphics.frame_rate @grabbingState += 1 else @grabbingState = 0 end - elsif @placingState>0 - if @placingState<=4*Graphics.frame_rate/20 + elsif @placingState > 0 + if @placingState <= 4 * Graphics.frame_rate / 20 @handsprite.changeBitmap((@quickswap) ? "fistq" : "fist") - self.y = @spriteY+4.0*@placingState*20/Graphics.frame_rate + self.y = @spriteY + 4.0 * @placingState * 20 / Graphics.frame_rate @placingState += 1 - elsif @placingState<=8*Graphics.frame_rate/20 + elsif @placingState <= 8 * Graphics.frame_rate / 20 @holding = false @heldpkmn = nil @handsprite.changeBitmap((@quickswap) ? "grabq" : "grab") - self.y = @spriteY+4*(8*Graphics.frame_rate/20-@placingState)*20/Graphics.frame_rate + self.y = @spriteY + 4 * (8 * Graphics.frame_rate / 20 - @placingState) * 20 / Graphics.frame_rate @placingState += 1 else @placingState = 0 @@ -273,14 +273,14 @@ class PokemonBoxArrow < SpriteWrapper else self.x = @spriteX self.y = @spriteY - if @frame=Graphics.frame_rate + @frame = 0 if @frame >= Graphics.frame_rate @updating = false end end @@ -292,7 +292,7 @@ class PokemonBoxSprite < SpriteWrapper attr_accessor :refreshBox attr_accessor :refreshSprites - def initialize(storage,boxnumber,viewport = nil) + def initialize(storage, boxnumber, viewport = nil) super(viewport) @storage = storage @boxnumber = boxnumber @@ -301,10 +301,10 @@ class PokemonBoxSprite < SpriteWrapper @pokemonsprites = [] for i in 0...PokemonBox::BOX_SIZE @pokemonsprites[i] = nil - pokemon = @storage[boxnumber,i] - @pokemonsprites[i] = PokemonBoxIcon.new(pokemon,viewport) + pokemon = @storage[boxnumber, i] + @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) end - @contents = BitmapWrapper.new(324,296) + @contents = BitmapWrapper.new(324, 296) self.bitmap = @contents self.x = 184 self.y = 18 @@ -356,10 +356,10 @@ class PokemonBoxSprite < SpriteWrapper end def getBoxBitmap - if !@bg || @bg!=@storage[@boxnumber].background + if !@bg || @bg != @storage[@boxnumber].background curbg = @storage[@boxnumber].background - if !curbg || (curbg.is_a?(String) && curbg.length==0) - @bg = @boxnumber%PokemonStorage::BASICWALLPAPERQTY + if !curbg || (curbg.is_a?(String) && curbg.length == 0) + @bg = @boxnumber % PokemonStorage::BASICWALLPAPERQTY else if curbg.is_a?(String) && curbg[/^box(\d+)$/] curbg = $~[1].to_i @@ -368,7 +368,7 @@ class PokemonBoxSprite < SpriteWrapper @bg = curbg end if !@storage.isAvailableWallpaper?(@bg) - @bg = @boxnumber%PokemonStorage::BASICWALLPAPERQTY + @bg = @boxnumber % PokemonStorage::BASICWALLPAPERQTY @storage[@boxnumber].background = @bg end @boxbitmap.dispose if @boxbitmap @@ -380,13 +380,13 @@ class PokemonBoxSprite < SpriteWrapper return @pokemonsprites[index] end - def setPokemon(index,sprite) + def setPokemon(index, sprite) @pokemonsprites[index] = sprite @pokemonsprites[index].refresh refresh end - def grabPokemon(index,arrow) + def grabPokemon(index, arrow) sprite = @pokemonsprites[index] if sprite arrow.grab(sprite) @@ -405,17 +405,17 @@ class PokemonBoxSprite < SpriteWrapper if @refreshBox boxname = @storage[@boxnumber].name getBoxBitmap - @contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,324,296)) + @contents.blt(0, 0, @boxbitmap.bitmap, Rect.new(0, 0, 324, 296)) pbSetSystemFont(@contents) widthval = @contents.text_size(boxname).width - xval = 162-(widthval/2) - pbDrawShadowText(@contents,xval,8,widthval,32, - boxname,Color.new(248,248,248),Color.new(40,48,48)) + xval = 162 - (widthval / 2) + pbDrawShadowText(@contents, xval, 8, widthval, 32, + boxname, Color.new(248, 248, 248), Color.new(40, 48, 48)) @refreshBox = false end - yval = self.y+30 + yval = self.y + 30 for j in 0...PokemonBox::BOX_HEIGHT - xval = self.x+10 + xval = self.x + 10 for k in 0...PokemonBox::BOX_WIDTH sprite = @pokemonsprites[j * PokemonBox::BOX_WIDTH + k] if sprite && !sprite.disposed? @@ -444,7 +444,7 @@ end # Party pop-up panel #=============================================================================== class PokemonBoxPartySprite < SpriteWrapper - def initialize(party,viewport = nil) + def initialize(party, viewport = nil) super(viewport) @party = party @boxbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/overlay_party") @@ -453,13 +453,13 @@ class PokemonBoxPartySprite < SpriteWrapper @pokemonsprites[i] = nil pokemon = @party[i] if pokemon - @pokemonsprites[i] = PokemonBoxIcon.new(pokemon,viewport) + @pokemonsprites[i] = PokemonBoxIcon.new(pokemon, viewport) end end - @contents = BitmapWrapper.new(172,352) + @contents = BitmapWrapper.new(172, 352) self.bitmap = @contents self.x = 182 - self.y = Graphics.height-352 + self.y = Graphics.height - 352 pbSetSystemFont(self.bitmap) refresh end @@ -487,7 +487,7 @@ class PokemonBoxPartySprite < SpriteWrapper super for i in 0...Settings::MAX_PARTY_SIZE if @pokemonsprites[i] && !@pokemonsprites[i].disposed? - @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color,value) + @pokemonsprites[i].color = pbSrcOver(@pokemonsprites[i].color, value) end end end @@ -505,13 +505,13 @@ class PokemonBoxPartySprite < SpriteWrapper return @pokemonsprites[index] end - def setPokemon(index,sprite) + def setPokemon(index, sprite) @pokemonsprites[index] = sprite @pokemonsprites.compact! refresh end - def grabPokemon(index,arrow) + def grabPokemon(index, arrow) sprite = @pokemonsprites[index] if sprite arrow.grab(sprite) @@ -529,7 +529,7 @@ class PokemonBoxPartySprite < SpriteWrapper def refresh @contents.blt(0, 0, @boxbitmap.bitmap, Rect.new(0, 0, 172, 352)) - pbDrawTextPositions(self.bitmap,[ + pbDrawTextPositions(self.bitmap, [ [_INTL("Back"), 86, 240, 2, Color.new(248, 248, 248), Color.new(80, 80, 80), 1] ]) xvalues = [] # [18, 90, 18, 90, 18, 90] @@ -572,55 +572,55 @@ class PokemonStorageScene @command = 1 end - def pbStartBox(screen,command) + def pbStartBox(screen, command) @screen = screen @storage = screen.storage - @bgviewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @bgviewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @bgviewport.z = 99999 - @boxviewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @boxviewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @boxviewport.z = 99999 - @boxsidesviewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @boxsidesviewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @boxsidesviewport.z = 99999 - @arrowviewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @arrowviewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @arrowviewport.z = 99999 - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @selection = 0 @quickswap = false @sprites = {} @choseFromParty = false @command = command - addBackgroundPlane(@sprites,"background","Storage/bg",@bgviewport) - @sprites["box"] = PokemonBoxSprite.new(@storage,@storage.currentBox,@boxviewport) - @sprites["boxsides"] = IconSprite.new(0,0,@boxsidesviewport) + addBackgroundPlane(@sprites, "background", "Storage/bg", @bgviewport) + @sprites["box"] = PokemonBoxSprite.new(@storage, @storage.currentBox, @boxviewport) + @sprites["boxsides"] = IconSprite.new(0, 0, @boxsidesviewport) @sprites["boxsides"].setBitmap("Graphics/Pictures/Storage/overlay_main") - @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@boxsidesviewport) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @boxsidesviewport) pbSetSystemFont(@sprites["overlay"].bitmap) @sprites["pokemon"] = AutoMosaicPokemonSprite.new(@boxsidesviewport) @sprites["pokemon"].setOffset(PictureOrigin::Center) @sprites["pokemon"].x = 90 @sprites["pokemon"].y = 134 - @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party,@boxsidesviewport) - if command!=2 # Drop down tab only on Deposit + @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party, @boxsidesviewport) + if command != 2 # Drop down tab only on Deposit @sprites["boxparty"].x = 182 @sprites["boxparty"].y = Graphics.height end @markingbitmap = AnimatedBitmap.new("Graphics/Pictures/Storage/markings") - @sprites["markingbg"] = IconSprite.new(292,68,@boxsidesviewport) + @sprites["markingbg"] = IconSprite.new(292, 68, @boxsidesviewport) @sprites["markingbg"].setBitmap("Graphics/Pictures/Storage/overlay_marking") @sprites["markingbg"].visible = false - @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@boxsidesviewport) + @sprites["markingoverlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @boxsidesviewport) @sprites["markingoverlay"].visible = false pbSetSystemFont(@sprites["markingoverlay"].bitmap) @sprites["arrow"] = PokemonBoxArrow.new(@arrowviewport) @sprites["arrow"].z += 1 - if command!=2 - pbSetArrow(@sprites["arrow"],@selection) + if command != 2 + pbSetArrow(@sprites["arrow"], @selection) pbUpdateOverlay(@selection) pbSetMosaic(@selection) else - pbPartySetArrow(@sprites["arrow"],@selection) - pbUpdateOverlay(@selection,@storage.party) + pbPartySetArrow(@sprites["arrow"], @selection) + pbUpdateOverlay(@selection, @storage.party) pbSetMosaic(@selection) end pbSEPlay("PC access") @@ -637,12 +637,12 @@ class PokemonStorageScene end def pbDisplay(message) - msgwindow = Window_UnformattedTextPokemon.newWithSize("",180,0,Graphics.width-180,32) + msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32) msgwindow.viewport = @viewport msgwindow.visible = true msgwindow.letterbyletter = false - msgwindow.resizeHeightToFit(message,Graphics.width-180) - msgwindow.text = message + msgwindow.resizeHeightToFit(message, Graphics.width - 180) + msgwindow.text = message pbBottomRight(msgwindow) loop do Graphics.update @@ -657,23 +657,23 @@ class PokemonStorageScene Input.update end - def pbShowCommands(message,commands,index = 0) + def pbShowCommands(message, commands, index = 0) ret = -1 - msgwindow = Window_UnformattedTextPokemon.newWithSize("",180,0,Graphics.width-180,32) + msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32) msgwindow.viewport = @viewport msgwindow.visible = true msgwindow.letterbyletter = false msgwindow.text = message - msgwindow.resizeHeightToFit(message,Graphics.width-180) + msgwindow.resizeHeightToFit(message, Graphics.width - 180) pbBottomRight(msgwindow) cmdwindow = Window_CommandPokemon.new(commands) cmdwindow.viewport = @viewport cmdwindow.visible = true cmdwindow.resizeToFit(cmdwindow.commands) - cmdwindow.height = Graphics.height-msgwindow.height if cmdwindow.height>Graphics.height-msgwindow.height + cmdwindow.height = Graphics.height - msgwindow.height if cmdwindow.height > Graphics.height - msgwindow.height pbBottomRight(cmdwindow) - cmdwindow.y -= msgwindow.height - cmdwindow.index = index + cmdwindow.y -= msgwindow.height + cmdwindow.index = index loop do Graphics.update Input.update @@ -694,42 +694,42 @@ class PokemonStorageScene return ret end - def pbSetArrow(arrow,selection) + def pbSetArrow(arrow, selection) case selection when -1, -4, -5 # Box name, move left, move right - arrow.x = 157*2 - arrow.y = -12*2 + arrow.x = 157 * 2 + arrow.y = -12 * 2 when -2 # Party Pokémon - arrow.x = 119*2 - arrow.y = 139*2 + arrow.x = 119 * 2 + arrow.y = 139 * 2 when -3 # Close Box - arrow.x = 207*2 - arrow.y = 139*2 + arrow.x = 207 * 2 + arrow.y = 139 * 2 else arrow.x = (97 + 24 * (selection % PokemonBox::BOX_WIDTH)) * 2 arrow.y = (8 + 24 * (selection / PokemonBox::BOX_WIDTH)) * 2 end end - def pbChangeSelection(key,selection) + def pbChangeSelection(key, selection) case key when Input::UP - if selection==-1 # Box name + if selection == -1 # Box name selection = -2 - elsif selection==-2 # Party + elsif selection == -2 # Party selection = PokemonBox::BOX_SIZE - 1 - PokemonBox::BOX_WIDTH * 2 / 3 # 25 - elsif selection==-3 # Close Box + elsif selection == -3 # Close Box selection = PokemonBox::BOX_SIZE - PokemonBox::BOX_WIDTH / 3 # 28 else selection -= PokemonBox::BOX_WIDTH selection = -1 if selection < 0 end when Input::DOWN - if selection==-1 # Box name + if selection == -1 # Box name selection = PokemonBox::BOX_WIDTH / 3 # 2 - elsif selection==-2 # Party + elsif selection == -2 # Party selection = -1 - elsif selection==-3 # Close Box + elsif selection == -3 # Close Box selection = -1 else selection += PokemonBox::BOX_WIDTH @@ -742,11 +742,11 @@ class PokemonStorageScene end end when Input::LEFT - if selection==-1 # Box name + if selection == -1 # Box name selection = -4 # Move to previous box - elsif selection==-2 + elsif selection == -2 selection = -3 - elsif selection==-3 + elsif selection == -3 selection = -2 elsif (selection % PokemonBox::BOX_WIDTH) == 0 # Wrap around selection += PokemonBox::BOX_WIDTH - 1 @@ -754,11 +754,11 @@ class PokemonStorageScene selection -= 1 end when Input::RIGHT - if selection==-1 # Box name + if selection == -1 # Box name selection = -5 # Move to next box - elsif selection==-2 + elsif selection == -2 selection = -3 - elsif selection==-3 + elsif selection == -3 selection = -2 elsif (selection % PokemonBox::BOX_WIDTH) == PokemonBox::BOX_WIDTH - 1 # Wrap around selection -= PokemonBox::BOX_WIDTH - 1 @@ -769,7 +769,7 @@ class PokemonStorageScene return selection end - def pbPartySetArrow(arrow,selection) + def pbPartySetArrow(arrow, selection) return if selection < 0 xvalues = [] # [200, 272, 200, 272, 200, 272, 236] yvalues = [] # [2, 18, 66, 82, 130, 146, 220] @@ -787,7 +787,7 @@ class PokemonStorageScene arrow.y = yvalues[selection] end - def pbPartyChangeSelection(key,selection) + def pbPartyChangeSelection(key, selection) case key when Input::LEFT selection -= 1 @@ -815,7 +815,7 @@ class PokemonStorageScene def pbSelectBoxInternal(_party) selection = @selection - pbSetArrow(@sprites["arrow"],selection) + pbSetArrow(@sprites["arrow"], selection) pbUpdateOverlay(selection) pbSetMosaic(selection) loop do @@ -826,47 +826,47 @@ class PokemonStorageScene key = Input::RIGHT if Input.repeat?(Input::RIGHT) key = Input::LEFT if Input.repeat?(Input::LEFT) key = Input::UP if Input.repeat?(Input::UP) - if key>=0 + if key >= 0 pbPlayCursorSE - selection = pbChangeSelection(key,selection) - pbSetArrow(@sprites["arrow"],selection) - if selection==-4 - nextbox = (@storage.currentBox+@storage.maxBoxes-1)%@storage.maxBoxes + selection = pbChangeSelection(key, selection) + pbSetArrow(@sprites["arrow"], selection) + if selection == -4 + nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes pbSwitchBoxToLeft(nextbox) @storage.currentBox = nextbox - elsif selection==-5 - nextbox = (@storage.currentBox+1)%@storage.maxBoxes + elsif selection == -5 + nextbox = (@storage.currentBox + 1) % @storage.maxBoxes pbSwitchBoxToRight(nextbox) @storage.currentBox = nextbox end - selection = -1 if selection==-4 || selection==-5 + selection = -1 if selection == -4 || selection == -5 pbUpdateOverlay(selection) pbSetMosaic(selection) end self.update if Input.trigger?(Input::JUMPUP) pbPlayCursorSE - nextbox = (@storage.currentBox+@storage.maxBoxes-1)%@storage.maxBoxes + nextbox = (@storage.currentBox + @storage.maxBoxes - 1) % @storage.maxBoxes pbSwitchBoxToLeft(nextbox) @storage.currentBox = nextbox pbUpdateOverlay(selection) pbSetMosaic(selection) elsif Input.trigger?(Input::JUMPDOWN) pbPlayCursorSE - nextbox = (@storage.currentBox+1)%@storage.maxBoxes + nextbox = (@storage.currentBox + 1) % @storage.maxBoxes pbSwitchBoxToRight(nextbox) @storage.currentBox = nextbox pbUpdateOverlay(selection) pbSetMosaic(selection) elsif Input.trigger?(Input::SPECIAL) # Jump to box name - if selection!=-1 + if selection != -1 pbPlayCursorSE selection = -1 - pbSetArrow(@sprites["arrow"],selection) + pbSetArrow(@sprites["arrow"], selection) pbUpdateOverlay(selection) pbSetMosaic(selection) end - elsif Input.trigger?(Input::ACTION) && @command==0 # Organize only + elsif Input.trigger?(Input::ACTION) && @command == 0 # Organize only pbPlayDecisionSE pbSetQuickSwap(!@quickswap) elsif Input.trigger?(Input::BACK) @@ -874,39 +874,39 @@ class PokemonStorageScene return nil elsif Input.trigger?(Input::USE) @selection = selection - if selection>=0 - return [@storage.currentBox,selection] - elsif selection==-1 # Box name - return [-4,-1] - elsif selection==-2 # Party Pokémon - return [-2,-1] - elsif selection==-3 # Close Box - return [-3,-1] + if selection >= 0 + return [@storage.currentBox, selection] + elsif selection == -1 # Box name + return [-4, -1] + elsif selection == -2 # Party Pokémon + return [-2, -1] + elsif selection == -3 # Close Box + return [-3, -1] end end end end def pbSelectBox(party) - return pbSelectBoxInternal(party) if @command==1 # Withdraw + return pbSelectBoxInternal(party) if @command == 1 # Withdraw ret = nil loop do if !@choseFromParty ret = pbSelectBoxInternal(party) end - if @choseFromParty || (ret && ret[0]==-2) # Party Pokémon + if @choseFromParty || (ret && ret[0] == -2) # Party Pokémon if !@choseFromParty pbShowPartyTab @selection = 0 end - ret = pbSelectPartyInternal(party,false) - if ret<0 + ret = pbSelectPartyInternal(party, false) + if ret < 0 pbHidePartyTab @selection = 0 @choseFromParty = false else @choseFromParty = true - return [-1,ret] + return [-1, ret] end else @choseFromParty = false @@ -915,10 +915,10 @@ class PokemonStorageScene end end - def pbSelectPartyInternal(party,depositing) + def pbSelectPartyInternal(party, depositing) selection = @selection - pbPartySetArrow(@sprites["arrow"],selection) - pbUpdateOverlay(selection,party) + pbPartySetArrow(@sprites["arrow"], selection) + pbUpdateOverlay(selection, party) pbSetMosaic(selection) lastsel = 1 loop do @@ -929,19 +929,19 @@ class PokemonStorageScene key = Input::RIGHT if Input.repeat?(Input::RIGHT) key = Input::LEFT if Input.repeat?(Input::LEFT) key = Input::UP if Input.repeat?(Input::UP) - if key>=0 + if key >= 0 pbPlayCursorSE - newselection = pbPartyChangeSelection(key,selection) - if newselection==-1 + newselection = pbPartyChangeSelection(key, selection) + if newselection == -1 return -1 if !depositing - elsif newselection==-2 + elsif newselection == -2 selection = lastsel else selection = newselection end - pbPartySetArrow(@sprites["arrow"],selection) - lastsel = selection if selection>0 - pbUpdateOverlay(selection,party) + pbPartySetArrow(@sprites["arrow"], selection) + lastsel = selection if selection > 0 + pbUpdateOverlay(selection, party) pbSetMosaic(selection) end self.update @@ -964,7 +964,7 @@ class PokemonStorageScene end def pbSelectParty(party) - return pbSelectPartyInternal(party,true) + return pbSelectPartyInternal(party, true) end def pbChangeBackground(wp) @@ -972,18 +972,18 @@ class PokemonStorageScene alpha = 0 Graphics.update self.update - timeTaken = Graphics.frame_rate*4/10 - alphaDiff = (255.0/timeTaken).ceil + timeTaken = Graphics.frame_rate * 4 / 10 + alphaDiff = (255.0 / timeTaken).ceil timeTaken.times do alpha += alphaDiff Graphics.update Input.update - @sprites["box"].color = Color.new(248,248,248,alpha) + @sprites["box"].color = Color.new(248, 248, 248, alpha) self.update end @sprites["box"].refreshBox = true @storage[@storage.currentBox].background = wp - (Graphics.frame_rate/10).times do + (Graphics.frame_rate / 10).times do Graphics.update Input.update self.update @@ -992,26 +992,26 @@ class PokemonStorageScene alpha -= alphaDiff Graphics.update Input.update - @sprites["box"].color = Color.new(248,248,248,alpha) + @sprites["box"].color = Color.new(248, 248, 248, alpha) self.update end @sprites["box"].refreshSprites = true end def pbSwitchBoxToRight(newbox) - newbox = PokemonBoxSprite.new(@storage,newbox,@boxviewport) + newbox = PokemonBoxSprite.new(@storage, newbox, @boxviewport) newbox.x = 520 Graphics.frame_reset - distancePerFrame = 64*20/Graphics.frame_rate + distancePerFrame = 64 * 20 / Graphics.frame_rate loop do Graphics.update Input.update @sprites["box"].x -= distancePerFrame newbox.x -= distancePerFrame self.update - break if newbox.x<=184 + break if newbox.x <= 184 end - diff = newbox.x-184 + diff = newbox.x - 184 newbox.x = 184 @sprites["box"].x -= diff @sprites["box"].dispose @@ -1019,19 +1019,19 @@ class PokemonStorageScene end def pbSwitchBoxToLeft(newbox) - newbox = PokemonBoxSprite.new(@storage,newbox,@boxviewport) + newbox = PokemonBoxSprite.new(@storage, newbox, @boxviewport) newbox.x = -152 Graphics.frame_reset - distancePerFrame = 64*20/Graphics.frame_rate + distancePerFrame = 64 * 20 / Graphics.frame_rate loop do Graphics.update Input.update @sprites["box"].x += distancePerFrame newbox.x += distancePerFrame self.update - break if newbox.x>=184 + break if newbox.x >= 184 end - diff = newbox.x-184 + diff = newbox.x - 184 newbox.x = 184 @sprites["box"].x -= diff @sprites["box"].dispose @@ -1039,8 +1039,8 @@ class PokemonStorageScene end def pbJumpToBox(newbox) - if @storage.currentBox!=newbox - if newbox>@storage.currentBox + if @storage.currentBox != newbox + if newbox > @storage.currentBox pbSwitchBoxToRight(newbox) else pbSwitchBoxToLeft(newbox) @@ -1051,8 +1051,8 @@ class PokemonStorageScene def pbSetMosaic(selection) if !@screen.pbHeldPokemon - if @boxForMosaic!=@storage.currentBox || @selectionForMosaic!=selection - @sprites["pokemon"].mosaic = Graphics.frame_rate/4 + if @boxForMosaic != @storage.currentBox || @selectionForMosaic != selection + @sprites["pokemon"].mosaic = Graphics.frame_rate / 4 @boxForMosaic = @storage.currentBox @selectionForMosaic = selection end @@ -1066,36 +1066,36 @@ class PokemonStorageScene def pbShowPartyTab pbSEPlay("GUI storage show party panel") - distancePerFrame = 48*20/Graphics.frame_rate + distancePerFrame = 48 * 20 / Graphics.frame_rate loop do Graphics.update Input.update @sprites["boxparty"].y -= distancePerFrame self.update - break if @sprites["boxparty"].y<=Graphics.height-352 + break if @sprites["boxparty"].y <= Graphics.height - 352 end - @sprites["boxparty"].y = Graphics.height-352 + @sprites["boxparty"].y = Graphics.height - 352 end def pbHidePartyTab pbSEPlay("GUI storage hide party panel") - distancePerFrame = 48*20/Graphics.frame_rate + distancePerFrame = 48 * 20 / Graphics.frame_rate loop do Graphics.update Input.update @sprites["boxparty"].y += distancePerFrame self.update - break if @sprites["boxparty"].y>=Graphics.height + break if @sprites["boxparty"].y >= Graphics.height end @sprites["boxparty"].y = Graphics.height end def pbHold(selected) pbSEPlay("GUI storage pick up") - if selected[0]==-1 - @sprites["boxparty"].grabPokemon(selected[1],@sprites["arrow"]) + if selected[0] == -1 + @sprites["boxparty"].grabPokemon(selected[1], @sprites["arrow"]) else - @sprites["box"].grabPokemon(selected[1],@sprites["arrow"]) + @sprites["box"].grabPokemon(selected[1], @sprites["arrow"]) end while @sprites["arrow"].grabbing? Graphics.update @@ -1104,19 +1104,19 @@ class PokemonStorageScene end end - def pbSwap(selected,_heldpoke) + def pbSwap(selected, _heldpoke) pbSEPlay("GUI storage pick up") heldpokesprite = @sprites["arrow"].heldPokemon boxpokesprite = nil - if selected[0]==-1 + if selected[0] == -1 boxpokesprite = @sprites["boxparty"].getPokemon(selected[1]) else boxpokesprite = @sprites["box"].getPokemon(selected[1]) end - if selected[0]==-1 - @sprites["boxparty"].setPokemon(selected[1],heldpokesprite) + if selected[0] == -1 + @sprites["boxparty"].setPokemon(selected[1], heldpokesprite) else - @sprites["box"].setPokemon(selected[1],heldpokesprite) + @sprites["box"].setPokemon(selected[1], heldpokesprite) end @sprites["arrow"].setSprite(boxpokesprite) @sprites["pokemon"].mosaic = 10 @@ -1124,7 +1124,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 @@ -1133,49 +1133,49 @@ class PokemonStorageScene Input.update self.update end - if selected[0]==-1 - @sprites["boxparty"].setPokemon(selected[1],heldpokesprite) + if selected[0] == -1 + @sprites["boxparty"].setPokemon(selected[1], heldpokesprite) else - @sprites["box"].setPokemon(selected[1],heldpokesprite) + @sprites["box"].setPokemon(selected[1], heldpokesprite) end @boxForMosaic = @storage.currentBox @selectionForMosaic = selected[1] end - def pbWithdraw(selected,heldpoke,partyindex) + def pbWithdraw(selected, heldpoke, partyindex) pbHold(selected) if !heldpoke pbShowPartyTab - pbPartySetArrow(@sprites["arrow"],partyindex) - pbPlace([-1,partyindex],heldpoke) + pbPartySetArrow(@sprites["arrow"], partyindex) + pbPlace([-1, partyindex], heldpoke) pbHidePartyTab end - def pbStore(selected,heldpoke,destbox,firstfree) + def pbStore(selected, heldpoke, destbox, firstfree) if heldpoke - if destbox==@storage.currentBox + if destbox == @storage.currentBox heldpokesprite = @sprites["arrow"].heldPokemon - @sprites["box"].setPokemon(firstfree,heldpokesprite) + @sprites["box"].setPokemon(firstfree, heldpokesprite) @sprites["arrow"].setSprite(nil) else @sprites["arrow"].deleteSprite end else sprite = @sprites["boxparty"].getPokemon(selected[1]) - if destbox==@storage.currentBox - @sprites["box"].setPokemon(firstfree,sprite) - @sprites["boxparty"].setPokemon(selected[1],nil) + if destbox == @storage.currentBox + @sprites["box"].setPokemon(firstfree, sprite) + @sprites["boxparty"].setPokemon(selected[1], nil) else @sprites["boxparty"].deletePokemon(selected[1]) end end end - def pbRelease(selected,heldpoke) + def pbRelease(selected, heldpoke) box = selected[0] index = selected[1] if heldpoke sprite = @sprites["arrow"].heldPokemon - elsif box==-1 + elsif box == -1 sprite = @sprites["boxparty"].getPokemon(index) else sprite = @sprites["box"].getPokemon(index) @@ -1195,92 +1195,92 @@ class PokemonStorageScene for i in 0...@storage.maxBoxes box = @storage[i] if box - commands.push(_INTL("{1} ({2}/{3})",box.name,box.nitems,box.length)) + commands.push(_INTL("{1} ({2}/{3})", box.name, box.nitems, box.length)) end end - return pbShowCommands(msg,commands,@storage.currentBox) + return pbShowCommands(msg, commands, @storage.currentBox) end - def pbBoxName(helptext,minchars,maxchars) + def pbBoxName(helptext, minchars, maxchars) oldsprites = pbFadeOutAndHide(@sprites) - ret = pbEnterBoxName(helptext,minchars,maxchars) - if ret.length>0 + ret = pbEnterBoxName(helptext, minchars, maxchars) + if ret.length > 0 @storage[@storage.currentBox].name = ret end @sprites["box"].refreshBox = true pbRefresh - pbFadeInAndShow(@sprites,oldsprites) + pbFadeInAndShow(@sprites, oldsprites) end def pbChooseItem(bag) ret = nil pbFadeOutIn { scene = PokemonBag_Scene.new - screen = PokemonBagScreen.new(scene,bag) + screen = PokemonBagScreen.new(scene, bag) ret = screen.pbChooseItemScreen(Proc.new { |item| GameData::Item.get(item).can_hold? }) } return ret end - def pbSummary(selected,heldpoke) + def pbSummary(selected, heldpoke) oldsprites = pbFadeOutAndHide(@sprites) scene = PokemonSummary_Scene.new screen = PokemonSummaryScreen.new(scene) if heldpoke - screen.pbStartScreen([heldpoke],0) - elsif selected[0]==-1 - @selection = screen.pbStartScreen(@storage.party,selected[1]) - pbPartySetArrow(@sprites["arrow"],@selection) - pbUpdateOverlay(@selection,@storage.party) + screen.pbStartScreen([heldpoke], 0) + elsif selected[0] == -1 + @selection = screen.pbStartScreen(@storage.party, selected[1]) + pbPartySetArrow(@sprites["arrow"], @selection) + pbUpdateOverlay(@selection, @storage.party) else - @selection = screen.pbStartScreen(@storage.boxes[selected[0]],selected[1]) - pbSetArrow(@sprites["arrow"],@selection) + @selection = screen.pbStartScreen(@storage.boxes[selected[0]], selected[1]) + pbSetArrow(@sprites["arrow"], @selection) pbUpdateOverlay(@selection) end - pbFadeInAndShow(@sprites,oldsprites) + pbFadeInAndShow(@sprites, oldsprites) end - def pbMarkingSetArrow(arrow,selection) - if selection>=0 - xvalues = [162,191,220,162,191,220,184,184] - yvalues = [24,24,24,49,49,49,77,109] + def pbMarkingSetArrow(arrow, selection) + if selection >= 0 + xvalues = [162, 191, 220, 162, 191, 220, 184, 184] + yvalues = [24, 24, 24, 49, 49, 49, 77, 109] arrow.angle = 0 arrow.mirror = false arrow.ox = 0 arrow.oy = 0 - arrow.x = xvalues[selection]*2 - arrow.y = yvalues[selection]*2 + arrow.x = xvalues[selection] * 2 + arrow.y = yvalues[selection] * 2 end end - def pbMarkingChangeSelection(key,selection) + def pbMarkingChangeSelection(key, selection) case key when Input::LEFT - if selection<6 + if selection < 6 selection -= 1 - selection += 3 if selection%3==2 + selection += 3 if selection % 3 == 2 end when Input::RIGHT - if selection<6 + if selection < 6 selection += 1 - selection -= 3 if selection%3==0 + selection -= 3 if selection % 3 == 0 end when Input::UP - if selection==7 + if selection == 7 selection = 6 - elsif selection==6 + elsif selection == 6 selection = 4 - elsif selection<3 + elsif selection < 3 selection = 7 else selection -= 3 end when Input::DOWN - if selection==7 + if selection == 7 selection = 1 - elsif selection==6 + elsif selection == 6 selection = 7 - elsif selection>=3 + elsif selection >= 3 selection = 6 else selection += 3 @@ -1289,23 +1289,23 @@ class PokemonStorageScene return selection end - def pbMark(selected,heldpoke) + def pbMark(selected, heldpoke) @sprites["markingbg"].visible = true @sprites["markingoverlay"].visible = true msg = _INTL("Mark your Pokémon.") - msgwindow = Window_UnformattedTextPokemon.newWithSize("",180,0,Graphics.width-180,32) + msgwindow = Window_UnformattedTextPokemon.newWithSize("", 180, 0, Graphics.width - 180, 32) msgwindow.viewport = @viewport msgwindow.visible = true msgwindow.letterbyletter = false msgwindow.text = msg - msgwindow.resizeHeightToFit(msg,Graphics.width-180) + msgwindow.resizeHeightToFit(msg, Graphics.width - 180) pbBottomRight(msgwindow) - base = Color.new(248,248,248) - shadow = Color.new(80,80,80) + base = Color.new(248, 248, 248) + shadow = Color.new(80, 80, 80) pokemon = heldpoke if heldpoke pokemon = heldpoke - elsif selected[0]==-1 + elsif selected[0] == -1 pokemon = @storage.party[selected[1]] else pokemon = @storage.boxes[selected[0]][selected[1]] @@ -1326,11 +1326,11 @@ class PokemonStorageScene @markingbitmap.bitmap, markrect) end textpos = [ - [_INTL("OK"),402,208,2,base,shadow,1], - [_INTL("Cancel"),402,272,2,base,shadow,1] + [_INTL("OK"), 402, 208, 2, base, shadow, 1], + [_INTL("Cancel"), 402, 272, 2, base, shadow, 1] ] - pbDrawTextPositions(@sprites["markingoverlay"].bitmap,textpos) - pbMarkingSetArrow(@sprites["arrow"],index) + pbDrawTextPositions(@sprites["markingoverlay"].bitmap, textpos) + pbMarkingSetArrow(@sprites["arrow"], index) redraw = false end Graphics.update @@ -1340,11 +1340,11 @@ class PokemonStorageScene key = Input::RIGHT if Input.repeat?(Input::RIGHT) key = Input::LEFT if Input.repeat?(Input::LEFT) key = Input::UP if Input.repeat?(Input::UP) - if key>=0 + if key >= 0 oldindex = index - index = pbMarkingChangeSelection(key,index) - pbPlayCursorSE if index!=oldindex - pbMarkingSetArrow(@sprites["arrow"],index) + index = pbMarkingChangeSelection(key, index) + pbPlayCursorSE if index != oldindex + pbMarkingSetArrow(@sprites["arrow"], index) end self.update if Input.trigger?(Input::BACK) @@ -1352,10 +1352,10 @@ class PokemonStorageScene break elsif Input.trigger?(Input::USE) pbPlayDecisionSE - if index==6 # OK + if index == 6 # OK pokemon.markings = markings break - elsif index==7 # Cancel + elsif index == 7 # Cancel break else markings[index] = ((markings[index] || 0) + 1) % mark_variants @@ -1376,13 +1376,13 @@ class PokemonStorageScene def pbHardRefresh oldPartyY = @sprites["boxparty"].y @sprites["box"].dispose - @sprites["box"] = PokemonBoxSprite.new(@storage,@storage.currentBox,@boxviewport) + @sprites["box"] = PokemonBoxSprite.new(@storage, @storage.currentBox, @boxviewport) @sprites["boxparty"].dispose - @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party,@boxsidesviewport) + @sprites["boxparty"] = PokemonBoxPartySprite.new(@storage.party, @boxsidesviewport) @sprites["boxparty"].y = oldPartyY end - def drawMarkings(bitmap,x,y,_width,_height,markings) + def drawMarkings(bitmap, x, y, _width, _height, markings) mark_variants = @markingbitmap.bitmap.height / MARK_HEIGHT markrect = Rect.new(0, 0, MARK_WIDTH, MARK_HEIGHT) (@markingbitmap.bitmap.width / MARK_WIDTH).times do |i| @@ -1392,55 +1392,55 @@ class PokemonStorageScene end end - def pbUpdateOverlay(selection,party = nil) + def pbUpdateOverlay(selection, party = nil) overlay = @sprites["overlay"].bitmap overlay.clear - buttonbase = Color.new(248,248,248) - buttonshadow = Color.new(80,80,80) - pbDrawTextPositions(overlay,[ - [_INTL("Party: {1}",(@storage.party.length rescue 0)),270,326,2,buttonbase,buttonshadow,1], - [_INTL("Exit"),446,326,2,buttonbase,buttonshadow,1], + buttonbase = Color.new(248, 248, 248) + buttonshadow = Color.new(80, 80, 80) + pbDrawTextPositions(overlay, [ + [_INTL("Party: {1}", (@storage.party.length rescue 0)), 270, 326, 2, buttonbase, buttonshadow, 1], + [_INTL("Exit"), 446, 326, 2, buttonbase, buttonshadow, 1], ]) pokemon = nil if @screen.pbHeldPokemon pokemon = @screen.pbHeldPokemon - elsif selection>=0 - pokemon = (party) ? party[selection] : @storage[@storage.currentBox,selection] + elsif selection >= 0 + pokemon = (party) ? party[selection] : @storage[@storage.currentBox, selection] end if !pokemon @sprites["pokemon"].visible = false return end @sprites["pokemon"].visible = true - base = Color.new(88,88,80) - shadow = Color.new(168,184,184) - nonbase = Color.new(208,208,208) - nonshadow = Color.new(224,224,224) + base = Color.new(88, 88, 80) + shadow = Color.new(168, 184, 184) + nonbase = Color.new(208, 208, 208) + nonshadow = Color.new(224, 224, 224) pokename = pokemon.name textstrings = [ - [pokename,10,2,false,base,shadow] + [pokename, 10, 2, false, base, shadow] ] if !pokemon.egg? imagepos = [] if pokemon.male? - textstrings.push([_INTL("♂"),148,2,false,Color.new(24,112,216),Color.new(136,168,208)]) + textstrings.push([_INTL("♂"), 148, 2, false, Color.new(24, 112, 216), Color.new(136, 168, 208)]) elsif pokemon.female? - textstrings.push([_INTL("♀"),148,2,false,Color.new(248,56,32),Color.new(224,152,144)]) + textstrings.push([_INTL("♀"), 148, 2, false, Color.new(248, 56, 32), Color.new(224, 152, 144)]) end - imagepos.push(["Graphics/Pictures/Storage/overlay_lv",6,246]) - textstrings.push([pokemon.level.to_s,28,228,false,base,shadow]) + imagepos.push(["Graphics/Pictures/Storage/overlay_lv", 6, 246]) + textstrings.push([pokemon.level.to_s, 28, 228, false, base, shadow]) if pokemon.ability - textstrings.push([pokemon.ability.name,86,300,2,base,shadow]) + textstrings.push([pokemon.ability.name, 86, 300, 2, base, shadow]) else - textstrings.push([_INTL("No ability"),86,300,2,nonbase,nonshadow]) + textstrings.push([_INTL("No ability"), 86, 300, 2, nonbase, nonshadow]) end if pokemon.item - textstrings.push([pokemon.item.name,86,336,2,base,shadow]) + textstrings.push([pokemon.item.name, 86, 336, 2, base, shadow]) else - textstrings.push([_INTL("No item"),86,336,2,nonbase,nonshadow]) + textstrings.push([_INTL("No item"), 86, 336, 2, nonbase, nonshadow]) end if pokemon.shiny? - imagepos.push(["Graphics/Pictures/shiny",156,198]) + imagepos.push(["Graphics/Pictures/shiny", 156, 198]) end typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) pokemon.types.each_with_index do |type, i| @@ -1449,10 +1449,10 @@ class PokemonStorageScene type_x = (pokemon.types.length == 1) ? 52 : 18 + 70 * i overlay.blt(type_x, 272, typebitmap.bitmap, type_rect) end - drawMarkings(overlay,70,240,128,20,pokemon.markings) - pbDrawImagePositions(overlay,imagepos) + drawMarkings(overlay, 70, 240, 128, 20, pokemon.markings) + pbDrawImagePositions(overlay, imagepos) end - pbDrawTextPositions(overlay,textstrings) + pbDrawTextPositions(overlay, textstrings) @sprites["pokemon"].setPokemonBitmap(pokemon) end @@ -1469,7 +1469,7 @@ class PokemonStorageScreen attr_reader :storage attr_accessor :heldpkmn - def initialize(scene,storage) + def initialize(scene, storage) @scene = scene @storage = storage @pbHeldPokemon = nil @@ -1478,18 +1478,18 @@ class PokemonStorageScreen def pbStartScreen(command) $game_temp.in_storage = true @heldpkmn = nil - if command==0 # Organise - @scene.pbStartBox(self,command) + if command == 0 # Organise + @scene.pbStartBox(self, command) loop do selected = @scene.pbSelectBox(@storage.party) - if selected==nil + if selected == nil if pbHeldPokemon pbDisplay(_INTL("You're holding a Pokémon!")) next end next if pbConfirm(_INTL("Continue Box operations?")) break - elsif selected[0]==-3 # Close box + elsif selected[0] == -3 # Close box if pbHeldPokemon pbDisplay(_INTL("You're holding a Pokémon!")) next @@ -1499,10 +1499,10 @@ class PokemonStorageScreen break end next - elsif selected[0]==-4 # Box name + elsif selected[0] == -4 # Box name pbBoxCommands else - pokemon = @storage[selected[0],selected[1]] + pokemon = @storage[selected[0], selected[1]] heldpoke = pbHeldPokemon next if !pokemon && !heldpoke if @scene.quickswap @@ -1522,48 +1522,48 @@ class PokemonStorageScreen cmdDebug = -1 cmdCancel = -1 if heldpoke - helptext = _INTL("{1} is selected.",heldpoke.name) - commands[cmdMove=commands.length] = (pokemon) ? _INTL("Shift") : _INTL("Place") + helptext = _INTL("{1} is selected.", heldpoke.name) + commands[cmdMove = commands.length] = (pokemon) ? _INTL("Shift") : _INTL("Place") elsif pokemon - helptext = _INTL("{1} is selected.",pokemon.name) - commands[cmdMove=commands.length] = _INTL("Move") + helptext = _INTL("{1} is selected.", pokemon.name) + commands[cmdMove = commands.length] = _INTL("Move") end - commands[cmdSummary=commands.length] = _INTL("Summary") - commands[cmdWithdraw=commands.length] = (selected[0]==-1) ? _INTL("Store") : _INTL("Withdraw") - commands[cmdItem=commands.length] = _INTL("Item") - commands[cmdMark=commands.length] = _INTL("Mark") - commands[cmdRelease=commands.length] = _INTL("Release") - commands[cmdDebug=commands.length] = _INTL("Debug") if $DEBUG - commands[cmdCancel=commands.length] = _INTL("Cancel") - command=pbShowCommands(helptext,commands) - if cmdMove>=0 && command==cmdMove # Move/Shift/Place + commands[cmdSummary = commands.length] = _INTL("Summary") + commands[cmdWithdraw = commands.length] = (selected[0] == -1) ? _INTL("Store") : _INTL("Withdraw") + commands[cmdItem = commands.length] = _INTL("Item") + commands[cmdMark = commands.length] = _INTL("Mark") + commands[cmdRelease = commands.length] = _INTL("Release") + commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG + commands[cmdCancel = commands.length] = _INTL("Cancel") + command = pbShowCommands(helptext, commands) + if cmdMove >= 0 && command == cmdMove # Move/Shift/Place if @heldpkmn (pokemon) ? pbSwap(selected) : pbPlace(selected) else pbHold(selected) end - elsif cmdSummary>=0 && command==cmdSummary # Summary - pbSummary(selected,@heldpkmn) - elsif cmdWithdraw>=0 && command==cmdWithdraw # Store/Withdraw - (selected[0]==-1) ? pbStore(selected,@heldpkmn) : pbWithdraw(selected,@heldpkmn) - elsif cmdItem>=0 && command==cmdItem # Item - pbItem(selected,@heldpkmn) - elsif cmdMark>=0 && command==cmdMark # Mark - pbMark(selected,@heldpkmn) - elsif cmdRelease>=0 && command==cmdRelease # Release - pbRelease(selected,@heldpkmn) - elsif cmdDebug>=0 && command==cmdDebug # Debug - pbPokemonDebug((@heldpkmn) ? @heldpkmn : pokemon,selected,heldpoke) + elsif cmdSummary >= 0 && command == cmdSummary # Summary + pbSummary(selected, @heldpkmn) + elsif cmdWithdraw >= 0 && command == cmdWithdraw # Store/Withdraw + (selected[0] == -1) ? pbStore(selected, @heldpkmn) : pbWithdraw(selected, @heldpkmn) + elsif cmdItem >= 0 && command == cmdItem # Item + pbItem(selected, @heldpkmn) + elsif cmdMark >= 0 && command == cmdMark # Mark + pbMark(selected, @heldpkmn) + elsif cmdRelease >= 0 && command == cmdRelease # Release + pbRelease(selected, @heldpkmn) + elsif cmdDebug >= 0 && command == cmdDebug # Debug + pbPokemonDebug((@heldpkmn) ? @heldpkmn : pokemon, selected, heldpoke) end end end end @scene.pbCloseBox - elsif command==1 # Withdraw - @scene.pbStartBox(self,command) + elsif command == 1 # Withdraw + @scene.pbStartBox(self, command) loop do selected = @scene.pbSelectBox(@storage.party) - if selected==nil + if selected == nil next if pbConfirm(_INTL("Continue Box operations?")) break else @@ -1581,9 +1581,9 @@ class PokemonStorageScreen pbBoxCommands next end - pokemon = @storage[selected[0],selected[1]] + pokemon = @storage[selected[0], selected[1]] next if !pokemon - command = pbShowCommands(_INTL("{1} is selected.",pokemon.name),[ + command = pbShowCommands(_INTL("{1} is selected.", pokemon.name), [ _INTL("Withdraw"), _INTL("Summary"), _INTL("Mark"), @@ -1599,23 +1599,23 @@ class PokemonStorageScreen end end @scene.pbCloseBox - elsif command==2 # Deposit - @scene.pbStartBox(self,command) + elsif command == 2 # Deposit + @scene.pbStartBox(self, command) loop do selected = @scene.pbSelectParty(@storage.party) - if selected==-3 # Close box + if selected == -3 # Close box if pbConfirm(_INTL("Exit from the Box?")) pbSEPlay("PC close") break end next - elsif selected<0 + elsif selected < 0 next if pbConfirm(_INTL("Continue Box operations?")) break else - pokemon = @storage[-1,selected] + pokemon = @storage[-1, selected] next if !pokemon - command = pbShowCommands(_INTL("{1} is selected.",pokemon.name),[ + command = pbShowCommands(_INTL("{1} is selected.", pokemon.name), [ _INTL("Store"), _INTL("Summary"), _INTL("Mark"), @@ -1631,8 +1631,8 @@ class PokemonStorageScreen end end @scene.pbCloseBox - elsif command==3 - @scene.pbStartBox(self,command) + elsif command == 3 + @scene.pbStartBox(self, command) @scene.pbCloseBox end $game_temp.in_storage = false @@ -1647,7 +1647,7 @@ class PokemonStorageScreen end def pbRefreshSingle(i) # For debug - @scene.pbUpdateOverlay(i[1],(i[0]==-1) ? @storage.party : nil) + @scene.pbUpdateOverlay(i[1], (i[0] == -1) ? @storage.party : nil) @scene.pbHardRefresh end @@ -1656,15 +1656,15 @@ class PokemonStorageScreen end def pbConfirm(str) - return pbShowCommands(str,[_INTL("Yes"),_INTL("No")])==0 + return pbShowCommands(str, [_INTL("Yes"), _INTL("No")]) == 0 end - def pbShowCommands(msg,commands,index = 0) - return @scene.pbShowCommands(msg,commands,index) + def pbShowCommands(msg, commands, index = 0) + return @scene.pbShowCommands(msg, commands, index) end def pbAble?(pokemon) - pokemon && !pokemon.egg? && pokemon.hp>0 + pokemon && !pokemon.egg? && pokemon.hp > 0 end def pbAbleCount @@ -1679,39 +1679,39 @@ class PokemonStorageScreen return @heldpkmn end - def pbWithdraw(selected,heldpoke) + def pbWithdraw(selected, heldpoke) box = selected[0] index = selected[1] - if box==-1 + if box == -1 raise _INTL("Can't withdraw from party...") end if @storage.party_full? pbDisplay(_INTL("Your party's full!")) return false end - @scene.pbWithdraw(selected,heldpoke,@storage.party.length) + @scene.pbWithdraw(selected, heldpoke, @storage.party.length) if heldpoke @storage.pbMoveCaughtToParty(heldpoke) @heldpkmn = nil else - @storage.pbMove(-1,-1,box,index) + @storage.pbMove(-1, -1, box, index) end @scene.pbRefresh return true end - def pbStore(selected,heldpoke) + def pbStore(selected, heldpoke) box = selected[0] index = selected[1] - if box!=-1 + if box != -1 raise _INTL("Can't deposit from box...") end - if pbAbleCount<=1 && pbAble?(@storage[box,index]) && !heldpoke + if pbAbleCount <= 1 && pbAble?(@storage[box, index]) && !heldpoke pbPlayBuzzerSE pbDisplay(_INTL("That's your last Pokémon!")) elsif heldpoke && heldpoke.mail pbDisplay(_INTL("Please remove the Mail.")) - elsif !heldpoke && @storage[box,index].mail + elsif !heldpoke && @storage[box, index].mail pbDisplay(_INTL("Please remove the Mail.")) elsif heldpoke && heldpoke.cannot_store pbDisplay(_INTL("{1} refuses to go into storage!", heldpoke.name)) @@ -1720,26 +1720,26 @@ class PokemonStorageScreen else loop do destbox = @scene.pbChooseBox(_INTL("Deposit in which Box?")) - if destbox>=0 + if destbox >= 0 firstfree = @storage.pbFirstFreePos(destbox) - if firstfree<0 + if firstfree < 0 pbDisplay(_INTL("The Box is full.")) next end - if heldpoke || selected[0]==-1 - p = (heldpoke) ? heldpoke : @storage[-1,index] + if heldpoke || selected[0] == -1 + p = (heldpoke) ? heldpoke : @storage[-1, index] if Settings::HEAL_STORED_POKEMON old_ready_evo = p.ready_to_evolve p.heal p.ready_to_evolve = old_ready_evo end end - @scene.pbStore(selected,heldpoke,destbox,firstfree) + @scene.pbStore(selected, heldpoke, destbox, firstfree) if heldpoke - @storage.pbMoveCaughtToBox(heldpoke,destbox) + @storage.pbMoveCaughtToBox(heldpoke, destbox) @heldpkmn = nil else - @storage.pbMove(destbox,-1,-1,index) + @storage.pbMove(destbox, -1, -1, index) end end break @@ -1751,22 +1751,22 @@ class PokemonStorageScreen def pbHold(selected) box = selected[0] index = selected[1] - if box==-1 && pbAble?(@storage[box,index]) && pbAbleCount<=1 + if box == -1 && pbAble?(@storage[box, index]) && pbAbleCount <= 1 pbPlayBuzzerSE pbDisplay(_INTL("That's your last Pokémon!")) return end @scene.pbHold(selected) - @heldpkmn = @storage[box,index] - @storage.pbDelete(box,index) + @heldpkmn = @storage[box, index] + @storage.pbDelete(box, index) @scene.pbRefresh end def pbPlace(selected) box = selected[0] index = selected[1] - if @storage[box,index] - raise _INTL("Position {1},{2} is not empty...",box,index) + if @storage[box, index] + raise _INTL("Position {1},{2} is not empty...", box, index) elsif box != -1 if index >= @storage.maxPokemon(box) pbDisplay("Can't place that there.") @@ -1784,9 +1784,9 @@ class PokemonStorageScreen @heldpkmn.heal @heldpkmn.ready_to_evolve = old_ready_evo end - @scene.pbPlace(selected,@heldpkmn) - @storage[box,index] = @heldpkmn - if box==-1 + @scene.pbPlace(selected, @heldpkmn) + @storage[box, index] = @heldpkmn + if box == -1 @storage.party.compact! end @scene.pbRefresh @@ -1796,19 +1796,19 @@ class PokemonStorageScreen def pbSwap(selected) box = selected[0] index = selected[1] - if !@storage[box,index] - raise _INTL("Position {1},{2} is empty...",box,index) + if !@storage[box, index] + raise _INTL("Position {1},{2} is empty...", box, index) end if @heldpkmn.cannot_store && box != -1 pbPlayBuzzerSE pbDisplay(_INTL("{1} refuses to go into storage!", @heldpkmn.name)) return false - elsif box==-1 && pbAble?(@storage[box,index]) && pbAbleCount<=1 && !pbAble?(@heldpkmn) + elsif box == -1 && pbAble?(@storage[box, index]) && pbAbleCount <= 1 && !pbAble?(@heldpkmn) pbPlayBuzzerSE pbDisplay(_INTL("That's your last Pokémon!")) return false end - if box!=-1 && @heldpkmn.mail + if box != -1 && @heldpkmn.mail pbDisplay("Please remove the mail.") return false end @@ -1817,18 +1817,18 @@ class PokemonStorageScreen @heldpkmn.heal @heldpkmn.ready_to_evolve = old_ready_evo end - @scene.pbSwap(selected,@heldpkmn) - tmp = @storage[box,index] - @storage[box,index] = @heldpkmn + @scene.pbSwap(selected, @heldpkmn) + tmp = @storage[box, index] + @storage[box, index] = @heldpkmn @heldpkmn = tmp @scene.pbRefresh return true end - def pbRelease(selected,heldpoke) + def pbRelease(selected, heldpoke) box = selected[0] index = selected[1] - pokemon = (heldpoke) ? heldpoke : @storage[box,index] + pokemon = (heldpoke) ? heldpoke : @storage[box, index] return if !pokemon if pokemon.egg? pbDisplay(_INTL("You can't release an Egg.")) @@ -1840,52 +1840,52 @@ class PokemonStorageScreen pbDisplay(_INTL("{1} refuses to leave you!", pokemon.name)) return false end - if box==-1 && pbAbleCount<=1 && pbAble?(pokemon) && !heldpoke + if box == -1 && pbAbleCount <= 1 && pbAble?(pokemon) && !heldpoke pbPlayBuzzerSE pbDisplay(_INTL("That's your last Pokémon!")) return end - command = pbShowCommands(_INTL("Release this Pokémon?"),[_INTL("No"),_INTL("Yes")]) - if command==1 + command = pbShowCommands(_INTL("Release this Pokémon?"), [_INTL("No"), _INTL("Yes")]) + if command == 1 pkmnname = pokemon.name - @scene.pbRelease(selected,heldpoke) + @scene.pbRelease(selected, heldpoke) if heldpoke @heldpkmn = nil else - @storage.pbDelete(box,index) + @storage.pbDelete(box, index) end @scene.pbRefresh - pbDisplay(_INTL("{1} was released.",pkmnname)) - pbDisplay(_INTL("Bye-bye, {1}!",pkmnname)) + pbDisplay(_INTL("{1} was released.", pkmnname)) + pbDisplay(_INTL("Bye-bye, {1}!", pkmnname)) @scene.pbRefresh end return end - def pbChooseMove(pkmn,helptext,index = 0) + def pbChooseMove(pkmn, helptext, index = 0) movenames = [] for i in pkmn.moves - if i.total_pp<=0 - movenames.push(_INTL("{1} (PP: ---)",i.name)) + if i.total_pp <= 0 + movenames.push(_INTL("{1} (PP: ---)", i.name)) else - movenames.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp)) + movenames.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp)) end end - return @scene.pbShowCommands(helptext,movenames,index) + return @scene.pbShowCommands(helptext, movenames, index) end - def pbSummary(selected,heldpoke) - @scene.pbSummary(selected,heldpoke) + def pbSummary(selected, heldpoke) + @scene.pbSummary(selected, heldpoke) end - def pbMark(selected,heldpoke) - @scene.pbMark(selected,heldpoke) + def pbMark(selected, heldpoke) + @scene.pbMark(selected, heldpoke) end - def pbItem(selected,heldpoke) + def pbItem(selected, heldpoke) box = selected[0] index = selected[1] - pokemon = (heldpoke) ? heldpoke : @storage[box,index] + pokemon = (heldpoke) ? heldpoke : @storage[box, index] if pokemon.egg? pbDisplay(_INTL("Eggs can't hold items.")) return @@ -1895,11 +1895,11 @@ class PokemonStorageScreen end if pokemon.item itemname = pokemon.item.name - if pbConfirm(_INTL("Take this {1}?",itemname)) + if pbConfirm(_INTL("Take this {1}?", itemname)) if !$bag.add(pokemon.item) - pbDisplay(_INTL("Can't store the {1}.",itemname)) + pbDisplay(_INTL("Can't store the {1}.", itemname)) else - pbDisplay(_INTL("Took the {1}.",itemname)) + pbDisplay(_INTL("Took the {1}.", itemname)) pokemon.item = nil @scene.pbHardRefresh end @@ -1910,7 +1910,7 @@ class PokemonStorageScreen itemname = GameData::Item.get(item).name pokemon.item = item $bag.remove(item) - pbDisplay(_INTL("{1} is now being held.",itemname)) + pbDisplay(_INTL("{1} is now being held.", itemname)) @scene.pbHardRefresh end end @@ -1924,52 +1924,52 @@ class PokemonStorageScreen _INTL("Cancel"), ] command = pbShowCommands( - _INTL("What do you want to do?"),commands) + _INTL("What do you want to do?"), commands) case command when 0 destbox = @scene.pbChooseBox(_INTL("Jump to which Box?")) - if destbox>=0 + if destbox >= 0 @scene.pbJumpToBox(destbox) end when 1 papers = @storage.availableWallpapers index = 0 for i in 0...papers[1].length - if papers[1][i]==@storage[@storage.currentBox].background + if papers[1][i] == @storage[@storage.currentBox].background index = i break end end - wpaper = pbShowCommands(_INTL("Pick the wallpaper."),papers[0],index) - if wpaper>=0 + wpaper = pbShowCommands(_INTL("Pick the wallpaper."), papers[0], index) + if wpaper >= 0 @scene.pbChangeBackground(papers[1][wpaper]) end when 2 - @scene.pbBoxName(_INTL("Box name?"),0,12) + @scene.pbBoxName(_INTL("Box name?"), 0, 12) end end def pbChoosePokemon(_party = nil) $game_temp.in_storage = true @heldpkmn = nil - @scene.pbStartBox(self,1) + @scene.pbStartBox(self, 1) retval = nil loop do selected = @scene.pbSelectBox(@storage.party) - if selected && selected[0]==-3 # Close box + if selected && selected[0] == -3 # Close box if pbConfirm(_INTL("Exit from the Box?")) pbSEPlay("PC close") break end next end - if selected==nil + if selected == nil next if pbConfirm(_INTL("Continue Box operations?")) break - elsif selected[0]==-4 # Box name + elsif selected[0] == -4 # Box name pbBoxCommands else - pokemon = @storage[selected[0],selected[1]] + pokemon = @storage[selected[0], selected[1]] next if !pokemon commands = [ _INTL("Select"), @@ -1979,9 +1979,9 @@ class PokemonStorageScreen _INTL("Mark") ] commands.push(_INTL("Cancel")) - commands[2] = _INTL("Store") if selected[0]==-1 - helptext = _INTL("{1} is selected.",pokemon.name) - command = pbShowCommands(helptext,commands) + commands[2] = _INTL("Store") if selected[0] == -1 + helptext = _INTL("{1} is selected.", pokemon.name) + command = pbShowCommands(helptext, commands) case command when 0 # Select if pokemon @@ -1989,17 +1989,17 @@ class PokemonStorageScreen break end when 1 - pbSummary(selected,nil) + pbSummary(selected, nil) when 2 # Store/Withdraw - if selected[0]==-1 - pbStore(selected,nil) + if selected[0] == -1 + pbStore(selected, nil) else - pbWithdraw(selected,nil) + pbWithdraw(selected, nil) end when 3 - pbItem(selected,nil) + pbItem(selected, nil) when 4 - pbMark(selected,nil) + pbMark(selected, nil) end end end diff --git a/Data/Scripts/016_UI/018_UI_ItemStorage.rb b/Data/Scripts/016_UI/018_UI_ItemStorage.rb index 4be47d82e..40918bee6 100644 --- a/Data/Scripts/016_UI/018_UI_ItemStorage.rb +++ b/Data/Scripts/016_UI/018_UI_ItemStorage.rb @@ -11,11 +11,11 @@ class Window_PokemonItemStorage < Window_DrawableCommand refresh end - def initialize(bag,x,y,width,height) + def initialize(bag, x, y, width, height) @bag = bag @sortIndex = -1 @adapter = PokemonMartAdapter.new - super(x,y,width,height) + super(x, y, width, height) self.windowskin = nil end @@ -25,27 +25,27 @@ class Window_PokemonItemStorage < Window_DrawableCommand end def itemCount - return @bag.length+1 + return @bag.length + 1 end - def drawItem(index,_count,rect) - rect = drawCursor(index,rect) + def drawItem(index, _count, rect) + rect = drawCursor(index, rect) textpos = [] - if index==@bag.length - textpos.push([_INTL("CANCEL"),rect.x,rect.y-6,false,self.baseColor,self.shadowColor]) + if index == @bag.length + textpos.push([_INTL("CANCEL"), rect.x, rect.y - 6, false, self.baseColor, self.shadowColor]) else item = @bag[index][0] itemname = @adapter.getDisplayName(item) - baseColor = (index==@sortIndex) ? Color.new(248,24,24) : self.baseColor - textpos.push([itemname,rect.x,rect.y-6,false,self.baseColor,self.shadowColor]) + baseColor = (index == @sortIndex) ? Color.new(248, 24, 24) : self.baseColor + textpos.push([itemname, rect.x, rect.y - 6, false, self.baseColor, self.shadowColor]) if !GameData::Item.get(item).is_important? # Not a Key item/HM/TM - qty = _ISPRINTF("x{1: 2d}",@bag[index][1]) + qty = _ISPRINTF("x{1: 2d}", @bag[index][1]) sizeQty = self.contents.text_size(qty).width - xQty = rect.x+rect.width-sizeQty-2 - textpos.push([qty,xQty,rect.y-6,false,baseColor,self.shadowColor]) + xQty = rect.x + rect.width - sizeQty - 2 + textpos.push([qty, xQty, rect.y - 6, false, baseColor, self.shadowColor]) end end - pbDrawTextPositions(self.contents,textpos) + pbDrawTextPositions(self.contents, textpos) end end @@ -53,12 +53,12 @@ end # #=============================================================================== class ItemStorage_Scene - ITEMLISTBASECOLOR = Color.new(88,88,80) - ITEMLISTSHADOWCOLOR = Color.new(168,184,184) - ITEMTEXTBASECOLOR = Color.new(248,248,248) - ITEMTEXTSHADOWCOLOR = Color.new(0,0,0) - TITLEBASECOLOR = Color.new(248,248,248) - TITLESHADOWCOLOR = Color.new(0,0,0) + ITEMLISTBASECOLOR = Color.new(88, 88, 80) + ITEMLISTSHADOWCOLOR = Color.new(168, 184, 184) + ITEMTEXTBASECOLOR = Color.new(248, 248, 248) + ITEMTEXTSHADOWCOLOR = Color.new(0, 0, 0) + TITLEBASECOLOR = Color.new(248, 248, 248) + TITLESHADOWCOLOR = Color.new(0, 0, 0) ITEMSVISIBLE = 7 def initialize(title) @@ -70,27 +70,27 @@ class ItemStorage_Scene end def pbStartScene(bag) - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @bag = bag @sprites = {} - @sprites["background"] = IconSprite.new(0,0,@viewport) + @sprites["background"] = IconSprite.new(0, 0, @viewport) @sprites["background"].setBitmap("Graphics/Pictures/pcItembg") - @sprites["icon"] = ItemIconSprite.new(50,334,nil,@viewport) + @sprites["icon"] = ItemIconSprite.new(50, 334, nil, @viewport) # Item list - @sprites["itemwindow"] = Window_PokemonItemStorage.new(@bag,98,14,334,32+ITEMSVISIBLE*32) + @sprites["itemwindow"] = Window_PokemonItemStorage.new(@bag, 98, 14, 334, 32 + ITEMSVISIBLE * 32) @sprites["itemwindow"].viewport = @viewport @sprites["itemwindow"].index = 0 @sprites["itemwindow"].baseColor = ITEMLISTBASECOLOR @sprites["itemwindow"].shadowColor = ITEMLISTSHADOWCOLOR @sprites["itemwindow"].refresh # Title - @sprites["pocketwindow"] = BitmapSprite.new(88,64,@viewport) + @sprites["pocketwindow"] = BitmapSprite.new(88, 64, @viewport) @sprites["pocketwindow"].x = 14 @sprites["pocketwindow"].y = 16 pbSetNarrowFont(@sprites["pocketwindow"].bitmap) # Item description - @sprites["itemtextwindow"] = Window_UnformattedTextPokemon.newWithSize("",84,270,Graphics.width-84,128,@viewport) + @sprites["itemtextwindow"] = Window_UnformattedTextPokemon.newWithSize("", 84, 270, Graphics.width - 84, 128, @viewport) @sprites["itemtextwindow"].baseColor = ITEMTEXTBASECOLOR @sprites["itemtextwindow"].shadowColor = ITEMTEXTSHADOWCOLOR @sprites["itemtextwindow"].windowskin = nil @@ -101,7 +101,7 @@ class ItemStorage_Scene @sprites["msgwindow"] = Window_AdvancedTextPokemon.new("") @sprites["msgwindow"].visible = false @sprites["msgwindow"].viewport = @viewport - pbBottomLeftLines(@sprites["helpwindow"],1) + pbBottomLeftLines(@sprites["helpwindow"], 1) pbDeactivateWindows(@sprites) pbRefresh pbFadeInAndShow(@sprites) @@ -113,26 +113,26 @@ class ItemStorage_Scene @viewport.dispose end - def pbChooseNumber(helptext,maximum) - return UIHelper.pbChooseNumber(@sprites["helpwindow"],helptext,maximum) { update } + def pbChooseNumber(helptext, maximum) + return UIHelper.pbChooseNumber(@sprites["helpwindow"], helptext, maximum) { update } end - def pbDisplay(msg,brief = false) - UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { update } + def pbDisplay(msg, brief = false) + UIHelper.pbDisplay(@sprites["msgwindow"], msg, brief) { update } end def pbConfirm(msg) - UIHelper.pbConfirm(@sprites["msgwindow"],msg) { update } + UIHelper.pbConfirm(@sprites["msgwindow"], msg) { update } end - def pbShowCommands(helptext,commands) - return UIHelper.pbShowCommands(@sprites["helpwindow"],helptext,commands) { update } + def pbShowCommands(helptext, commands) + return UIHelper.pbShowCommands(@sprites["helpwindow"], helptext, commands) { update } end def pbRefresh bm = @sprites["pocketwindow"].bitmap # Draw title at upper left corner ("Toss Item/Withdraw Item") - drawTextEx(bm,0,4,bm.width,2,@title,TITLEBASECOLOR,TITLESHADOWCOLOR) + drawTextEx(bm, 0, 4, bm.width, 2, @title, TITLEBASECOLOR, TITLESHADOWCOLOR) itemwindow = @sprites["itemwindow"] # Draw item icon @sprites["icon"].item = itemwindow.item @@ -150,17 +150,17 @@ class ItemStorage_Scene @sprites["helpwindow"].visible = false itemwindow = @sprites["itemwindow"] itemwindow.refresh - pbActivateWindow(@sprites,"itemwindow") { + pbActivateWindow(@sprites, "itemwindow") { loop do Graphics.update Input.update olditem = itemwindow.item self.update - pbRefresh if itemwindow.item!=olditem + pbRefresh if itemwindow.item != olditem if Input.trigger?(Input::BACK) return nil elsif Input.trigger?(Input::USE) - if itemwindow.index<@bag.length + if itemwindow.index < @bag.length pbRefresh return @bag[itemwindow.index][0] else @@ -197,13 +197,13 @@ end #=============================================================================== module UIHelper # Letter by letter display of the message _msg_ by the window _helpwindow_. - def self.pbDisplay(helpwindow,msg,brief) + def self.pbDisplay(helpwindow, msg, brief) cw = helpwindow oldvisible = cw.visible cw.letterbyletter = true - cw.text = msg+"\1" + cw.text = msg + "\1" cw.visible = true - pbBottomLeftLines(cw,2) + pbBottomLeftLines(cw, 2) loop do Graphics.update Input.update @@ -217,13 +217,13 @@ module UIHelper cw.visible = oldvisible end - def self.pbDisplayStatic(msgwindow,message) + def self.pbDisplayStatic(msgwindow, message) oldvisible = msgwindow.visible msgwindow.visible = true msgwindow.letterbyletter = false msgwindow.width = Graphics.width - msgwindow.resizeHeightToFit(message,Graphics.width) - msgwindow.text = message + msgwindow.resizeHeightToFit(message, Graphics.width) + msgwindow.text = message pbBottomRight(msgwindow) loop do Graphics.update @@ -239,14 +239,14 @@ module UIHelper # Letter by letter display of the message _msg_ by the window _helpwindow_, # used to ask questions. Returns true if the user chose yes, false if no. - def self.pbConfirm(helpwindow,msg) + def self.pbConfirm(helpwindow, msg) dw = helpwindow oldvisible = dw.visible dw.letterbyletter = true dw.text = msg dw.visible = true - pbBottomLeftLines(dw,2) - commands = [_INTL("Yes"),_INTL("No")] + pbBottomLeftLines(dw, 2) + commands = [_INTL("Yes"), _INTL("No")] cw = Window_CommandPokemon.new(commands) cw.index = 0 cw.viewport = helpwindow.viewport @@ -265,7 +265,7 @@ module UIHelper break elsif Input.trigger?(Input::USE) pbPlayDecisionSE - ret = (cw.index==0) + ret = (cw.index == 0) break end end @@ -275,7 +275,7 @@ module UIHelper return ret end - def self.pbChooseNumber(helpwindow,helptext,maximum,initnum = 1) + def self.pbChooseNumber(helpwindow, helptext, maximum, initnum = 1) oldvisible = helpwindow.visible helpwindow.visible = true helpwindow.text = helptext @@ -285,10 +285,10 @@ module UIHelper numwindow = Window_UnformattedTextPokemon.new("x000") numwindow.viewport = helpwindow.viewport numwindow.letterbyletter = false - numwindow.text = _ISPRINTF("x{1:03d}",curnumber) - numwindow.resizeToFit(numwindow.text,Graphics.width) + numwindow.text = _ISPRINTF("x{1:03d}", curnumber) + numwindow.resizeToFit(numwindow.text, Graphics.width) pbBottomRight(numwindow) - helpwindow.resizeHeightToFit(helpwindow.text,Graphics.width-numwindow.width) + helpwindow.resizeHeightToFit(helpwindow.text, Graphics.width - numwindow.width) pbBottomLeft(helpwindow) loop do Graphics.update @@ -306,23 +306,23 @@ module UIHelper break elsif Input.repeat?(Input::UP) curnumber += 1 - curnumber = 1 if curnumber>maximum - numwindow.text = _ISPRINTF("x{1:03d}",curnumber) + curnumber = 1 if curnumber > maximum + numwindow.text = _ISPRINTF("x{1:03d}", curnumber) pbPlayCursorSE elsif Input.repeat?(Input::DOWN) curnumber -= 1 - curnumber = maximum if curnumber<1 - numwindow.text = _ISPRINTF("x{1:03d}",curnumber) + curnumber = maximum if curnumber < 1 + numwindow.text = _ISPRINTF("x{1:03d}", curnumber) pbPlayCursorSE elsif Input.repeat?(Input::LEFT) curnumber -= 10 - curnumber = 1 if curnumber<1 - numwindow.text = _ISPRINTF("x{1:03d}",curnumber) + curnumber = 1 if curnumber < 1 + numwindow.text = _ISPRINTF("x{1:03d}", curnumber) pbPlayCursorSE elsif Input.repeat?(Input::RIGHT) curnumber += 10 - curnumber = maximum if curnumber>maximum - numwindow.text = _ISPRINTF("x{1:03d}",curnumber) + curnumber = maximum if curnumber > maximum + numwindow.text = _ISPRINTF("x{1:03d}", curnumber) pbPlayCursorSE end end @@ -331,7 +331,7 @@ module UIHelper return ret end - def self.pbShowCommands(helpwindow,helptext,commands,initcmd = 0) + def self.pbShowCommands(helpwindow, helptext, commands, initcmd = 0) ret = -1 oldvisible = helpwindow.visible helpwindow.visible = helptext ? true : false @@ -342,7 +342,7 @@ module UIHelper begin cmdwindow.viewport = helpwindow.viewport pbBottomRight(cmdwindow) - helpwindow.resizeHeightToFit(helpwindow.text,Graphics.width-cmdwindow.width) + helpwindow.resizeHeightToFit(helpwindow.text, Graphics.width - cmdwindow.width) pbBottomLeft(helpwindow) loop do Graphics.update diff --git a/Data/Scripts/016_UI/019_UI_PC.rb b/Data/Scripts/016_UI/019_UI_PC.rb index 3694ab87c..797f7f85f 100644 --- a/Data/Scripts/016_UI/019_UI_PC.rb +++ b/Data/Scripts/016_UI/019_UI_PC.rb @@ -26,7 +26,7 @@ class StorageSystemPC def name if $player.seen_storage_creator - return _INTL("{1}'s PC",pbGetStorageCreator) + return _INTL("{1}'s PC", pbGetStorageCreator) else return _INTL("Someone's PC") end @@ -44,27 +44,27 @@ class StorageSystemPC [_INTL("Organize the Pokémon in Boxes and in your party."), _INTL("Move Pokémon stored in Boxes to your party."), _INTL("Store Pokémon in your party in Boxes."), - _INTL("Return to the previous menu.")],-1,command + _INTL("Return to the previous menu.")], -1, command ) - if command>=0 && command<3 - if command==1 # Withdraw + if command >= 0 && command < 3 + if command == 1 # Withdraw if $PokemonStorage.party_full? pbMessage(_INTL("Your party is full!")) next end - elsif command==2 # Deposit - count=0 + elsif command == 2 # Deposit + count = 0 for p in $PokemonStorage.party - count += 1 if p && !p.egg? && p.hp>0 + count += 1 if p && !p.egg? && p.hp > 0 end - if count<=1 + if count <= 1 pbMessage(_INTL("Can't deposit the last Pokémon!")) next end end pbFadeOutIn { scene = PokemonStorageScene.new - screen = PokemonStorageScreen.new(scene,$PokemonStorage) + screen = PokemonStorageScreen.new(scene, $PokemonStorage) screen.pbStartScreen(command) } else @@ -94,11 +94,11 @@ module PokemonPCList end def self.callCommand(cmd) - return false if cmd<0 || cmd>=@@pclist.length + return false if cmd < 0 || cmd >= @@pclist.length i = 0 for pc in @@pclist next if !pc.shouldShow? - if i==cmd + if i == cmd pc.access return true end @@ -122,7 +122,7 @@ def pbPCItemStorage [_INTL("Take out items from the PC."), _INTL("Store items in the PC."), _INTL("Throw away items stored in the PC."), - _INTL("Go back to the previous menu.")],-1,command + _INTL("Go back to the previous menu.")], -1, command ) case command when 0 # Withdraw Item @@ -164,26 +164,26 @@ def pbPCItemStorage end def pbPCMailbox - if !$PokemonGlobal.mailbox || $PokemonGlobal.mailbox.length==0 + if !$PokemonGlobal.mailbox || $PokemonGlobal.mailbox.length == 0 pbMessage(_INTL("There's no Mail here.")) else loop do command = 0 - commands=[] + commands = [] for mail in $PokemonGlobal.mailbox commands.push(mail.sender) end commands.push(_INTL("Cancel")) - command = pbShowCommands(nil,commands,-1,command) - if command>=0 && command<$PokemonGlobal.mailbox.length + command = pbShowCommands(nil, commands, -1, command) + if command >= 0 && command < $PokemonGlobal.mailbox.length mailIndex = command commandMail = pbMessage(_INTL("What do you want to do with {1}'s Mail?", - $PokemonGlobal.mailbox[mailIndex].sender),[ + $PokemonGlobal.mailbox[mailIndex].sender), [ _INTL("Read"), _INTL("Move to Bag"), _INTL("Give"), _INTL("Cancel") - ],-1) + ], -1) case commandMail when 0 # Read pbFadeOutIn { @@ -215,11 +215,11 @@ end def pbTrainerPCMenu command = 0 loop do - command = pbMessage(_INTL("What do you want to do?"),[ + command = pbMessage(_INTL("What do you want to do?"), [ _INTL("Item Storage"), _INTL("Mailbox"), _INTL("Turn Off") - ],-1,nil,command) + ], -1, nil, command) case command when 0 then pbPCItemStorage when 1 then pbPCMailbox @@ -239,8 +239,8 @@ def pbPokeCenterPC command = 0 loop do commands = PokemonPCList.getCommandList - command = pbMessage(_INTL("Which PC should be accessed?"),commands, - commands.length,nil,command) + command = pbMessage(_INTL("Which PC should be accessed?"), commands, + commands.length, nil, command) break if !PokemonPCList.callCommand(command) end pbSEPlay("PC close") diff --git a/Data/Scripts/016_UI/020_UI_PokeMart.rb b/Data/Scripts/016_UI/020_UI_PokeMart.rb index 18aa1713d..204469a77 100644 --- a/Data/Scripts/016_UI/020_UI_PokeMart.rb +++ b/Data/Scripts/016_UI/020_UI_PokeMart.rb @@ -137,8 +137,8 @@ class Window_PokemonMart < Window_DrawableCommand @adapter = adapter super(x, y, width, height, viewport) @selarrow = AnimatedBitmap.new("Graphics/Pictures/martSel") - @baseColor = Color.new(88,88,80) - @shadowColor = Color.new(168,184,184) + @baseColor = Color.new(88, 88, 80) + @shadowColor = Color.new(168, 184, 184) self.windowskin = nil end @@ -154,7 +154,7 @@ class Window_PokemonMart < Window_DrawableCommand textpos = [] rect = drawCursor(index, rect) ypos = rect.y - if index == count-1 + if index == count - 1 textpos.push([_INTL("CANCEL"), rect.x, ypos - 4, false, self.baseColor, self.shadowColor]) else item = @stock[index] @@ -407,7 +407,7 @@ class PokemonMart_Scene end end - def pbChooseNumber(helptext,item,maximum) + def pbChooseNumber(helptext, item, maximum) curnumber = 1 ret = 0 helpwindow = @sprites["helpwindow"] @@ -521,10 +521,10 @@ end # #=============================================================================== class PokemonMartScreen - def initialize(scene,stock) - @scene=scene - @stock=stock - @adapter=PokemonMartAdapter.new + def initialize(scene, stock) + @scene = scene + @stock = stock + @adapter = PokemonMartAdapter.new end def pbConfirm(msg) @@ -535,51 +535,51 @@ class PokemonMartScreen return @scene.pbDisplay(msg) end - def pbDisplayPaused(msg,&block) - return @scene.pbDisplayPaused(msg,&block) + def pbDisplayPaused(msg, &block) + return @scene.pbDisplayPaused(msg, &block) end def pbBuyScreen - @scene.pbStartBuyScene(@stock,@adapter) - item=nil + @scene.pbStartBuyScene(@stock, @adapter) + item = nil loop do - item=@scene.pbChooseBuyItem + item = @scene.pbChooseBuyItem break if !item - quantity=0 - itemname=@adapter.getDisplayName(item) - price=@adapter.getPrice(item) - if @adapter.getMoney Settings::BAG_MAX_PER_SLOT - quantity=@scene.pbChooseNumber( - _INTL("{1}? Certainly. How many would you like?",itemname),item,maxafford) - next if quantity==0 - price*=quantity + quantity = @scene.pbChooseNumber( + _INTL("{1}? Certainly. How many would you like?", itemname), item, maxafford) + next if quantity == 0 + price *= quantity if !pbConfirm(_INTL("{1}, and you want {2}. That will be ${3}. OK?", - itemname,quantity,price.to_s_formatted)) + itemname, quantity, price.to_s_formatted)) next end end - if @adapter.getMoney= 10 && $bag && GameData::Item.exists?(:PREMIERBALL) @@ -618,37 +618,37 @@ class PokemonMartScreen end def pbSellScreen - item=@scene.pbStartSellScene(@adapter.getInventory,@adapter) + item = @scene.pbStartSellScene(@adapter.getInventory, @adapter) loop do - item=@scene.pbChooseSellItem + item = @scene.pbChooseSellItem break if !item - itemname=@adapter.getDisplayName(item) + itemname = @adapter.getDisplayName(item) if !@adapter.canSell?(item) - pbDisplayPaused(_INTL("{1}? Oh, no. I can't buy that.",itemname)) + pbDisplayPaused(_INTL("{1}? Oh, no. I can't buy that.", itemname)) next end - price=@adapter.getPrice(item,true) - qty=@adapter.getQuantity(item) - next if qty==0 + price = @adapter.getPrice(item, true) + qty = @adapter.getQuantity(item) + next if qty == 0 @scene.pbShowMoney - if qty>1 - qty=@scene.pbChooseNumber( - _INTL("{1}? How many would you like to sell?",itemname),item,qty) + if qty > 1 + qty = @scene.pbChooseNumber( + _INTL("{1}? How many would you like to sell?", itemname), item, qty) end - if qty==0 + if qty == 0 @scene.pbHideMoney next end - price/=2 - price*=qty - if pbConfirm(_INTL("I can pay ${1}. Would that be OK?",price.to_s_formatted)) + price /= 2 + price *= qty + if pbConfirm(_INTL("I can pay ${1}. Would that be OK?", price.to_s_formatted)) old_money = @adapter.getMoney - @adapter.setMoney(@adapter.getMoney+price) + @adapter.setMoney(@adapter.getMoney + price) $stats.money_earned_at_marts += @adapter.getMoney - old_money 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") } + pbDisplayPaused(_INTL("Turned over the {1} and received ${2}.", itemname, price.to_s_formatted)) { pbSEPlay("Mart buy item") } @scene.pbRefresh end @scene.pbHideMoney @@ -660,7 +660,7 @@ end #=============================================================================== # #=============================================================================== -def pbPokemonMart(stock,speech = nil,cantsell = false) +def pbPokemonMart(stock, speech = nil, cantsell = false) stock.delete_if { |item| GameData::Item.get(item).is_important? && $bag.has?(item) } commands = [] cmdBuy = -1 @@ -671,22 +671,22 @@ def pbPokemonMart(stock,speech = nil,cantsell = false) commands[cmdQuit = commands.length] = _INTL("Quit") cmd = pbMessage( speech ? speech : _INTL("Welcome! How may I serve you?"), - commands,cmdQuit+1) + commands, cmdQuit + 1) loop do - if cmdBuy>=0 && cmd==cmdBuy + if cmdBuy >= 0 && cmd == cmdBuy scene = PokemonMart_Scene.new - screen = PokemonMartScreen.new(scene,stock) + screen = PokemonMartScreen.new(scene, stock) screen.pbBuyScreen - elsif cmdSell>=0 && cmd==cmdSell + elsif cmdSell >= 0 && cmd == cmdSell scene = PokemonMart_Scene.new - screen = PokemonMartScreen.new(scene,stock) + screen = PokemonMartScreen.new(scene, stock) screen.pbSellScreen else pbMessage(_INTL("Please come again!")) break end cmd = pbMessage(_INTL("Is there anything else I can help you with?"), - commands,cmdQuit+1) + commands, cmdQuit + 1) end $game_temp.clear_mart_prices end diff --git a/Data/Scripts/016_UI/021_UI_MoveRelearner.rb b/Data/Scripts/016_UI/021_UI_MoveRelearner.rb index 333077da4..f76876527 100644 --- a/Data/Scripts/016_UI/021_UI_MoveRelearner.rb +++ b/Data/Scripts/016_UI/021_UI_MoveRelearner.rb @@ -4,45 +4,45 @@ class MoveRelearner_Scene VISIBLEMOVES = 4 - def pbDisplay(msg,brief = false) - UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { pbUpdate } + def pbDisplay(msg, brief = false) + UIHelper.pbDisplay(@sprites["msgwindow"], msg, brief) { pbUpdate } end def pbConfirm(msg) - UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate } + UIHelper.pbConfirm(@sprites["msgwindow"], msg) { pbUpdate } end def pbUpdate pbUpdateSpriteHash(@sprites) end - def pbStartScene(pokemon,moves) - @pokemon=pokemon - @moves=moves - moveCommands=[] + def pbStartScene(pokemon, moves) + @pokemon = pokemon + @moves = moves + moveCommands = [] moves.each { |m| moveCommands.push(GameData::Move.get(m).name) } # Create sprite hash - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 - @sprites={} - addBackgroundPlane(@sprites,"bg","reminderbg",@viewport) - @sprites["pokeicon"]=PokemonIconSprite.new(@pokemon,@viewport) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 + @sprites = {} + addBackgroundPlane(@sprites, "bg", "reminderbg", @viewport) + @sprites["pokeicon"] = PokemonIconSprite.new(@pokemon, @viewport) @sprites["pokeicon"].setOffset(PictureOrigin::Center) - @sprites["pokeicon"].x=320 - @sprites["pokeicon"].y=84 - @sprites["background"]=IconSprite.new(0,0,@viewport) + @sprites["pokeicon"].x = 320 + @sprites["pokeicon"].y = 84 + @sprites["background"] = IconSprite.new(0, 0, @viewport) @sprites["background"].setBitmap("Graphics/Pictures/reminderSel") - @sprites["background"].y=78 - @sprites["background"].src_rect=Rect.new(0,72,258,72) - @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport) + @sprites["background"].y = 78 + @sprites["background"].src_rect = Rect.new(0, 72, 258, 72) + @sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) pbSetSystemFont(@sprites["overlay"].bitmap) - @sprites["commands"]=Window_CommandPokemon.new(moveCommands,32) - @sprites["commands"].height=32*(VISIBLEMOVES+1) - @sprites["commands"].visible=false - @sprites["msgwindow"]=Window_AdvancedTextPokemon.new("") - @sprites["msgwindow"].visible=false - @sprites["msgwindow"].viewport=@viewport - @typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) + @sprites["commands"] = Window_CommandPokemon.new(moveCommands, 32) + @sprites["commands"].height = 32 * (VISIBLEMOVES + 1) + @sprites["commands"].visible = false + @sprites["msgwindow"] = Window_AdvancedTextPokemon.new("") + @sprites["msgwindow"].visible = false + @sprites["msgwindow"].viewport = @viewport + @typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/types")) pbDrawMoveList pbDeactivateWindows(@sprites) # Fade in all sprites @@ -50,7 +50,7 @@ class MoveRelearner_Scene end def pbDrawMoveList - overlay=@sprites["overlay"].bitmap + overlay = @sprites["overlay"].bitmap overlay.clear @pokemon.types.each_with_index do |type, i| type_number = GameData::Type.get(type).icon_position @@ -58,68 +58,68 @@ class MoveRelearner_Scene type_x = (@pokemon.types.length == 1) ? 400 : 366 + 70 * i overlay.blt(type_x, 70, @typebitmap.bitmap, type_rect) end - textpos=[ - [_INTL("Teach which move?"),16,2,0,Color.new(88,88,80),Color.new(168,184,184)] + textpos = [ + [_INTL("Teach which move?"), 16, 2, 0, Color.new(88, 88, 80), Color.new(168, 184, 184)] ] - imagepos=[] - yPos=76 + imagepos = [] + yPos = 76 for i in 0...VISIBLEMOVES - moveobject=@moves[@sprites["commands"].top_item+i] + moveobject = @moves[@sprites["commands"].top_item + i] if moveobject - moveData=GameData::Move.get(moveobject) + moveData = GameData::Move.get(moveobject) type_number = GameData::Type.get(moveData.display_type(@pokemon)).icon_position imagepos.push(["Graphics/Pictures/types", 12, yPos + 8, 0, type_number * 28, 64, 28]) - textpos.push([moveData.name,80,yPos,0,Color.new(248,248,248),Color.new(0,0,0)]) - if moveData.total_pp>0 - textpos.push([_INTL("PP"),112,yPos+32,0,Color.new(64,64,64),Color.new(176,176,176)]) - textpos.push([_INTL("{1}/{1}",moveData.total_pp),230,yPos+32,1, - Color.new(64,64,64),Color.new(176,176,176)]) + textpos.push([moveData.name, 80, yPos, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)]) + if moveData.total_pp > 0 + textpos.push([_INTL("PP"), 112, yPos + 32, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)]) + textpos.push([_INTL("{1}/{1}", moveData.total_pp), 230, yPos + 32, 1, + Color.new(64, 64, 64), Color.new(176, 176, 176)]) else - textpos.push(["-",80,yPos,0,Color.new(64,64,64),Color.new(176,176,176)]) - textpos.push(["--",228,yPos+32,1,Color.new(64,64,64),Color.new(176,176,176)]) + textpos.push(["-", 80, yPos, 0, Color.new(64, 64, 64), Color.new(176, 176, 176)]) + textpos.push(["--", 228, yPos + 32, 1, Color.new(64, 64, 64), Color.new(176, 176, 176)]) end end - yPos+=64 + yPos += 64 end imagepos.push(["Graphics/Pictures/reminderSel", - 0,78+(@sprites["commands"].index-@sprites["commands"].top_item)*64, - 0,0,258,72]) - selMoveData=GameData::Move.get(@moves[@sprites["commands"].index]) + 0, 78 + (@sprites["commands"].index - @sprites["commands"].top_item) * 64, + 0, 0, 258, 72]) + selMoveData = GameData::Move.get(@moves[@sprites["commands"].index]) basedamage = selMoveData.display_damage(@pokemon) category = selMoveData.display_category(@pokemon) accuracy = selMoveData.display_accuracy(@pokemon) - textpos.push([_INTL("CATEGORY"),272,108,0,Color.new(248,248,248),Color.new(0,0,0)]) - textpos.push([_INTL("POWER"),272,140,0,Color.new(248,248,248),Color.new(0,0,0)]) - textpos.push([basedamage<=1 ? basedamage==1 ? "???" : "---" : sprintf("%d",basedamage), - 468,140,2,Color.new(64,64,64),Color.new(176,176,176)]) - textpos.push([_INTL("ACCURACY"),272,172,0,Color.new(248,248,248),Color.new(0,0,0)]) - textpos.push([accuracy==0 ? "---" : "#{accuracy}%", - 468,172,2,Color.new(64,64,64),Color.new(176,176,176)]) - pbDrawTextPositions(overlay,textpos) - imagepos.push(["Graphics/Pictures/category",436,116,0,category*28,64,28]) - if @sprites["commands"].index<@moves.length-1 - imagepos.push(["Graphics/Pictures/reminderButtons",48,350,0,0,76,32]) + textpos.push([_INTL("CATEGORY"), 272, 108, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)]) + textpos.push([_INTL("POWER"), 272, 140, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)]) + textpos.push([basedamage <= 1 ? basedamage == 1 ? "???" : "---" : sprintf("%d", basedamage), + 468, 140, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)]) + textpos.push([_INTL("ACCURACY"), 272, 172, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)]) + textpos.push([accuracy == 0 ? "---" : "#{accuracy}%", + 468, 172, 2, Color.new(64, 64, 64), Color.new(176, 176, 176)]) + pbDrawTextPositions(overlay, textpos) + imagepos.push(["Graphics/Pictures/category", 436, 116, 0, category * 28, 64, 28]) + if @sprites["commands"].index < @moves.length - 1 + imagepos.push(["Graphics/Pictures/reminderButtons", 48, 350, 0, 0, 76, 32]) end - if @sprites["commands"].index>0 - imagepos.push(["Graphics/Pictures/reminderButtons",134,350,76,0,76,32]) + if @sprites["commands"].index > 0 + imagepos.push(["Graphics/Pictures/reminderButtons", 134, 350, 76, 0, 76, 32]) end - pbDrawImagePositions(overlay,imagepos) - drawTextEx(overlay,272,214,230,5,selMoveData.description, - Color.new(64,64,64),Color.new(176,176,176)) + pbDrawImagePositions(overlay, imagepos) + drawTextEx(overlay, 272, 214, 230, 5, selMoveData.description, + Color.new(64, 64, 64), Color.new(176, 176, 176)) end # Processes the scene def pbChooseMove - oldcmd=-1 - pbActivateWindow(@sprites,"commands") { + oldcmd = -1 + pbActivateWindow(@sprites, "commands") { loop do - oldcmd=@sprites["commands"].index + oldcmd = @sprites["commands"].index Graphics.update Input.update pbUpdate - if @sprites["commands"].index!=oldcmd - @sprites["background"].x=0 - @sprites["background"].y=78+(@sprites["commands"].index-@sprites["commands"].top_item)*64 + if @sprites["commands"].index != oldcmd + @sprites["background"].x = 0 + @sprites["background"].y = 78 + (@sprites["commands"].index - @sprites["commands"].top_item) * 64 pbDrawMoveList end if Input.trigger?(Input::BACK) diff --git a/Data/Scripts/016_UI/022_UI_PurifyChamber.rb b/Data/Scripts/016_UI/022_UI_PurifyChamber.rb index a21233b8f..08ac8c962 100644 --- a/Data/Scripts/016_UI/022_UI_PurifyChamber.rb +++ b/Data/Scripts/016_UI/022_UI_PurifyChamber.rb @@ -25,20 +25,20 @@ end #=============================================================================== # General purpose utilities #=============================================================================== -def pbDrawGauge(bitmap,rect,color,value,maxValue) +def pbDrawGauge(bitmap, rect, color, value, maxValue) return if !bitmap - bitmap.fill_rect(rect.x,rect.y,rect.width,rect.height,Color.new(0,0,0)) - width=(maxValue<=0) ? 0 : (rect.width-4)*value/maxValue - if rect.width>=4 && rect.height>=4 - bitmap.fill_rect(rect.x+2,rect.y+2,rect.width-4,rect.height-4,Color.new(248,248,248)) - bitmap.fill_rect(rect.x+2,rect.y+2,width,rect.height-4,color) + bitmap.fill_rect(rect.x, rect.y, rect.width, rect.height, Color.new(0, 0, 0)) + width = (maxValue <= 0) ? 0 : (rect.width - 4) * value / maxValue + if rect.width >= 4 && rect.height >= 4 + bitmap.fill_rect(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4, Color.new(248, 248, 248)) + bitmap.fill_rect(rect.x + 2, rect.y + 2, width, rect.height - 4, color) end end -def calcPoint(x,y,distance,angle) # angle in degrees - angle -=(angle/360.0).floor*360 # normalize - angle = (angle/360.0)*(2*Math::PI) # convert to radians - angle = -angle % (2*Math::PI) # normalize radians +def calcPoint(x, y, distance, angle) # angle in degrees + angle -= (angle / 360.0).floor * 360 # normalize + angle = (angle / 360.0) * (2 * Math::PI) # convert to radians + angle = -angle % (2 * Math::PI) # normalize radians point = [(Math.cos(angle) * distance), (Math.sin(angle) * distance)] point[0] += x point[1] += y @@ -53,7 +53,7 @@ class PurifyChamberSet attr_reader :facing # Index in list of Pokémon the Shadow Pokémon is facing def partialSum(x) - return (x*x+x)/2 # pattern: 1, 3, 6, 10, 15, 21, 28, ... + return (x * x + x) / 2 # pattern: 1, 3, 6, 10, 15, 21, 28, ... end def length @@ -61,19 +61,19 @@ class PurifyChamberSet end def initialize - @list=[] - @facing=0 + @list = [] + @facing = 0 end def facing=(value) - if value>=0 && value<@list.length - @facing=value + if value >= 0 && value < @list.length + @facing = value end end def shadow=(value) - if value==nil || value.shadowPokemon? - @shadow=value + if value == nil || value.shadowPokemon? + @shadow = value end end @@ -81,35 +81,35 @@ class PurifyChamberSet # Boosted if center has advantage over facing Pokemon # Boosted based on number of best circles def flow - ret=0 + ret = 0 return 0 if !@shadow for i in 0...@list.length - ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0 + ret += (PurifyChamberSet.isSuperEffective(@list[i], @list[(i + 1) % @list.length])) ? 1 : 0 end if @list[@facing] - ret+=PurifyChamberSet.isSuperEffective(@shadow,@list[@facing]) ? 1 : 0 + ret += PurifyChamberSet.isSuperEffective(@shadow, @list[@facing]) ? 1 : 0 end - return [ret+(@list.length/2),4].min + return [ret + (@list.length / 2), 4].min end def shadowAffinity - return 0 if @facing<0 || @facing>=@list.length || !@shadow - return (PurifyChamberSet.isSuperEffective(@shadow,@list[@facing])) ? 2 : 1 + return 0 if @facing < 0 || @facing >= @list.length || !@shadow + return (PurifyChamberSet.isSuperEffective(@shadow, @list[@facing])) ? 2 : 1 end def affinity(i) - return 0 if i<0 || i>=@list.length - return (PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 2 : 1 + return 0 if i < 0 || i >= @list.length + return (PurifyChamberSet.isSuperEffective(@list[i], @list[(i + 1) % @list.length])) ? 2 : 1 end # 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 + ret = 0 for i in 0...@list.length - ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0 + ret += (PurifyChamberSet.isSuperEffective(@list[i], @list[(i + 1) % @list.length])) ? 1 : 0 end - return partialSum(@list.length)+ret + return partialSum(@list.length) + ret end def list @@ -120,33 +120,33 @@ class PurifyChamberSet return @list[index] end - def insertAfter(index,value) - return if self.length>=PurifyChamber::SETSIZE - return if index<0 || index>=PurifyChamber::SETSIZE + def insertAfter(index, value) + return if self.length >= PurifyChamber::SETSIZE + return if index < 0 || index >= PurifyChamber::SETSIZE unless value && value.shadowPokemon? - @list.insert(index+1,value) + @list.insert(index + 1, value) @list.compact! - @facing+=1 if @facing>index && value!=nil - @facing=[[@facing,@list.length-1].min,0].max + @facing += 1 if @facing > index && value != nil + @facing = [[@facing, @list.length - 1].min, 0].max end end - def insertAt(index,value) - return if index<0 || index>=PurifyChamber::SETSIZE + def insertAt(index, value) + return if index < 0 || index >= PurifyChamber::SETSIZE unless value && value.shadowPokemon? - @list[index]=value + @list[index] = value @list.compact! - @facing=[[@facing,@list.length-1].min,0].max + @facing = [[@facing, @list.length - 1].min, 0].max end end # Purify Chamber treats Normal/Normal matchup as super effective - def self.typeAdvantage(p1,p2) + def self.typeAdvantage(p1, p2) return true if p1 == :NORMAL && p2 == :NORMAL return Effectiveness.super_effective_type?(p1, p2) end - def self.isSuperEffective(p1,p2) + def self.isSuperEffective(p1, p2) return (typeAdvantage(p1.types[0], p2.types[0]) || typeAdvantage(p1.types[0], p2.types[1])) end end @@ -162,18 +162,18 @@ class PurifyChamber SETSIZE = 4 def self.maximumTempo # Calculates the maximum possible tempo - x=SETSIZE+1 - return ((x*x+x)/2)-1 + x = SETSIZE + 1 + return ((x * x + x) / 2) - 1 end def initialize - @sets=[] - @currentSet=0 - NUMSETS.times { |i| @sets[i]=PurifyChamberSet.new } + @sets = [] + @currentSet = 0 + NUMSETS.times { |i| @sets[i] = PurifyChamberSet.new } end def currentSet=(value) - @currentSet=value if value>=0 && value= 0 && value < NUMSETS end # Number of regular Pokemon in a set @@ -182,68 +182,68 @@ class PurifyChamber end def setList(set) - return [] if set<0 || set>=NUMSETS + return [] if set < 0 || set >= NUMSETS return @sets[set].list end def chamberFlow(chamber) # for speeding up purification - return 0 if chamber<0 || chamber>=NUMSETS + return 0 if chamber < 0 || chamber >= NUMSETS return @sets[chamber].flow end def getShadow(chamber) - return nil if chamber<0 || chamber>=NUMSETS + return nil if chamber < 0 || chamber >= NUMSETS return @sets[chamber].shadow end - def setShadow(chamber,value) # allow only "shadow" Pokemon - return if chamber<0 || chamber>=NUMSETS - @sets[chamber].shadow=value + def setShadow(chamber, value) # allow only "shadow" Pokemon + return if chamber < 0 || chamber >= NUMSETS + @sets[chamber].shadow = value end - def switch(set1,set2) - return if set1<0 || set1>=NUMSETS - return if set2<0 || set2>=NUMSETS - s=@sets[set1] - @sets[set1]=@sets[set2] - @sets[set2]=s + def switch(set1, set2) + return if set1 < 0 || set1 >= NUMSETS + return if set2 < 0 || set2 >= NUMSETS + s = @sets[set1] + @sets[set1] = @sets[set2] + @sets[set2] = s end - def insertAfter(set,index,value) - return if set<0 || set>=NUMSETS - @sets[set].insertAfter(index,value) + def insertAfter(set, index, value) + return if set < 0 || set >= NUMSETS + @sets[set].insertAfter(index, value) end - def insertAt(set,index,value) - return if set<0 || set>=NUMSETS - @sets[set].insertAt(index,value) + def insertAt(set, index, value) + return if set < 0 || set >= NUMSETS + @sets[set].insertAt(index, value) end - def [](chamber,slot = nil) - if slot==nil + def [](chamber, slot = nil) + if slot == nil return @sets[chamber] end - return nil if chamber<0 || chamber>=NUMSETS - return nil if slot<0 || slot>=SETSIZE + return nil if chamber < 0 || chamber >= NUMSETS + return nil if slot < 0 || slot >= SETSIZE return @sets[chamber][slot] end def isPurifiableIgnoreRegular?(set) - shadow=getShadow(set) + shadow = getShadow(set) return false if !shadow return false if shadow.heart_gauge != 0 # Define an exception for Lugia if shadow.isSpecies?(:LUGIA) - maxtempo=PurifyChamber.maximumTempo + maxtempo = PurifyChamber.maximumTempo for i in 0...NUMSETS - return false if @sets[i].tempo!=maxtempo + return false if @sets[i].tempo != maxtempo end end return true end def isPurifiable?(set) - isPurifiableIgnoreRegular?(set) && setCount(set)>0 + isPurifiableIgnoreRegular?(set) && setCount(set) > 0 end def update # called each step @@ -251,33 +251,33 @@ class PurifyChamber # If a shadow Pokemon and a regular Pokemon are on the same set if @sets[set].shadow if @sets[set].shadow.heart_gauge > 0 - flow=self.chamberFlow(set) + flow = self.chamberFlow(set) @sets[set].shadow.adjustHeart(-flow) if isPurifiable?(set) - pbMessage(_INTL("Your {1} in the Purify Chamber is ready for purification!",@sets[set].shadow.name)) + pbMessage(_INTL("Your {1} in the Purify Chamber is ready for purification!", @sets[set].shadow.name)) end end end end end - def debugAddShadow(set,species) - pkmn=Pokemon.new(species,1) + def debugAddShadow(set, species) + pkmn = Pokemon.new(species, 1) pkmn.makeShadow - setShadow(set,pkmn) + setShadow(set, pkmn) end - def debugAddNormal(set,species) - pkmn=Pokemon.new(species,1) - insertAfter(set,setCount(set),pkmn) + def debugAddNormal(set, species) + pkmn = Pokemon.new(species, 1) + insertAfter(set, setCount(set), pkmn) end - def debugAdd(set,shadow,type1,type2 = nil) + def debugAdd(set, shadow, type1, type2 = nil) 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 @@ -286,13 +286,13 @@ end # #=============================================================================== module PurifyChamberHelper - def self.pbGetPokemon2(chamber,set,position) - if position==0 + def self.pbGetPokemon2(chamber, set, position) + if position == 0 return chamber.getShadow(set) - elsif position>0 - position-=1 - if position%2==0 - return chamber[set,position/2] + elsif position > 0 + position -= 1 + if position % 2 == 0 + return chamber[set, position / 2] else # In between two indices return nil end @@ -300,13 +300,13 @@ module PurifyChamberHelper return nil end - def self.pbGetPokemon(chamber,position) - if position==0 + def self.pbGetPokemon(chamber, position) + if position == 0 return chamber.getShadow(chamber.currentSet) - elsif position>0 - position-=1 - if position%2==0 - return chamber[chamber.currentSet,position/2] + elsif position > 0 + position -= 1 + if position % 2 == 0 + return chamber[chamber.currentSet, position / 2] else # In between two indices return nil end @@ -315,27 +315,27 @@ module PurifyChamberHelper end def self.adjustOnInsert(position) - if position>0 - position-=1 - oldpos=position/2 - if position%2==0 - return position+1 + if position > 0 + position -= 1 + oldpos = position / 2 + if position % 2 == 0 + return position + 1 else - return ((oldpos+1)*2)+1 + return ((oldpos + 1) * 2) + 1 end end return position end - def self.pbSetPokemon(chamber,position,value) - if position==0 - chamber.setShadow(chamber.currentSet,value) - elsif position>0 - position-=1 - if position%2==0 - chamber.insertAt(chamber.currentSet,position/2,value) + def self.pbSetPokemon(chamber, position, value) + if position == 0 + chamber.setShadow(chamber.currentSet, value) + elsif position > 0 + position -= 1 + if position % 2 == 0 + chamber.insertAt(chamber.currentSet, position / 2, value) else # In between two indices - chamber.insertAfter(chamber.currentSet,position/2,value) + chamber.insertAfter(chamber.currentSet, position / 2, value) end end end @@ -346,8 +346,8 @@ end #=============================================================================== class PurifyChamberScreen def initialize(scene) - @scene=scene - @chamber=$PokemonGlobal.purifyChamber + @scene = scene + @chamber = $PokemonGlobal.purifyChamber # for j in 0...PurifyChamber::NUMSETS # @chamber.debugAddShadow(j,rand(100)+1) # @chamber[j].shadow.heart_gauge = 0 @@ -357,151 +357,150 @@ class PurifyChamberScreen # end end - def pbPlace(pkmn,position) + def pbPlace(pkmn, position) return false if !pkmn if pkmn.egg? @scene.pbDisplay(_INTL("Can't place an egg there.")) return false end - if (position==0) + if (position == 0) if pkmn.shadowPokemon? # Remove from storage and place in set - oldpkmn=PurifyChamberHelper.pbGetPokemon(@chamber,position) + oldpkmn = PurifyChamberHelper.pbGetPokemon(@chamber, position) if oldpkmn - @scene.pbShift(position,pkmn) + @scene.pbShift(position, pkmn) else - @scene.pbPlace(position,pkmn) + @scene.pbPlace(position, pkmn) end - PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn) + PurifyChamberHelper.pbSetPokemon(@chamber, position, pkmn) @scene.pbRefresh else @scene.pbDisplay(_INTL("Only a Shadow Pokémon can go there.")) return false end - elsif (position>=1) + elsif (position >= 1) if pkmn.shadowPokemon? @scene.pbDisplay(_INTL("Can't place a Shadow Pokémon there.")) return false else - oldpkmn=PurifyChamberHelper.pbGetPokemon(@chamber,position) + oldpkmn = PurifyChamberHelper.pbGetPokemon(@chamber, position) if oldpkmn - @scene.pbShift(position,pkmn) + @scene.pbShift(position, pkmn) else - @scene.pbPlace(position,pkmn) + @scene.pbPlace(position, pkmn) end - PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn) + PurifyChamberHelper.pbSetPokemon(@chamber, position, pkmn) @scene.pbRefresh end end return true end - def pbPlacePokemon(pos,position) + def pbPlacePokemon(pos, position) return false if !pos - pkmn=$PokemonStorage[pos[0],pos[1]] - if pbPlace(pkmn,position) - $PokemonStorage.pbDelete(pos[0],pos[1]) + pkmn = $PokemonStorage[pos[0], pos[1]] + if pbPlace(pkmn, position) + $PokemonStorage.pbDelete(pos[0], pos[1]) return true end return false end def pbOnPlace(pkmn) - set=@chamber.currentSet - if @chamber.setCount(set)==0 && @chamber.isPurifiableIgnoreRegular?(set) - pkmn=@chamber.getShadow(set) + set = @chamber.currentSet + if @chamber.setCount(set) == 0 && @chamber.isPurifiableIgnoreRegular?(set) + pkmn = @chamber.getShadow(set) @scene.pbDisplay( - _INTL("This {1} is ready to open its heart. However, there must be at least one regular Pokémon in the set to perform a purification ceremony.",pkmn.name)) + _INTL("This {1} is ready to open its heart. However, there must be at least one regular Pokémon in the set to perform a purification ceremony.", pkmn.name)) end end def pbOpenSetDetail - chamber=@chamber + chamber = @chamber @scene.pbOpenSetDetail(chamber.currentSet) - heldpkmn=nil + heldpkmn = nil loop do # Commands # array[0]==0 - a position was chosen # array[0]==1 - a new set was chosen # array[0]==2 - choose Pokemon command - cmd=@scene.pbSetScreen - if cmd[0]==0 + cmd = @scene.pbSetScreen + if cmd[0] == 0 # Place Pokemon in the set - curpkmn=PurifyChamberHelper.pbGetPokemon(@chamber,cmd[1]) + curpkmn = PurifyChamberHelper.pbGetPokemon(@chamber, cmd[1]) if curpkmn || heldpkmn - commands=[_INTL("MOVE"),_INTL("SUMMARY"), - _INTL("WITHDRAW")] + commands = [_INTL("MOVE"), _INTL("SUMMARY"), _INTL("WITHDRAW")] if curpkmn && heldpkmn - commands[0]=_INTL("EXCHANGE") + commands[0] = _INTL("EXCHANGE") elsif heldpkmn - commands[0]=_INTL("PLACE") + commands[0] = _INTL("PLACE") end - cmdReplace=-1 - cmdRotate=-1 - if !heldpkmn && curpkmn && cmd[1]==0 && - @chamber[@chamber.currentSet].length>0 - commands[cmdRotate=commands.length]=_INTL("ROTATE") + cmdReplace = -1 + cmdRotate = -1 + if !heldpkmn && curpkmn && cmd[1] == 0 && + @chamber[@chamber.currentSet].length > 0 + commands[cmdRotate = commands.length] = _INTL("ROTATE") end if !heldpkmn && curpkmn - commands[cmdReplace=commands.length]=_INTL("REPLACE") + commands[cmdReplace = commands.length] = _INTL("REPLACE") end commands.push(_INTL("CANCEL")) - choice=@scene.pbShowCommands( + choice = @scene.pbShowCommands( _INTL("What shall I do with this {1}?", - heldpkmn ? heldpkmn.name : curpkmn.name),commands) - if choice==0 + heldpkmn ? heldpkmn.name : curpkmn.name), commands) + if choice == 0 if heldpkmn - if pbPlace(heldpkmn,cmd[1]) # calls place or shift as appropriate + if pbPlace(heldpkmn, cmd[1]) # calls place or shift as appropriate if !curpkmn pbOnPlace(heldpkmn) @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1])) - heldpkmn=nil # Pokemon was placed + heldpkmn = nil # Pokemon was placed else - heldpkmn=curpkmn # Pokemon was shifted + heldpkmn = curpkmn # Pokemon was shifted end end else @scene.pbMove(cmd[1]) - PurifyChamberHelper.pbSetPokemon(@chamber,cmd[1],nil) + PurifyChamberHelper.pbSetPokemon(@chamber, cmd[1], nil) @scene.pbRefresh - heldpkmn=curpkmn + heldpkmn = curpkmn end - elsif choice==1 - @scene.pbSummary(cmd[1],heldpkmn) - elsif choice==2 + elsif choice == 1 + @scene.pbSummary(cmd[1], heldpkmn) + elsif choice == 2 if pbBoxesFull? @scene.pbDisplay("All boxes are full.") elsif heldpkmn - @scene.pbWithdraw(cmd[1],heldpkmn) + @scene.pbWithdraw(cmd[1], heldpkmn) $PokemonStorage.pbStoreCaught(heldpkmn) - heldpkmn=nil + heldpkmn = nil @scene.pbRefresh else # Store and delete Pokemon. - @scene.pbWithdraw(cmd[1],heldpkmn) + @scene.pbWithdraw(cmd[1], heldpkmn) $PokemonStorage.pbStoreCaught(curpkmn) - PurifyChamberHelper.pbSetPokemon(@chamber,cmd[1],nil) + PurifyChamberHelper.pbSetPokemon(@chamber, cmd[1], nil) @scene.pbRefresh end - elsif cmdRotate>=0 && choice==cmdRotate - count=@chamber[@chamber.currentSet].length - nextPos=@chamber[@chamber.currentSet].facing - if count>0 - @scene.pbRotate((nextPos+1)%count) - @chamber[@chamber.currentSet].facing=(nextPos+1)%count + elsif cmdRotate >= 0 && choice == cmdRotate + count = @chamber[@chamber.currentSet].length + nextPos = @chamber[@chamber.currentSet].facing + if count > 0 + @scene.pbRotate((nextPos + 1) % count) + @chamber[@chamber.currentSet].facing = (nextPos + 1) % count @scene.pbRefresh end - elsif cmdReplace>=0 && choice==cmdReplace - pos=@scene.pbChoosePokemon + elsif cmdReplace >= 0 && choice == cmdReplace + pos = @scene.pbChoosePokemon if pos - newpkmn=$PokemonStorage[pos[0],pos[1]] + newpkmn = $PokemonStorage[pos[0], pos[1]] if newpkmn - if (newpkmn.shadowPokemon?)!=(curpkmn.shadowPokemon?) + if (newpkmn.shadowPokemon?) != (curpkmn.shadowPokemon?) @scene.pbDisplay(_INTL("That Pokémon can't be placed there.")) else - @scene.pbReplace(cmd,pos) - PurifyChamberHelper.pbSetPokemon(@chamber,cmd[1],newpkmn) - $PokemonStorage[pos[0],pos[1]]=curpkmn + @scene.pbReplace(cmd, pos) + PurifyChamberHelper.pbSetPokemon(@chamber, cmd[1], newpkmn) + $PokemonStorage[pos[0], pos[1]] = curpkmn @scene.pbRefresh pbOnPlace(curpkmn) end @@ -509,20 +508,20 @@ class PurifyChamberScreen end end else # No current Pokemon - pos=@scene.pbChoosePokemon - if pbPlacePokemon(pos,cmd[1]) - curpkmn=PurifyChamberHelper.pbGetPokemon(@chamber,cmd[1]) + pos = @scene.pbChoosePokemon + if pbPlacePokemon(pos, cmd[1]) + curpkmn = PurifyChamberHelper.pbGetPokemon(@chamber, cmd[1]) pbOnPlace(curpkmn) @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1])) end end - elsif cmd[0]==1 # Change the active set + elsif cmd[0] == 1 # Change the active set @scene.pbChangeSet(cmd[1]) - chamber.currentSet=cmd[1] - elsif cmd[0]==2 # Choose a Pokemon - pos=@scene.pbChoosePokemon - pkmn=pos ? $PokemonStorage[pos[0],pos[1]] : nil - heldpkmn=pkmn if pkmn + chamber.currentSet = cmd[1] + elsif cmd[0] == 2 # Choose a Pokemon + pos = @scene.pbChoosePokemon + pkmn = pos ? $PokemonStorage[pos[0], pos[1]] : nil + heldpkmn = pkmn if pkmn else # cancel if heldpkmn @scene.pbDisplay("You're holding a Pokémon!") @@ -557,31 +556,31 @@ class PurifyChamberScreen end def pbCheckPurify - purifiables=[] + purifiables = [] for set in 0...PurifyChamber::NUMSETS if @chamber.isPurifiable?(set) # if ready for purification purifiables.push(set) end end - return purifiables.length>0 + return purifiables.length > 0 end def pbDoPurify - purifiables=[] + purifiables = [] for set in 0...PurifyChamber::NUMSETS if @chamber.isPurifiable?(set) # if ready for purification purifiables.push(set) end end for i in 0...purifiables.length - set=purifiables[i] - @chamber.currentSet=set + set = purifiables[i] + @chamber.currentSet = set @scene.pbOpenSet(set) @scene.pbPurify - pbPurify(@chamber[set].shadow,self) + pbPurify(@chamber[set].shadow, self) pbStorePokemon(@chamber[set].shadow) - @chamber.setShadow(set,nil) # Remove shadow Pokemon from set - if (i+1)!=purifiables.length + @chamber.setShadow(set, nil) # Remove shadow Pokemon from set + if (i + 1) != purifiables.length @scene.pbDisplay(_INTL("There is another Pokémon that is ready to open its heart!")) if !@scene.pbConfirm("Would you like to switch sets?") @scene.pbCloseSet @@ -593,7 +592,7 @@ class PurifyChamberScreen end def pbStartPurify - chamber=@chamber + chamber = @chamber @scene.pbStart(chamber) if pbCheckPurify pbDoPurify @@ -602,26 +601,26 @@ class PurifyChamberScreen end @scene.pbOpenSet(chamber.currentSet) loop do - set=@scene.pbChooseSet - if set<0 + set = @scene.pbChooseSet + if set < 0 if !@scene.pbConfirm("Continue viewing holograms?") break end else - chamber.currentSet=set - cmd=@scene.pbShowCommands( + chamber.currentSet = set + cmd = @scene.pbShowCommands( _INTL("What do you want to do?"), [_INTL("EDIT"), _INTL("SWITCH"), _INTL("CANCEL")] ) - if cmd==0 # edit + if cmd == 0 # edit if !pbOpenSetDetail break end - elsif cmd==1 # switch - chamber.currentSet=set - newSet=@scene.pbSwitch(set) - chamber.switch(set,newSet) - chamber.currentSet=newSet + elsif cmd == 1 # switch + chamber.currentSet = set + newSet = @scene.pbSwitch(set) + chamber.switch(set, newSet) + chamber.currentSet = newSet @scene.pbRefresh end end @@ -637,10 +636,10 @@ end class Window_PurifyChamberSets < Window_DrawableCommand attr_reader :switching - def initialize(chamber,x,y,width,height,viewport = nil) - @chamber=chamber - @switching=-1 - super(x,y,width,height,viewport) + def initialize(chamber, x, y, width, height, viewport = nil) + @chamber = chamber + @switching = -1 + super(x, y, width, height, viewport) end def itemCount @@ -652,27 +651,27 @@ class Window_PurifyChamberSets < Window_DrawableCommand refresh end - def drawItem(index,_count,rect) - textpos=[] - rect=drawCursor(index,rect) - if index==@switching - textpos.push([(index+1).to_s,rect.x, - rect.y-6,false,Color.new(248,0,0),self.shadowColor]) + def drawItem(index, _count, rect) + textpos = [] + rect = drawCursor(index, rect) + if index == @switching + textpos.push([(index + 1).to_s, rect.x, + rect.y - 6, false, Color.new(248, 0, 0), self.shadowColor]) else - textpos.push([(index+1).to_s,rect.x, - rect.y-6,false,self.baseColor,self.shadowColor]) + textpos.push([(index + 1).to_s, rect.x, + rect.y - 6, false, self.baseColor, self.shadowColor]) end - if @chamber.setCount(index)>0 - pbDrawGauge(self.contents,Rect.new(rect.x+16,rect.y+6,48,8), - Color.new(0,0,256),@chamber[index].tempo,PurifyChamber.maximumTempo) + if @chamber.setCount(index) > 0 + pbDrawGauge(self.contents, Rect.new(rect.x + 16, rect.y + 6, 48, 8), + Color.new(0, 0, 256), @chamber[index].tempo, PurifyChamber.maximumTempo) end if @chamber.getShadow(index) - pbDrawGauge(self.contents, Rect.new(rect.x+16,rect.y+18,48,8), - Color.new(192,0,256), + pbDrawGauge(self.contents, Rect.new(rect.x + 16, rect.y + 18, 48, 8), + Color.new(192, 0, 256), @chamber.getShadow(index).heart_gauge, @chamber.getShadow(index).max_gauge_size) end - pbDrawTextPositions(self.contents,textpos) + pbDrawTextPositions(self.contents, textpos) end end @@ -681,24 +680,24 @@ end #=============================================================================== class DirectFlowDiagram def initialize(viewport = nil) - @points=[] - @angles=[] - @viewport=viewport - @strength=0 - @offset=0 - @x=306 - @y=138 - @distance=96 + @points = [] + @angles = [] + @viewport = viewport + @strength = 0 + @offset = 0 + @x = 306 + @y = 138 + @distance = 96 end # 0=none, 1=weak, 2=strong def setFlowStrength(strength) - @strength=strength + @strength = strength end def visible=(value) for point in @points - point.visible=value + point.visible = value end end @@ -710,43 +709,43 @@ class DirectFlowDiagram def ensurePoint(j) if !@points[j] || @points[j].disposed? - @points[j]=BitmapSprite.new(8,8,@viewport) - @points[j].bitmap.fill_rect(0,0,8,8,Color.new(0,0,0)) + @points[j] = BitmapSprite.new(8, 8, @viewport) + @points[j].bitmap.fill_rect(0, 0, 8, 8, Color.new(0, 0, 0)) end @points[j].tone = (@strength == 2) ? Tone.new(232, 232, 248) : Tone.new(16, 16, 232) - @points[j].visible=(@strength!=0) + @points[j].visible = (@strength != 0) end def update for point in @points point.update - point.visible=false + point.visible = false end - j=0 - i=0 - while i<@distance - o=(i+@offset)%@distance - if o>=0 && o<@distance + j = 0 + i = 0 + while i < @distance + o = (i + @offset) % @distance + if o >= 0 && o < @distance ensurePoint(j) - pt=calcPoint(@x,@y,o,@angle) - @points[j].x=pt[0] - @points[j].y=pt[1] - j+=1 + pt = calcPoint(@x, @y, o, @angle) + @points[j].x = pt[0] + @points[j].y = pt[1] + j += 1 end - i+=(@strength==2) ? 16 : 32 + i += (@strength == 2) ? 16 : 32 end - @offset+=(@strength==2) ? 3 : 2 - @offset%=@distance + @offset += (@strength == 2) ? 3 : 2 + @offset %= @distance end def color=(value) for point in @points - point.color=value + point.color = value end end def setAngle(angle1) - @angle=angle1-(angle1/360).floor*360 + @angle = angle1 - (angle1 / 360).floor * 360 end end @@ -755,24 +754,24 @@ end #=============================================================================== class FlowDiagram def initialize(viewport = nil) - @points=[] - @angles=[] - @viewport=viewport - @strength=0 - @offset=0 - @x=306 - @y=138 - @distance=96 + @points = [] + @angles = [] + @viewport = viewport + @strength = 0 + @offset = 0 + @x = 306 + @y = 138 + @distance = 96 end # 0=none, 1=weak, 2=strong def setFlowStrength(strength) - @strength=strength + @strength = strength end def visible=(value) for point in @points - point.visible=value + point.visible = value end end @@ -784,56 +783,56 @@ class FlowDiagram def ensurePoint(j) if !@points[j] || @points[j].disposed? - @points[j]=BitmapSprite.new(8,8,@viewport) - @points[j].bitmap.fill_rect(0,0,8,8,Color.new(0,0,0)) + @points[j] = BitmapSprite.new(8, 8, @viewport) + @points[j].bitmap.fill_rect(0, 0, 8, 8, Color.new(0, 0, 0)) end @points[j].tone = (@strength == 2) ? Tone.new(232, 232, 248) : Tone.new(16, 16, 232) - @points[j].visible=(@strength!=0) + @points[j].visible = (@strength != 0) end - def withinRange(angle,startAngle,endAngle) - if startAngle>endAngle - return (angle>=startAngle || angle<=endAngle) && - (angle>=0 && angle<=360) + def withinRange(angle, startAngle, endAngle) + if startAngle > endAngle + return (angle >= startAngle || angle <= endAngle) && + (angle >= 0 && angle <= 360) else - return (angle>=startAngle && angle<=endAngle) + return (angle >= startAngle && angle <= endAngle) end end def update for point in @points point.update - point.visible=false + point.visible = false end - j=0 - i=0 - while i<360 - angle=(i+@offset)%360 - if withinRange(angle,@startAngle,@endAngle) + j = 0 + i = 0 + while i < 360 + angle = (i + @offset) % 360 + if withinRange(angle, @startAngle, @endAngle) ensurePoint(j) - pt=calcPoint(@x,@y,@distance,angle) - @points[j].x=pt[0] - @points[j].y=pt[1] - j+=1 + pt = calcPoint(@x, @y, @distance, angle) + @points[j].x = pt[0] + @points[j].y = pt[1] + j += 1 end - i+=(@strength==2) ? 10 : 20 + i += (@strength == 2) ? 10 : 20 end - @offset-=(@strength==2) ? 3 : 2 - @offset%=(360*6) + @offset -= (@strength == 2) ? 3 : 2 + @offset %= (360 * 6) end def color=(value) for point in @points - point.color=value + point.color = value end end - def setRange(angle1,angle2) - @startAngle=angle1-(angle1/360).floor*360 - @endAngle=angle2-(angle2/360).floor*360 - if @startAngle==@endAngle && angle1!=angle2 - @startAngle=0 - @endAngle=359.99 + def setRange(angle1, angle2) + @startAngle = angle1 - (angle1 / 360).floor * 360 + @endAngle = angle2 - (angle2 / 360).floor * 360 + if @startAngle == @endAngle && angle1 != angle2 + @startAngle = 0 + @endAngle = 359.99 end end end @@ -846,26 +845,26 @@ class PurifyChamberSetView < SpriteWrapper attr_reader :cursor attr_reader :heldpkmn - def initialize(chamber,set,viewport = nil) + def initialize(chamber, set, viewport = nil) super(viewport) - @set=set - @heldpkmn=nil - @cursor=-1 - @view=BitmapSprite.new(64,64,viewport) - @view.bitmap.fill_rect(8,8,48,48,Color.new(255,255,255)) - @view.bitmap.fill_rect(10,10,44,44,Color.new(255,255,255,128)) - @info=BitmapSprite.new(Graphics.width-112,48,viewport) - @flows=[] - @directflow=DirectFlowDiagram.new(viewport) + @set = set + @heldpkmn = nil + @cursor = -1 + @view = BitmapSprite.new(64, 64, viewport) + @view.bitmap.fill_rect(8, 8, 48, 48, Color.new(255, 255, 255)) + @view.bitmap.fill_rect(10, 10, 44, 44, Color.new(255, 255, 255, 128)) + @info = BitmapSprite.new(Graphics.width - 112, 48, viewport) + @flows = [] + @directflow = DirectFlowDiagram.new(viewport) @directflow.setAngle(0) @directflow.setFlowStrength(1) - @__sprites=[] - @__sprites[0]=PokemonIconSprite.new(nil,viewport) - for i in 0...PurifyChamber::SETSIZE*2 - @__sprites[i+1]=PokemonIconSprite.new(nil,viewport) + @__sprites = [] + @__sprites[0] = PokemonIconSprite.new(nil, viewport) + for i in 0...PurifyChamber::SETSIZE * 2 + @__sprites[i + 1] = PokemonIconSprite.new(nil, viewport) end - @__sprites[1+PurifyChamber::SETSIZE*2]=PokemonIconSprite.new(nil,viewport) - @chamber=chamber + @__sprites[1 + PurifyChamber::SETSIZE * 2] = PokemonIconSprite.new(nil, viewport) + @chamber = chamber refresh end @@ -873,78 +872,78 @@ class PurifyChamberSetView < SpriteWrapper for flow in @flows flow.setFlowStrength(0) end - setcount=@chamber.setCount(@set) + setcount = @chamber.setCount(@set) for i in 0...setcount if !@flows[i] - @flows[i]=FlowDiagram.new(self.viewport) + @flows[i] = FlowDiagram.new(self.viewport) end - angle=360-(i*360/setcount) - angle+=90 # start at 12 not 3 o'clock - endAngle=angle-(360/setcount) - @flows[i].setRange(endAngle,angle) + angle = 360 - (i * 360 / setcount) + angle += 90 # start at 12 not 3 o'clock + endAngle = angle - (360 / setcount) + @flows[i].setRange(endAngle, angle) @flows[i].setFlowStrength(@chamber[@set].affinity(i)) end end def moveCursor(button) - points=[@chamber.setCount(@set)*2,1].max - oldcursor=@cursor - if @cursor==0 && points>0 - @cursor=1 if button==Input::UP - @cursor=points*1/4+1 if button==Input::RIGHT - @cursor=points*2/4+1 if button==Input::DOWN - @cursor=points*3/4+1 if button==Input::LEFT - elsif @cursor>0 - pos=@cursor-1 - if @chamber.setCount(@set)==PurifyChamber::SETSIZE - points=[points/2,1].max - pos/=2 + points = [@chamber.setCount(@set) * 2, 1].max + oldcursor = @cursor + if @cursor == 0 && points > 0 + @cursor = 1 if button == Input::UP + @cursor = points * 1 / 4 + 1 if button == Input::RIGHT + @cursor = points * 2 / 4 + 1 if button == Input::DOWN + @cursor = points * 3 / 4 + 1 if button == Input::LEFT + elsif @cursor > 0 + pos = @cursor - 1 + if @chamber.setCount(@set) == PurifyChamber::SETSIZE + points = [points / 2, 1].max + pos /= 2 end - seg=pos*8/points - if seg==7 || seg==0 - pos-=1 if button==Input::LEFT - pos+=1 if button==Input::RIGHT - pos=nil if button==Input::DOWN - elsif seg==1 || seg==2 - pos-=1 if button==Input::UP - pos+=1 if button==Input::DOWN - pos=nil if button==Input::LEFT - elsif seg==3 || seg==4 - pos-=1 if button==Input::RIGHT - pos+=1 if button==Input::LEFT - pos=nil if button==Input::UP - elsif seg==5 || seg==6 - pos-=1 if button==Input::DOWN - pos+=1 if button==Input::UP - pos=nil if button==Input::RIGHT + seg = pos * 8 / points + if seg == 7 || seg == 0 + pos -= 1 if button == Input::LEFT + pos += 1 if button == Input::RIGHT + pos = nil if button == Input::DOWN + elsif seg == 1 || seg == 2 + pos -= 1 if button == Input::UP + pos += 1 if button == Input::DOWN + pos = nil if button == Input::LEFT + elsif seg == 3 || seg == 4 + pos -= 1 if button == Input::RIGHT + pos += 1 if button == Input::LEFT + pos = nil if button == Input::UP + elsif seg == 5 || seg == 6 + pos -= 1 if button == Input::DOWN + pos += 1 if button == Input::UP + pos = nil if button == Input::RIGHT end - if pos!=nil - pos-=(pos/points).floor*points # modulus - pos*=2 if @chamber.setCount(@set)==PurifyChamber::SETSIZE - @cursor=pos+1 + if pos != nil + pos -= (pos / points).floor * points # modulus + pos *= 2 if @chamber.setCount(@set) == PurifyChamber::SETSIZE + @cursor = pos + 1 else - @cursor=0 + @cursor = 0 end end - if @cursor!=oldcursor + if @cursor != oldcursor refresh end end def checkCursor(index) - if @cursor==index - @view.x=@__sprites[index].x-32 - @view.y=@__sprites[index].y-40 - @view.visible=true + if @cursor == index + @view.x = @__sprites[index].x - 32 + @view.y = @__sprites[index].y - 40 + @view.visible = true end end def refresh - pkmn=@chamber.getShadow(@set) - @view.visible=false - @info.bitmap.fill_rect(0,0,@info.bitmap.width,@info.bitmap.height,Color.new(0,248,0)) + pkmn = @chamber.getShadow(@set) + @view.visible = false + @info.bitmap.fill_rect(0, 0, @info.bitmap.width, @info.bitmap.height, Color.new(0, 248, 0)) pbSetSmallFont(@info.bitmap) - textpos=[] + textpos = [] if pkmn if pkmn.types.length == 1 textpos.push([_INTL("{1} Lv.{2} {3}", pkmn.name, pkmn.level, @@ -956,101 +955,101 @@ class PurifyChamberSetView < SpriteWrapper GameData::Type.get(pkmn.types[1]).name), 2, -6, 0, Color.new(248, 248, 248), Color.new(128, 128, 128)]) end - textpos.push([_INTL("FLOW"),2+@info.bitmap.width/2,18,0, - Color.new(248,248,248),Color.new(128,128,128)]) + textpos.push([_INTL("FLOW"), 2 + @info.bitmap.width / 2, 18, 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.heart_gauge, pkmn.max_gauge_size) + pbDrawGauge(@info.bitmap, Rect.new(@info.bitmap.width * 3 / 4, 8, @info.bitmap.width * 1 / 4, 8), + Color.new(192, 0, 256), pkmn.heart_gauge, pkmn.max_gauge_size) # 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) + 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) end - if @chamber.setCount(@set)>0 - textpos.push([_INTL("TEMPO"),2,18,0, - Color.new(248,248,248),Color.new(128,128,128)]) + if @chamber.setCount(@set) > 0 + textpos.push([_INTL("TEMPO"), 2, 18, 0, + 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, + 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, PurifyChamber.maximumTempo) end - pbDrawTextPositions(@info.bitmap,textpos) - @info.x=Graphics.width-@info.bitmap.width - @info.y=Graphics.height-@info.bitmap.height - @__sprites[0].pokemon=pkmn - @__sprites[0].x=312 - @__sprites[0].y=136 - @__sprites[0].z=2 + pbDrawTextPositions(@info.bitmap, textpos) + @info.x = Graphics.width - @info.bitmap.width + @info.y = Graphics.height - @info.bitmap.height + @__sprites[0].pokemon = pkmn + @__sprites[0].x = 312 + @__sprites[0].y = 136 + @__sprites[0].z = 2 @directflow.setAngle(angle) @directflow.setFlowStrength(0) checkCursor(0) - points=[@chamber.setCount(@set)*2,1].max - setList=@chamber.setList(@set) + points = [@chamber.setCount(@set) * 2, 1].max + setList = @chamber.setList(@set) refreshFlows - for i in 0...PurifyChamber::SETSIZE*2 - pkmn=(i%2==1 || i>=points) ? nil : setList[i/2] - angle=360-(i*360/points) - angle+=90 # start at 12 not 3 o'clock - if pkmn && @chamber[@set].facing==i/2 + for i in 0...PurifyChamber::SETSIZE * 2 + pkmn = (i % 2 == 1 || i >= points) ? nil : setList[i / 2] + angle = 360 - (i * 360 / points) + angle += 90 # start at 12 not 3 o'clock + if pkmn && @chamber[@set].facing == i / 2 @directflow.setAngle(angle) @directflow.setFlowStrength(@chamber[@set].shadowAffinity) end - point=calcPoint(280,96,96,angle) - @__sprites[i+1].x=point[0]+32 - @__sprites[i+1].y=point[1]+40 - @__sprites[i+1].z=2 - @__sprites[i+1].pokemon=pkmn - checkCursor(i+1) + point = calcPoint(280, 96, 96, angle) + @__sprites[i + 1].x = point[0] + 32 + @__sprites[i + 1].y = point[1] + 40 + @__sprites[i + 1].z = 2 + @__sprites[i + 1].pokemon = pkmn + checkCursor(i + 1) end - @__sprites[1+PurifyChamber::SETSIZE*2].pokemon=@heldpkmn - @__sprites[1+PurifyChamber::SETSIZE*2].visible=@view.visible - @__sprites[1+PurifyChamber::SETSIZE*2].x=@view.x+32 - @__sprites[1+PurifyChamber::SETSIZE*2].y=@view.y-6+40 - @__sprites[1+PurifyChamber::SETSIZE*2].z=3 + @__sprites[1 + PurifyChamber::SETSIZE * 2].pokemon = @heldpkmn + @__sprites[1 + PurifyChamber::SETSIZE * 2].visible = @view.visible + @__sprites[1 + PurifyChamber::SETSIZE * 2].x = @view.x + 32 + @__sprites[1 + PurifyChamber::SETSIZE * 2].y = @view.y - 6 + 40 + @__sprites[1 + PurifyChamber::SETSIZE * 2].z = 3 end def getCurrent - return PurifyChamberHelper.pbGetPokemon(@chamber,@cursor) + return PurifyChamberHelper.pbGetPokemon(@chamber, @cursor) end def cursor=(value) - @cursor=value + @cursor = value refresh end def heldpkmn=(value) - @heldpkmn=value + @heldpkmn = value refresh end def set=(value) - @set=value + @set = value refresh end def visible=(value) super for sprite in @__sprites - sprite.visible=value + sprite.visible = value end for flow in @flows - flow.visible=value + flow.visible = value end - @directflow.visible=value - @view.visible=value - @info.visible=value + @directflow.visible = value + @view.visible = value + @info.visible = value end def color=(value) super for sprite in @__sprites - sprite.color=pbSrcOver(sprite.color,value.clone) + sprite.color = pbSrcOver(sprite.color, value.clone) end for flow in @flows - flow.color=value.clone + flow.color = value.clone end - @directflow.color=value.clone - @view.color=value.clone - @info.color=value.clone + @directflow.color = value.clone + @view.color = value.clone + @info.color = value.clone end def update @@ -1097,27 +1096,27 @@ class PurifyChamberScene end def pbStart(chamber) - @chamber=chamber + @chamber = chamber end def pbEnd end def pbOpenSet(set) - @sprites={} - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 - @viewportmsg=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewportmsg.z=99999 - addBackgroundOrColoredPlane(@sprites,"bg","purifychamberbg", - Color.new(0,0,0),@viewport) - @sprites["setwindow"]=Window_PurifyChamberSets.new( - @chamber,0,0,112,Graphics.height,@viewport) - @sprites["setview"]=PurifyChamberSetView.new(@chamber,set,@viewport) - @sprites["msgwindow"]=Window_AdvancedTextPokemon.new("") - @sprites["msgwindow"].viewport=@viewportmsg - @sprites["msgwindow"].visible=false - @sprites["setwindow"].index=set + @sprites = {} + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 + @viewportmsg = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewportmsg.z = 99999 + addBackgroundOrColoredPlane(@sprites, "bg", "purifychamberbg", + Color.new(0, 0, 0), @viewport) + @sprites["setwindow"] = Window_PurifyChamberSets.new( + @chamber, 0, 0, 112, Graphics.height, @viewport) + @sprites["setview"] = PurifyChamberSetView.new(@chamber, set, @viewport) + @sprites["msgwindow"] = Window_AdvancedTextPokemon.new("") + @sprites["msgwindow"].viewport = @viewportmsg + @sprites["msgwindow"].visible = false + @sprites["setwindow"].index = set pbDeactivateWindows(@sprites) pbFadeInAndShow(@sprites) { pbUpdate } end @@ -1130,9 +1129,9 @@ class PurifyChamberScene end def pbOpenSetDetail(set) - @sprites["setwindow"].index=set - @sprites["setview"].set=set - @sprites["setview"].cursor=0 + @sprites["setwindow"].index = set + @sprites["setview"].set = set + @sprites["setview"].cursor = 0 end def pbCloseSetDetail @@ -1143,42 +1142,42 @@ class PurifyChamberScene end def pbMove(_pos) - @sprites["setview"].heldpkmn=@sprites["setview"].getCurrent + @sprites["setview"].heldpkmn = @sprites["setview"].getCurrent pbRefresh end - def pbShift(_pos,_heldpoke) - @sprites["setview"].heldpkmn=@sprites["setview"].getCurrent + def pbShift(_pos, _heldpoke) + @sprites["setview"].heldpkmn = @sprites["setview"].getCurrent pbRefresh end - def pbPlace(_pos,_heldpoke) - @sprites["setview"].heldpkmn=nil + def pbPlace(_pos, _heldpoke) + @sprites["setview"].heldpkmn = nil pbRefresh end - def pbReplace(_pos,_storagePos) - @sprites["setview"].heldpkmn=nil + def pbReplace(_pos, _storagePos) + @sprites["setview"].heldpkmn = nil pbRefresh end def pbRotate(facing); end - def pbWithdraw(_pos,_heldpoke) - @sprites["setview"].heldpkmn=nil + def pbWithdraw(_pos, _heldpoke) + @sprites["setview"].heldpkmn = nil pbRefresh end def pbDisplay(msg) - UIHelper.pbDisplay(@sprites["msgwindow"],msg,false) { pbUpdate } + UIHelper.pbDisplay(@sprites["msgwindow"], msg, false) { pbUpdate } end def pbConfirm(msg) - UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate } + UIHelper.pbConfirm(@sprites["msgwindow"], msg) { pbUpdate } end - def pbShowCommands(msg,commands) - UIHelper.pbShowCommands(@sprites["msgwindow"],msg,commands) { pbUpdate } + def pbShowCommands(msg, commands) + UIHelper.pbShowCommands(@sprites["msgwindow"], msg, commands) { pbUpdate } end def pbSetScreen @@ -1187,41 +1186,41 @@ class PurifyChamberScene Graphics.update Input.update pbUpdate - btn=0 - btn=Input::DOWN if Input.repeat?(Input::DOWN) - btn=Input::UP if Input.repeat?(Input::UP) - btn=Input::RIGHT if Input.repeat?(Input::RIGHT) - btn=Input::LEFT if Input.repeat?(Input::LEFT) - if btn!=0 + btn = 0 + btn = Input::DOWN if Input.repeat?(Input::DOWN) + btn = Input::UP if Input.repeat?(Input::UP) + btn = Input::RIGHT if Input.repeat?(Input::RIGHT) + btn = Input::LEFT if Input.repeat?(Input::LEFT) + if btn != 0 pbPlayCursorSE @sprites["setview"].moveCursor(btn) end if Input.repeat?(Input::JUMPUP) - nextset=(@sprites["setview"].set==0) ? PurifyChamber::NUMSETS-1 : @sprites["setview"].set-1 + nextset = (@sprites["setview"].set == 0) ? PurifyChamber::NUMSETS - 1 : @sprites["setview"].set - 1 pbPlayCursorSE - return [1,nextset] + return [1, nextset] elsif Input.repeat?(Input::JUMPDOWN) - nextset=(@sprites["setview"].set==PurifyChamber::NUMSETS-1) ? 0 : @sprites["setview"].set+1 + nextset = (@sprites["setview"].set == PurifyChamber::NUMSETS - 1) ? 0 : @sprites["setview"].set + 1 pbPlayCursorSE - return [1,nextset] + return [1, nextset] elsif Input.trigger?(Input::USE) pbPlayDecisionSE - return [0,@sprites["setview"].cursor] + return [0, @sprites["setview"].cursor] elsif Input.trigger?(Input::BACK) pbPlayCancelSE - return [3,0] + return [3, 0] end end } end def pbChooseSet - pbActivateWindow(@sprites,"setwindow") { - oldindex=@sprites["setwindow"].index + pbActivateWindow(@sprites, "setwindow") { + oldindex = @sprites["setwindow"].index loop do - if oldindex!=@sprites["setwindow"].index - oldindex=@sprites["setwindow"].index - @sprites["setview"].set=oldindex + if oldindex != @sprites["setwindow"].index + oldindex = @sprites["setwindow"].index + @sprites["setview"].set = oldindex end Graphics.update Input.update @@ -1239,61 +1238,61 @@ class PurifyChamberScene end def pbSwitch(set) - @sprites["setwindow"].switching=set - ret=pbChooseSet - @sprites["setwindow"].switching=-1 - return ret<0 ? set : ret + @sprites["setwindow"].switching = set + ret = pbChooseSet + @sprites["setwindow"].switching = -1 + return ret < 0 ? set : ret end - def pbSummary(pos,heldpkmn) + def pbSummary(pos, heldpkmn) if heldpkmn - oldsprites=pbFadeOutAndHide(@sprites) - scene=PokemonSummary_Scene.new - screen=PokemonSummaryScreen.new(scene) - screen.pbStartScreen([heldpkmn],0) - pbFadeInAndShow(@sprites,oldsprites) + oldsprites = pbFadeOutAndHide(@sprites) + scene = PokemonSummary_Scene.new + screen = PokemonSummaryScreen.new(scene) + screen.pbStartScreen([heldpkmn], 0) + pbFadeInAndShow(@sprites, oldsprites) return end - party=[] - indexes=[] - startindex=0 - set=@sprites["setview"].set - for i in 0...@chamber.setCount(set)*2 - p=PurifyChamberHelper.pbGetPokemon2(@chamber,set,i) + party = [] + indexes = [] + startindex = 0 + set = @sprites["setview"].set + for i in 0...@chamber.setCount(set) * 2 + p = PurifyChamberHelper.pbGetPokemon2(@chamber, set, i) if p - startindex=party.length if i==pos + startindex = party.length if i == pos party.push(p) indexes.push(i) end end - return if party.length==0 - oldsprites=pbFadeOutAndHide(@sprites) - scene=PokemonSummary_Scene.new - screen=PokemonSummaryScreen.new(scene) - selection=screen.pbStartScreen(party,startindex) - @sprites["setview"].cursor=indexes[selection] - pbFadeInAndShow(@sprites,oldsprites) + return if party.length == 0 + oldsprites = pbFadeOutAndHide(@sprites) + scene = PokemonSummary_Scene.new + screen = PokemonSummaryScreen.new(scene) + selection = screen.pbStartScreen(party, startindex) + @sprites["setview"].cursor = indexes[selection] + pbFadeInAndShow(@sprites, oldsprites) end def pbPositionHint(pos) - @sprites["setview"].cursor=pos + @sprites["setview"].cursor = pos pbRefresh end def pbChangeSet(set) - @sprites["setview"].set=set - @sprites["setwindow"].index=set + @sprites["setview"].set = set + @sprites["setwindow"].index = set @sprites["setwindow"].refresh pbRefresh end def pbChoosePokemon - visible=pbFadeOutAndHide(@sprites) - scene=PokemonStorageScene.new - screen=PokemonStorageScreen.new(scene,$PokemonStorage) - pos=screen.pbChoosePokemon + visible = pbFadeOutAndHide(@sprites) + scene = PokemonStorageScene.new + screen = PokemonStorageScreen.new(scene, $PokemonStorage) + pos = screen.pbChoosePokemon pbRefresh - pbFadeInAndShow(@sprites,visible) + pbFadeInAndShow(@sprites, visible) return pos end end diff --git a/Data/Scripts/016_UI/023_UI_MysteryGift.rb b/Data/Scripts/016_UI/023_UI_MysteryGift.rb index a7ba4cf65..028fe95c8 100644 --- a/Data/Scripts/016_UI/023_UI_MysteryGift.rb +++ b/Data/Scripts/016_UI/023_UI_MysteryGift.rb @@ -14,104 +14,104 @@ end #=============================================================================== # type: 0=Pokémon; 1 or higher=item (is the item's quantity). # item: The thing being turned into a Mystery Gift (Pokémon object or item ID). -def pbEditMysteryGift(type,item,id = 0,giftname = "") +def pbEditMysteryGift(type, item, id = 0, giftname = "") begin - if type==0 # Pokémon - commands=[_INTL("Mystery Gift"), - _INTL("Faraway place")] + if type == 0 # Pokémon + commands = [_INTL("Mystery Gift"), + _INTL("Faraway place")] commands.push(item.obtain_text) if item.obtain_text && !item.obtain_text.empty? commands.push(_INTL("[Custom]")) loop do - command=pbMessage( - _INTL("Choose a phrase to be where the gift Pokémon was obtained from."),commands,-1) - if command<0 + command = pbMessage( + _INTL("Choose a phrase to be where the gift Pokémon was obtained from."), commands, -1) + if command < 0 return nil if pbConfirmMessage(_INTL("Stop editing this gift?")) - elsif command0 # Item - params=ChooseNumberParams.new - params.setRange(1,99999) + elsif type > 0 # Item + params = ChooseNumberParams.new + params.setRange(1, 99999) params.setDefaultValue(type) params.setCancelValue(0) loop do - newtype=pbMessageChooseNumber(_INTL("Choose a quantity of {1}.", - GameData::Item.get(item).name),params) - if newtype==0 + newtype = pbMessageChooseNumber(_INTL("Choose a quantity of {1}.", + GameData::Item.get(item).name), params) + if newtype == 0 return nil if pbConfirmMessage(_INTL("Stop editing this gift?")) else - type=newtype + type = newtype break end end end - if id==0 - master=[] - idlist=[] + if id == 0 + master = [] + idlist = [] if safeExists?("MysteryGiftMaster.txt") - master=IO.read("MysteryGiftMaster.txt") - master=pbMysteryGiftDecrypt(master) + master = IO.read("MysteryGiftMaster.txt") + master = pbMysteryGiftDecrypt(master) end for i in master idlist.push(i[0]) end - params=ChooseNumberParams.new - params.setRange(0,99999) + params = ChooseNumberParams.new + params.setRange(0, 99999) params.setDefaultValue(id) params.setCancelValue(0) loop do - newid=pbMessageChooseNumber(_INTL("Choose a unique ID for this gift."),params) - if newid==0 + newid = pbMessageChooseNumber(_INTL("Choose a unique ID for this gift."), params) + if newid == 0 return nil if pbConfirmMessage(_INTL("Stop editing this gift?")) else if idlist.include?(newid) pbMessage(_INTL("That ID is already used by a Mystery Gift.")) else - id=newid + id = newid break end end end end loop do - newgiftname=pbMessageFreeText(_INTL("Enter a name for the gift."),giftname,false,250) - if newgiftname!="" - giftname=newgiftname + newgiftname = pbMessageFreeText(_INTL("Enter a name for the gift."), giftname, false, 250) + if newgiftname != "" + giftname = newgiftname break end return nil if pbConfirmMessage(_INTL("Stop editing this gift?")) end - return [id,type,item,giftname] + return [id, type, item, giftname] rescue pbMessage(_INTL("Couldn't edit the gift.")) return nil end end -def pbCreateMysteryGift(type,item) - gift=pbEditMysteryGift(type,item) +def pbCreateMysteryGift(type, item) + gift = pbEditMysteryGift(type, item) if !gift pbMessage(_INTL("Didn't create a gift.")) else begin if safeExists?("MysteryGiftMaster.txt") - master=IO.read("MysteryGiftMaster.txt") - master=pbMysteryGiftDecrypt(master) + master = IO.read("MysteryGiftMaster.txt") + master = pbMysteryGiftDecrypt(master) master.push(gift) else - master=[gift] + master = [gift] end - string=pbMysteryGiftEncrypt(master) - File.open("MysteryGiftMaster.txt","wb") { |f| f.write(string) } + string = pbMysteryGiftEncrypt(master) + File.open("MysteryGiftMaster.txt", "wb") { |f| f.write(string) } pbMessage(_INTL("The gift was saved to MysteryGiftMaster.txt.")) rescue pbMessage(_INTL("Couldn't save the gift to MysteryGiftMaster.txt.")) @@ -129,85 +129,85 @@ def pbManageMysteryGifts return end # Load all gifts from the Master file. - master=IO.read("MysteryGiftMaster.txt") - master=pbMysteryGiftDecrypt(master) - if !master || !master.is_a?(Array) || master.length==0 + master = IO.read("MysteryGiftMaster.txt") + master = pbMysteryGiftDecrypt(master) + if !master || !master.is_a?(Array) || master.length == 0 pbMessage(_INTL("There are no Mystery Gifts defined.")) return end # Download all gifts from online - msgwindow=pbCreateMessageWindow - pbMessageDisplay(msgwindow,_INTL("Searching for online gifts...\\wtnp[0]")) + msgwindow = pbCreateMessageWindow + pbMessageDisplay(msgwindow, _INTL("Searching for online gifts...\\wtnp[0]")) online = pbDownloadToString(MysteryGift::URL) pbDisposeMessageWindow(msgwindow) if nil_or_empty?(online) pbMessage(_INTL("No online Mystery Gifts found.\\wtnp[20]")) - online=[] + online = [] else pbMessage(_INTL("Online Mystery Gifts found.\\wtnp[20]")) - online=pbMysteryGiftDecrypt(online) - t=[] + online = pbMysteryGiftDecrypt(online) + t = [] online.each { |gift| t.push(gift[0]) } - online=t + online = t end # Show list of all gifts. - command=0 + command = 0 loop do - commands=pbRefreshMGCommands(master,online) - command=pbMessage(_INTL("\\ts[]Manage Mystery Gifts (X=online)."),commands,-1,nil,command) + commands = pbRefreshMGCommands(master, online) + command = pbMessage(_INTL("\\ts[]Manage Mystery Gifts (X=online)."), commands, -1, nil, command) # Gift chosen - if command==-1 || command==commands.length-1 # Cancel + if command == -1 || command == commands.length - 1 # Cancel break - elsif command==commands.length-2 # Export selected to file + elsif command == commands.length - 2 # Export selected to file begin - newfile=[] + newfile = [] for gift in master newfile.push(gift) if online.include?(gift[0]) end - string=pbMysteryGiftEncrypt(newfile) - File.open("MysteryGift.txt","wb") { |f| f.write(string) } + string = pbMysteryGiftEncrypt(newfile) + File.open("MysteryGift.txt", "wb") { |f| f.write(string) } pbMessage(_INTL("The gifts were saved to MysteryGift.txt.")) pbMessage(_INTL("Upload MysteryGift.txt to the Internet.")) rescue pbMessage(_INTL("Couldn't save the gifts to MysteryGift.txt.")) end - elsif command>=0 && command= 0 && command < commands.length - 2 # A gift + cmd = 0 loop do - commands=pbRefreshMGCommands(master,online) - gift=master[command] - cmds=[_INTL("Toggle on/offline"), - _INTL("Edit"), - _INTL("Receive"), - _INTL("Delete"), - _INTL("Cancel")] - cmd=pbMessage("\\ts[]"+commands[command],cmds,-1,nil,cmd) - if cmd==-1 || cmd==cmds.length-1 + commands = pbRefreshMGCommands(master, online) + gift = master[command] + cmds = [_INTL("Toggle on/offline"), + _INTL("Edit"), + _INTL("Receive"), + _INTL("Delete"), + _INTL("Cancel")] + cmd = pbMessage("\\ts[]" + commands[command], cmds, -1, nil, cmd) + if cmd == -1 || cmd == cmds.length - 1 break - elsif cmd==0 # Toggle on/offline + elsif cmd == 0 # Toggle on/offline if online.include?(gift[0]) online.delete(gift[0]) else online.push(gift[0]) end - elsif cmd==1 # Edit - newgift=pbEditMysteryGift(gift[1],gift[2],gift[0],gift[3]) - master[command]=newgift if newgift - elsif cmd==2 # Receive + elsif cmd == 1 # Edit + newgift = pbEditMysteryGift(gift[1], gift[2], gift[0], gift[3]) + master[command] = newgift if newgift + elsif cmd == 2 # Receive if !$player pbMessage(_INTL("There is no save file loaded. Cannot receive any gifts.")) next end - replaced=false + replaced = false for i in 0...$player.mystery_gifts.length - if $player.mystery_gifts[i][0]==gift[0] - $player.mystery_gifts[i]=gift - replaced=true + if $player.mystery_gifts[i][0] == gift[0] + $player.mystery_gifts[i] = gift + replaced = true end end $player.mystery_gifts.push(gift) if !replaced pbReceiveMysteryGift(gift[0]) - elsif cmd==3 # Delete + elsif cmd == 3 # Delete master.delete_at(command) if pbConfirmMessage(_INTL("Are you sure you want to delete this gift?")) break end @@ -238,85 +238,85 @@ end #=============================================================================== # Called from the Continue/New Game screen. def pbDownloadMysteryGift(trainer) - sprites={} - viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - viewport.z=99999 - addBackgroundPlane(sprites,"background","mysteryGiftbg",viewport) + sprites = {} + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + viewport.z = 99999 + addBackgroundPlane(sprites, "background", "mysteryGiftbg", viewport) pbFadeInAndShow(sprites) - sprites["msgwindow"]=pbCreateMessageWindow - pbMessageDisplay(sprites["msgwindow"],_INTL("Searching for a gift.\nPlease wait...\\wtnp[0]")) + sprites["msgwindow"] = pbCreateMessageWindow + pbMessageDisplay(sprites["msgwindow"], _INTL("Searching for a gift.\nPlease wait...\\wtnp[0]")) string = pbDownloadToString(MysteryGift::URL) if nil_or_empty?(string) - pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available.")) + pbMessageDisplay(sprites["msgwindow"], _INTL("No new gifts are available.")) else - online=pbMysteryGiftDecrypt(string) - pending=[] + online = pbMysteryGiftDecrypt(string) + pending = [] for gift in online - notgot=true + notgot = true for j in trainer.mystery_gifts - notgot=false if j[0]==gift[0] + notgot = false if j[0] == gift[0] end pending.push(gift) if notgot end - if pending.length==0 - pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available.")) + if pending.length == 0 + pbMessageDisplay(sprites["msgwindow"], _INTL("No new gifts are available.")) else loop do - commands=[] + commands = [] for gift in pending commands.push(gift[3]) end commands.push(_INTL("Cancel")) - pbMessageDisplay(sprites["msgwindow"],_INTL("Choose the gift you want to receive.\\wtnp[0]")) - command=pbShowCommands(sprites["msgwindow"],commands,-1) - if command==-1 || command==commands.length-1 + pbMessageDisplay(sprites["msgwindow"], _INTL("Choose the gift you want to receive.\\wtnp[0]")) + command = pbShowCommands(sprites["msgwindow"], commands, -1) + if command == -1 || command == commands.length - 1 break else - gift=pending[command] - sprites["msgwindow"].visible=false - if gift[1]==0 - sprite=PokemonSprite.new(viewport) + gift = pending[command] + sprites["msgwindow"].visible = false + if gift[1] == 0 + sprite = PokemonSprite.new(viewport) sprite.setOffset(PictureOrigin::Center) sprite.setPokemonBitmap(gift[2]) - sprite.x=Graphics.width/2 - sprite.y=-sprite.bitmap.height/2 + sprite.x = Graphics.width / 2 + sprite.y = -sprite.bitmap.height / 2 else - sprite=ItemIconSprite.new(0,0,gift[2],viewport) - sprite.x=Graphics.width/2 - sprite.y=-sprite.height/2 + sprite = ItemIconSprite.new(0, 0, gift[2], viewport) + sprite.x = Graphics.width / 2 + sprite.y = -sprite.height / 2 end - distanceDiff = 8*20/Graphics.frame_rate + distanceDiff = 8 * 20 / Graphics.frame_rate loop do Graphics.update Input.update sprite.update - sprite.y+=distanceDiff - break if sprite.y>=Graphics.height/2 + sprite.y += distanceDiff + break if sprite.y >= Graphics.height / 2 end pbMEPlay("Battle capture success") - (Graphics.frame_rate*3).times do + (Graphics.frame_rate * 3).times do Graphics.update Input.update sprite.update pbUpdateSceneMap end - sprites["msgwindow"].visible=true - pbMessageDisplay(sprites["msgwindow"],_INTL("The gift has been received!")) { sprite.update } - pbMessageDisplay(sprites["msgwindow"],_INTL("Please pick up your gift from the deliveryman in any Poké Mart.")) { sprite.update } + sprites["msgwindow"].visible = true + pbMessageDisplay(sprites["msgwindow"], _INTL("The gift has been received!")) { sprite.update } + pbMessageDisplay(sprites["msgwindow"], _INTL("Please pick up your gift from the deliveryman in any Poké Mart.")) { sprite.update } trainer.mystery_gifts.push(gift) pending.delete_at(command) - opacityDiff = 16*20/Graphics.frame_rate + opacityDiff = 16 * 20 / Graphics.frame_rate loop do Graphics.update Input.update sprite.update - sprite.opacity-=opacityDiff - break if sprite.opacity<=0 + sprite.opacity -= opacityDiff + break if sprite.opacity <= 0 end sprite.dispose end - if pending.length==0 - pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available.")) + if pending.length == 0 + pbMessageDisplay(sprites["msgwindow"], _INTL("No new gifts are available.")) break end end @@ -332,7 +332,7 @@ end # Converts an array of gifts into a string and back. #=============================================================================== def pbMysteryGiftEncrypt(gift) - ret=[Zlib::Deflate.deflate(Marshal.dump(gift))].pack("m") + ret = [Zlib::Deflate.deflate(Marshal.dump(gift))].pack("m") return ret end @@ -356,63 +356,63 @@ end #=============================================================================== def pbNextMysteryGiftID for i in $player.mystery_gifts - return i[0] if i.length>1 + return i[0] if i.length > 1 end return 0 end def pbReceiveMysteryGift(id) - index=-1 + index = -1 for i in 0...$player.mystery_gifts.length - if $player.mystery_gifts[i][0]==id && $player.mystery_gifts[i].length>1 - index=i + if $player.mystery_gifts[i][0] == id && $player.mystery_gifts[i].length > 1 + index = i break end end - if index==-1 - pbMessage(_INTL("Couldn't find an unclaimed Mystery Gift with ID {1}.",id)) + if index == -1 + pbMessage(_INTL("Couldn't find an unclaimed Mystery Gift with ID {1}.", id)) return false end - gift=$player.mystery_gifts[index] - if gift[1]==0 # Pokémon + gift = $player.mystery_gifts[index] + if gift[1] == 0 # Pokémon gift[2].personalID = rand(2**16) | rand(2**16) << 16 gift[2].calc_stats - time=pbGetTimeNow - gift[2].timeReceived=time.getgm.to_i + time = pbGetTimeNow + gift[2].timeReceived = time.getgm.to_i gift[2].obtain_method = 4 # Fateful encounter gift[2].record_first_moves if $game_map - gift[2].obtain_map=$game_map.map_id - gift[2].obtain_level=gift[2].level + gift[2].obtain_map = $game_map.map_id + gift[2].obtain_level = gift[2].level else - gift[2].obtain_map=0 - gift[2].obtain_level=gift[2].level + gift[2].obtain_map = 0 + gift[2].obtain_level = gift[2].level end if pbAddPokemonSilent(gift[2]) - pbMessage(_INTL("\\me[Pkmn get]{1} received {2}!",$player.name,gift[2].name)) - $player.mystery_gifts[index]=[id] + pbMessage(_INTL("\\me[Pkmn get]{1} received {2}!", $player.name, gift[2].name)) + $player.mystery_gifts[index] = [id] return true end - elsif gift[1]>0 # Item - item=gift[2] - qty=gift[1] - if $bag.can_add?(item,qty) - $bag.add(item,qty) + elsif gift[1] > 0 # Item + item = gift[2] + qty = gift[1] + if $bag.can_add?(item, qty) + $bag.add(item, qty) itm = GameData::Item.get(item) - itemname=(qty>1) ? itm.name_plural : itm.name + itemname = (qty > 1) ? itm.name_plural : itm.name if item == :LEFTOVERS - pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) + pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]", itemname)) elsif itm.is_machine? # TM or HM - pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname, + pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]", itemname, GameData::Move.get(itm.move).name)) - elsif qty>1 - pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname)) + elsif qty > 1 + pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]", qty, itemname)) elsif itemname.starts_with_vowel? - pbMessage(_INTL("\\me[Item get]You obtained an \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) + pbMessage(_INTL("\\me[Item get]You obtained an \\c[1]{1}\\c[0]!\\wtnp[30]", itemname)) else - pbMessage(_INTL("\\me[Item get]You obtained a \\c[1]{1}\\c[0]!\\wtnp[30]",itemname)) + pbMessage(_INTL("\\me[Item get]You obtained a \\c[1]{1}\\c[0]!\\wtnp[30]", itemname)) end - $player.mystery_gifts[index]=[id] + $player.mystery_gifts[index] = [id] return true end end diff --git a/Data/Scripts/016_UI/024_UI_TextEntry.rb b/Data/Scripts/016_UI/024_UI_TextEntry.rb index d7eb6a8ef..79e60e54a 100644 --- a/Data/Scripts/016_UI/024_UI_TextEntry.rb +++ b/Data/Scripts/016_UI/024_UI_TextEntry.rb @@ -2,33 +2,33 @@ # #=============================================================================== class Window_CharacterEntry < Window_DrawableCommand - XSIZE=13 - YSIZE=4 + XSIZE = 13 + YSIZE = 4 - def initialize(charset,viewport = nil) - @viewport=viewport - @charset=charset - @othercharset="" - super(0,96,480,192) - colors=getDefaultTextColors(self.windowskin) - self.baseColor=colors[0] - self.shadowColor=colors[1] - self.columns=XSIZE + def initialize(charset, viewport = nil) + @viewport = viewport + @charset = charset + @othercharset = "" + super(0, 96, 480, 192) + colors = getDefaultTextColors(self.windowskin) + self.baseColor = colors[0] + self.shadowColor = colors[1] + self.columns = XSIZE refresh end def setOtherCharset(value) - @othercharset=value.clone + @othercharset = value.clone refresh end def setCharset(value) - @charset=value.clone + @charset = value.clone refresh end def character - if self.index<0 || self.index>=@charset.length + if self.index < 0 || self.index >= @charset.length return "" else return @charset[self.index] @@ -36,30 +36,30 @@ class Window_CharacterEntry < Window_DrawableCommand end def command - return -1 if self.index==@charset.length - return -2 if self.index==@charset.length+1 - return -3 if self.index==@charset.length+2 + return -1 if self.index == @charset.length + return -2 if self.index == @charset.length + 1 + return -3 if self.index == @charset.length + 2 return self.index end def itemCount - return @charset.length+3 + return @charset.length + 3 end - 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,"[ ]", - self.baseColor,self.shadowColor) - elsif index==@charset.length+1 # -2 - pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,@othercharset, - self.baseColor,self.shadowColor) - elsif index==@charset.length+2 # -3 - pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,_INTL("OK"), - self.baseColor,self.shadowColor) + 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, "[ ]", + self.baseColor, self.shadowColor) + elsif index == @charset.length + 1 # -2 + pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height, @othercharset, + self.baseColor, self.shadowColor) + elsif index == @charset.length + 2 # -3 + pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height, _INTL("OK"), + self.baseColor, self.shadowColor) else - pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,@charset[index], - self.baseColor,self.shadowColor) + pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height, @charset[index], + self.baseColor, self.shadowColor) end end end @@ -70,124 +70,124 @@ end # Text entry screen - free typing. #=============================================================================== class PokemonEntryScene - @@Characters=[ - [("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").scan(/./),"[*]"], - [("0123456789 !@\#$%^&*() ~`-_+={}[] :;'\"<>,.?/ ").scan(/./),"[A]"], + @@Characters = [ + [("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").scan(/./), "[*]"], + [("0123456789 !@\#$%^&*() ~`-_+={}[] :;'\"<>,.?/ ").scan(/./), "[A]"], ] - USEKEYBOARD=true + USEKEYBOARD = true - def pbStartScene(helptext,minlength,maxlength,initialText,subject = 0,pokemon = nil) - @sprites={} - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 + def pbStartScene(helptext, minlength, maxlength, initialText, subject = 0, pokemon = nil) + @sprites = {} + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 if USEKEYBOARD - @sprites["entry"]=Window_TextEntry_Keyboard.new(initialText, - 0,0,400-112,96,helptext,true) + @sprites["entry"] = Window_TextEntry_Keyboard.new(initialText, + 0, 0, 400 - 112, 96, helptext, true) Input.text_input = true else - @sprites["entry"]=Window_TextEntry.new(initialText,0,0,400,96,helptext,true) + @sprites["entry"] = Window_TextEntry.new(initialText, 0, 0, 400, 96, helptext, true) end - @sprites["entry"].x=(Graphics.width/2)-(@sprites["entry"].width/2)+32 - @sprites["entry"].viewport=@viewport - @sprites["entry"].visible=true - @minlength=minlength - @maxlength=maxlength - @symtype=0 - @sprites["entry"].maxlength=maxlength + @sprites["entry"].x = (Graphics.width / 2) - (@sprites["entry"].width / 2) + 32 + @sprites["entry"].viewport = @viewport + @sprites["entry"].visible = true + @minlength = minlength + @maxlength = maxlength + @symtype = 0 + @sprites["entry"].maxlength = maxlength if !USEKEYBOARD - @sprites["entry2"]=Window_CharacterEntry.new(@@Characters[@symtype][0]) + @sprites["entry2"] = Window_CharacterEntry.new(@@Characters[@symtype][0]) @sprites["entry2"].setOtherCharset(@@Characters[@symtype][1]) - @sprites["entry2"].viewport=@viewport - @sprites["entry2"].visible=true - @sprites["entry2"].x=(Graphics.width/2)-(@sprites["entry2"].width/2) + @sprites["entry2"].viewport = @viewport + @sprites["entry2"].visible = true + @sprites["entry2"].x = (Graphics.width / 2) - (@sprites["entry2"].width / 2) end - if minlength==0 - @sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize( + if minlength == 0 + @sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize( _INTL("Enter text using the keyboard. Press\nEnter to confirm, or Esc to cancel."), - 32,Graphics.height-96,Graphics.width-64,96,@viewport + 32, Graphics.height - 96, Graphics.width - 64, 96, @viewport ) else - @sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize( + @sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize( _INTL("Enter text using the keyboard.\nPress Enter to confirm."), - 32,Graphics.height-96,Graphics.width-64,96,@viewport + 32, Graphics.height - 96, Graphics.width - 64, 96, @viewport ) end - @sprites["helpwindow"].letterbyletter=false - @sprites["helpwindow"].viewport=@viewport - @sprites["helpwindow"].visible=USEKEYBOARD - @sprites["helpwindow"].baseColor=Color.new(16,24,32) - @sprites["helpwindow"].shadowColor=Color.new(168,184,184) - addBackgroundPlane(@sprites,"background","Naming/bg_2",@viewport) + @sprites["helpwindow"].letterbyletter = false + @sprites["helpwindow"].viewport = @viewport + @sprites["helpwindow"].visible = USEKEYBOARD + @sprites["helpwindow"].baseColor = Color.new(16, 24, 32) + @sprites["helpwindow"].shadowColor = Color.new(168, 184, 184) + addBackgroundPlane(@sprites, "background", "Naming/bg_2", @viewport) case subject when 1 # Player meta = GameData::PlayerMetadata.get($player.character_ID) if meta - @sprites["shadow"]=IconSprite.new(0,0,@viewport) + @sprites["shadow"] = IconSprite.new(0, 0, @viewport) @sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow") - @sprites["shadow"].x=33*2 - @sprites["shadow"].y=32*2 + @sprites["shadow"].x = 33 * 2 + @sprites["shadow"].y = 32 * 2 filename = pbGetPlayerCharset(meta.walk_charset, nil, true) - @sprites["subject"]=TrainerWalkingCharSprite.new(filename,@viewport) - charwidth=@sprites["subject"].bitmap.width - charheight=@sprites["subject"].bitmap.height - @sprites["subject"].x = 44*2 - charwidth/8 - @sprites["subject"].y = 38*2 - charheight/4 + @sprites["subject"] = TrainerWalkingCharSprite.new(filename, @viewport) + charwidth = @sprites["subject"].bitmap.width + charheight = @sprites["subject"].bitmap.height + @sprites["subject"].x = 44 * 2 - charwidth / 8 + @sprites["subject"].y = 38 * 2 - charheight / 4 end when 2 # Pokémon if pokemon - @sprites["shadow"]=IconSprite.new(0,0,@viewport) + @sprites["shadow"] = IconSprite.new(0, 0, @viewport) @sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow") - @sprites["shadow"].x=33*2 - @sprites["shadow"].y=32*2 - @sprites["subject"]=PokemonIconSprite.new(pokemon,@viewport) + @sprites["shadow"].x = 33 * 2 + @sprites["shadow"].y = 32 * 2 + @sprites["subject"] = PokemonIconSprite.new(pokemon, @viewport) @sprites["subject"].setOffset(PictureOrigin::Center) - @sprites["subject"].x=88 - @sprites["subject"].y=54 - @sprites["gender"]=BitmapSprite.new(32,32,@viewport) - @sprites["gender"].x=430 - @sprites["gender"].y=54 + @sprites["subject"].x = 88 + @sprites["subject"].y = 54 + @sprites["gender"] = BitmapSprite.new(32, 32, @viewport) + @sprites["gender"].x = 430 + @sprites["gender"].y = 54 @sprites["gender"].bitmap.clear pbSetSystemFont(@sprites["gender"].bitmap) - textpos=[] + textpos = [] if pokemon.male? - textpos.push([_INTL("♂"),0,-6,false,Color.new(0,128,248),Color.new(168,184,184)]) + textpos.push([_INTL("♂"), 0, -6, false, Color.new(0, 128, 248), Color.new(168, 184, 184)]) elsif pokemon.female? - textpos.push([_INTL("♀"),0,-6,false,Color.new(248,24,24),Color.new(168,184,184)]) + textpos.push([_INTL("♀"), 0, -6, false, Color.new(248, 24, 24), Color.new(168, 184, 184)]) end - pbDrawTextPositions(@sprites["gender"].bitmap,textpos) + pbDrawTextPositions(@sprites["gender"].bitmap, textpos) end when 3 # NPC - @sprites["shadow"]=IconSprite.new(0,0,@viewport) + @sprites["shadow"] = IconSprite.new(0, 0, @viewport) @sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow") - @sprites["shadow"].x=33*2 - @sprites["shadow"].y=32*2 - @sprites["subject"]=TrainerWalkingCharSprite.new(pokemon.to_s,@viewport) - charwidth=@sprites["subject"].bitmap.width - charheight=@sprites["subject"].bitmap.height - @sprites["subject"].x = 44*2 - charwidth/8 - @sprites["subject"].y = 38*2 - charheight/4 + @sprites["shadow"].x = 33 * 2 + @sprites["shadow"].y = 32 * 2 + @sprites["subject"] = TrainerWalkingCharSprite.new(pokemon.to_s, @viewport) + charwidth = @sprites["subject"].bitmap.width + charheight = @sprites["subject"].bitmap.height + @sprites["subject"].x = 44 * 2 - charwidth / 8 + @sprites["subject"].y = 38 * 2 - charheight / 4 when 4 # Storage box - @sprites["subject"]=TrainerWalkingCharSprite.new(nil,@viewport) - @sprites["subject"].altcharset="Graphics/Pictures/Naming/icon_storage" - @sprites["subject"].animspeed=4 - charwidth=@sprites["subject"].bitmap.width - charheight=@sprites["subject"].bitmap.height - @sprites["subject"].x = 44*2 - charwidth/8 - @sprites["subject"].y = 26*2 - charheight/2 + @sprites["subject"] = TrainerWalkingCharSprite.new(nil, @viewport) + @sprites["subject"].altcharset = "Graphics/Pictures/Naming/icon_storage" + @sprites["subject"].animspeed = 4 + charwidth = @sprites["subject"].bitmap.width + charheight = @sprites["subject"].bitmap.height + @sprites["subject"].x = 44 * 2 - charwidth / 8 + @sprites["subject"].y = 26 * 2 - charheight / 2 end pbFadeInAndShow(@sprites) end def pbEntry1 - ret="" + ret = "" loop do Graphics.update Input.update - if Input.triggerex?(:ESCAPE) && @minlength==0 - ret="" + if Input.triggerex?(:ESCAPE) && @minlength == 0 + ret = "" break - elsif Input.triggerex?(:RETURN) && @sprites["entry"].text.length>=@minlength - ret=@sprites["entry"].text + elsif Input.triggerex?(:RETURN) && @sprites["entry"].text.length >= @minlength + ret = @sprites["entry"].text break end @sprites["helpwindow"].update @@ -199,7 +199,7 @@ class PokemonEntryScene end def pbEntry2 - ret="" + ret = "" loop do Graphics.update Input.update @@ -208,25 +208,25 @@ class PokemonEntryScene @sprites["entry2"].update @sprites["subject"].update if @sprites["subject"] if Input.trigger?(Input::USE) - index=@sprites["entry2"].command - if index==-3 # Confirm text - ret=@sprites["entry"].text - if ret.length<@minlength || ret.length>@maxlength + index = @sprites["entry2"].command + if index == -3 # Confirm text + ret = @sprites["entry"].text + if ret.length < @minlength || ret.length > @maxlength pbPlayBuzzerSE() else pbPlayDecisionSE() break end - elsif index==-1 # Insert a space + elsif index == -1 # Insert a space if @sprites["entry"].insert(" ") pbPlayDecisionSE() else pbPlayBuzzerSE() end - elsif index==-2 # Change character set + elsif index == -2 # Change character set pbPlayDecisionSE() - @symtype+=1 - @symtype=0 if @symtype>=@@Characters.length + @symtype += 1 + @symtype = 0 if @symtype >= @@Characters.length @sprites["entry2"].setCharset(@@Characters[@symtype][0]) @sprites["entry2"].setOtherCharset(@@Characters[@symtype][1]) else # Insert given character @@ -373,7 +373,7 @@ class PokemonEntryScene2 - def pbStartScene(helptext,minlength,maxlength,initialText,subject = 0,pokemon = nil) + def pbStartScene(helptext, minlength, maxlength, initialText, subject = 0, pokemon = nil) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @helptext = helptext @@ -476,7 +476,7 @@ class PokemonEntryScene2 @sprites["bottomtab"].x = 22 @sprites["bottomtab"].y = 162 @sprites["bottomtab"].bitmap = @bitmaps[@@Characters.length] - @sprites["toptab"]=SpriteWrapper.new(@viewport) # Next tab + @sprites["toptab"] = SpriteWrapper.new(@viewport) # Next tab @sprites["toptab"].x = 22 - 504 @sprites["toptab"].y = 162 @sprites["toptab"].bitmap = @bitmaps[@@Characters.length + 1] @@ -753,12 +753,12 @@ end #=============================================================================== class PokemonEntry def initialize(scene) - @scene=scene + @scene = scene end - def pbStartScreen(helptext,minlength,maxlength,initialText,mode = -1,pokemon = nil) - @scene.pbStartScene(helptext,minlength,maxlength,initialText,mode,pokemon) - ret=@scene.pbEntry + def pbStartScreen(helptext, minlength, maxlength, initialText, mode = -1, pokemon = nil) + @scene.pbStartScene(helptext, minlength, maxlength, initialText, mode, pokemon) + ret = @scene.pbEntry @scene.pbEndScene return ret end @@ -769,36 +769,36 @@ end #=============================================================================== # #=============================================================================== -def pbEnterText(helptext,minlength,maxlength,initialText = "",mode = 0,pokemon = nil,nofadeout = false) - ret="" - if ($PokemonSystem.textinput==1 rescue false) # Keyboard - pbFadeOutIn(99999,nofadeout) { - sscene=PokemonEntryScene.new - sscreen=PokemonEntry.new(sscene) - ret=sscreen.pbStartScreen(helptext,minlength,maxlength,initialText,mode,pokemon) +def pbEnterText(helptext, minlength, maxlength, initialText = "", mode = 0, pokemon = nil, nofadeout = false) + ret = "" + if ($PokemonSystem.textinput == 1 rescue false) # Keyboard + pbFadeOutIn(99999, nofadeout) { + sscene = PokemonEntryScene.new + sscreen = PokemonEntry.new(sscene) + ret = sscreen.pbStartScreen(helptext, minlength, maxlength, initialText, mode, pokemon) } else # Cursor - pbFadeOutIn(99999,nofadeout) { - sscene=PokemonEntryScene2.new - sscreen=PokemonEntry.new(sscene) - ret=sscreen.pbStartScreen(helptext,minlength,maxlength,initialText,mode,pokemon) + pbFadeOutIn(99999, nofadeout) { + sscene = PokemonEntryScene2.new + sscreen = PokemonEntry.new(sscene) + ret = sscreen.pbStartScreen(helptext, minlength, maxlength, initialText, mode, pokemon) } end return ret end -def pbEnterPlayerName(helptext,minlength,maxlength,initialText = "",nofadeout = false) - return pbEnterText(helptext,minlength,maxlength,initialText,1,nil,nofadeout) +def pbEnterPlayerName(helptext, minlength, maxlength, initialText = "", nofadeout = false) + return pbEnterText(helptext, minlength, maxlength, initialText, 1, nil, nofadeout) end -def pbEnterPokemonName(helptext,minlength,maxlength,initialText = "",pokemon = nil,nofadeout = false) - return pbEnterText(helptext,minlength,maxlength,initialText,2,pokemon,nofadeout) +def pbEnterPokemonName(helptext, minlength, maxlength, initialText = "", pokemon = nil, nofadeout = false) + return pbEnterText(helptext, minlength, maxlength, initialText, 2, pokemon, nofadeout) end -def pbEnterNPCName(helptext,minlength,maxlength,initialText = "",id = 0,nofadeout = false) - return pbEnterText(helptext,minlength,maxlength,initialText,3,id,nofadeout) +def pbEnterNPCName(helptext, minlength, maxlength, initialText = "", id = 0, nofadeout = false) + return pbEnterText(helptext, minlength, maxlength, initialText, 3, id, nofadeout) end -def pbEnterBoxName(helptext,minlength,maxlength,initialText = "",nofadeout = false) - return pbEnterText(helptext,minlength,maxlength,initialText,4,nil,nofadeout) +def pbEnterBoxName(helptext, minlength, maxlength, initialText = "", nofadeout = false) + return pbEnterText(helptext, minlength, maxlength, initialText, 4, nil, nofadeout) end diff --git a/Data/Scripts/017_Minigames/001_Minigame_Duel.rb b/Data/Scripts/017_Minigames/001_Minigame_Duel.rb index 0e3a4bc80..d2128ca9d 100644 --- a/Data/Scripts/017_Minigames/001_Minigame_Duel.rb +++ b/Data/Scripts/017_Minigames/001_Minigame_Duel.rb @@ -419,7 +419,7 @@ def pbDuel(trainer_id, trainer_name, event, speeches) trainer_id = GameData::TrainerType.get(trainer_id).id duel = PokemonDuel.new opponent = NPCTrainer.new( - pbGetMessageFromHash(MessageTypes::TrainerNames,trainer_name), trainer_id) + pbGetMessageFromHash(MessageTypes::TrainerNames, trainer_name), trainer_id) speech_texts = [] for i in 0...12 speech_texts.push(_I(speeches[i])) diff --git a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb index 186530763..552f2766a 100644 --- a/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb +++ b/Data/Scripts/017_Minigames/002_Minigame_TripleTriad.rb @@ -166,17 +166,17 @@ class TriadScene @bitmaps = [] @battle = battle # Allocate viewport - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 - addBackgroundPlane(@sprites,"background","triad_bg",@viewport) + addBackgroundPlane(@sprites, "background", "triad_bg", @viewport) @sprites["helpwindow"] = Window_AdvancedTextPokemon.newWithSize("", - 0,Graphics.height-64,Graphics.width,64,@viewport) - for i in 0...@battle.width*@battle.height + 0, Graphics.height - 64, Graphics.width, 64, @viewport) + for i in 0...@battle.width * @battle.height @sprites["sprite#{i}"] = SpriteWrapper.new(@viewport) - @sprites["sprite#{i}"].x = Graphics.width/2 - 118 + (i%3)*78 - @sprites["sprite#{i}"].y = 36 + (i/3)*94 + @sprites["sprite#{i}"].x = Graphics.width / 2 - 118 + (i % 3) * 78 + @sprites["sprite#{i}"].y = 36 + (i / 3) * 94 @sprites["sprite#{i}"].z = 2 - bm = TriadCard.createBack(@battle.board[i].type,true) + bm = TriadCard.createBack(@battle.board[i].type, true) @bitmaps.push(bm) @sprites["sprite#{i}"].bitmap = bm end @@ -188,20 +188,20 @@ class TriadScene @boardCards = [] for i in 0...@battle.maxCards @sprites["player#{i}"] = Sprite.new(@viewport) - @sprites["player#{i}"].x = Graphics.width-92 - @sprites["player#{i}"].y = 44+44*i + @sprites["player#{i}"].x = Graphics.width - 92 + @sprites["player#{i}"].y = 44 + 44 * i @sprites["player#{i}"].z = 2 @cardIndexes.push(i) end @sprites["overlay"] = Sprite.new(@viewport) - @sprites["overlay"].bitmap = BitmapWrapper.new(Graphics.width,Graphics.height) + @sprites["overlay"].bitmap = BitmapWrapper.new(Graphics.width, Graphics.height) pbSetSystemFont(@sprites["overlay"].bitmap) - pbDrawTextPositions(@sprites["overlay"].bitmap,[ - [@battle.opponentName,52,-2,2,Color.new(248,248,248),Color.new(96,96,96)], - [@battle.playerName,Graphics.width-52,-2,2,Color.new(248,248,248),Color.new(96,96,96)] + pbDrawTextPositions(@sprites["overlay"].bitmap, [ + [@battle.opponentName, 52, -2, 2, Color.new(248, 248, 248), Color.new(96, 96, 96)], + [@battle.playerName, Graphics.width - 52, -2, 2, Color.new(248, 248, 248), Color.new(96, 96, 96)] ]) @sprites["score"] = Sprite.new(@viewport) - @sprites["score"].bitmap = BitmapWrapper.new(Graphics.width,Graphics.height) + @sprites["score"].bitmap = BitmapWrapper.new(Graphics.width, Graphics.height) pbSetSystemFont(@sprites["score"].bitmap) pbBGMPlay("Triple Triad") # Fade in all sprites @@ -230,7 +230,7 @@ class TriadScene def pbDisplayPaused(text) @sprites["helpwindow"].letterbyletter = true - @sprites["helpwindow"].text = text+"\1" + @sprites["helpwindow"].text = text + "\1" loop do Graphics.update Input.update @@ -248,7 +248,7 @@ class TriadScene @sprites["helpwindow"].text = "" end - def pbNotifyCards(playerCards,opponentCards) + def pbNotifyCards(playerCards, opponentCards) @playerCards = playerCards @opponentCards = opponentCards end @@ -259,17 +259,17 @@ class TriadScene for item in cardStorage commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1])) end - command = Window_CommandPokemonEx.newWithSize(commands,0,0,Graphics.width/2,Graphics.height-64,@viewport) - @sprites["helpwindow"].text = _INTL("Choose {1} cards to use for this duel.",@battle.maxCards) + command = Window_CommandPokemonEx.newWithSize(commands, 0, 0, Graphics.width / 2, Graphics.height - 64, @viewport) + @sprites["helpwindow"].text = _INTL("Choose {1} cards to use for this duel.", @battle.maxCards) preview = Sprite.new(@viewport) - preview.x = Graphics.width/2 + 20 + preview.x = Graphics.width / 2 + 20 preview.y = 60 preview.z = 4 index = -1 for i in 0...@battle.maxCards @sprites["player#{i}"] = Sprite.new(@viewport) - @sprites["player#{i}"].x = Graphics.width-92 - @sprites["player#{i}"].y = 44+44*i + @sprites["player#{i}"].x = Graphics.width - 92 + @sprites["player#{i}"].y = 44 + 44 * i @sprites["player#{i}"].z = 2 end loop do @@ -277,18 +277,18 @@ class TriadScene Input.update pbUpdate command.update - if command.index!=index + if command.index != index preview.bitmap.dispose if preview.bitmap - if command.index0 + if chosenCards.length > 0 item = chosenCards.pop - @battle.pbAdd(cardStorage,item) + @battle.pbAdd(cardStorage, item) commands = [] for item in cardStorage commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1])) @@ -299,9 +299,9 @@ class TriadScene pbPlayBuzzerSE end elsif Input.trigger?(Input::USE) - break if chosenCards.length==@battle.maxCards + break if chosenCards.length == @battle.maxCards item = cardStorage[command.index] - if !item || @battle.quantity(cardStorage,item[0])==0 + if !item || @battle.quantity(cardStorage, item[0]) == 0 pbPlayBuzzerSE else pbPlayDecisionSE @@ -310,27 +310,27 @@ class TriadScene @cardBitmaps[chosenCards.length] = TriadCard.new(item[0]).createBitmap(1) sprite.bitmap = @cardBitmaps[chosenCards.length] chosenCards.push(item[0]) - @battle.pbSubtract(cardStorage,item[0]) + @battle.pbSubtract(cardStorage, item[0]) commands = [] for item in cardStorage commands.push(_INTL("{1} x{2}", GameData::Species.get(item[0]).name, item[1])) end command.commands = commands - command.index = commands.length-1 if command.index>=commands.length + command.index = commands.length - 1 if command.index >= commands.length index = -1 end end if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK) for i in 0...@battle.maxCards - @sprites["player#{i}"].visible = (i=numCards + choice = 0 if choice >= numCards elsif Input.repeat?(Input::UP) pbPlayCursorSE choice -= 1 - choice = numCards-1 if choice<0 + choice = numCards - 1 if choice < 0 elsif Input.trigger?(Input::BACK) pbPlayCancelSE choice = -1 @@ -411,11 +411,11 @@ class TriadScene choice = 0 lastChoice = -1 loop do - if lastChoice!=choice + if lastChoice != choice y = 44 for i in 0...@cardIndexes.length @sprites["player#{@cardIndexes[i]}"].bitmap = @cardBitmaps[@cardIndexes[i]] - @sprites["player#{@cardIndexes[i]}"].x = (i==choice) ? Graphics.width-108 : Graphics.width-92 + @sprites["player#{@cardIndexes[i]}"].x = (i == choice) ? Graphics.width - 108 : Graphics.width - 92 @sprites["player#{@cardIndexes[i]}"].y = y @sprites["player#{@cardIndexes[i]}"].z = 2 y += 44 @@ -428,11 +428,11 @@ class TriadScene if Input.repeat?(Input::DOWN) pbPlayCursorSE choice += 1 - choice = 0 if choice>=numCards + choice = 0 if choice >= numCards elsif Input.repeat?(Input::UP) pbPlayCursorSE choice -= 1 - choice = numCards-1 if choice<0 + choice = numCards - 1 if choice < 0 elsif Input.trigger?(Input::USE) pbPlayDecisionSE break @@ -456,12 +456,12 @@ class TriadScene if doRefresh y = 44 for i in 0...@cardIndexes.length - if i==cardIndex # Card being placed - @sprites["player#{@cardIndexes[i]}"].x = Graphics.width/2 - 118 + boardX*78 - @sprites["player#{@cardIndexes[i]}"].y = 36 + boardY*94 + if i == cardIndex # Card being placed + @sprites["player#{@cardIndexes[i]}"].x = Graphics.width / 2 - 118 + boardX * 78 + @sprites["player#{@cardIndexes[i]}"].y = 36 + boardY * 94 @sprites["player#{@cardIndexes[i]}"].z = 4 else # Other cards in hand - @sprites["player#{@cardIndexes[i]}"].x = Graphics.width-92 + @sprites["player#{@cardIndexes[i]}"].x = Graphics.width - 92 @sprites["player#{@cardIndexes[i]}"].y = y @sprites["player#{@cardIndexes[i]}"].z = 2 y += 44 @@ -475,27 +475,27 @@ class TriadScene if Input.repeat?(Input::DOWN) pbPlayCursorSE boardY += 1 - boardY = 0 if boardY>=@battle.height + boardY = 0 if boardY >= @battle.height doRefresh = true elsif Input.repeat?(Input::UP) pbPlayCursorSE boardY -= 1 - boardY = @battle.height-1 if boardY<0 + boardY = @battle.height - 1 if boardY < 0 doRefresh = true elsif Input.repeat?(Input::LEFT) pbPlayCursorSE boardX -= 1 - boardX = @battle.width-1 if boardX<0 + boardX = @battle.width - 1 if boardX < 0 doRefresh = true elsif Input.repeat?(Input::RIGHT) pbPlayCursorSE boardX += 1 - boardX = 0 if boardX>=@battle.width + boardX = 0 if boardX >= @battle.width doRefresh = true elsif Input.trigger?(Input::BACK) return nil elsif Input.trigger?(Input::USE) - if @battle.isOccupied?(boardX,boardY) + if @battle.isOccupied?(boardX, boardY) pbPlayBuzzerSE else pbPlayDecisionSE @@ -504,12 +504,12 @@ class TriadScene end end end - return [boardX,boardY] + return [boardX, boardY] end def pbEndPlaceCard(position, cardIndex) spriteIndex = @cardIndexes[cardIndex] - boardIndex = position[1]*@battle.width+position[0] + boardIndex = position[1] * @battle.width + position[0] @boardSprites[boardIndex] = @sprites["player#{spriteIndex}"] @boardCards[boardIndex] = TriadCard.new(@playerCards[spriteIndex]) pbRefresh @@ -521,12 +521,12 @@ class TriadScene y = 44 for i in 0...@opponentCardIndexes.length sprite = @sprites["opponent#{@opponentCardIndexes[i]}"] - if i==cardIndex + if i == cardIndex @opponentCardBitmaps[@opponentCardIndexes[i]] = triadCard.createBitmap(2) sprite.bitmap.dispose if sprite.bitmap sprite.bitmap = @opponentCardBitmaps[@opponentCardIndexes[i]] - sprite.x = Graphics.width/2 - 118 + position[0]*78 - sprite.y = 36 + position[1]*94 + sprite.x = Graphics.width / 2 - 118 + position[0] * 78 + sprite.y = 36 + position[1] * 94 sprite.z = 2 else sprite.x = 12 @@ -539,7 +539,7 @@ class TriadScene def pbEndOpponentPlaceCard(position, cardIndex) spriteIndex = @opponentCardIndexes[cardIndex] - boardIndex = position[1]*@battle.width+position[0] + boardIndex = position[1] * @battle.width + position[0] @boardSprites[boardIndex] = @sprites["opponent#{spriteIndex}"] @boardCards[boardIndex] = TriadCard.new(@opponentCards[spriteIndex]) pbRefresh @@ -548,11 +548,11 @@ class TriadScene end def pbRefresh - for i in 0...@battle.width*@battle.height - x = i%@battle.width - y = i/@battle.width + for i in 0...@battle.width * @battle.height + x = i % @battle.width + y = i / @battle.width if @boardSprites[i] - owner = @battle.getOwner(x,y) + owner = @battle.getOwner(x, y) @boardSprites[i].bitmap.dispose if @boardSprites[i].bitmap @boardSprites[i].bitmap = @boardCards[i].createBitmap(owner) end @@ -564,18 +564,18 @@ class TriadScene bitmap.clear playerscore = 0 oppscore = 0 - for i in 0...@battle.width*@battle.height + for i in 0...@battle.width * @battle.height if @boardSprites[i] - playerscore += 1 if @battle.board[i].owner==1 - oppscore += 1 if @battle.board[i].owner==2 + playerscore += 1 if @battle.board[i].owner == 1 + oppscore += 1 if @battle.board[i].owner == 2 end end if @battle.countUnplayedCards playerscore += @cardIndexes.length oppscore += @opponentCardIndexes.length end - pbDrawTextPositions(bitmap,[ - [_INTL("{1}-{2}",oppscore,playerscore),Graphics.width/2,-2,2,Color.new(248,248,248),Color.new(96,96,96)] + pbDrawTextPositions(bitmap, [ + [_INTL("{1}-{2}", oppscore, playerscore), Graphics.width / 2, -2, 2, Color.new(248, 248, 248), Color.new(96, 96, 96)] ]) end @@ -610,32 +610,32 @@ class TriadScreen end def maxCards - numcards = @width*@height - if numcards%2 == 1 - numcards = numcards/2+1 + numcards = @width * @height + if numcards % 2 == 1 + numcards = numcards / 2 + 1 else - numcards = numcards/2 + numcards = numcards / 2 end return numcards end - def isOccupied?(x,y) - return @board[y*@width+x].owner!=0 + def isOccupied?(x, y) + return @board[y * @width + x].owner != 0 end - def getOwner(x,y) - return @board[y*@width+x].owner + def getOwner(x, y) + return @board[y * @width + x].owner end - def getPanel(x,y) - return @board[y*@width+x] + def getPanel(x, y) + return @board[y * @width + x] end - def quantity(items,item) + def quantity(items, item) return ItemStorageHelper.quantity(items, item) end - def pbAdd(items,item) + def pbAdd(items, item) return ItemStorageHelper.add(items, $PokemonGlobal.triads.maxSize, TriadStorage::MAX_PER_SLOT, item, 1) end @@ -644,28 +644,28 @@ class TriadScreen return ItemStorageHelper.remove(items, item, 1) end - def flipBoard(x,y,attackerParam = nil,recurse = false) - panels = [x-1,y,x+1,y,x,y-1,x,y+1] - panels[0] = (@wrapAround ? @width-1 : 0) if panels[0]<0 # left - panels[2] = (@wrapAround ? 0 : @width-1) if panels[2]>@width-1 # right - panels[5] = (@wrapAround ? @height-1 : 0) if panels[5]<0 # top - panels[7] = (@wrapAround ? 0 : @height-1) if panels[7]>@height-1 # bottom - attacker = attackerParam!=nil ? attackerParam : @board[y*@width+x] + def flipBoard(x, y, attackerParam = nil, recurse = false) + panels = [x - 1, y, x + 1, y, x, y - 1, x, y + 1] + panels[0] = (@wrapAround ? @width - 1 : 0) if panels[0] < 0 # left + panels[2] = (@wrapAround ? 0 : @width - 1) if panels[2] > @width - 1 # right + panels[5] = (@wrapAround ? @height - 1 : 0) if panels[5] < 0 # top + panels[7] = (@wrapAround ? 0 : @height - 1) if panels[7] > @height - 1 # bottom + attacker = attackerParam != nil ? attackerParam : @board[y * @width + x] flips = [] - return nil if attackerParam!=nil && @board[y*@width+x].owner!=0 - return nil if !attacker.card || attacker.owner==0 + return nil if attackerParam != nil && @board[y * @width + x].owner != 0 + return nil if !attacker.card || attacker.owner == 0 for i in 0...4 - defenderX = panels[i*2] - defenderY = panels[i*2+1] - defender = @board[defenderY*@width+defenderX] + defenderX = panels[i * 2] + defenderY = panels[i * 2 + 1] + defender = @board[defenderY * @width + defenderX] next if !defender.card - if attacker.owner!=defender.owner + if attacker.owner != defender.owner attack = attacker.attack(i) defense = defender.defense(i) if @elements # If attacker's type matches the tile's element, add # a bonus of 1 (only for original attacker, not combos) - attack += 1 if !recurse && attacker.type==attacker.card.type + attack += 1 if !recurse && attacker.type == attacker.card.type else # Modifier depends on opponent's Pokémon type: # +1 - Super effective @@ -673,19 +673,19 @@ class TriadScreen # -2 - Immune # attack += attacker.bonus(defender) end - if attack>defense || (attack==defense && @sameWins) - flips.push([defenderX,defenderY]) - if attackerParam==nil + if attack > defense || (attack == defense && @sameWins) + flips.push([defenderX, defenderY]) + if attackerParam == nil defender.owner = attacker.owner if @sameWins # Combo with the "sameWins" rule - ret = flipBoard(defenderX,defenderY,nil,true) + ret = flipBoard(defenderX, defenderY, nil, true) flips.concat(ret) if ret end else if @sameWins # Combo with the "sameWins" rule - ret = flipBoard(defenderX,defenderY,attackerParam,true) + ret = flipBoard(defenderX, defenderY, attackerParam, true) flips.concat(ret) if ret end end @@ -697,21 +697,21 @@ class TriadScreen # If pbStartScreen includes parameters, it should # pass the parameters to pbStartScene. - def pbStartScreen(opponentName,minLevel,maxLevel,rules = nil,oppdeck = nil,prize = nil) - raise _INTL("Minimum level must be 0 through 9.") if minLevel<0 || minLevel>9 - raise _INTL("Maximum level must be 0 through 9.") if maxLevel<0 || maxLevel>9 - raise _INTL("Maximum level shouldn't be less than the minimum level.") if maxLevel0 + def pbStartScreen(opponentName, minLevel, maxLevel, rules = nil, oppdeck = nil, prize = nil) + raise _INTL("Minimum level must be 0 through 9.") if minLevel < 0 || minLevel > 9 + raise _INTL("Maximum level must be 0 through 9.") if maxLevel < 0 || maxLevel > 9 + raise _INTL("Maximum level shouldn't be less than the minimum level.") if maxLevel < minLevel + if rules && rules.is_a?(Array) && rules.length > 0 for rule in rules - @sameWins = true if rule=="samewins" - @openHand = true if rule=="openhand" - @wrapAround = true if rule=="wrap" - @elements = true if rule=="elements" - @randomHand = true if rule=="randomhand" - @countUnplayedCards = true if rule=="countunplayed" - @trade = 1 if rule=="direct" - @trade = 2 if rule=="winall" - @trade = 3 if rule=="noprize" + @sameWins = true if rule == "samewins" + @openHand = true if rule == "openhand" + @wrapAround = true if rule == "wrap" + @elements = true if rule == "elements" + @randomHand = true if rule == "randomhand" + @countUnplayedCards = true if rule == "countunplayed" + @trade = 1 if rule == "direct" + @trade = 2 if rule == "winall" + @trade = 3 if rule == "noprize" end end @triadCards = [] @@ -726,7 +726,7 @@ class TriadScreen @playerName = $player ? $player.name : "Trainer" @opponentName = opponentName type_keys = GameData::Type.keys - for i in 0...@width*@height + for i in 0...@width * @height square = TriadSquare.new if @elements loop do @@ -741,7 +741,7 @@ class TriadScreen end @scene.pbStartScene(self) # (param1, param2) # Check whether there are enough cards. - if count b[1] } + candidates.sort! { |a, b| a[1] <=> b[1] } opponentCards = [] self.maxCards.times do # Choose random card from candidates based on trainer's level @@ -797,13 +797,13 @@ class TriadScreen end originalCards = cards.clone originalOpponentCards = opponentCards.clone - @scene.pbNotifyCards(cards.clone,opponentCards.clone) + @scene.pbNotifyCards(cards.clone, opponentCards.clone) @scene.pbShowOpponentCards(opponentCards) @scene.pbDisplay(_INTL("Choosing the starting player...")) @scene.pbUpdateScore playerTurn = (rand(2) == 0) @scene.pbDisplay(_INTL("{1} will go first.", (playerTurn) ? @playerName : @opponentName)) - for i in 0...@width*@height + for i in 0...@width * @height position = nil triadCard = nil cardIndex = 0 @@ -816,65 +816,65 @@ class TriadScreen end else # Opponent's turn - @scene.pbDisplay(_INTL("{1} is making a move...",@opponentName)) + @scene.pbDisplay(_INTL("{1} is making a move...", @opponentName)) scores = [] for cardIndex in 0...opponentCards.length square = TriadSquare.new square.card = TriadCard.new(opponentCards[cardIndex]) square.owner = 2 - for i in 0...@width*@height + for i in 0...@width * @height x = i % @width y = i / @width square.type = @board[i].type - flips = flipBoard(x,y,square) - if flips!=nil - scores.push([cardIndex,x,y,flips.length]) + flips = flipBoard(x, y, square) + if flips != nil + scores.push([cardIndex, x, y, flips.length]) end end end # Sort by number of flips - scores.sort! { |a,b| (b[3]==a[3]) ? rand(3)-1 : b[3]<=>a[3] } - scores = scores[0,opponentCards.length] # Get the best results - if scores.length==0 - @scene.pbDisplay(_INTL("{1} can't move somehow...",@opponentName)) + scores.sort! { |a, b| (b[3] == a[3]) ? rand(3) - 1 : b[3] <=> a[3] } + scores = scores[0, opponentCards.length] # Get the best results + if scores.length == 0 + @scene.pbDisplay(_INTL("{1} can't move somehow...", @opponentName)) playerTurn = !playerTurn continue end result = scores[rand(scores.length)] cardIndex = result[0] triadCard = TriadCard.new(opponentCards[cardIndex]) - position = [result[1],result[2]] - @scene.pbOpponentPlaceCard(triadCard,position,cardIndex) + position = [result[1], result[2]] + @scene.pbOpponentPlaceCard(triadCard, position, cardIndex) end - boardIndex = position[1]*@width+position[0] + boardIndex = position[1] * @width + position[0] board[boardIndex].card = triadCard board[boardIndex].owner = playerTurn ? 1 : 2 - flipBoard(position[0],position[1]) + flipBoard(position[0], position[1]) if playerTurn cards.delete_at(cardIndex) - @scene.pbEndPlaceCard(position,cardIndex) + @scene.pbEndPlaceCard(position, cardIndex) else opponentCards.delete_at(cardIndex) - @scene.pbEndOpponentPlaceCard(position,cardIndex) + @scene.pbEndOpponentPlaceCard(position, cardIndex) end playerTurn = !playerTurn end # Determine the winner playerCount = 0 opponentCount = 0 - for i in 0...@width*@height - playerCount += 1 if board[i].owner==1 - opponentCount += 1 if board[i].owner==2 + for i in 0...@width * @height + playerCount += 1 if board[i].owner == 1 + opponentCount += 1 if board[i].owner == 2 end if @countUnplayedCards playerCount += cards.length opponentCount += opponentCards.length end result = 0 - if playerCount==opponentCount + if playerCount == opponentCount @scene.pbDisplayPaused(_INTL("The game is a draw.")) result = 3 - if @trade==1 + if @trade == 1 # Keep only cards of your color for card in originalCards $PokemonGlobal.triads.remove(card) @@ -882,16 +882,16 @@ class TriadScreen for i in cards $PokemonGlobal.triads.add(i) end - for i in 0...@width*@height - if board[i].owner==1 + for i in 0...@width * @height + if board[i].owner == 1 card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id $PokemonGlobal.triads.add(card) end end @scene.pbDisplayPaused(_INTL("Kept all cards of your color.")) end - elsif playerCount>opponentCount - @scene.pbDisplayPaused(_INTL("{1} won against {2}.",@playerName,@opponentName)) + elsif playerCount > opponentCount + @scene.pbDisplayPaused(_INTL("{1} won against {2}.", @playerName, @opponentName)) result = 1 if prize species_data = GameData::Species.try_get(prize) @@ -904,7 +904,7 @@ class TriadScreen card = originalOpponentCards[rand(originalOpponentCards.length)] if $PokemonGlobal.triads.add(card) cardname = GameData::Species.get(card).name - @scene.pbDisplayPaused(_INTL("Got opponent's {1} card.",cardname)) + @scene.pbDisplayPaused(_INTL("Got opponent's {1} card.", cardname)) end when 1 # Keep only cards of your color for card in originalCards @@ -913,8 +913,8 @@ class TriadScreen for i in cards $PokemonGlobal.triads.add(i) end - for i in 0...@width*@height - if board[i].owner==1 + for i in 0...@width * @height + if board[i].owner == 1 card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id $PokemonGlobal.triads.add(card) end @@ -928,14 +928,14 @@ class TriadScreen end end else - @scene.pbDisplayPaused(_INTL("{1} lost against {2}.",@playerName,@opponentName)) + @scene.pbDisplayPaused(_INTL("{1} lost against {2}.", @playerName, @opponentName)) result = 2 case @trade when 0 # Lose 1 random card from your deck card = originalCards[rand(originalCards.length)] $PokemonGlobal.triads.remove(card) cardname = GameData::Species.get(card).name - @scene.pbDisplayPaused(_INTL("Opponent won your {1} card.",cardname)) + @scene.pbDisplayPaused(_INTL("Opponent won your {1} card.", cardname)) when 1 # Keep only cards of your color for card in originalCards $PokemonGlobal.triads.remove(card) @@ -943,13 +943,13 @@ class TriadScreen for i in cards $PokemonGlobal.triads.add(i) end - for i in 0...@width*@height - if board[i].owner==1 + for i in 0...@width * @height + if board[i].owner == 1 card = GameData::Species.get_species_form(board[i].card.species, board[i].card.form).id $PokemonGlobal.triads.add(card) end end - @scene.pbDisplayPaused(_INTL("Kept all cards of your color.",cardname)) + @scene.pbDisplayPaused(_INTL("Kept all cards of your color.", cardname)) when 2 # Lose all your cards for card in originalCards $PokemonGlobal.triads.remove(card) @@ -967,12 +967,12 @@ end #=============================================================================== # Start duel #=============================================================================== -def pbTriadDuel(name,minLevel,maxLevel,rules = nil,oppdeck = nil,prize = nil) +def pbTriadDuel(name, minLevel, maxLevel, rules = nil, oppdeck = nil, prize = nil) ret = 0 pbFadeOutInWithMusic { scene = TriadScene.new screen = TriadScreen.new(scene) - ret = screen.pbStartScreen(name,minLevel,maxLevel,rules,oppdeck,prize) + ret = screen.pbStartScreen(name, minLevel, maxLevel, rules, oppdeck, prize) } return ret end @@ -1072,18 +1072,18 @@ def pbBuyTriads realcommands.push(command[2]) end # Scroll right before showing screen - pbScrollMap(4,3,5) - cmdwindow = Window_CommandPokemonEx.newWithSize(realcommands,0,0,Graphics.width/2,Graphics.height) + pbScrollMap(4, 3, 5) + cmdwindow = Window_CommandPokemonEx.newWithSize(realcommands, 0, 0, Graphics.width / 2, Graphics.height) cmdwindow.z = 99999 goldwindow = Window_UnformattedTextPokemon.newWithSize( - _INTL("Money:\r\n{1}",pbGetGoldString),0,0,32,32) - goldwindow.resizeToFit(goldwindow.text,Graphics.width) - goldwindow.x = Graphics.width-goldwindow.width + _INTL("Money:\r\n{1}", pbGetGoldString), 0, 0, 32, 32) + goldwindow.resizeToFit(goldwindow.text, Graphics.width) + goldwindow.x = Graphics.width - goldwindow.width goldwindow.y = 0 goldwindow.z = 99999 preview = Sprite.new - preview.x = Graphics.width*3/4-40 - preview.y = Graphics.height/2-48 + preview.x = Graphics.width * 3 / 4 - 40 + preview.y = Graphics.height / 2 - 48 preview.z = 4 preview.bitmap = TriadCard.new(commands[cmdwindow.index][3]).createBitmap(1) olditem = commands[cmdwindow.index][3] @@ -1094,7 +1094,7 @@ def pbBuyTriads cmdwindow.active = true cmdwindow.update goldwindow.update - if commands[cmdwindow.index][3]!=olditem + if commands[cmdwindow.index][3] != olditem preview.bitmap.dispose if preview.bitmap preview.bitmap = TriadCard.new(commands[cmdwindow.index][3]).createBitmap(1) olditem = commands[cmdwindow.index][3] @@ -1107,22 +1107,22 @@ def pbBuyTriads itemname = commands[cmdwindow.index][1] cmdwindow.active = false cmdwindow.update - if $player.money99 + maxafford = (price <= 0) ? 99 : $player.money / price + maxafford = 99 if maxafford > 99 params = ChooseNumberParams.new - params.setRange(1,maxafford) + params.setRange(1, maxafford) params.setInitialValue(1) params.setCancelValue(0) quantity = pbMessageChooseNumber( - _INTL("The {1} card? Certainly. How many would you like?",itemname),params) - next if quantity<=0 + _INTL("The {1} card? Certainly. How many would you like?", itemname), params) + next if quantity <= 0 price *= quantity - next if !pbConfirmMessage(_INTL("{1}, and you want {2}. That will be ${3}. OK?",itemname,quantity,price.to_s_formatted)) - if $player.money=$PokemonGlobal.triads.length + if cmdwindow.index >= $PokemonGlobal.triads.length done = true break end @@ -1204,33 +1204,33 @@ def pbSellTriads itemname = GameData::Species.get(item).name quantity = $PokemonGlobal.triads.quantity(item) price = TriadCard.new(item).price - if price==0 - pbDisplayPaused(_INTL("The {1} card? Oh, no. I can't buy that.",itemname)) + if price == 0 + pbDisplayPaused(_INTL("The {1} card? Oh, no. I can't buy that.", itemname)) break end cmdwindow.active = false cmdwindow.update - if quantity>1 + if quantity > 1 params = ChooseNumberParams.new - params.setRange(1,quantity) + params.setRange(1, quantity) params.setInitialValue(1) params.setCancelValue(0) quantity = pbMessageChooseNumber( - _INTL("The {1} card? How many would you like to sell?",itemname),params) + _INTL("The {1} card? How many would you like to sell?", itemname), params) end - if quantity>0 + if quantity > 0 price /= 4 price *= quantity - if pbConfirmMessage(_INTL("I can pay ${1}. Would that be OK?",price.to_s_formatted)) + if pbConfirmMessage(_INTL("I can pay ${1}. Would that be OK?", price.to_s_formatted)) $player.money += price - goldwindow.text = _INTL("Money:\r\n{1}",pbGetGoldString) - $PokemonGlobal.triads.remove(item,quantity) - pbMessage(_INTL("Turned over the {1} card and received ${2}.\\se[Mart buy item]",itemname,price.to_s_formatted)) + goldwindow.text = _INTL("Money:\r\n{1}", pbGetGoldString) + $PokemonGlobal.triads.remove(item, quantity) + pbMessage(_INTL("Turned over the {1} card and received ${2}.\\se[Mart buy item]", itemname, price.to_s_formatted)) commands = [] for i in 0...$PokemonGlobal.triads.length item = $PokemonGlobal.triads[i] speciesname = GameData::Species.get(item[0]).name - commands.push(_INTL("{1} x{2}",speciesname,item[1])) + commands.push(_INTL("{1} x{2}", speciesname, item[1])) end commands.push(_INTL("CANCEL")) cmdwindow.commands = commands @@ -1246,7 +1246,7 @@ def pbSellTriads preview.dispose Graphics.frame_reset # Scroll right before showing screen - pbScrollMap(6,3,5) + pbScrollMap(6, 3, 5) end def pbTriadList @@ -1254,17 +1254,17 @@ def pbTriadList for i in 0...$PokemonGlobal.triads.length item = $PokemonGlobal.triads[i] speciesname = GameData::Species.get(item[0]).name - commands.push(_INTL("{1} x{2}",speciesname,item[1])) + commands.push(_INTL("{1} x{2}", speciesname, item[1])) end commands.push(_INTL("CANCEL")) - if commands.length==1 + if commands.length == 1 pbMessage(_INTL("You have no cards.")) return end - cmdwindow = Window_CommandPokemonEx.newWithSize(commands,0,0,Graphics.width/2,Graphics.height) + cmdwindow = Window_CommandPokemonEx.newWithSize(commands, 0, 0, Graphics.width / 2, Graphics.height) cmdwindow.z = 99999 sprite = Sprite.new - sprite.x = Graphics.width/2+40 + sprite.x = Graphics.width / 2 + 40 sprite.y = 48 sprite.z = 99999 done = false @@ -1274,9 +1274,9 @@ def pbTriadList Graphics.update Input.update cmdwindow.update - if lastIndex!=cmdwindow.index + if lastIndex != cmdwindow.index sprite.bitmap.dispose if sprite.bitmap - if cmdwindow.index<$PokemonGlobal.triads.length + if cmdwindow.index < $PokemonGlobal.triads.length sprite.bitmap = TriadCard.new($PokemonGlobal.triads.get_item(cmdwindow.index)).createBitmap(1) end lastIndex = cmdwindow.index @@ -1286,7 +1286,7 @@ def pbTriadList break end if Input.trigger?(Input::USE) - if cmdwindow.index>=$PokemonGlobal.triads.length + if cmdwindow.index >= $PokemonGlobal.triads.length done = true break end diff --git a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb index ef9faad8c..49b4de928 100644 --- a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb +++ b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb @@ -13,45 +13,45 @@ class SlotMachineReel < BitmapSprite attr_accessor :slipping SCROLLSPEED = 16 # Must be a divisor of 48 - ICONSPOOL = [[0,0,0,0,1,1,2,2,3,3,3,4,4,4,5,5,6,6,7], # 0 - Easy - [0,0,0,0,1,1,1,2,2,2,3,3,4,4,5,6,7], # 1 - Medium (default) - [0,0,1,1,1,2,2,2,3,3,4,4,5,6,7]] # 2 - Hard - SLIPPING = [0,0,0,0,0,0,1,1,1,2,2,3] + ICONSPOOL = [[0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7], # 0 - Easy + [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7], # 1 - Medium (default) + [0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7]] # 2 - Hard + SLIPPING = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3] - def initialize(x,y,difficulty = 1) - @viewport=Viewport.new(x,y,64,144) - @viewport.z=99999 - super(64,144,@viewport) - @reel=[] + def initialize(x, y, difficulty = 1) + @viewport = Viewport.new(x, y, 64, 144) + @viewport.z = 99999 + super(64, 144, @viewport) + @reel = [] for i in 0...ICONSPOOL[difficulty].length @reel.push(ICONSPOOL[difficulty][i]) end @reel.shuffle! - @toppos=0 - @spinning=false - @stopping=false - @slipping=0 - @index=rand(@reel.length) - @images=AnimatedBitmap.new(_INTL("Graphics/Pictures/Slot Machine/images")) - @shading=AnimatedBitmap.new(_INTL("Graphics/Pictures/Slot Machine/ReelOverlay")) + @toppos = 0 + @spinning = false + @stopping = false + @slipping = 0 + @index = rand(@reel.length) + @images = AnimatedBitmap.new(_INTL("Graphics/Pictures/Slot Machine/images")) + @shading = AnimatedBitmap.new(_INTL("Graphics/Pictures/Slot Machine/ReelOverlay")) update end def startSpinning - @spinning=true + @spinning = true end def stopSpinning(noslipping = false) - @stopping=true - @slipping=SLIPPING[rand(SLIPPING.length)] - @slipping=0 if noslipping + @stopping = true + @slipping = SLIPPING[rand(SLIPPING.length)] + @slipping = 0 if noslipping end def showing - array=[] + array = [] for i in 0...3 - num=@index-i - num+=@reel.length if num<0 + num = @index - i + num += @reel.length if num < 0 array.push(@reel[num]) end return array # [0] = top, [1] = middle, [2] = bottom @@ -59,23 +59,23 @@ class SlotMachineReel < BitmapSprite def update self.bitmap.clear - if @toppos==0 && @stopping && @slipping==0 - @spinning=@stopping=false + if @toppos == 0 && @stopping && @slipping == 0 + @spinning = @stopping = false end if @spinning - @toppos+=SCROLLSPEED - if @toppos>0 - @toppos-=48 - @index=(@index+1)%@reel.length - @slipping-=1 if @slipping>0 + @toppos += SCROLLSPEED + if @toppos > 0 + @toppos -= 48 + @index = (@index + 1) % @reel.length + @slipping -= 1 if @slipping > 0 end end for i in 0...4 - num=@index-i - num+=@reel.length if num<0 - self.bitmap.blt(0,@toppos+i*48,@images.bitmap,Rect.new(@reel[num]*64,0,64,48)) + num = @index - i + num += @reel.length if num < 0 + self.bitmap.blt(0, @toppos + i * 48, @images.bitmap, Rect.new(@reel[num] * 64, 0, 64, 48)) end - self.bitmap.blt(0,0,@shading.bitmap,Rect.new(0,0,64,144)) + self.bitmap.blt(0, 0, @shading.bitmap, Rect.new(0, 0, 64, 144)) end end @@ -84,12 +84,12 @@ end class SlotMachineScore < BitmapSprite attr_reader :score - def initialize(x,y,score = 0) - @viewport=Viewport.new(x,y,70,22) - @viewport.z=99999 - super(70,22,@viewport) - @numbers=AnimatedBitmap.new(_INTL("Graphics/Pictures/Slot Machine/numbers")) - self.score=score + def initialize(x, y, score = 0) + @viewport = Viewport.new(x, y, 70, 22) + @viewport.z = 99999 + super(70, 22, @viewport) + @numbers = AnimatedBitmap.new(_INTL("Graphics/Pictures/Slot Machine/numbers")) + self.score = score end def score=(value) @@ -101,8 +101,8 @@ class SlotMachineScore < BitmapSprite def refresh self.bitmap.clear for i in 0...5 - digit=(@score/(10**i))%10 # Least significant digit first - self.bitmap.blt(14*(4-i),0,@numbers.bitmap,Rect.new(digit*14,0,14,22)) + digit = (@score / (10**i)) % 10 # Least significant digit first + self.bitmap.blt(14 * (4 - i), 0, @numbers.bitmap, Rect.new(digit * 14, 0, 14, 22)) end end end @@ -120,92 +120,92 @@ class SlotMachineScene end def pbPayout - @replay=false - payout=0 - bonus=0 - wonRow=[] + @replay = false + payout = 0 + bonus = 0 + wonRow = [] # Get reel pictures - reel1=@sprites["reel1"].showing - reel2=@sprites["reel2"].showing - reel3=@sprites["reel3"].showing - combinations=[[reel1[1],reel2[1],reel3[1]], # Centre row - [reel1[0],reel2[0],reel3[0]], # Top row - [reel1[2],reel2[2],reel3[2]], # Bottom row - [reel1[0],reel2[1],reel3[2]], # Diagonal top left -> bottom right - [reel1[2],reel2[1],reel3[0]]] # Diagonal bottom left -> top right + reel1 = @sprites["reel1"].showing + reel2 = @sprites["reel2"].showing + reel3 = @sprites["reel3"].showing + combinations = [[reel1[1], reel2[1], reel3[1]], # Centre row + [reel1[0], reel2[0], reel3[0]], # Top row + [reel1[2], reel2[2], reel3[2]], # Bottom row + [reel1[0], reel2[1], reel3[2]], # Diagonal top left -> bottom right + [reel1[2], reel2[1], reel3[0]]] # Diagonal bottom left -> top right for i in 0...combinations.length - break if i>=1 && @wager<=1 # One coin = centre row only - break if i>=3 && @wager<=2 # Two coins = three rows only - wonRow[i]=true + break if i >= 1 && @wager <= 1 # One coin = centre row only + break if i >= 3 && @wager <= 2 # Two coins = three rows only + wonRow[i] = true case combinations[i] - when [1,1,1] # Three Magnemites + when [1, 1, 1] # Three Magnemites payout += 8 - when [2,2,2] # Three Shellders + when [2, 2, 2] # Three Shellders payout += 8 - when [3,3,3] # Three Pikachus + when [3, 3, 3] # Three Pikachus payout += 15 - when [4,4,4] # Three Psyducks + when [4, 4, 4] # Three Psyducks payout += 15 - when [5,5,6], [5,6,5], [6,5,5], [6,6,5], [6,5,6], [5,6,6] # 777 multi-colored + when [5, 5, 6], [5, 6, 5], [6, 5, 5], [6, 6, 5], [6, 5, 6], [5, 6, 6] # 777 multi-colored payout += 90 - bonus = 1 if bonus<1 - when [5,5,5], [6,6,6] # Red 777, blue 777 + bonus = 1 if bonus < 1 + when [5, 5, 5], [6, 6, 6] # Red 777, blue 777 payout += 300 - bonus = 2 if bonus<2 - when [7,7,7] # Three replays + bonus = 2 if bonus < 2 + when [7, 7, 7] # Three replays @replay = true else - if combinations[i][0]==0 # Left cherry - if combinations[i][1]==0 # Centre cherry as well - payout+=4 + if combinations[i][0] == 0 # Left cherry + if combinations[i][1] == 0 # Centre cherry as well + payout += 4 else - payout+=2 + payout += 2 end else - wonRow[i]=false + wonRow[i] = false end end end - @sprites["payout"].score=payout - frame=0 - if payout>0 || @replay - if bonus>0 + @sprites["payout"].score = payout + frame = 0 + if payout > 0 || @replay + if bonus > 0 pbMEPlay("Slots big win") else pbMEPlay("Slots win") end # Show winning animation - timePerFrame = Graphics.frame_rate/8 - until frame==Graphics.frame_rate*3 + timePerFrame = Graphics.frame_rate / 8 + until frame == Graphics.frame_rate * 3 Graphics.update Input.update update @sprites["window2"].bitmap.clear if @sprites["window2"].bitmap @sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/win")) - @sprites["window1"].src_rect.set(152*((frame/timePerFrame)%4),0,152,208) - if bonus>0 + @sprites["window1"].src_rect.set(152 * ((frame / timePerFrame) % 4), 0, 152, 208) + if bonus > 0 @sprites["window2"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/bonus")) - @sprites["window2"].src_rect.set(152*(bonus-1),0,152,208) + @sprites["window2"].src_rect.set(152 * (bonus - 1), 0, 152, 208) end - @sprites["light1"].visible=true - @sprites["light1"].src_rect.set(0,26*((frame/timePerFrame)%4),96,26) - @sprites["light2"].visible=true - @sprites["light2"].src_rect.set(0,26*((frame/timePerFrame)%4),96,26) + @sprites["light1"].visible = true + @sprites["light1"].src_rect.set(0, 26 * ((frame / timePerFrame) % 4), 96, 26) + @sprites["light2"].visible = true + @sprites["light2"].src_rect.set(0, 26 * ((frame / timePerFrame) % 4), 96, 26) for i in 1..5 - if wonRow[i-1] - @sprites["row#{i}"].visible = ((frame/timePerFrame)%2)==0 + if wonRow[i - 1] + @sprites["row#{i}"].visible = ((frame / timePerFrame) % 2) == 0 else @sprites["row#{i}"].visible = false end end frame += 1 end - @sprites["light1"].visible=false - @sprites["light2"].visible=false - @sprites["window1"].src_rect.set(0,0,152,208) + @sprites["light1"].visible = false + @sprites["light2"].visible = false + @sprites["window1"].src_rect.set(0, 0, 152, 208) # Pay out loop do - break if @sprites["payout"].score<=0 + break if @sprites["payout"].score <= 0 Graphics.update Input.update update @@ -216,21 +216,21 @@ class SlotMachineScene @sprites["payout"].score = 0 end end - (Graphics.frame_rate/2).times do + (Graphics.frame_rate / 2).times do Graphics.update Input.update update end else # Show losing animation - timePerFrame = Graphics.frame_rate/4 - until frame==Graphics.frame_rate*2 + timePerFrame = Graphics.frame_rate / 4 + until frame == Graphics.frame_rate * 2 Graphics.update Input.update update @sprites["window2"].bitmap.clear if @sprites["window2"].bitmap @sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/lose")) - @sprites["window1"].src_rect.set(152*((frame/timePerFrame)%2),0,152,208) + @sprites["window1"].src_rect.set(152 * ((frame / timePerFrame) % 2), 0, 152, 208) frame += 1 end end @@ -238,47 +238,47 @@ class SlotMachineScene end def pbStartScene(difficulty) - @sprites={} - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 - addBackgroundPlane(@sprites,"bg","Slot Machine/bg",@viewport) - @sprites["reel1"]=SlotMachineReel.new(64,112,difficulty) - @sprites["reel2"]=SlotMachineReel.new(144,112,difficulty) - @sprites["reel3"]=SlotMachineReel.new(224,112,difficulty) + @sprites = {} + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 + addBackgroundPlane(@sprites, "bg", "Slot Machine/bg", @viewport) + @sprites["reel1"] = SlotMachineReel.new(64, 112, difficulty) + @sprites["reel2"] = SlotMachineReel.new(144, 112, difficulty) + @sprites["reel3"] = SlotMachineReel.new(224, 112, difficulty) for i in 1..3 - @sprites["button#{i}"]=IconSprite.new(68+80*(i-1),260,@viewport) + @sprites["button#{i}"] = IconSprite.new(68 + 80 * (i - 1), 260, @viewport) @sprites["button#{i}"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/button")) - @sprites["button#{i}"].visible=false + @sprites["button#{i}"].visible = false end for i in 1..5 - y=[170,122,218,82,82][i-1] - @sprites["row#{i}"]=IconSprite.new(2,y,@viewport) + y = [170, 122, 218, 82, 82][i - 1] + @sprites["row#{i}"] = IconSprite.new(2, y, @viewport) @sprites["row#{i}"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/line%1d%s", - 1+i/2,(i>=4) ? ((i==4) ? "a" : "b") : "")) - @sprites["row#{i}"].visible=false + 1 + i / 2, (i >= 4) ? ((i == 4) ? "a" : "b") : "")) + @sprites["row#{i}"].visible = false end - @sprites["light1"]=IconSprite.new(16,32,@viewport) + @sprites["light1"] = IconSprite.new(16, 32, @viewport) @sprites["light1"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/lights")) - @sprites["light1"].visible=false - @sprites["light2"]=IconSprite.new(240,32,@viewport) + @sprites["light1"].visible = false + @sprites["light2"] = IconSprite.new(240, 32, @viewport) @sprites["light2"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/lights")) - @sprites["light2"].mirror=true - @sprites["light2"].visible=false - @sprites["window1"]=IconSprite.new(358,96,@viewport) + @sprites["light2"].mirror = true + @sprites["light2"].visible = false + @sprites["window1"] = IconSprite.new(358, 96, @viewport) @sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/insert")) - @sprites["window1"].src_rect.set(0,0,152,208) - @sprites["window2"]=IconSprite.new(358,96,@viewport) - @sprites["credit"]=SlotMachineScore.new(360,66,$player.coins) - @sprites["payout"]=SlotMachineScore.new(438,66,0) - @wager=0 + @sprites["window1"].src_rect.set(0, 0, 152, 208) + @sprites["window2"] = IconSprite.new(358, 96, @viewport) + @sprites["credit"] = SlotMachineScore.new(360, 66, $player.coins) + @sprites["payout"] = SlotMachineScore.new(438, 66, 0) + @wager = 0 update pbFadeInAndShow(@sprites) end def pbMain - frame=0 - spinFrameTime = Graphics.frame_rate/4 - insertFrameTime = Graphics.frame_rate*4/10 + frame = 0 + spinFrameTime = Graphics.frame_rate / 4 + insertFrameTime = Graphics.frame_rate * 4 / 10 loop do Graphics.update Input.update @@ -288,77 +288,77 @@ class SlotMachineScene if @sprites["credit"].score == Settings::MAX_COINS pbMessage(_INTL("You've got {1} Coins.", Settings::MAX_COINS.to_s_formatted)) break - elsif $player.coins==0 + elsif $player.coins == 0 pbMessage(_INTL("You've run out of Coins.\nGame over!")) break elsif @gameRunning # Reels are spinning @sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/stop")) - @sprites["window1"].src_rect.set(152*((frame/spinFrameTime)%4),0,152,208) + @sprites["window1"].src_rect.set(152 * ((frame / spinFrameTime) % 4), 0, 152, 208) if Input.trigger?(Input::USE) pbSEPlay("Slots stop") if @sprites["reel1"].spinning @sprites["reel1"].stopSpinning(@replay) - @sprites["button1"].visible=true + @sprites["button1"].visible = true elsif @sprites["reel2"].spinning @sprites["reel2"].stopSpinning(@replay) - @sprites["button2"].visible=true + @sprites["button2"].visible = true elsif @sprites["reel3"].spinning @sprites["reel3"].stopSpinning(@replay) - @sprites["button3"].visible=true + @sprites["button3"].visible = true end end if !@sprites["reel3"].spinning - @gameEnd=true - @gameRunning=false + @gameEnd = true + @gameRunning = false end elsif @gameEnd # Reels have been stopped pbPayout # Reset graphics - @sprites["button1"].visible=false - @sprites["button2"].visible=false - @sprites["button3"].visible=false + @sprites["button1"].visible = false + @sprites["button2"].visible = false + @sprites["button3"].visible = false for i in 1..5 - @sprites["row#{i}"].visible=false + @sprites["row#{i}"].visible = false end - @gameEnd=false + @gameEnd = false else # Awaiting coins for the next spin @sprites["window1"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/insert")) - @sprites["window1"].src_rect.set(152*((frame/insertFrameTime)%2),0,152,208) - if @wager>0 + @sprites["window1"].src_rect.set(152 * ((frame / insertFrameTime) % 2), 0, 152, 208) + if @wager > 0 @sprites["window2"].setBitmap(sprintf("Graphics/Pictures/Slot Machine/press")) - @sprites["window2"].src_rect.set(152*((frame/insertFrameTime)%2),0,152,208) + @sprites["window2"].src_rect.set(152 * ((frame / insertFrameTime) % 2), 0, 152, 208) end - if Input.trigger?(Input::DOWN) && @wager<3 && @sprites["credit"].score>0 + if Input.trigger?(Input::DOWN) && @wager < 3 && @sprites["credit"].score > 0 pbSEPlay("Slots coin") - @wager+=1 - @sprites["credit"].score-=1 - if @wager>=3 - @sprites["row5"].visible=true - @sprites["row4"].visible=true - elsif @wager>=2 - @sprites["row3"].visible=true - @sprites["row2"].visible=true - elsif @wager>=1 - @sprites["row1"].visible=true + @wager += 1 + @sprites["credit"].score -= 1 + if @wager >= 3 + @sprites["row5"].visible = true + @sprites["row4"].visible = true + elsif @wager >= 2 + @sprites["row3"].visible = true + @sprites["row2"].visible = true + elsif @wager >= 1 + @sprites["row1"].visible = true end - elsif @wager>=3 || (@wager>0 && @sprites["credit"].score==0) || - (Input.trigger?(Input::USE) && @wager>0) || @replay + elsif @wager >= 3 || (@wager > 0 && @sprites["credit"].score == 0) || + (Input.trigger?(Input::USE) && @wager > 0) || @replay if @replay - @wager=3 + @wager = 3 for i in 1..5 - @sprites["row#{i}"].visible=true + @sprites["row#{i}"].visible = true end end @sprites["reel1"].startSpinning @sprites["reel2"].startSpinning @sprites["reel3"].startSpinning - frame=0 - @gameRunning=true - elsif Input.trigger?(Input::BACK) && @wager==0 + frame = 0 + @gameRunning = true + elsif Input.trigger?(Input::BACK) && @wager == 0 break end end - frame = (frame+1)%(Graphics.frame_rate*4) + frame = (frame + 1) % (Graphics.frame_rate * 4) end old_coins = $player.coins $player.coins = @sprites["credit"].score @@ -380,7 +380,7 @@ end class SlotMachine def initialize(scene) - @scene=scene + @scene = scene end def pbStartScreen(difficulty) diff --git a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb index 8d233ce8f..4494a503c 100644 --- a/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb +++ b/Data/Scripts/017_Minigames/004_Minigame_VoltorbFlip.rb @@ -11,341 +11,341 @@ class VoltorbFlip def pbStart # Set initial level - @level=1 + @level = 1 # Maximum and minimum total point values for each level - @levelRanges=[[20, 50],[50, 100],[100, 200],[200, 350], - [350,600],[600,1000],[1000,2000],[2000,3500]] - @firstRound=true + @levelRanges = [[20, 50], [50, 100], [100, 200], [200, 350], + [350, 600], [600, 1000], [1000, 2000], [2000, 3500]] + @firstRound = true pbNewGame end def pbNewGame # Initialize variables - @sprites={} - @cursor=[] - @marks=[] - @coins=[] - @numbers=[] - @voltorbNumbers=[] - @points=0 - @index=[0,0] + @sprites = {} + @cursor = [] + @marks = [] + @coins = [] + @numbers = [] + @voltorbNumbers = [] + @points = 0 + @index = [0, 0] # [x,y,points,selected] - @squares=[0,0,0,false] - @directory="Graphics/Pictures/Voltorb Flip/" - squareValues=[] - total=1 - voltorbs=0 + @squares = [0, 0, 0, false] + @directory = "Graphics/Pictures/Voltorb Flip/" + squareValues = [] + total = 1 + voltorbs = 0 for i in 0...25 # Sets the value to 1 by default - squareValues[i]=1 + squareValues[i] = 1 # Sets the value to 0 (a voltorb) if # for that level hasn't been reached - if voltorbs < 5+@level - squareValues[i]=0 - voltorbs+=1 + if voltorbs < 5 + @level + squareValues[i] = 0 + voltorbs += 1 # Sets the value randomly to a 2 or 3 if the total is less than the max - elsif total<@levelRanges[@level-1][1] - squareValues[i]=rand(2)+2 - total*=squareValues[i] + elsif total < @levelRanges[@level - 1][1] + squareValues[i] = rand(2) + 2 + total *= squareValues[i] end - if total>(@levelRanges[@level-1][1]) + if total > (@levelRanges[@level - 1][1]) # Lowers value of square to 1 if over max - total/=squareValues[i] - squareValues[i]=1 + total /= squareValues[i] + squareValues[i] = 1 end end # Randomize the values a little for i in 0...25 - temp=squareValues[i] - if squareValues[i]>1 - if rand(10)>8 - total/=squareValues[i] - squareValues[i]-=1 - total*=squareValues[i] + temp = squareValues[i] + if squareValues[i] > 1 + if rand(10) > 8 + total /= squareValues[i] + squareValues[i] -= 1 + total *= squareValues[i] end end - if total<@levelRanges[@level-1][0] - if squareValues[i]>0 - total/=squareValues[i] - squareValues[i]=temp - total*=squareValues[i] + if total < @levelRanges[@level - 1][0] + if squareValues[i] > 0 + total /= squareValues[i] + squareValues[i] = temp + total *= squareValues[i] end end end # Populate @squares array for i in 0...25 - x=i if i%5==0 - r=rand(squareValues.length) - @squares[i]=[(i-x).abs*64+128,(i/5).abs*64,squareValues[r],false] + x = i if i % 5 == 0 + r = rand(squareValues.length) + @squares[i] = [(i - x).abs * 64 + 128, (i / 5).abs * 64, squareValues[r], false] squareValues.delete_at(r) end pbCreateSprites # Display numbers (all zeroes, as no values have been calculated yet) for i in 0...5 - pbUpdateRowNumbers(0,0,i) - pbUpdateColumnNumbers(0,0,i) + pbUpdateRowNumbers(0, 0, i) + pbUpdateColumnNumbers(0, 0, i) end - pbDrawShadowText(@sprites["text"].bitmap,8,16,118,26, - _INTL("Your coins"),Color.new(60,60,60),Color.new(150,190,170),1) - pbDrawShadowText(@sprites["text"].bitmap,8,82,118,26, - _INTL("Earned coins"),Color.new(60,60,60),Color.new(150,190,170),1) + pbDrawShadowText(@sprites["text"].bitmap, 8, 16, 118, 26, + _INTL("Your coins"), Color.new(60, 60, 60), Color.new(150, 190, 170), 1) + pbDrawShadowText(@sprites["text"].bitmap, 8, 82, 118, 26, + _INTL("Earned coins"), Color.new(60, 60, 60), Color.new(150, 190, 170), 1) # Draw current level - pbDrawShadowText(@sprites["level"].bitmap,8,150,118,28, - _INTL("Level {1}",@level.to_s),Color.new(60,60,60),Color.new(150,190,170),1) + pbDrawShadowText(@sprites["level"].bitmap, 8, 150, 118, 28, + _INTL("Level {1}", @level.to_s), Color.new(60, 60, 60), Color.new(150, 190, 170), 1) # Displays total and current coins pbUpdateCoins # Draw curtain effect if @firstRound - angleDiff = 10*20/Graphics.frame_rate + angleDiff = 10 * 20 / Graphics.frame_rate loop do @sprites["curtainL"].angle -= angleDiff @sprites["curtainR"].angle += angleDiff Graphics.update Input.update update - break if @sprites["curtainL"].angle<=-180 + break if @sprites["curtainL"].angle <= -180 end end - @sprites["curtainL"].visible=false - @sprites["curtainR"].visible=false - @sprites["curtain"].opacity=100 + @sprites["curtainL"].visible = false + @sprites["curtainR"].visible = false + @sprites["curtain"].opacity = 100 if $player.coins >= Settings::MAX_COINS pbMessage(_INTL("You've gathered {1} Coins. You cannot gather any more.", Settings::MAX_COINS.to_s_formatted)) $player.coins = Settings::MAX_COINS # As a precaution - @quit=true + @quit = true # elsif !pbConfirmMessage(_INTL("Play Voltorb Flip Lv. {1}?",@level)) && $player.coins0 - @index[1]-=1 - @sprites["cursor"].y-=64 + if @index[1] > 0 + @index[1] -= 1 + @sprites["cursor"].y -= 64 else - @index[1]=4 - @sprites["cursor"].y=256 + @index[1] = 4 + @sprites["cursor"].y = 256 end elsif Input.trigger?(Input::DOWN) pbPlayCursorSE - if @index[1]<4 - @index[1]+=1 - @sprites["cursor"].y+=64 + if @index[1] < 4 + @index[1] += 1 + @sprites["cursor"].y += 64 else - @index[1]=0 - @sprites["cursor"].y=0 + @index[1] = 0 + @sprites["cursor"].y = 0 end elsif Input.trigger?(Input::LEFT) pbPlayCursorSE - if @index[0]>0 - @index[0]-=1 - @sprites["cursor"].x-=64 + if @index[0] > 0 + @index[0] -= 1 + @sprites["cursor"].x -= 64 else - @index[0]=4 - @sprites["cursor"].x=256 + @index[0] = 4 + @sprites["cursor"].x = 256 end elsif Input.trigger?(Input::RIGHT) pbPlayCursorSE - if @index[0]<4 - @index[0]+=1 - @sprites["cursor"].x+=64 + if @index[0] < 4 + @index[0] += 1 + @sprites["cursor"].x += 64 else - @index[0]=0 - @sprites["cursor"].x=0 + @index[0] = 0 + @sprites["cursor"].x = 0 end elsif Input.trigger?(Input::USE) - if @cursor[0][3]==64 # If in mark mode + if @cursor[0][3] == 64 # If in mark mode for i in 0...@squares.length - if @index[0]*64+128==@squares[i][0] && @index[1]*64==@squares[i][1] && @squares[i][3]==false + if @index[0] * 64 + 128 == @squares[i][0] && @index[1] * 64 == @squares[i][1] && @squares[i][3] == false pbSEPlay("Voltorb Flip mark") end end - for i in 0...@marks.length+1 - if @marks[i]==nil - @marks[i]=[@directory+"tiles",@index[0]*64+128,@index[1]*64,256,0,64,64] - elsif @marks[i][1]==@index[0]*64+128 && @marks[i][2]==@index[1]*64 + for i in 0...@marks.length + 1 + if @marks[i] == nil + @marks[i] = [@directory + "tiles", @index[0] * 64 + 128, @index[1] * 64, 256, 0, 64, 64] + elsif @marks[i][1] == @index[0] * 64 + 128 && @marks[i][2] == @index[1] * 64 @marks.delete_at(i) @marks.compact! @sprites["mark"].bitmap.clear break end end - pbDrawImagePositions(@sprites["mark"].bitmap,@marks) - pbWait(Graphics.frame_rate/20) + pbDrawImagePositions(@sprites["mark"].bitmap, @marks) + pbWait(Graphics.frame_rate / 20) else # Display the tile for the selected spot - icons=[] + icons = [] for i in 0...@squares.length - if @index[0]*64+128==@squares[i][0] && @index[1]*64==@squares[i][1] && @squares[i][3]==false - pbAnimateTile(@index[0]*64+128,@index[1]*64,@squares[i][2]) - @squares[i][3]=true + if @index[0] * 64 + 128 == @squares[i][0] && @index[1] * 64 == @squares[i][1] && @squares[i][3] == false + pbAnimateTile(@index[0] * 64 + 128, @index[1] * 64, @squares[i][2]) + @squares[i][3] = true # If Voltorb (0), display all tiles on the board - if @squares[i][2]==0 + if @squares[i][2] == 0 pbSEPlay("Voltorb Flip explosion") # Play explosion animation # Part1 - animation=[] + animation = [] for j in 0...3 - animation[0]=icons[0]=[@directory+"tiles",@index[0]*64+128,@index[1]*64,704+(64*j),0,64,64] - pbDrawImagePositions(@sprites["animation"].bitmap,animation) - pbWait(Graphics.frame_rate/20) + animation[0] = icons[0] = [@directory + "tiles", @index[0] * 64 + 128, @index[1] * 64, 704 + (64 * j), 0, 64, 64] + pbDrawImagePositions(@sprites["animation"].bitmap, animation) + pbWait(Graphics.frame_rate / 20) @sprites["animation"].bitmap.clear end # Part2 - animation=[] + animation = [] for j in 0...6 - animation[0]=[@directory+"explosion",@index[0]*64-32+128,@index[1]*64-32,j*128,0,128,128] - pbDrawImagePositions(@sprites["animation"].bitmap,animation) - pbWait(Graphics.frame_rate/10) + animation[0] = [@directory + "explosion", @index[0] * 64 - 32 + 128, @index[1] * 64 - 32, j * 128, 0, 128, 128] + pbDrawImagePositions(@sprites["animation"].bitmap, animation) + pbWait(Graphics.frame_rate / 10) @sprites["animation"].bitmap.clear end # Unskippable text block, parameter 2 = wait time (corresponds to ME length) pbMessage(_INTL("\\me[Voltorb Flip game over]Oh no! You get 0 Coins!\\wtnp[50]")) pbShowAndDispose @sprites["mark"].bitmap.clear - if @level>1 + if @level > 1 # Determine how many levels to reduce by - newLevel=0 + newLevel = 0 for j in 0...@squares.length - newLevel+=1 if @squares[j][3]==true && @squares[j][2]>1 + newLevel += 1 if @squares[j][3] == true && @squares[j][2] > 1 end - newLevel=@level if newLevel>@level - if @level>newLevel - @level=newLevel - @level=1 if @level<1 - pbMessage(_INTL("\\se[Voltorb Flip level down]Dropped to Game Lv. {1}!",@level.to_s)) + newLevel = @level if newLevel > @level + if @level > newLevel + @level = newLevel + @level = 1 if @level < 1 + pbMessage(_INTL("\\se[Voltorb Flip level down]Dropped to Game Lv. {1}!", @level.to_s)) end end # Update level text @sprites["level"].bitmap.clear - pbDrawShadowText(@sprites["level"].bitmap,8,150,118,28,"Level "+@level.to_s,Color.new(60,60,60),Color.new(150,190,170),1) - @points=0 + pbDrawShadowText(@sprites["level"].bitmap, 8, 150, 118, 28, "Level " + @level.to_s, Color.new(60, 60, 60), Color.new(150, 190, 170), 1) + @points = 0 pbUpdateCoins # Revert numbers to 0s @sprites["numbers"].bitmap.clear for i in 0...5 - pbUpdateRowNumbers(0,0,i) - pbUpdateColumnNumbers(0,0,i) + pbUpdateRowNumbers(0, 0, i) + pbUpdateColumnNumbers(0, 0, i) end pbDisposeSpriteHash(@sprites) - @firstRound=false + @firstRound = false pbNewGame else # Play tile animation - animation=[] + animation = [] for j in 0...4 - animation[0]=[@directory+"flipAnimation",@index[0]*64-14+128,@index[1]*64-16,j*92,0,92,96] - pbDrawImagePositions(@sprites["animation"].bitmap,animation) - pbWait(Graphics.frame_rate/20) + animation[0] = [@directory + "flipAnimation", @index[0] * 64 - 14 + 128, @index[1] * 64 - 16, j * 92, 0, 92, 96] + pbDrawImagePositions(@sprites["animation"].bitmap, animation) + pbWait(Graphics.frame_rate / 20) @sprites["animation"].bitmap.clear end - if @points==0 - @points+=@squares[i][2] + if @points == 0 + @points += @squares[i][2] pbSEPlay("Voltorb Flip point") - elsif @squares[i][2]>1 - @points*=@squares[i][2] + elsif @squares[i][2] > 1 + @points *= @squares[i][2] pbSEPlay("Voltorb Flip point") end break @@ -353,44 +353,44 @@ class VoltorbFlip end end end - count=0 + count = 0 for i in 0...@squares.length - if @squares[i][3]==false && @squares[i][2]>1 - count+=1 + if @squares[i][3] == false && @squares[i][2] > 1 + count += 1 end end pbUpdateCoins # Game cleared - if count==0 - @sprites["curtain"].opacity=100 + if count == 0 + @sprites["curtain"].opacity = 100 pbMessage(_INTL("\\me[Voltorb Flip win]Game clear!\\wtnp[40]")) # pbMessage(_INTL("You've found all of the hidden x2 and x3 cards.")) # pbMessage(_INTL("This means you've found all the Coins in this game, so the game is now over.")) - pbMessage(_INTL("\\se[Voltorb Flip gain coins]{1} received {2} Coins!",$player.name,@points.to_s_formatted)) + pbMessage(_INTL("\\se[Voltorb Flip gain coins]{1} received {2} Coins!", $player.name, @points.to_s_formatted)) # Update level text @sprites["level"].bitmap.clear - pbDrawShadowText(@sprites["level"].bitmap,8,150,118,28,_INTL("Level {1}",@level.to_s),Color.new(60,60,60),Color.new(150,190,170),1) + pbDrawShadowText(@sprites["level"].bitmap, 8, 150, 118, 28, _INTL("Level {1}", @level.to_s), Color.new(60, 60, 60), Color.new(150, 190, 170), 1) old_coins = $player.coins - $player.coins+=@points + $player.coins += @points $stats.coins_won += $player.coins - old_coins if $player.coins > old_coins - @points=0 + @points = 0 pbUpdateCoins - @sprites["curtain"].opacity=0 + @sprites["curtain"].opacity = 0 pbShowAndDispose # Revert numbers to 0s @sprites["numbers"].bitmap.clear for i in 0...5 - pbUpdateRowNumbers(0,0,i) - pbUpdateColumnNumbers(0,0,i) + pbUpdateRowNumbers(0, 0, i) + pbUpdateColumnNumbers(0, 0, i) end - @sprites["curtain"].opacity=100 - if @level<8 - @level+=1 - pbMessage(_INTL("\\se[Voltorb Flip level up]Advanced to Game Lv. {1}!",@level.to_s)) + @sprites["curtain"].opacity = 100 + if @level < 8 + @level += 1 + pbMessage(_INTL("\\se[Voltorb Flip level up]Advanced to Game Lv. {1}!", @level.to_s)) # if @firstRound # pbMessage(_INTL("Congratulations!")) # pbMessage(_INTL("You can receive even more Coins in the next game!")) - @firstRound=false + @firstRound = false # end end pbDisposeSpriteHash(@sprites) @@ -399,124 +399,124 @@ class VoltorbFlip elsif Input.trigger?(Input::ACTION) pbPlayDecisionSE @sprites["cursor"].bitmap.clear - if @cursor[0][3]==0 # If in normal mode - @cursor[0]=[@directory+"cursor",128,0,64,0,64,64] - @sprites["memo"].visible=true + if @cursor[0][3] == 0 # If in normal mode + @cursor[0] = [@directory + "cursor", 128, 0, 64, 0, 64, 64] + @sprites["memo"].visible = true else # Mark mode - @cursor[0]=[@directory+"cursor",128,0,0,0,64,64] - @sprites["memo"].visible=false + @cursor[0] = [@directory + "cursor", 128, 0, 0, 0, 64, 64] + @sprites["memo"].visible = false end elsif Input.trigger?(Input::BACK) - @sprites["curtain"].opacity=100 - if @points==0 + @sprites["curtain"].opacity = 100 + if @points == 0 if pbConfirmMessage("You haven't found any Coins! Are you sure you want to quit?") - @sprites["curtain"].opacity=0 + @sprites["curtain"].opacity = 0 pbShowAndDispose - @quit=true + @quit = true end - elsif pbConfirmMessage(_INTL("If you quit now, you will recieve {1} Coin(s). Will you quit?",@points.to_s_formatted)) - pbMessage(_INTL("{1} received {2} Coin(s)!",$player.name,@points.to_s_formatted)) + elsif pbConfirmMessage(_INTL("If you quit now, you will recieve {1} Coin(s). Will you quit?", @points.to_s_formatted)) + pbMessage(_INTL("{1} received {2} Coin(s)!", $player.name, @points.to_s_formatted)) old_coins = $player.coins - $player.coins+=@points + $player.coins += @points $stats.coins_won += $player.coins - old_coins if $player.coins > old_coins - @points=0 + @points = 0 pbUpdateCoins - @sprites["curtain"].opacity=0 + @sprites["curtain"].opacity = 0 pbShowAndDispose - @quit=true + @quit = true end - @sprites["curtain"].opacity=0 + @sprites["curtain"].opacity = 0 end # Draw cursor - pbDrawImagePositions(@sprites["cursor"].bitmap,@cursor) + pbDrawImagePositions(@sprites["cursor"].bitmap, @cursor) end - def pbUpdateRowNumbers(num,voltorbs,i) + def pbUpdateRowNumbers(num, voltorbs, i) # Create and split a string for the number, with padded 0s - zeroes=2-num.to_s.length - numText="" + zeroes = 2 - num.to_s.length + numText = "" zeroes.times do - numText+="0" + numText += "0" end - numText+=num.to_s - numImages=numText.split(//)[0...2] + numText += num.to_s + numImages = numText.split(//)[0...2] for j in 0...2 - @numbers[j]=[@directory+"numbersSmall",472+j*16,i*64+8,numImages[j].to_i*16,0,16,16] + @numbers[j] = [@directory + "numbersSmall", 472 + j * 16, i * 64 + 8, numImages[j].to_i * 16, 0, 16, 16] end - @voltorbNumbers[i]=[@directory+"numbersSmall",488,i*64+34,voltorbs*16,0,16,16] + @voltorbNumbers[i] = [@directory + "numbersSmall", 488, i * 64 + 34, voltorbs * 16, 0, 16, 16] # Display the numbers - pbDrawImagePositions(@sprites["numbers"].bitmap,@numbers) - pbDrawImagePositions(@sprites["numbers"].bitmap,@voltorbNumbers) + pbDrawImagePositions(@sprites["numbers"].bitmap, @numbers) + pbDrawImagePositions(@sprites["numbers"].bitmap, @voltorbNumbers) end - def pbUpdateColumnNumbers(num,voltorbs,i) + def pbUpdateColumnNumbers(num, voltorbs, i) # Create and split a string for the number, with padded 0s - zeroes=2-num.to_s.length - numText="" + zeroes = 2 - num.to_s.length + numText = "" zeroes.times do - numText+="0" + numText += "0" end - numText+=num.to_s - numImages=numText.split(//)[0...2] + numText += num.to_s + numImages = numText.split(//)[0...2] for j in 0...2 - @numbers[j]=[@directory+"numbersSmall",(i*64)+152+j*16,328,numImages[j].to_i*16,0,16,16] + @numbers[j] = [@directory + "numbersSmall", (i * 64) + 152 + j * 16, 328, numImages[j].to_i * 16, 0, 16, 16] end - @voltorbNumbers[i]=[@directory+"numbersSmall",(i*64)+168,354,voltorbs*16,0,16,16] + @voltorbNumbers[i] = [@directory + "numbersSmall", (i * 64) + 168, 354, voltorbs * 16, 0, 16, 16] # Display the numbers - pbDrawImagePositions(@sprites["numbers"].bitmap,@numbers) - pbDrawImagePositions(@sprites["numbers"].bitmap,@voltorbNumbers) + pbDrawImagePositions(@sprites["numbers"].bitmap, @numbers) + pbDrawImagePositions(@sprites["numbers"].bitmap, @voltorbNumbers) end - def pbCreateCoins(source,y) - zeroes=5-source.to_s.length - coinText="" + def pbCreateCoins(source, y) + zeroes = 5 - source.to_s.length + coinText = "" zeroes.times do - coinText+="0" + coinText += "0" end - coinText+=source.to_s - coinImages=coinText.split(//)[0...5] + coinText += source.to_s + coinImages = coinText.split(//)[0...5] for i in 0...5 - @coins[i]=[@directory+"numbersScore",6+i*24,y,coinImages[i].to_i*24,0,24,38] + @coins[i] = [@directory + "numbersScore", 6 + i * 24, y, coinImages[i].to_i * 24, 0, 24, 38] end end def pbUpdateCoins # Update coins display @sprites["totalCoins"].bitmap.clear - pbCreateCoins($player.coins,44) - pbDrawImagePositions(@sprites["totalCoins"].bitmap,@coins) + pbCreateCoins($player.coins, 44) + pbDrawImagePositions(@sprites["totalCoins"].bitmap, @coins) # Update points display @sprites["currentCoins"].bitmap.clear - pbCreateCoins(@points,110) - pbDrawImagePositions(@sprites["currentCoins"].bitmap,@coins) + pbCreateCoins(@points, 110) + pbDrawImagePositions(@sprites["currentCoins"].bitmap, @coins) end - def pbAnimateTile(x,y,tile) - icons=[] - points=0 + def pbAnimateTile(x, y, tile) + icons = [] + points = 0 for i in 0...3 - points=tile if i==2 - icons[i]=[@directory+"tiles",x,y,320+(i*64)+(points*64),0,64,64] - pbDrawImagePositions(@sprites["icon"].bitmap,icons) - pbWait(Graphics.frame_rate/20) + points = tile if i == 2 + icons[i] = [@directory + "tiles", x, y, 320 + (i * 64) + (points * 64), 0, 64, 64] + pbDrawImagePositions(@sprites["icon"].bitmap, icons) + pbWait(Graphics.frame_rate / 20) end - icons[3]=[@directory+"tiles",x,y,tile*64,0,64,64] - pbDrawImagePositions(@sprites["icon"].bitmap,icons) + icons[3] = [@directory + "tiles", x, y, tile * 64, 0, 64, 64] + pbDrawImagePositions(@sprites["icon"].bitmap, icons) pbSEPlay("Voltorb Flip tile") end def pbShowAndDispose # Make pre-rendered sprites visible (this approach reduces lag) for i in 0...5 - @sprites[i].visible=true - pbWait(Graphics.frame_rate/20) if i<3 + @sprites[i].visible = true + pbWait(Graphics.frame_rate / 20) if i < 3 @sprites[i].bitmap.clear - @sprites[i].z=99997 + @sprites[i].z = 99997 end pbSEPlay("Voltorb Flip tile") - @sprites[5].visible=true + @sprites[5].visible = true @sprites["mark"].bitmap.clear - pbWait(Graphics.frame_rate/10) + pbWait(Graphics.frame_rate / 10) # Wait for user input to continue loop do Graphics.update @@ -528,28 +528,28 @@ class VoltorbFlip end # "Dispose" of tiles by column for i in 0...5 - icons=[] + icons = [] pbSEPlay("Voltorb Flip tile") for j in 0...5 - icons[j]=[@directory+"tiles",@squares[i+(j*5)][0],@squares[i+(j*5)][1],448+(@squares[i+(j*5)][2]*64),0,64,64] + icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 448 + (@squares[i + (j * 5)][2] * 64), 0, 64, 64] end - pbDrawImagePositions(@sprites[i].bitmap,icons) - pbWait(Graphics.frame_rate/20) + pbDrawImagePositions(@sprites[i].bitmap, icons) + pbWait(Graphics.frame_rate / 20) for j in 0...5 - icons[j]=[@directory+"tiles",@squares[i+(j*5)][0],@squares[i+(j*5)][1],384,0,64,64] + icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 384, 0, 64, 64] end - pbDrawImagePositions(@sprites[i].bitmap,icons) - pbWait(Graphics.frame_rate/20) + pbDrawImagePositions(@sprites[i].bitmap, icons) + pbWait(Graphics.frame_rate / 20) for j in 0...5 - icons[j]=[@directory+"tiles",@squares[i+(j*5)][0],@squares[i+(j*5)][1],320,0,64,64] + icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 320, 0, 64, 64] end - pbDrawImagePositions(@sprites[i].bitmap,icons) - pbWait(Graphics.frame_rate/20) + pbDrawImagePositions(@sprites[i].bitmap, icons) + pbWait(Graphics.frame_rate / 20) for j in 0...5 - icons[j]=[@directory+"tiles",@squares[i+(j*5)][0],@squares[i+(j*5)][1],896,0,64,64] + icons[j] = [@directory + "tiles", @squares[i + (j * 5)][0], @squares[i + (j * 5)][1], 896, 0, 64, 64] end - pbDrawImagePositions(@sprites[i].bitmap,icons) - pbWait(Graphics.frame_rate/20) + pbDrawImagePositions(@sprites[i].bitmap, icons) + pbWait(Graphics.frame_rate / 20) end @sprites["icon"].bitmap.clear for i in 0...6 @@ -568,21 +568,21 @@ class VoltorbFlip # end def pbEndScene - @sprites["curtainL"].angle=-180 - @sprites["curtainR"].angle=90 + @sprites["curtainL"].angle = -180 + @sprites["curtainR"].angle = 90 # Draw curtain effect - @sprites["curtainL"].visible=true - @sprites["curtainR"].visible=true - angleDiff = 18*20/Graphics.frame_rate + @sprites["curtainL"].visible = true + @sprites["curtainR"].visible = true + angleDiff = 18 * 20 / Graphics.frame_rate loop do @sprites["curtainL"].angle += angleDiff @sprites["curtainR"].angle -= angleDiff # Fixes a minor graphical bug - @sprites["curtainL"].y-=2 if @sprites["curtainL"].angle>=-90 + @sprites["curtainL"].y -= 2 if @sprites["curtainL"].angle >= -90 Graphics.update Input.update update - if @sprites["curtainL"].angle>=-90 + if @sprites["curtainL"].angle >= -90 break end end @@ -605,7 +605,7 @@ end class VoltorbFlipScreen def initialize(scene) - @scene=scene + @scene = scene end def pbStartScreen @@ -623,8 +623,8 @@ def pbVoltorbFlip elsif $player.coins == Settings::MAX_COINS pbMessage(_INTL("Your Coin Case is full!")) else - scene=VoltorbFlip.new - screen=VoltorbFlipScreen.new(scene) + scene = VoltorbFlip.new + screen = VoltorbFlipScreen.new(scene) screen.pbStartScreen end end diff --git a/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb b/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb index eed3c5251..2da873d91 100644 --- a/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb +++ b/Data/Scripts/017_Minigames/005_Minigame_Lottery.rb @@ -8,47 +8,47 @@ def pbSetLotteryNumber(variable = 1) srand(hash) # seed RNG with fixed value depending on date lottery = rand(65536) # get a number srand # reseed RNG - pbSet(variable,sprintf("%05d",lottery)) + pbSet(variable, sprintf("%05d", lottery)) end -def pbLottery(winnum,nameVar = 2,positionVar = 3,matchedVar = 4) - winnum=winnum.to_i - winpoke=nil - winpos=0 - winmatched=0 +def pbLottery(winnum, nameVar = 2, positionVar = 3, matchedVar = 4) + winnum = winnum.to_i + winpoke = nil + winpos = 0 + winmatched = 0 for i in $player.party - thismatched=0 - id=i.owner.public_id + thismatched = 0 + id = i.owner.public_id for j in 0...5 - if (id/(10**j))%10 == (winnum/(10**j))%10 - thismatched+=1 + if (id / (10**j)) % 10 == (winnum / (10**j)) % 10 + thismatched += 1 else break end end - if thismatched>winmatched - winpoke=i.name - winpos=1 # Party - winmatched=thismatched + if thismatched > winmatched + winpoke = i.name + winpos = 1 # Party + winmatched = thismatched end end - pbEachPokemon { |poke,_box| - thismatched=0 - id=poke.owner.public_id + pbEachPokemon { |poke, _box| + thismatched = 0 + id = poke.owner.public_id for j in 0...5 - if (id/(10**j))%10 == (winnum/(10**j))%10 - thismatched+=1 + if (id / (10**j)) % 10 == (winnum / (10**j)) % 10 + thismatched += 1 else break end end - if thismatched>winmatched - winpoke=poke.name - winpos=2 # Storage - winmatched=thismatched + if thismatched > winmatched + winpoke = poke.name + winpos = 2 # Storage + winmatched = thismatched end } - $game_variables[nameVar]=winpoke - $game_variables[positionVar]=winpos - $game_variables[matchedVar]=winmatched + $game_variables[nameVar] = winpoke + $game_variables[positionVar] = winpos + $game_variables[matchedVar] = winmatched end diff --git a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb index a4003c484..3bc6fcf17 100644 --- a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb +++ b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb @@ -7,27 +7,27 @@ class MiningGameCounter < BitmapSprite attr_accessor :hits - def initialize(x,y) - @viewport=Viewport.new(x,y,416,60) - @viewport.z=99999 - super(416,60,@viewport) - @hits=0 - @image=AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/cracks")) + def initialize(x, y) + @viewport = Viewport.new(x, y, 416, 60) + @viewport.z = 99999 + super(416, 60, @viewport) + @hits = 0 + @image = AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/cracks")) update end def update self.bitmap.clear - value=@hits - startx=416-48 - while value>6 - self.bitmap.blt(startx,0,@image.bitmap,Rect.new(0,0,48,52)) - startx-=48 - value-=6 + value = @hits + startx = 416 - 48 + while value > 6 + self.bitmap.blt(startx, 0, @image.bitmap, Rect.new(0, 0, 48, 52)) + startx -= 48 + value -= 6 end - startx-=48 - if value>0 - self.bitmap.blt(startx,0,@image.bitmap,Rect.new(0,value*52,96,52)) + startx -= 48 + if value > 0 + self.bitmap.blt(startx, 0, @image.bitmap, Rect.new(0, value * 52, 96, 52)) end end end @@ -37,10 +37,10 @@ end class MiningGameTile < BitmapSprite attr_reader :layer - def initialize(x,y) - @viewport=Viewport.new(x,y,32,32) - @viewport.z=99999 - super(32,32,@viewport) + def initialize(x, y) + @viewport = Viewport.new(x, y, 32, 32) + @viewport.z = 99999 + super(32, 32, @viewport) r = rand(100) if r < 10 @layer = 2 # 10% @@ -53,19 +53,19 @@ class MiningGameTile < BitmapSprite else @layer = 6 # 15% end - @image=AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/tiles")) + @image = AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/tiles")) update end def layer=(value) - @layer=value - @layer=0 if @layer<0 + @layer = value + @layer = 0 if @layer < 0 end def update self.bitmap.clear - if @layer>0 - self.bitmap.blt(0,0,@image.bitmap,Rect.new(0,32*(@layer-1),32,32)) + if @layer > 0 + self.bitmap.blt(0, 0, @image.bitmap, Rect.new(0, 32 * (@layer - 1), 32, 32)) end end end @@ -78,13 +78,13 @@ class MiningGameCursor < BitmapSprite attr_accessor :hit attr_accessor :counter - ToolPositions = [[1,0],[1,1],[1,1],[0,0],[0,0], - [0,2],[0,2],[0,0],[0,0],[0,2],[0,2]] # Graphic, position + ToolPositions = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0], + [0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position - def initialize(position = 0,mode = 0) # mode: 0=pick, 1=hammer - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + def initialize(position = 0, mode = 0) # mode: 0=pick, 1=hammer + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 - super(Graphics.width,Graphics.height,@viewport) + super(Graphics.width, Graphics.height, @viewport) @position = position @mode = mode @hit = 0 # 0=regular, 1=hit item, 2=hit iron @@ -96,7 +96,7 @@ class MiningGameCursor < BitmapSprite end def isAnimating? - return @counter>0 + return @counter > 0 end def animate(hit) @@ -106,33 +106,33 @@ class MiningGameCursor < BitmapSprite def update self.bitmap.clear - x = 32*(@position%MiningGameScene::BOARDWIDTH) - y = 32*(@position/MiningGameScene::BOARDWIDTH) - if @counter>0 + x = 32 * (@position % MiningGameScene::BOARDWIDTH) + y = 32 * (@position / MiningGameScene::BOARDWIDTH) + if @counter > 0 @counter -= 1 toolx = x tooly = y - i = 10-(@counter/2).floor - if ToolPositions[i][1]==1 + i = 10 - (@counter / 2).floor + if ToolPositions[i][1] == 1 toolx -= 8 tooly += 8 - elsif ToolPositions[i][1]==2 + elsif ToolPositions[i][1] == 2 toolx += 6 end - self.bitmap.blt(toolx,tooly,@toolbitmap.bitmap, - Rect.new(96*ToolPositions[i][0],96*@mode,96,96)) - if i<5 && i%2==0 - if @hit==2 - self.bitmap.blt(x-64,y,@hitsbitmap.bitmap,Rect.new(160*2,0,160,160)) + self.bitmap.blt(toolx, tooly, @toolbitmap.bitmap, + Rect.new(96 * ToolPositions[i][0], 96 * @mode, 96, 96)) + if i < 5 && i % 2 == 0 + if @hit == 2 + self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * 2, 0, 160, 160)) else - self.bitmap.blt(x-64,y,@hitsbitmap.bitmap,Rect.new(160*@mode,0,160,160)) + self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * @mode, 0, 160, 160)) end end - if @hit==1 && i<3 - self.bitmap.blt(x-64,y,@hitsbitmap.bitmap,Rect.new(160*i,160,160,160)) + if @hit == 1 && i < 3 + self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * i, 160, 160, 160)) end else - self.bitmap.blt(x,y+64,@cursorbitmap.bitmap,Rect.new(32*@mode,0,32,32)) + self.bitmap.blt(x, y + 64, @cursorbitmap.bitmap, Rect.new(32 * @mode, 0, 32, 32)) end end end @@ -143,82 +143,82 @@ class MiningGameScene BOARDWIDTH = 13 BOARDHEIGHT = 10 ITEMS = [ # Item, probability, graphic x, graphic y, width, height, pattern - [:DOMEFOSSIL,20, 0,3, 5,4,[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0]], - [:HELIXFOSSIL,5, 5,3, 4,4,[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0]], - [:HELIXFOSSIL,5, 9,3, 4,4,[1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1]], - [:HELIXFOSSIL,5, 13,3, 4,4,[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0]], - [:HELIXFOSSIL,5, 17,3, 4,4,[1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1]], - [:OLDAMBER,10, 21,3, 4,4,[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0]], - [:OLDAMBER,10, 25,3, 4,4,[1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1]], - [:ROOTFOSSIL,5, 0,7, 5,5,[1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,0,0,1,1,0,0,1,1,0]], - [:ROOTFOSSIL,5, 5,7, 5,5,[0,0,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1,0,1,1,1,0]], - [:ROOTFOSSIL,5, 10,7, 5,5,[0,1,1,0,0,1,1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1]], - [:ROOTFOSSIL,5, 15,7, 5,5,[0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,0,0]], - [:SKULLFOSSIL,20, 20,7, 4,4,[1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0]], - [:ARMORFOSSIL,20, 24,7, 5,4,[0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0,1,1,1,0]], - [:CLAWFOSSIL,5, 0,12, 4,5,[0,0,1,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0,0]], - [:CLAWFOSSIL,5, 4,12, 5,4,[1,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1]], - [:CLAWFOSSIL,5, 9,12, 4,5,[0,0,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,0,0]], - [:CLAWFOSSIL,5, 13,12, 5,4,[1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,1,1]], - [:FIRESTONE,20, 20,11, 3,3,[1,1,1,1,1,1,1,1,1]], - [:WATERSTONE,20, 23,11, 3,3,[1,1,1,1,1,1,1,1,0]], - [:THUNDERSTONE,20, 26,11, 3,3,[0,1,1,1,1,1,1,1,0]], - [:LEAFSTONE,10, 18,14, 3,4,[0,1,0,1,1,1,1,1,1,0,1,0]], - [:LEAFSTONE,10, 21,14, 4,3,[0,1,1,0,1,1,1,1,0,1,1,0]], - [:MOONSTONE,10, 25,14, 4,2,[0,1,1,1,1,1,1,0]], - [:MOONSTONE,10, 27,16, 2,4,[1,0,1,1,1,1,0,1]], - [:SUNSTONE,20, 21,17, 3,3,[0,1,0,1,1,1,1,1,1]], - [:OVALSTONE,150, 24,17, 3,3,[1,1,1,1,1,1,1,1,1]], - [:EVERSTONE,150, 21,20, 4,2,[1,1,1,1,1,1,1,1]], - [:STARPIECE,100, 0,17, 3,3,[0,1,0,1,1,1,0,1,0]], - [:REVIVE,100, 0,20, 3,3,[0,1,0,1,1,1,0,1,0]], - [:MAXREVIVE,50, 0,23, 3,3,[1,1,1,1,1,1,1,1,1]], - [:RAREBONE,50, 3,17, 6,3,[1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1]], - [:RAREBONE,50, 3,20, 3,6,[1,1,1,0,1,0,0,1,0,0,1,0,0,1,0,1,1,1]], - [:LIGHTCLAY,100, 6,20, 4,4,[1,0,1,0,1,1,1,0,1,1,1,1,0,1,0,1]], - [:HARDSTONE,200, 6,24, 2,2,[1,1,1,1]], - [:HEARTSCALE,200, 8,24, 2,2,[1,0,1,1]], - [:IRONBALL,100, 9,17, 3,3,[1,1,1,1,1,1,1,1,1]], - [:ODDKEYSTONE,100, 10,20, 4,4,[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]], - [:HEATROCK,50, 12,17, 4,3,[1,0,1,0,1,1,1,1,1,1,1,1]], - [:DAMPROCK,50, 14,20, 3,3,[1,1,1,1,1,1,1,0,1]], - [:SMOOTHROCK,50, 17,18, 4,4,[0,0,1,0,1,1,1,0,0,1,1,1,0,1,0,0]], - [:ICYROCK,50, 17,22, 4,4,[0,1,1,0,1,1,1,1,1,1,1,1,1,0,0,1]], - [:REDSHARD,100, 21,22, 3,3,[1,1,1,1,1,0,1,1,1]], - [:GREENSHARD,100, 25,20, 4,3,[1,1,1,1,1,1,1,1,1,1,0,1]], - [:YELLOWSHARD,100, 25,23, 4,3,[1,0,1,0,1,1,1,0,1,1,1,1]], - [:BLUESHARD,100, 26,26, 3,3,[1,1,1,1,1,1,1,1,0]], - [:INSECTPLATE,10, 0,26, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:DREADPLATE,10, 4,26, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:DRACOPLATE,10, 8,26, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:ZAPPLATE,10, 12,26, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:FISTPLATE,10, 16,26, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:FLAMEPLATE,10, 20,26, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:MEADOWPLATE,10, 0,29, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:EARTHPLATE,10, 4,29, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:ICICLEPLATE,10, 8,29, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:TOXICPLATE,10, 12,29, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:MINDPLATE,10, 16,29, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:STONEPLATE,10, 20,29, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:SKYPLATE,10, 0,32, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:SPOOKYPLATE,10, 4,32, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:IRONPLATE,10, 8,32, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]], - [:SPLASHPLATE,10, 12,32, 4,3,[1,1,1,1,1,1,1,1,1,1,1,1]] + [:DOMEFOSSIL, 20, 0, 3, 5, 4, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]], + [:HELIXFOSSIL, 5, 5, 3, 4, 4, [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]], + [:HELIXFOSSIL, 5, 9, 3, 4, 4, [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]], + [:HELIXFOSSIL, 5, 13, 3, 4, 4, [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]], + [:HELIXFOSSIL, 5, 17, 3, 4, 4, [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]], + [:OLDAMBER, 10, 21, 3, 4, 4, [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]], + [:OLDAMBER, 10, 25, 3, 4, 4, [1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1]], + [:ROOTFOSSIL, 5, 0, 7, 5, 5, [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0]], + [:ROOTFOSSIL, 5, 5, 7, 5, 5, [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]], + [:ROOTFOSSIL, 5, 10, 7, 5, 5, [0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]], + [:ROOTFOSSIL, 5, 15, 7, 5, 5, [0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0]], + [:SKULLFOSSIL, 20, 20, 7, 4, 4, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0]], + [:ARMORFOSSIL, 20, 24, 7, 5, 4, [0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0]], + [:CLAWFOSSIL, 5, 0, 12, 4, 5, [0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0]], + [:CLAWFOSSIL, 5, 4, 12, 5, 4, [1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1]], + [:CLAWFOSSIL, 5, 9, 12, 4, 5, [0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0]], + [:CLAWFOSSIL, 5, 13, 12, 5, 4, [1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1]], + [:FIRESTONE, 20, 20, 11, 3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:WATERSTONE, 20, 23, 11, 3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 0]], + [:THUNDERSTONE, 20, 26, 11, 3, 3, [0, 1, 1, 1, 1, 1, 1, 1, 0]], + [:LEAFSTONE, 10, 18, 14, 3, 4, [0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0]], + [:LEAFSTONE, 10, 21, 14, 4, 3, [0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0]], + [:MOONSTONE, 10, 25, 14, 4, 2, [0, 1, 1, 1, 1, 1, 1, 0]], + [:MOONSTONE, 10, 27, 16, 2, 4, [1, 0, 1, 1, 1, 1, 0, 1]], + [:SUNSTONE, 20, 21, 17, 3, 3, [0, 1, 0, 1, 1, 1, 1, 1, 1]], + [:OVALSTONE, 150, 24, 17, 3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:EVERSTONE, 150, 21, 20, 4, 2, [1, 1, 1, 1, 1, 1, 1, 1]], + [:STARPIECE, 100, 0, 17, 3, 3, [0, 1, 0, 1, 1, 1, 0, 1, 0]], + [:REVIVE, 100, 0, 20, 3, 3, [0, 1, 0, 1, 1, 1, 0, 1, 0]], + [:MAXREVIVE, 50, 0, 23, 3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:RAREBONE, 50, 3, 17, 6, 3, [1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1]], + [:RAREBONE, 50, 3, 20, 3, 6, [1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1]], + [:LIGHTCLAY, 100, 6, 20, 4, 4, [1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1]], + [:HARDSTONE, 200, 6, 24, 2, 2, [1, 1, 1, 1]], + [:HEARTSCALE, 200, 8, 24, 2, 2, [1, 0, 1, 1]], + [:IRONBALL, 100, 9, 17, 3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:ODDKEYSTONE, 100, 10, 20, 4, 4, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:HEATROCK, 50, 12, 17, 4, 3, [1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]], + [:DAMPROCK, 50, 14, 20, 3, 3, [1, 1, 1, 1, 1, 1, 1, 0, 1]], + [:SMOOTHROCK, 50, 17, 18, 4, 4, [0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0]], + [:ICYROCK, 50, 17, 22, 4, 4, [0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1]], + [:REDSHARD, 100, 21, 22, 3, 3, [1, 1, 1, 1, 1, 0, 1, 1, 1]], + [:GREENSHARD, 100, 25, 20, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]], + [:YELLOWSHARD, 100, 25, 23, 4, 3, [1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1]], + [:BLUESHARD, 100, 26, 26, 3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 0]], + [:INSECTPLATE, 10, 0, 26, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:DREADPLATE, 10, 4, 26, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:DRACOPLATE, 10, 8, 26, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:ZAPPLATE, 10, 12, 26, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:FISTPLATE, 10, 16, 26, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:FLAMEPLATE, 10, 20, 26, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:MEADOWPLATE, 10, 0, 29, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:EARTHPLATE, 10, 4, 29, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:ICICLEPLATE, 10, 8, 29, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:TOXICPLATE, 10, 12, 29, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:MINDPLATE, 10, 16, 29, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:STONEPLATE, 10, 20, 29, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:SKYPLATE, 10, 0, 32, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:SPOOKYPLATE, 10, 4, 32, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:IRONPLATE, 10, 8, 32, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], + [:SPLASHPLATE, 10, 12, 32, 4, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] ] IRON = [ # Graphic x, graphic y, width, height, pattern - [0,0, 1,4,[1,1,1,1]], - [1,0, 2,4,[1,1,1,1,1,1,1,1]], - [3,0, 4,2,[1,1,1,1,1,1,1,1]], - [3,2, 4,1,[1,1,1,1]], - [7,0, 3,3,[1,1,1,1,1,1,1,1,1]], - [0,5, 3,2,[1,1,0,0,1,1]], - [0,7, 3,2,[0,1,0,1,1,1]], - [3,5, 3,2,[0,1,1,1,1,0]], - [3,7, 3,2,[1,1,1,0,1,0]], - [6,3, 2,3,[1,0,1,1,0,1]], - [8,3, 2,3,[0,1,1,1,1,0]], - [6,6, 2,3,[1,0,1,1,1,0]], - [8,6, 2,3,[0,1,1,1,0,1]] + [0, 0, 1, 4, [1, 1, 1, 1]], + [1, 0, 2, 4, [1, 1, 1, 1, 1, 1, 1, 1]], + [3, 0, 4, 2, [1, 1, 1, 1, 1, 1, 1, 1]], + [3, 2, 4, 1, [1, 1, 1, 1]], + [7, 0, 3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1]], + [0, 5, 3, 2, [1, 1, 0, 0, 1, 1]], + [0, 7, 3, 2, [0, 1, 0, 1, 1, 1]], + [3, 5, 3, 2, [0, 1, 1, 1, 1, 0]], + [3, 7, 3, 2, [1, 1, 1, 0, 1, 0]], + [6, 3, 2, 3, [1, 0, 1, 1, 0, 1]], + [8, 3, 2, 3, [0, 1, 1, 1, 1, 0]], + [6, 6, 2, 3, [1, 0, 1, 1, 1, 0]], + [8, 6, 2, 3, [0, 1, 1, 1, 0, 1]] ] def update @@ -226,54 +226,54 @@ class MiningGameScene end def pbStartScene - @sprites={} - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 - addBackgroundPlane(@sprites,"bg","Mining/miningbg",@viewport) - @sprites["itemlayer"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport) - @itembitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/items")) - @ironbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/irons")) - @items=[] - @itemswon=[] - @iron=[] + @sprites = {} + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 + addBackgroundPlane(@sprites, "bg", "Mining/miningbg", @viewport) + @sprites["itemlayer"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) + @itembitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/items")) + @ironbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Mining/irons")) + @items = [] + @itemswon = [] + @iron = [] pbDistributeItems pbDistributeIron for i in 0...BOARDHEIGHT for j in 0...BOARDWIDTH - @sprites["tile#{j+i*BOARDWIDTH}"]=MiningGameTile.new(32*j,64+32*i) + @sprites["tile#{j + i * BOARDWIDTH}"] = MiningGameTile.new(32 * j, 64 + 32 * i) end end - @sprites["crack"]=MiningGameCounter.new(0,4) - @sprites["cursor"]=MiningGameCursor.new(58,0) # central position, pick - @sprites["tool"]=IconSprite.new(434,254,@viewport) + @sprites["crack"] = MiningGameCounter.new(0, 4) + @sprites["cursor"] = MiningGameCursor.new(58, 0) # central position, pick + @sprites["tool"] = IconSprite.new(434, 254, @viewport) @sprites["tool"].setBitmap(sprintf("Graphics/Pictures/Mining/toolicons")) - @sprites["tool"].src_rect.set(0,0,68,100) + @sprites["tool"].src_rect.set(0, 0, 68, 100) update pbFadeInAndShow(@sprites) end def pbDistributeItems # Set items to be buried (index in ITEMS, x coord, y coord) - ptotal=0 + ptotal = 0 for i in ITEMS - ptotal+=i[1] + ptotal += i[1] end - numitems=2+rand(3) + numitems = 2 + rand(3) tries = 0 - while numitems>0 - rnd=rand(ptotal) - added=false + while numitems > 0 + rnd = rand(ptotal) + added = false for i in 0...ITEMS.length - rnd-=ITEMS[i][1] - if rnd<0 + rnd -= ITEMS[i][1] + if rnd < 0 if pbNoDuplicateItems(ITEMS[i][0]) while !added - provx=rand(BOARDWIDTH-ITEMS[i][4]+1) - provy=rand(BOARDHEIGHT-ITEMS[i][5]+1) - if pbCheckOverlaps(false,provx,provy,ITEMS[i][4],ITEMS[i][5],ITEMS[i][6]) - @items.push([i,provx,provy]) - numitems-=1 - added=true + provx = rand(BOARDWIDTH - ITEMS[i][4] + 1) + provy = rand(BOARDHEIGHT - ITEMS[i][5] + 1) + if pbCheckOverlaps(false, provx, provy, ITEMS[i][4], ITEMS[i][5], ITEMS[i][6]) + @items.push([i, provx, provy]) + numitems -= 1 + added = true end end else @@ -283,95 +283,95 @@ class MiningGameScene break if added end tries += 1 - break if tries>=500 + break if tries >= 500 end # Draw items on item layer - layer=@sprites["itemlayer"].bitmap + layer = @sprites["itemlayer"].bitmap for i in @items - ox=ITEMS[i[0]][2] - oy=ITEMS[i[0]][3] - rectx=ITEMS[i[0]][4] - recty=ITEMS[i[0]][5] - layer.blt(32*i[1],64+32*i[2],@itembitmap.bitmap,Rect.new(32*ox,32*oy,32*rectx,32*recty)) + ox = ITEMS[i[0]][2] + oy = ITEMS[i[0]][3] + rectx = ITEMS[i[0]][4] + recty = ITEMS[i[0]][5] + layer.blt(32 * i[1], 64 + 32 * i[2], @itembitmap.bitmap, Rect.new(32 * ox, 32 * oy, 32 * rectx, 32 * recty)) end end def pbDistributeIron # Set iron to be buried (index in IRON, x coord, y coord) - numitems=4+rand(3) + numitems = 4 + rand(3) tries = 0 - while numitems>0 - rnd=rand(IRON.length) - provx=rand(BOARDWIDTH-IRON[rnd][2]+1) - provy=rand(BOARDHEIGHT-IRON[rnd][3]+1) - if pbCheckOverlaps(true,provx,provy,IRON[rnd][2],IRON[rnd][3],IRON[rnd][4]) - @iron.push([rnd,provx,provy]) - numitems-=1 + while numitems > 0 + rnd = rand(IRON.length) + provx = rand(BOARDWIDTH - IRON[rnd][2] + 1) + provy = rand(BOARDHEIGHT - IRON[rnd][3] + 1) + if pbCheckOverlaps(true, provx, provy, IRON[rnd][2], IRON[rnd][3], IRON[rnd][4]) + @iron.push([rnd, provx, provy]) + numitems -= 1 end tries += 1 - break if tries>=500 + break if tries >= 500 end # Draw items on item layer - layer=@sprites["itemlayer"].bitmap + layer = @sprites["itemlayer"].bitmap for i in @iron - ox=IRON[i[0]][0] - oy=IRON[i[0]][1] - rectx=IRON[i[0]][2] - recty=IRON[i[0]][3] - layer.blt(32*i[1],64+32*i[2],@ironbitmap.bitmap,Rect.new(32*ox,32*oy,32*rectx,32*recty)) + ox = IRON[i[0]][0] + oy = IRON[i[0]][1] + rectx = IRON[i[0]][2] + recty = IRON[i[0]][3] + layer.blt(32 * i[1], 64 + 32 * i[2], @ironbitmap.bitmap, Rect.new(32 * ox, 32 * oy, 32 * rectx, 32 * recty)) end end def pbNoDuplicateItems(newitem) - return true if newitem==:HEARTSCALE # Allow multiple Heart Scales - fossils=[:DOMEFOSSIL,:HELIXFOSSIL,:OLDAMBER,:ROOTFOSSIL, - :SKULLFOSSIL,:ARMORFOSSIL,:CLAWFOSSIL] - plates=[:INSECTPLATE,:DREADPLATE,:DRACOPLATE,:ZAPPLATE,:FISTPLATE, - :FLAMEPLATE,:MEADOWPLATE,:EARTHPLATE,:ICICLEPLATE,:TOXICPLATE, - :MINDPLATE,:STONEPLATE,:SKYPLATE,:SPOOKYPLATE,:IRONPLATE,:SPLASHPLATE] + return true if newitem == :HEARTSCALE # Allow multiple Heart Scales + fossils = [:DOMEFOSSIL, :HELIXFOSSIL, :OLDAMBER, :ROOTFOSSIL, + :SKULLFOSSIL, :ARMORFOSSIL, :CLAWFOSSIL] + plates = [:INSECTPLATE, :DREADPLATE, :DRACOPLATE, :ZAPPLATE, :FISTPLATE, + :FLAMEPLATE, :MEADOWPLATE, :EARTHPLATE, :ICICLEPLATE, :TOXICPLATE, + :MINDPLATE, :STONEPLATE, :SKYPLATE, :SPOOKYPLATE, :IRONPLATE, :SPLASHPLATE] for i in @items - preitem=ITEMS[i[0]][0] - return false if preitem==newitem # No duplicate items + preitem = ITEMS[i[0]][0] + return false if preitem == newitem # No duplicate items return false if fossils.include?(preitem) && fossils.include?(newitem) return false if plates.include?(preitem) && plates.include?(newitem) end return true end - def pbCheckOverlaps(checkiron,provx,provy,provwidth,provheight,provpattern) + def pbCheckOverlaps(checkiron, provx, provy, provwidth, provheight, provpattern) for i in @items - prex=i[1] - prey=i[2] - prewidth=ITEMS[i[0]][4] - preheight=ITEMS[i[0]][5] - prepattern=ITEMS[i[0]][6] - next if provx+provwidth<=prex || provx>=prex+prewidth || - provy+provheight<=prey || provy>=prey+preheight + prex = i[1] + prey = i[2] + prewidth = ITEMS[i[0]][4] + preheight = ITEMS[i[0]][5] + prepattern = ITEMS[i[0]][6] + next if provx + provwidth <= prex || provx >= prex + prewidth || + provy + provheight <= prey || provy >= prey + preheight for j in 0...prepattern.length - next if prepattern[j]==0 - xco=prex+(j%prewidth) - yco=prey+(j/prewidth).floor - next if provx+provwidth<=xco || provx>xco || - provy+provheight<=yco || provy>yco - return false if provpattern[xco-provx+(yco-provy)*provwidth]==1 + next if prepattern[j] == 0 + xco = prex + (j % prewidth) + yco = prey + (j / prewidth).floor + next if provx + provwidth <= xco || provx > xco || + provy + provheight <= yco || provy > yco + return false if provpattern[xco - provx + (yco - provy) * provwidth] == 1 end end if checkiron # Check other irons as well for i in @iron - prex=i[1] - prey=i[2] - prewidth=IRON[i[0]][2] - preheight=IRON[i[0]][3] - prepattern=IRON[i[0]][4] - next if provx+provwidth<=prex || provx>=prex+prewidth || - provy+provheight<=prey || provy>=prey+preheight + prex = i[1] + prey = i[2] + prewidth = IRON[i[0]][2] + preheight = IRON[i[0]][3] + prepattern = IRON[i[0]][4] + next if provx + provwidth <= prex || provx >= prex + prewidth || + provy + provheight <= prey || provy >= prey + preheight for j in 0...prepattern.length - next if prepattern[j]==0 - xco=prex+(j%prewidth) - yco=prey+(j/prewidth).floor - next if provx+provwidth<=xco || provx>xco || - provy+provheight<=yco || provy>yco - return false if provpattern[xco-provx+(yco-provy)*provwidth]==1 + next if prepattern[j] == 0 + xco = prex + (j % prewidth) + yco = prey + (j / prewidth).floor + next if provx + provwidth <= xco || provx > xco || + provy + provheight <= yco || provy > yco + return false if provpattern[xco - provx + (yco - provy) * provwidth] == 1 end end end @@ -379,34 +379,34 @@ class MiningGameScene end def pbHit - hittype=0 - position=@sprites["cursor"].position - if @sprites["cursor"].mode==1 # Hammer - pattern=[1,2,1, - 2,2,2, - 1,2,1] - @sprites["crack"].hits+=2 if !($DEBUG && Input.press?(Input::CTRL)) + hittype = 0 + position = @sprites["cursor"].position + if @sprites["cursor"].mode == 1 # Hammer + pattern = [1, 2, 1, + 2, 2, 2, + 1, 2, 1] + @sprites["crack"].hits += 2 if !($DEBUG && Input.press?(Input::CTRL)) else # Pick - pattern=[0,1,0, - 1,2,1, - 0,1,0] - @sprites["crack"].hits+=1 if !($DEBUG && Input.press?(Input::CTRL)) + pattern = [0, 1, 0, + 1, 2, 1, + 0, 1, 0] + @sprites["crack"].hits += 1 if !($DEBUG && Input.press?(Input::CTRL)) end - if @sprites["tile#{position}"].layer<=pattern[4] && pbIsIronThere?(position) - @sprites["tile#{position}"].layer-=pattern[4] + if @sprites["tile#{position}"].layer <= pattern[4] && pbIsIronThere?(position) + @sprites["tile#{position}"].layer -= pattern[4] pbSEPlay("Mining iron") - hittype=2 + hittype = 2 else for i in 0..2 - ytile=i-1+position/BOARDWIDTH - next if ytile<0 || ytile>=BOARDHEIGHT + ytile = i - 1 + position / BOARDWIDTH + next if ytile < 0 || ytile >= BOARDHEIGHT for j in 0..2 - xtile=j-1+position%BOARDWIDTH - next if xtile<0 || xtile>=BOARDWIDTH - @sprites["tile#{xtile+ytile*BOARDWIDTH}"].layer-=pattern[j+i*3] + xtile = j - 1 + position % BOARDWIDTH + next if xtile < 0 || xtile >= BOARDWIDTH + @sprites["tile#{xtile + ytile * BOARDWIDTH}"].layer -= pattern[j + i * 3] end end - if @sprites["cursor"].mode==1 # Hammer + if @sprites["cursor"].mode == 1 # Hammer pbSEPlay("Mining hammer") else pbSEPlay("Mining pick") @@ -414,11 +414,11 @@ class MiningGameScene end update Graphics.update - hititem=(@sprites["tile#{position}"].layer==0 && pbIsItemThere?(position)) - hittype=1 if hititem + hititem = (@sprites["tile#{position}"].layer == 0 && pbIsItemThere?(position)) + hittype = 1 if hititem @sprites["cursor"].animate(hittype) - revealed=pbCheckRevealed - if revealed.length>0 + revealed = pbCheckRevealed + if revealed.length > 0 pbSEPlay("Mining reveal full") pbFlashItems(revealed) elsif hititem @@ -427,52 +427,52 @@ class MiningGameScene end def pbIsItemThere?(position) - posx=position%BOARDWIDTH - posy=position/BOARDWIDTH + posx = position % BOARDWIDTH + posy = position / BOARDWIDTH for i in @items - index=i[0] - width=ITEMS[index][4] - height=ITEMS[index][5] - pattern=ITEMS[index][6] - next if posx=(i[1]+width) - next if posy=(i[2]+height) - dx=posx-i[1] - dy=posy-i[2] - return true if pattern[dx+dy*width]>0 + index = i[0] + width = ITEMS[index][4] + height = ITEMS[index][5] + pattern = ITEMS[index][6] + next if posx < i[1] || posx >= (i[1] + width) + next if posy < i[2] || posy >= (i[2] + height) + dx = posx - i[1] + dy = posy - i[2] + return true if pattern[dx + dy * width] > 0 end return false end def pbIsIronThere?(position) - posx=position%BOARDWIDTH - posy=position/BOARDWIDTH + posx = position % BOARDWIDTH + posy = position / BOARDWIDTH for i in @iron - index=i[0] - width=IRON[index][2] - height=IRON[index][3] - pattern=IRON[index][4] - next if posx=(i[1]+width) - next if posy=(i[2]+height) - dx=posx-i[1] - dy=posy-i[2] - return true if pattern[dx+dy*width]>0 + index = i[0] + width = IRON[index][2] + height = IRON[index][3] + pattern = IRON[index][4] + next if posx < i[1] || posx >= (i[1] + width) + next if posy < i[2] || posy >= (i[2] + height) + dx = posx - i[1] + dy = posy - i[2] + return true if pattern[dx + dy * width] > 0 end return false end def pbCheckRevealed - ret=[] + ret = [] for i in 0...@items.length next if @items[i][3] - revealed=true - index=@items[i][0] - width=ITEMS[index][4] - height=ITEMS[index][5] - pattern=ITEMS[index][6] + revealed = true + index = @items[i][0] + width = ITEMS[index][4] + height = ITEMS[index][5] + pattern = ITEMS[index][6] for j in 0...height for k in 0...width - layer=@sprites["tile#{@items[i][1]+k+(@items[i][2]+j)*BOARDWIDTH}"].layer - revealed=false if layer>0 && pattern[k+j*width]>0 + layer = @sprites["tile#{@items[i][1] + k + (@items[i][2] + j) * BOARDWIDTH}"].layer + revealed = false if layer > 0 && pattern[k + j * width] > 0 break if !revealed end break if !revealed @@ -483,21 +483,21 @@ class MiningGameScene end def pbFlashItems(revealed) - return if revealed.length<=0 - revealeditems = BitmapSprite.new(Graphics.width,Graphics.height,@viewport) - halfFlashTime = Graphics.frame_rate/8 - alphaDiff = (255.0/halfFlashTime).ceil - for i in 1..halfFlashTime*2 + return if revealed.length <= 0 + revealeditems = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) + halfFlashTime = Graphics.frame_rate / 8 + alphaDiff = (255.0 / halfFlashTime).ceil + for i in 1..halfFlashTime * 2 for index in revealed - burieditem=@items[index] - revealeditems.bitmap.blt(32*burieditem[1],64+32*burieditem[2], + burieditem = @items[index] + revealeditems.bitmap.blt(32 * burieditem[1], 64 + 32 * burieditem[2], @itembitmap.bitmap, - Rect.new(32*ITEMS[burieditem[0]][2],32*ITEMS[burieditem[0]][3], - 32*ITEMS[burieditem[0]][4],32*ITEMS[burieditem[0]][5])) - if i>halfFlashTime - revealeditems.color = Color.new(255,255,255,(halfFlashTime*2-i)*alphaDiff) + Rect.new(32 * ITEMS[burieditem[0]][2], 32 * ITEMS[burieditem[0]][3], + 32 * ITEMS[burieditem[0]][4], 32 * ITEMS[burieditem[0]][5])) + if i > halfFlashTime + revealeditems.color = Color.new(255, 255, 255, (halfFlashTime * 2 - i) * alphaDiff) else - revealeditems.color = Color.new(255,255,255,i*alphaDiff) + revealeditems.color = Color.new(255, 255, 255, i * alphaDiff) end end update @@ -505,76 +505,76 @@ class MiningGameScene end revealeditems.dispose for index in revealed - @items[index][3]=true - item=ITEMS[@items[index][0]][0] + @items[index][3] = true + item = ITEMS[@items[index][0]][0] @itemswon.push(item) end end def pbMain pbSEPlay("Mining ping") - pbMessage(_INTL("Something pinged in the wall!\n{1} confirmed!",@items.length)) + pbMessage(_INTL("Something pinged in the wall!\n{1} confirmed!", @items.length)) loop do update Graphics.update Input.update next if @sprites["cursor"].isAnimating? # Check end conditions - if @sprites["crack"].hits>=49 - @sprites["cursor"].visible=false + if @sprites["crack"].hits >= 49 + @sprites["cursor"].visible = false pbSEPlay("Mining collapse") - collapseviewport=Viewport.new(0,0,Graphics.width,Graphics.height) - collapseviewport.z=99999 - @sprites["collapse"]=BitmapSprite.new(Graphics.width,Graphics.height,collapseviewport) - collapseTime = Graphics.frame_rate*8/10 - collapseFraction = (Graphics.height.to_f/collapseTime).ceil + collapseviewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + collapseviewport.z = 99999 + @sprites["collapse"] = BitmapSprite.new(Graphics.width, Graphics.height, collapseviewport) + collapseTime = Graphics.frame_rate * 8 / 10 + collapseFraction = (Graphics.height.to_f / collapseTime).ceil for i in 1..collapseTime - @sprites["collapse"].bitmap.fill_rect(0,collapseFraction*(i-1), - Graphics.width,collapseFraction*i,Color.new(0,0,0)) + @sprites["collapse"].bitmap.fill_rect(0, collapseFraction * (i - 1), + Graphics.width, collapseFraction * i, Color.new(0, 0, 0)) Graphics.update end pbMessage(_INTL("The wall collapsed!")) break end - foundall=true + foundall = true for i in @items - foundall=false if !i[3] + foundall = false if !i[3] break if !foundall end if foundall - @sprites["cursor"].visible=false - pbWait(Graphics.frame_rate*3/4) + @sprites["cursor"].visible = false + pbWait(Graphics.frame_rate * 3 / 4) pbSEPlay("Mining found all") pbMessage(_INTL("Everything was dug up!")) break end # Input if Input.trigger?(Input::UP) || Input.repeat?(Input::UP) - if @sprites["cursor"].position>=BOARDWIDTH + if @sprites["cursor"].position >= BOARDWIDTH pbSEPlay("Mining cursor") - @sprites["cursor"].position-=BOARDWIDTH + @sprites["cursor"].position -= BOARDWIDTH end elsif Input.trigger?(Input::DOWN) || Input.repeat?(Input::DOWN) - if @sprites["cursor"].position<(BOARDWIDTH*(BOARDHEIGHT-1)) + if @sprites["cursor"].position < (BOARDWIDTH * (BOARDHEIGHT - 1)) pbSEPlay("Mining cursor") - @sprites["cursor"].position+=BOARDWIDTH + @sprites["cursor"].position += BOARDWIDTH end elsif Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT) - if @sprites["cursor"].position%BOARDWIDTH>0 + if @sprites["cursor"].position % BOARDWIDTH > 0 pbSEPlay("Mining cursor") - @sprites["cursor"].position-=1 + @sprites["cursor"].position -= 1 end elsif Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT) - if @sprites["cursor"].position%BOARDWIDTH<(BOARDWIDTH-1) + if @sprites["cursor"].position % BOARDWIDTH < (BOARDWIDTH - 1) pbSEPlay("Mining cursor") - @sprites["cursor"].position+=1 + @sprites["cursor"].position += 1 end elsif Input.trigger?(Input::ACTION) # Change tool mode pbSEPlay("Mining tool change") - newmode=(@sprites["cursor"].mode+1)%2 - @sprites["cursor"].mode=newmode - @sprites["tool"].src_rect.set(newmode*68,0,68,100) - @sprites["tool"].y=254-144*newmode + newmode = (@sprites["cursor"].mode + 1) % 2 + @sprites["cursor"].mode = newmode + @sprites["tool"].src_rect.set(newmode * 68, 0, 68, 100) + @sprites["tool"].y = 254 - 144 * newmode elsif Input.trigger?(Input::USE) # Hit pbHit elsif Input.trigger?(Input::BACK) # Quit @@ -585,7 +585,7 @@ class MiningGameScene end def pbGiveItems - if @itemswon.length>0 + if @itemswon.length > 0 for i in @itemswon if $bag.add(i) pbMessage(_INTL("One {1} was obtained.\\se[Mining item get]\\wtnp[30]", @@ -609,7 +609,7 @@ end class MiningGame def initialize(scene) - @scene=scene + @scene = scene end def pbStartScreen diff --git a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb index 251f6f94b..89f784206 100644 --- a/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb +++ b/Data/Scripts/017_Minigames/007_Minigame_TilePuzzles.rb @@ -22,60 +22,60 @@ class TilePuzzleCursor < BitmapSprite attr_accessor :selected attr_accessor :holding - def initialize(game,position,tilewidth,tileheight,boardwidth,boardheight) - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 - super(Graphics.width,Graphics.height,@viewport) - @game=game - @position=position - @tilewidth=tilewidth - @tileheight=tileheight - @boardwidth=boardwidth - @boardheight=boardheight - @arrows=[] - @selected=false - @holding=false - @cursorbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/Tile Puzzle/cursor")) + def initialize(game, position, tilewidth, tileheight, boardwidth, boardheight) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 + super(Graphics.width, Graphics.height, @viewport) + @game = game + @position = position + @tilewidth = tilewidth + @tileheight = tileheight + @boardwidth = boardwidth + @boardheight = boardheight + @arrows = [] + @selected = false + @holding = false + @cursorbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Tile Puzzle/cursor")) update end def update self.bitmap.clear - x=(Graphics.width-(@tilewidth*@boardwidth))/2 - if @position>=@boardwidth*@boardheight - x=(x-(@tilewidth*(@boardwidth/2).ceil))/2-10 - if (@position%@boardwidth)>=(@boardwidth/2).ceil - x=Graphics.width-x-@tilewidth*@boardwidth + x = (Graphics.width - (@tilewidth * @boardwidth)) / 2 + if @position >= @boardwidth * @boardheight + x = (x - (@tilewidth * (@boardwidth / 2).ceil)) / 2 - 10 + if (@position % @boardwidth) >= (@boardwidth / 2).ceil + x = Graphics.width - x - @tilewidth * @boardwidth end end - x+=@tilewidth*(@position%@boardwidth) - y=(Graphics.height-(@tileheight*@boardheight))/2-32 - y+=@tileheight*((@position%(@boardwidth*@boardheight))/@boardwidth) - self.tone=Tone.new(0,(@holding ? 64 : 0),(@holding ? 64 : 0),0) + x += @tilewidth * (@position % @boardwidth) + y = (Graphics.height - (@tileheight * @boardheight)) / 2 - 32 + y += @tileheight * ((@position % (@boardwidth * @boardheight)) / @boardwidth) + self.tone = Tone.new(0, (@holding ? 64 : 0), (@holding ? 64 : 0), 0) # Cursor - if @game!=3 - expand=(@holding) ? 0 : 4 + if @game != 3 + expand = (@holding) ? 0 : 4 for i in 0...4 - self.bitmap.blt(x+(i%2)*(@tilewidth-@cursorbitmap.width/4)+expand*(((i%2)*2)-1), - y+(i/2)*(@tileheight-@cursorbitmap.height/2)+expand*(((i/2)*2)-1), - @cursorbitmap.bitmap,Rect.new( - (i%2)*@cursorbitmap.width/4,(i/2)*@cursorbitmap.height/2, - @cursorbitmap.width/4,@cursorbitmap.height/2)) + self.bitmap.blt(x + (i % 2) * (@tilewidth - @cursorbitmap.width / 4) + expand * (((i % 2) * 2) - 1), + y + (i / 2) * (@tileheight - @cursorbitmap.height / 2) + expand * (((i / 2) * 2) - 1), + @cursorbitmap.bitmap, Rect.new( + (i % 2) * @cursorbitmap.width / 4, (i / 2) * @cursorbitmap.height / 2, + @cursorbitmap.width / 4, @cursorbitmap.height / 2)) end end # Arrows - if @selected || @game==3 - expand=(@game==3) ? 0 : 4 - xin=[(@tilewidth-@cursorbitmap.width/4)/2,-expand, - @tilewidth-@cursorbitmap.width/4+expand,(@tilewidth-@cursorbitmap.width/4)/2] - yin=[@tileheight-@cursorbitmap.height/2+expand,(@tileheight-@cursorbitmap.height/2)/2, - (@tileheight-@cursorbitmap.height/2)/2,-expand] + if @selected || @game == 3 + expand = (@game == 3) ? 0 : 4 + xin = [(@tilewidth - @cursorbitmap.width / 4) / 2, -expand, + @tilewidth - @cursorbitmap.width / 4 + expand, (@tilewidth - @cursorbitmap.width / 4) / 2] + yin = [@tileheight - @cursorbitmap.height / 2 + expand, (@tileheight - @cursorbitmap.height / 2) / 2, + (@tileheight - @cursorbitmap.height / 2) / 2, -expand] for i in 0...4 if @arrows[i] - self.bitmap.blt(x+xin[i],y+yin[i],@cursorbitmap.bitmap,Rect.new( - @cursorbitmap.width/2+(i%2)*(@cursorbitmap.width/4), - (i/2)*(@cursorbitmap.height/2), - @cursorbitmap.width/4,@cursorbitmap.height/2)) + self.bitmap.blt(x + xin[i], y + yin[i], @cursorbitmap.bitmap, Rect.new( + @cursorbitmap.width / 2 + (i % 2) * (@cursorbitmap.width / 4), + (i / 2) * (@cursorbitmap.height / 2), + @cursorbitmap.width / 4, @cursorbitmap.height / 2)) end end end @@ -85,49 +85,49 @@ end class TilePuzzleScene - def initialize(game,board,width,height) - @game=game - @board=board - @boardwidth=(width>0) ? width : 4 - @boardheight=(height>0) ? height : 4 + def initialize(game, board, width, height) + @game = game + @board = board + @boardwidth = (width > 0) ? width : 4 + @boardheight = (height > 0) ? height : 4 end def update - xtop=(Graphics.width-(@tilewidth*@boardwidth))/2 - ytop=(Graphics.height-(@tileheight*@boardheight))/2+@tileheight/2-32 - for i in 0...@boardwidth*@boardheight - pos=-1 + xtop = (Graphics.width - (@tilewidth * @boardwidth)) / 2 + ytop = (Graphics.height - (@tileheight * @boardheight)) / 2 + @tileheight / 2 - 32 + for i in 0...@boardwidth * @boardheight + pos = -1 for j in 0...@tiles.length - pos=j if @tiles[j]==i + pos = j if @tiles[j] == i end - @sprites["tile#{i}"].z=0 - @sprites["tile#{i}"].tone=Tone.new(0,0,0,0) - if @heldtile==i - pos=@sprites["cursor"].position - @sprites["tile#{i}"].z=1 - @sprites["tile#{i}"].tone=Tone.new(64,0,0,0) if @tiles[pos]>=0 + @sprites["tile#{i}"].z = 0 + @sprites["tile#{i}"].tone = Tone.new(0, 0, 0, 0) + if @heldtile == i + pos = @sprites["cursor"].position + @sprites["tile#{i}"].z = 1 + @sprites["tile#{i}"].tone = Tone.new(64, 0, 0, 0) if @tiles[pos] >= 0 end - thisx=xtop - if pos>=0 - if pos>=@boardwidth*@boardheight - thisx=(xtop-(@tilewidth*(@boardwidth/2).ceil))/2-10 - if (pos%@boardwidth)>=(@boardwidth/2).ceil - thisx=Graphics.width-thisx-@tilewidth*@boardwidth + thisx = xtop + if pos >= 0 + if pos >= @boardwidth * @boardheight + thisx = (xtop - (@tilewidth * (@boardwidth / 2).ceil)) / 2 - 10 + if (pos % @boardwidth) >= (@boardwidth / 2).ceil + thisx = Graphics.width - thisx - @tilewidth * @boardwidth end end - @sprites["tile#{i}"].x=thisx+@tilewidth*(pos%@boardwidth)+@tilewidth/2 - @sprites["tile#{i}"].y=ytop+@tileheight*((pos%(@boardwidth*@boardheight))/@boardwidth) - next if @game==3 - rotatebitmaps=[@tilebitmap,@tilebitmap1,@tilebitmap2,@tilebitmap3] + @sprites["tile#{i}"].x = thisx + @tilewidth * (pos % @boardwidth) + @tilewidth / 2 + @sprites["tile#{i}"].y = ytop + @tileheight * ((pos % (@boardwidth * @boardheight)) / @boardwidth) + next if @game == 3 + rotatebitmaps = [@tilebitmap, @tilebitmap1, @tilebitmap2, @tilebitmap3] @sprites["tile#{i}"].bitmap.clear if rotatebitmaps[@angles[i]] - @sprites["tile#{i}"].bitmap.blt(0,0,rotatebitmaps[@angles[i]].bitmap, - Rect.new(@tilewidth*(i%@boardwidth),@tileheight*(i/@boardwidth),@tilewidth,@tileheight)) - @sprites["tile#{i}"].angle=0 + @sprites["tile#{i}"].bitmap.blt(0, 0, rotatebitmaps[@angles[i]].bitmap, + Rect.new(@tilewidth * (i % @boardwidth), @tileheight * (i / @boardwidth), @tilewidth, @tileheight)) + @sprites["tile#{i}"].angle = 0 else - @sprites["tile#{i}"].bitmap.blt(0,0,@tilebitmap.bitmap, - Rect.new(@tilewidth*(i%@boardwidth),@tileheight*(i/@boardwidth),@tilewidth,@tileheight)) - @sprites["tile#{i}"].angle=@angles[i]*90 + @sprites["tile#{i}"].bitmap.blt(0, 0, @tilebitmap.bitmap, + Rect.new(@tilewidth * (i % @boardwidth), @tileheight * (i / @boardwidth), @tilewidth, @tileheight)) + @sprites["tile#{i}"].angle = @angles[i] * 90 end end end @@ -136,100 +136,100 @@ class TilePuzzleScene end def updateCursor - arrows=[] + arrows = [] for i in 0...4 - arrows.push(pbCanMoveInDir?(@sprites["cursor"].position,(i+1)*2,@game==6)) + arrows.push(pbCanMoveInDir?(@sprites["cursor"].position, (i + 1) * 2, @game == 6)) end - @sprites["cursor"].arrows=arrows + @sprites["cursor"].arrows = arrows end def pbStartScene - @sprites={} - @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - @viewport.z=99999 + @sprites = {} + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + @viewport.z = 99999 if pbResolveBitmap("Graphics/Pictures/Tile Puzzle/bg#{@board}") - addBackgroundPlane(@sprites,"bg","Tile Puzzle/bg#{@board}",@viewport) + addBackgroundPlane(@sprites, "bg", "Tile Puzzle/bg#{@board}", @viewport) else - addBackgroundPlane(@sprites,"bg","Tile Puzzle/bg",@viewport) + addBackgroundPlane(@sprites, "bg", "Tile Puzzle/bg", @viewport) end - @tilebitmap=AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}") - @tilebitmap1=nil - @tilebitmap2=nil - @tilebitmap3=nil + @tilebitmap = AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}") + @tilebitmap1 = nil + @tilebitmap2 = nil + @tilebitmap3 = nil if pbResolveBitmap("Graphics/Pictures/Tile Puzzle/tiles#{@board}_1") - @tilebitmap1=AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}_1") + @tilebitmap1 = AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}_1") end if pbResolveBitmap("Graphics/Pictures/Tile Puzzle/tiles#{@board}_2") - @tilebitmap2=AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}_2") + @tilebitmap2 = AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}_2") end if pbResolveBitmap("Graphics/Pictures/Tile Puzzle/tiles#{@board}_3") - @tilebitmap3=AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}_3") + @tilebitmap3 = AnimatedBitmap.new("Graphics/Pictures/Tile Puzzle/tiles#{@board}_3") end - @tilewidth=@tilebitmap.width/@boardwidth - @tileheight=@tilebitmap.height/@boardheight - for i in 0...@boardwidth*@boardheight - @sprites["tile#{i}"]=BitmapSprite.new(@tilewidth,@tileheight,@viewport) - @sprites["tile#{i}"].ox=@tilewidth/2 - @sprites["tile#{i}"].oy=@tileheight/2 - break if @game==3 && i>=@boardwidth*@boardheight-1 - @sprites["tile#{i}"].bitmap.blt(0,0,@tilebitmap.bitmap, - Rect.new(@tilewidth*(i%@boardwidth),@tileheight*(i/@boardwidth),@tilewidth,@tileheight)) + @tilewidth = @tilebitmap.width / @boardwidth + @tileheight = @tilebitmap.height / @boardheight + for i in 0...@boardwidth * @boardheight + @sprites["tile#{i}"] = BitmapSprite.new(@tilewidth, @tileheight, @viewport) + @sprites["tile#{i}"].ox = @tilewidth / 2 + @sprites["tile#{i}"].oy = @tileheight / 2 + break if @game == 3 && i >= @boardwidth * @boardheight - 1 + @sprites["tile#{i}"].bitmap.blt(0, 0, @tilebitmap.bitmap, + Rect.new(@tilewidth * (i % @boardwidth), @tileheight * (i / @boardwidth), @tilewidth, @tileheight)) end - @heldtile=-1 - @angles=[] - @tiles=pbShuffleTiles - @sprites["cursor"]=TilePuzzleCursor.new(@game,pbDefaultCursorPosition, - @tilewidth,@tileheight,@boardwidth,@boardheight) + @heldtile = -1 + @angles = [] + @tiles = pbShuffleTiles + @sprites["cursor"] = TilePuzzleCursor.new(@game, pbDefaultCursorPosition, + @tilewidth, @tileheight, @boardwidth, @boardheight) update pbFadeInAndShow(@sprites) end def pbShuffleTiles - ret=[] - for i in 0...@boardwidth*@boardheight + ret = [] + for i in 0...@boardwidth * @boardheight ret.push(i) @angles.push(0) end - if @game==6 - @tiles=ret + if @game == 6 + @tiles = ret 5.times do - pbShiftLine([2,4,6,8][rand(4)],rand(@boardwidth*@boardheight),false) + pbShiftLine([2, 4, 6, 8][rand(4)], rand(@boardwidth * @boardheight), false) end return @tiles - elsif @game==7 - @tiles=ret + elsif @game == 7 + @tiles = ret 5.times do - pbRotateTile(rand(@boardwidth*@boardheight),false) + pbRotateTile(rand(@boardwidth * @boardheight), false) end else ret.shuffle! - if @game==3 # Make sure only solvable Mystic Squares are allowed. - num=0 - blank=-1 - for i in 0...ret.length-1 - blank=i if ret[i]==@boardwidth*@boardheight-1 + if @game == 3 # Make sure only solvable Mystic Squares are allowed. + num = 0 + blank = -1 + for i in 0...ret.length - 1 + blank = i if ret[i] == @boardwidth * @boardheight - 1 for j in i...ret.length - num+=1 if ret[j]=@boardwidth*@boardheight - if pos%@boardwidth==(@boardwidth/2).ceil - pos=((pos%(@boardwidth*@boardheight))/@boardwidth)*@boardwidth+@boardwidth-1 + def pbMoveCursor(pos, dir) + if dir == 2 + pos += @boardwidth + elsif dir == 4 + if pos >= @boardwidth * @boardheight + if pos % @boardwidth == (@boardwidth / 2).ceil + pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth + @boardwidth - 1 else - pos-=1 + pos -= 1 end else - if (pos%@boardwidth)==0 - pos=(((pos/@boardwidth)+@boardheight)*@boardwidth)+(@boardwidth/2).ceil-1 + if (pos % @boardwidth) == 0 + pos = (((pos / @boardwidth) + @boardheight) * @boardwidth) + (@boardwidth / 2).ceil - 1 else - pos-=1 + pos -= 1 end end - elsif dir==6 - if pos>=@boardwidth*@boardheight - if pos%@boardwidth==(@boardwidth/2).ceil-1 - pos=((pos%(@boardwidth*@boardheight))/@boardwidth)*@boardwidth + elsif dir == 6 + if pos >= @boardwidth * @boardheight + if pos % @boardwidth == (@boardwidth / 2).ceil - 1 + pos = ((pos % (@boardwidth * @boardheight)) / @boardwidth) * @boardwidth else - pos+=1 + pos += 1 end else - if pos%@boardwidth>=@boardwidth-1 - pos=(((pos/@boardwidth)+@boardheight)*@boardwidth)+(@boardwidth/2).ceil + if pos % @boardwidth >= @boardwidth - 1 + pos = (((pos / @boardwidth) + @boardheight) * @boardwidth) + (@boardwidth / 2).ceil else - pos+=1 + pos += 1 end end - elsif dir==8 - pos-=@boardwidth + elsif dir == 8 + pos -= @boardwidth end return pos end - def pbCanMoveInDir?(pos,dir,swapping) - return true if @game==6 && swapping - if dir==2 - return false if (pos/@boardwidth)%@boardheight>=@boardheight-1 - elsif dir==4 - if @game==1 || @game==2 - return false if pos>=@boardwidth*@boardheight && pos%@boardwidth==0 + def pbCanMoveInDir?(pos, dir, swapping) + return true if @game == 6 && swapping + if dir == 2 + return false if (pos / @boardwidth) % @boardheight >= @boardheight - 1 + elsif dir == 4 + if @game == 1 || @game == 2 + return false if pos >= @boardwidth * @boardheight && pos % @boardwidth == 0 else - return false if pos%@boardwidth==0 + return false if pos % @boardwidth == 0 end - elsif dir==6 - if @game==1 || @game==2 - return false if pos>=@boardwidth*@boardheight && pos%@boardwidth>=@boardwidth-1 + elsif dir == 6 + if @game == 1 || @game == 2 + return false if pos >= @boardwidth * @boardheight && pos % @boardwidth >= @boardwidth - 1 else - return false if pos%@boardwidth>=@boardwidth-1 + return false if pos % @boardwidth >= @boardwidth - 1 end - elsif dir==8 - return false if (pos/@boardwidth)%@boardheight==0 + elsif dir == 8 + return false if (pos / @boardwidth) % @boardheight == 0 end return true end - def pbRotateTile(pos,anim = true) - if @heldtile>=0 + def pbRotateTile(pos, anim = true) + if @heldtile >= 0 if anim - @sprites["cursor"].visible=false + @sprites["cursor"].visible = false @sprites["tile#{@heldtile}"].z = 1 oldAngle = @sprites["tile#{@heldtile}"].angle - rotateTime = Graphics.frame_rate/4 - angleDiff = 90.0/rotateTime + rotateTime = Graphics.frame_rate / 4 + angleDiff = 90.0 / rotateTime rotateTime.times do @sprites["tile#{@heldtile}"].angle -= angleDiff pbUpdateSpriteHash(@sprites) @@ -321,23 +321,23 @@ class TilePuzzleScene Input.update end @sprites["tile#{@heldtile}"].z = 0 - @sprites["tile#{@heldtile}"].angle = oldAngle-90 - @sprites["cursor"].visible=true if !pbCheckWin + @sprites["tile#{@heldtile}"].angle = oldAngle - 90 + @sprites["cursor"].visible = true if !pbCheckWin end - @angles[@heldtile]-=1 - @angles[@heldtile]+=4 if @angles[@heldtile]<0 + @angles[@heldtile] -= 1 + @angles[@heldtile] += 4 if @angles[@heldtile] < 0 else - return if @tiles[pos]<0 - group=pbGetNearTiles(pos) + return if @tiles[pos] < 0 + group = pbGetNearTiles(pos) if anim - @sprites["cursor"].visible=false + @sprites["cursor"].visible = false oldAngles = [] for i in group @sprites["tile#{@tiles[i]}"].z = 1 oldAngles[i] = @sprites["tile#{@tiles[i]}"].angle end - rotateTime = Graphics.frame_rate/4 - angleDiff = 90.0/rotateTime + rotateTime = Graphics.frame_rate / 4 + angleDiff = 90.0 / rotateTime rotateTime.times do for i in group @sprites["tile#{@tiles[i]}"].angle -= angleDiff @@ -348,114 +348,114 @@ class TilePuzzleScene end for i in group @sprites["tile#{@tiles[i]}"].z = 0 - @sprites["tile#{@tiles[i]}"].angle = oldAngles[i]-90 + @sprites["tile#{@tiles[i]}"].angle = oldAngles[i] - 90 end - @sprites["cursor"].visible=true if !pbCheckWin + @sprites["cursor"].visible = true if !pbCheckWin end for i in group - tile=@tiles[i] - @angles[tile]-=1 - @angles[tile]+=4 if @angles[tile]<0 + tile = @tiles[i] + @angles[tile] -= 1 + @angles[tile] += 4 if @angles[tile] < 0 end end end def pbGetNearTiles(pos) - ret=[pos] - if @game==7 - for i in [2,4,6,8] - ret.push(pbMoveCursor(pos,i)) if pbCanMoveInDir?(pos,i,true) + ret = [pos] + if @game == 7 + for i in [2, 4, 6, 8] + ret.push(pbMoveCursor(pos, i)) if pbCanMoveInDir?(pos, i, true) end end return ret end def pbSwapTiles(dir) - cursor=@sprites["cursor"].position - return pbShiftLine(dir,cursor) if @game==6 - movetile=pbMoveCursor(cursor,dir) - @sprites["cursor"].visible=false - @sprites["tile#{@tiles[cursor]}"].z=1 - if dir==2 || dir==8 # Swap vertically - swapTime = Graphics.frame_rate*3/10 - distancePerFrame = (@tileheight.to_f/swapTime).ceil - dist = (dir/4).floor-1 + cursor = @sprites["cursor"].position + return pbShiftLine(dir, cursor) if @game == 6 + movetile = pbMoveCursor(cursor, dir) + @sprites["cursor"].visible = false + @sprites["tile#{@tiles[cursor]}"].z = 1 + if dir == 2 || dir == 8 # Swap vertically + swapTime = Graphics.frame_rate * 3 / 10 + distancePerFrame = (@tileheight.to_f / swapTime).ceil + dist = (dir / 4).floor - 1 swapTime.times do - @sprites["tile#{@tiles[movetile]}"].y += dist*distancePerFrame - @sprites["tile#{@tiles[cursor]}"].y -= dist*distancePerFrame + @sprites["tile#{@tiles[movetile]}"].y += dist * distancePerFrame + @sprites["tile#{@tiles[cursor]}"].y -= dist * distancePerFrame pbUpdateSpriteHash(@sprites) Graphics.update Input.update end else # Swap horizontally - swapTime = Graphics.frame_rate*3/10 - distancePerFrame = (@tilewidth.to_f/swapTime).ceil - dist = dir-5 + swapTime = Graphics.frame_rate * 3 / 10 + distancePerFrame = (@tilewidth.to_f / swapTime).ceil + dist = dir - 5 swapTime.times do - @sprites["tile#{@tiles[movetile]}"].x -= dist*distancePerFrame - @sprites["tile#{@tiles[cursor]}"].x += dist*distancePerFrame + @sprites["tile#{@tiles[movetile]}"].x -= dist * distancePerFrame + @sprites["tile#{@tiles[cursor]}"].x += dist * distancePerFrame pbUpdateSpriteHash(@sprites) Graphics.update Input.update end end - @tiles[cursor], @tiles[movetile]=@tiles[movetile], @tiles[cursor] - @sprites["tile#{@tiles[cursor]}"].z=0 - @sprites["cursor"].position=movetile - @sprites["cursor"].selected=false - @sprites["cursor"].visible=true if !pbCheckWin + @tiles[cursor], @tiles[movetile] = @tiles[movetile], @tiles[cursor] + @sprites["tile#{@tiles[cursor]}"].z = 0 + @sprites["cursor"].position = movetile + @sprites["cursor"].selected = false + @sprites["cursor"].visible = true if !pbCheckWin return true end - def pbShiftLine(dir,cursor,anim = true) + def pbShiftLine(dir, cursor, anim = true) # Get tiles involved - tiles=[] - dist=0 - if dir==2 || dir==8 - dist=(dir/4).floor-1 - while (dist>0 && cursor<(@boardwidth-1)*@boardheight) || - (dist<0 && cursor>=@boardwidth) - cursor+=(@boardwidth*dist) + tiles = [] + dist = 0 + if dir == 2 || dir == 8 + dist = (dir / 4).floor - 1 + while (dist > 0 && cursor < (@boardwidth - 1) * @boardheight) || + (dist < 0 && cursor >= @boardwidth) + cursor += (@boardwidth * dist) end for i in 0...@boardheight - tiles.push(cursor-i*dist*@boardwidth) + tiles.push(cursor - i * dist * @boardwidth) end else - dist=dir-5 - while (dist>0 && cursor%@boardwidth>0) || - (dist<0 && cursor%@boardwidth<@boardwidth-1) - cursor-=dist + dist = dir - 5 + while (dist > 0 && cursor % @boardwidth > 0) || + (dist < 0 && cursor % @boardwidth < @boardwidth - 1) + cursor -= dist end for i in 0...@boardwidth - tiles.push(cursor+i*dist) + tiles.push(cursor + i * dist) end end # Shift tiles - fadeTime = Graphics.frame_rate*4/10 - fadeDiff = (255.0/fadeTime).ceil + fadeTime = Graphics.frame_rate * 4 / 10 + fadeDiff = (255.0 / fadeTime).ceil if anim - @sprites["cursor"].visible=false + @sprites["cursor"].visible = false fadeTime.times do - @sprites["tile#{@tiles[tiles[tiles.length-1]]}"].opacity-=fadeDiff + @sprites["tile#{@tiles[tiles[tiles.length - 1]]}"].opacity -= fadeDiff Graphics.update Input.update end - shiftTime = Graphics.frame_rate*3/10 - if dir==2 || dir==8 - distancePerFrame = (@tileheight.to_f/shiftTime).ceil + shiftTime = Graphics.frame_rate * 3 / 10 + if dir == 2 || dir == 8 + distancePerFrame = (@tileheight.to_f / shiftTime).ceil shiftTime.times do for i in tiles - @sprites["tile#{@tiles[i]}"].y -= dist*distancePerFrame + @sprites["tile#{@tiles[i]}"].y -= dist * distancePerFrame end pbUpdateSpriteHash(@sprites) Graphics.update Input.update end else - distancePerFrame = (@tilewidth.to_f/shiftTime).ceil + distancePerFrame = (@tilewidth.to_f / shiftTime).ceil shiftTime.times do for i in tiles - @sprites["tile#{@tiles[i]}"].x += dist*distancePerFrame + @sprites["tile#{@tiles[i]}"].x += dist * distancePerFrame end pbUpdateSpriteHash(@sprites) Graphics.update @@ -463,36 +463,36 @@ class TilePuzzleScene end end end - temp=[] + temp = [] for i in tiles temp.push(@tiles[i]) end for i in 0...temp.length - @tiles[tiles[(i+1)%(temp.length)]]=temp[i] + @tiles[tiles[(i + 1) % (temp.length)]] = temp[i] end if anim update fadeTime.times do - @sprites["tile#{@tiles[tiles[0]]}"].opacity+=fadeDiff + @sprites["tile#{@tiles[tiles[0]]}"].opacity += fadeDiff Graphics.update Input.update end - @sprites["cursor"].selected=false - @sprites["cursor"].visible=true if !pbCheckWin + @sprites["cursor"].selected = false + @sprites["cursor"].visible = true if !pbCheckWin end return true end def pbGrabTile(pos) @heldtile, @tiles[pos] = @tiles[pos], @heldtile - @sprites["cursor"].holding=(@heldtile>=0) - @sprites["cursor"].visible=false if pbCheckWin + @sprites["cursor"].holding = (@heldtile >= 0) + @sprites["cursor"].visible = false if pbCheckWin end def pbCheckWin - for i in 0...@boardwidth*@boardheight - return false if @tiles[i]!=i - return false if @angles[i]!=0 + for i in 0...@boardwidth * @boardheight + return false if @tiles[i] != i + return false if @angles[i] != 0 end return true end @@ -504,23 +504,23 @@ class TilePuzzleScene Input.update # Check end conditions if pbCheckWin - @sprites["cursor"].visible=false - if @game==3 - extratile=@sprites["tile#{@boardwidth*@boardheight-1}"] + @sprites["cursor"].visible = false + if @game == 3 + extratile = @sprites["tile#{@boardwidth * @boardheight - 1}"] extratile.bitmap.clear - extratile.bitmap.blt(0,0,@tilebitmap.bitmap, - Rect.new(@tilewidth*(@boardwidth-1),@tileheight*(@boardheight-1), - @tilewidth,@tileheight)) - extratile.opacity=0 - appearTime = Graphics.frame_rate*8/10 - opacityDiff = (255.0/appearTime).ceil + extratile.bitmap.blt(0, 0, @tilebitmap.bitmap, + Rect.new(@tilewidth * (@boardwidth - 1), @tileheight * (@boardheight - 1), + @tilewidth, @tileheight)) + extratile.opacity = 0 + appearTime = Graphics.frame_rate * 8 / 10 + opacityDiff = (255.0 / appearTime).ceil appearTime.times do extratile.opacity += opacityDiff Graphics.update Input.update end else - pbWait(Graphics.frame_rate/2) + pbWait(Graphics.frame_rate / 2) end loop do Graphics.update @@ -530,29 +530,29 @@ class TilePuzzleScene return true end # Input - @sprites["cursor"].selected=(Input.press?(Input::USE) && @game>=3 && @game<=6) - dir=0 - dir=2 if Input.trigger?(Input::DOWN) || Input.repeat?(Input::DOWN) - dir=4 if Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT) - dir=6 if Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT) - dir=8 if Input.trigger?(Input::UP) || Input.repeat?(Input::UP) - if dir>0 - if @game==3 || (@game!=3 && @sprites["cursor"].selected) - if pbCanMoveInDir?(@sprites["cursor"].position,dir,true) + @sprites["cursor"].selected = (Input.press?(Input::USE) && @game >= 3 && @game <= 6) + dir = 0 + dir = 2 if Input.trigger?(Input::DOWN) || Input.repeat?(Input::DOWN) + dir = 4 if Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT) + dir = 6 if Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT) + dir = 8 if Input.trigger?(Input::UP) || Input.repeat?(Input::UP) + if dir > 0 + if @game == 3 || (@game != 3 && @sprites["cursor"].selected) + if pbCanMoveInDir?(@sprites["cursor"].position, dir, true) pbSEPlay("Tile Game cursor") pbSwapTiles(dir) end else - if pbCanMoveInDir?(@sprites["cursor"].position,dir,false) + if pbCanMoveInDir?(@sprites["cursor"].position, dir, false) pbSEPlay("Tile Game cursor") - @sprites["cursor"].position=pbMoveCursor(@sprites["cursor"].position,dir) + @sprites["cursor"].position = pbMoveCursor(@sprites["cursor"].position, dir) end end - elsif (@game==1 || @game==2) && Input.trigger?(Input::USE) + elsif (@game == 1 || @game == 2) && Input.trigger?(Input::USE) pbGrabTile(@sprites["cursor"].position) - elsif (@game==2 && Input.trigger?(Input::ACTION)) || - (@game==5 && Input.trigger?(Input::ACTION)) || - (@game==7 && Input.trigger?(Input::USE)) + elsif (@game == 2 && Input.trigger?(Input::ACTION)) || + (@game == 5 && Input.trigger?(Input::ACTION)) || + (@game == 7 && Input.trigger?(Input::USE)) pbRotateTile(@sprites["cursor"].position) elsif Input.trigger?(Input::BACK) return false @@ -571,12 +571,12 @@ end class TilePuzzle def initialize(scene) - @scene=scene + @scene = scene end def pbStartScreen @scene.pbStartScene - ret=@scene.pbMain + ret = @scene.pbMain @scene.pbEndScene return ret end @@ -584,10 +584,10 @@ end -def pbTilePuzzle(game,board,width = 0,height = 0) +def pbTilePuzzle(game, board, width = 0, height = 0) ret = false pbFadeOutIn { - scene = TilePuzzleScene.new(game,board,width,height) + scene = TilePuzzleScene.new(game, board, width, height) screen = TilePuzzle.new(scene) ret = screen.pbStartScreen } diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb index bab2c74bb..5a8705b37 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/001_Challenge_BattleChallenge.rb @@ -98,7 +98,7 @@ class BattleChallenge opponent = pbGenerateBattleTrainer(self.nextTrainer, self.rules) bttrainers = pbGetBTTrainers(@id) trainerdata = bttrainers[self.nextTrainer] - ret = pbOrganizedBattleEx(opponent,self.rules, + ret = pbOrganizedBattleEx(opponent, self.rules, pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]), pbGetMessageFromHash(MessageTypes::EndSpeechWin, trainerdata[3])) return ret diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb index 0636f8cae..60e351a1e 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/004_Challenge_Battles.rb @@ -105,7 +105,7 @@ end #=============================================================================== def pbRecordLastBattle $PokemonGlobal.lastbattle = $game_temp.last_battle_record - $game_temp.last_battle_record = nil + $game_temp.last_battle_record = nil end def pbPlayLastBattle diff --git a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb index 924d63e19..39b632c4e 100644 --- a/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb +++ b/Data/Scripts/018_Alternate battle modes/001_Battle Frontier/005_UI_BattleSwap.rb @@ -115,7 +115,7 @@ class BattleSwapScene end def pbSwapChosen(_pkmnindex) - commands=pbGetCommands(@newPokemon, []) + commands = pbGetCommands(@newPokemon, []) commands.push(_INTL("PKMN FOR SWAP")) commands.push(_INTL("CANCEL")) @sprites["help"].text = _INTL("Select Pokémon to accept.") diff --git a/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb b/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb index b5cd9df87..3e7f35a7f 100644 --- a/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb +++ b/Data/Scripts/018_Alternate battle modes/001_SafariZone.rb @@ -36,7 +36,7 @@ class SafariState end def pbStart(ballcount) - @start = [$game_map.map_id,$game_player.x,$game_player.y,$game_player.direction] + @start = [$game_map.map_id, $game_player.x, $game_player.y, $game_player.direction] @ballcount = ballcount @inProgress = true @steps = Settings::SAFARI_STEPS @@ -55,7 +55,7 @@ end -Events.onMapChange += proc { |_sender,*args| +Events.onMapChange += proc { |_sender, *args| pbSafariState.pbEnd if !pbInSafari? } @@ -75,12 +75,12 @@ 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 && Settings::SAFARI_STEPS > 0 + if pbInSafari? && pbSafariState.decision == 0 && Settings::SAFARI_STEPS > 0 pbSafariState.steps -= 1 - if pbSafariState.steps<=0 + if pbSafariState.steps <= 0 pbMessage(_INTL("PA: Ding-dong!\1")) pbMessage(_INTL("PA: Your safari game is over!")) pbSafariState.decision = 1 @@ -90,30 +90,30 @@ 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] - next if handled[0]!=nil + next if handled[0] != nil next if !pbInSafari? - handled[0] = pbSafariBattle(species,level) + handled[0] = pbSafariBattle(species, level) } -def pbSafariBattle(species,level) +def pbSafariBattle(species, level) # Generate a wild Pokémon based on the species and level - pkmn = pbGenerateWildPokemon(species,level) + pkmn = pbGenerateWildPokemon(species, level) foeParty = [pkmn] # Calculate who the trainer is playerTrainer = $player # Create the battle scene (the visual side of it) scene = pbNewBattleScene # Create the battle class (the mechanics side of it) - battle = SafariBattle.new(scene,playerTrainer,foeParty) + battle = SafariBattle.new(scene, playerTrainer, foeParty) battle.ballCount = pbSafariState.ballcount pbPrepareBattle(battle) # Perform the battle itself decision = 0 - pbBattleAnimation(pbGetWildBattleBGM(foeParty),0,foeParty) { + pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) { pbSceneStandby { decision = battle.pbStartBattle } @@ -121,8 +121,8 @@ def pbSafariBattle(species,level) Input.update # Update Safari game data based on result of battle pbSafariState.ballcount = battle.ballCount - if pbSafariState.ballcount<=0 - if decision!=2 # Last Safari Ball was used to catch the wild Pokémon + if pbSafariState.ballcount <= 0 + if decision != 2 # Last Safari Ball was used to catch the wild Pokémon pbMessage(_INTL("Announcer: You're out of Safari Balls! Game over!")) end pbSafariState.decision = 1 @@ -138,9 +138,9 @@ def pbSafariBattle(species,level) pbSafariState.captures += 1 $stats.most_captures_per_safari_game = [$stats.most_captures_per_safari_game, pbSafariState.captures].max end - pbSet(1,decision) + pbSet(1, decision) # Used by the Poké Radar to update/break the chain - Events.onWildBattleEnd.trigger(nil,species,level,decision) + Events.onWildBattleEnd.trigger(nil, species, level, decision) # Return the outcome of the battle return decision end diff --git a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb index bd755b9be..5fc9b4d4f 100644 --- a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb +++ b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/001_Challenge_ChallengeRules.rb @@ -67,14 +67,14 @@ class PokemonChallengeRules @levelAdjustment.unadjustLevels(party1, party2, adjusts) if @levelAdjustment && adjusts end - def adjustLevelsBilateral(party1,party2) + def adjustLevelsBilateral(party1, party2) if @levelAdjustment && @levelAdjustment.type == LevelAdjustment::BothTeams return @levelAdjustment.adjustLevels(party1, party2) end return nil end - def unadjustLevelsBilateral(party1,party2,adjusts) + def unadjustLevelsBilateral(party1, party2, adjusts) if @levelAdjustment && adjusts && @levelAdjustment.type == LevelAdjustment::BothTeams @levelAdjustment.unadjustLevels(party1, party2, adjusts) end @@ -85,7 +85,7 @@ class PokemonChallengeRules return self end - def addLevelRule(minLevel,maxLevel,totalLevel) + def addLevelRule(minLevel, maxLevel, totalLevel) self.addPokemonRule(MinimumLevelRestriction.new(minLevel)) self.addPokemonRule(MaximumLevelRestriction.new(maxLevel)) self.addSubsetRule(TotalLevelRestriction.new(totalLevel)) diff --git a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/003_Challenge_EntryRestrictions.rb b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/003_Challenge_EntryRestrictions.rb index 62cda9a35..611afe63b 100644 --- a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/003_Challenge_EntryRestrictions.rb +++ b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/003_Challenge_EntryRestrictions.rb @@ -326,7 +326,7 @@ class BannedItemRestriction @itemlist = itemlist.clone end - def isSpecies?(item,itemlist) + def isSpecies?(item, itemlist) return itemlist.include?(item) end diff --git a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb index 889a49101..b2955a30f 100644 --- a/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb +++ b/Data/Scripts/018_Alternate battle modes/002_Battle Frontier rules/004_Challenge_LevelAdjustment.rb @@ -100,7 +100,7 @@ class TotalLevelAdjustment < LevelAdjustment super(LevelAdjustment::EnemyTeam) @minLevel = minLevel.clamp(1, GameData::GrowthRate.max_level) @maxLevel = maxLevel.clamp(1, GameData::GrowthRate.max_level) - @totalLevel=totalLevel + @totalLevel = totalLevel end def getAdjustment(thisTeam, _otherTeam) @@ -134,12 +134,12 @@ class CombinedLevelAdjustment < LevelAdjustment @their = their end - def getMyAdjustment(myTeam,theirTeam) + def getMyAdjustment(myTeam, theirTeam) return @my.getAdjustment(myTeam, theirTeam) if @my return LevelAdjustment.getNullAdjustment(myTeam, theirTeam) end - def getTheirAdjustment(theirTeam,myTeam) + def getTheirAdjustment(theirTeam, myTeam) return @their.getAdjustment(theirTeam, myTeam) if @their return LevelAdjustment.getNullAdjustment(theirTeam, myTeam) end diff --git a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb index c2c72f41c..5393a82d8 100644 --- a/Data/Scripts/018_Alternate battle modes/002_BugContest.rb +++ b/Data/Scripts/018_Alternate battle modes/002_BugContest.rb @@ -18,35 +18,35 @@ class BugContestState def initialize clear - @lastContest=nil + @lastContest = nil end def pbContestHeld? return false if !@lastContest - timenow=pbGetTimeNow - return timenow.to_i-@lastContest<86400 + timenow = pbGetTimeNow + return timenow.to_i - @lastContest < 86400 end def expired? return false if !undecided? - return false if TimerSeconds<=0 - curtime=@timer+TimerSeconds*Graphics.frame_rate - curtime=[curtime-Graphics.frame_count,0].max - return (curtime<=0) + return false if TimerSeconds <= 0 + curtime = @timer + TimerSeconds * Graphics.frame_rate + curtime = [curtime - Graphics.frame_count, 0].max + return (curtime <= 0) end def clear - @ballcount=0 - @ended=false - @inProgress=false - @decision=0 - @encounterMap=0 - @lastPokemon=nil - @otherparty=[] - @contestants=[] - @places=[] - @start=nil - @reception=[] + @ballcount = 0 + @ended = false + @inProgress = false + @decision = 0 + @encounterMap = 0 + @lastPokemon = nil + @otherparty = [] + @contestants = [] + @places = [] + @start = nil + @reception = [] end def inProgress? @@ -54,21 +54,21 @@ class BugContestState end def undecided? - return (@inProgress && @decision==0) + return (@inProgress && @decision == 0) end def decided? - return (@inProgress && @decision!=0) || @ended + return (@inProgress && @decision != 0) || @ended end def pbSetPokemon(chosenpoke) - @chosenPokemon=chosenpoke + @chosenPokemon = chosenpoke end # Reception map is handled separately from contest map since the reception map # can be outdoors, with its own grassy patches. def pbSetReception(*arg) - @reception=[] + @reception = [] for i in arg @reception.push(i) end @@ -76,31 +76,31 @@ class BugContestState def pbOffLimits?(map) # p [map,@contestMap,@reception] - return false if map==@contestMap + return false if map == @contestMap for i in @reception - return false if map==i + return false if map == i end return true end - def pbSetJudgingPoint(startMap,startX,startY,dir = 8) - @start=[startMap,startX,startY,dir] + def pbSetJudgingPoint(startMap, startX, startY, dir = 8) + @start = [startMap, startX, startY, dir] end def pbSetContestMap(map) - @contestMap=map + @contestMap = map end def pbJudge - judgearray=[] + judgearray = [] if @lastPokemon - judgearray.push([-1,@lastPokemon.species,pbBugContestScore(@lastPokemon)]) + judgearray.push([-1, @lastPokemon.species, pbBugContestScore(@lastPokemon)]) end - @contestants=[] - [5,ContestantNames.length].min.times do + @contestants = [] + [5, ContestantNames.length].min.times do loop do - value=rand(ContestantNames.length) - if !@contestants.any? { |i| i==value } + value = rand(ContestantNames.length) + if !@contestants.any? { |i| i == value } @contestants.push(value) break end @@ -111,33 +111,33 @@ class BugContestState enctype = :Land end for cont in @contestants - enc=$PokemonEncounters.choose_wild_pokemon_for_map(@contestMap,enctype) + enc = $PokemonEncounters.choose_wild_pokemon_for_map(@contestMap, enctype) if !enc - raise _INTL("No encounters for map {1}, so can't judge contest",@contestMap) + raise _INTL("No encounters for map {1}, so can't judge contest", @contestMap) end - pokemon=Pokemon.new(enc[0],enc[1]) + pokemon = Pokemon.new(enc[0], enc[1]) pokemon.hp = rand(1..pokemon.totalhp - 1) - score=pbBugContestScore(pokemon) - judgearray.push([cont,pokemon.species,score]) + score = pbBugContestScore(pokemon) + judgearray.push([cont, pokemon.species, score]) end - if judgearray.length<3 + if judgearray.length < 3 raise _INTL("Too few bug catching contestants") end - judgearray.sort! { |a,b| b[2]<=>a[2] } # sort by score in descending order + judgearray.sort! { |a, b| b[2] <=> a[2] } # sort by score in descending order @places.push(judgearray[0]) @places.push(judgearray[1]) @places.push(judgearray[2]) end def pbGetPlaceInfo(place) - cont=@places[place][0] - if cont<0 - $game_variables[1]=$player.name + cont = @places[place][0] + if cont < 0 + $game_variables[1] = $player.name else - $game_variables[1]=ContestantNames[cont] + $game_variables[1] = ContestantNames[cont] end - $game_variables[2]=GameData::Species.get(@places[place][1]).name - $game_variables[3]=@places[place][2] + $game_variables[2] = GameData::Species.get(@places[place][1]).name + $game_variables[3] = @places[place][2] end def pbClearIfEnded @@ -145,7 +145,7 @@ class BugContestState end def pbStartJudging - @decision=1 + @decision = 1 pbJudge if $scene.is_a?(Scene_Map) pbFadeOutIn { @@ -161,40 +161,40 @@ class BugContestState end def pbIsContestant?(i) - return @contestants.any? { |item| i==item } + return @contestants.any? { |item| i == item } end def pbStart(ballcount) - @ballcount=ballcount - @inProgress=true - @otherparty=[] - @lastPokemon=nil - @lastContest=nil - @timer=Graphics.frame_count - @places=[] - chosenpkmn=$player.party[@chosenPokemon] + @ballcount = ballcount + @inProgress = true + @otherparty = [] + @lastPokemon = nil + @lastContest = nil + @timer = Graphics.frame_count + @places = [] + chosenpkmn = $player.party[@chosenPokemon] for i in 0...$player.party.length - @otherparty.push($player.party[i]) if i!=@chosenPokemon + @otherparty.push($player.party[i]) if i != @chosenPokemon end - @contestants=[] - [5,ContestantNames.length].min.times do + @contestants = [] + [5, ContestantNames.length].min.times do loop do - value=rand(ContestantNames.length) - if !@contestants.any? { |i| i==value } + value = rand(ContestantNames.length) + if !@contestants.any? { |i| i == value } @contestants.push(value) break end end end - $player.party=[chosenpkmn] - @decision=0 - @ended=false + $player.party = [chosenpkmn] + @decision = 0 + @ended = false $stats.bug_contest_count += 1 end def place for i in 0...3 - return i if @places[i][0]<0 + return i if @places[i][0] < 0 end return 3 end @@ -208,32 +208,32 @@ class BugContestState if @lastPokemon pbNicknameAndStore(@lastPokemon) end - @ended=true + @ended = true else - @ended=false + @ended = false end $stats.bug_contest_wins += 1 if place == 0 - @lastPokemon=nil - @otherparty=[] - @reception=[] - @ballcount=0 - @inProgress=false - @decision=0 - timenow=pbGetTimeNow - @lastContest=timenow.to_i - $game_map.need_refresh=true + @lastPokemon = nil + @otherparty = [] + @reception = [] + @ballcount = 0 + @inProgress = false + @decision = 0 + timenow = pbGetTimeNow + @lastContest = timenow.to_i + $game_map.need_refresh = true end end class TimerDisplay # :nodoc: - def initialize(start,maxtime) - @timer=Window_AdvancedTextPokemon.newWithSize("",Graphics.width-120,0,120,64) - @timer.z=99999 - @total_sec=nil - @start=start - @maxtime=maxtime + def initialize(start, maxtime) + @timer = Window_AdvancedTextPokemon.newWithSize("", Graphics.width - 120, 0, 120, 64) + @timer.z = 99999 + @total_sec = nil + @start = start + @maxtime = maxtime end def dispose @@ -245,8 +245,8 @@ class TimerDisplay # :nodoc: end def update - curtime=[(@start+@maxtime)-Graphics.frame_count,0].max - curtime/=Graphics.frame_rate + curtime = [(@start + @maxtime) - Graphics.frame_count, 0].max + curtime /= Graphics.frame_rate if curtime != @total_sec # Calculate total number of seconds @total_sec = curtime @@ -277,7 +277,7 @@ end def pbBugContestState if !$PokemonGlobal.bugContestState - $PokemonGlobal.bugContestState=BugContestState.new + $PokemonGlobal.bugContestState = BugContestState.new end return $PokemonGlobal.bugContestState end @@ -297,20 +297,20 @@ def pbBugContestDecided? return pbBugContestState.decided? end -Events.onMapChange += proc { |_sender,_e| +Events.onMapChange += proc { |_sender, _e| pbBugContestState.pbClearIfEnded } -Events.onMapSceneChange += proc { |_sender,e| - scene=e[0] - if pbInBugContest? && pbBugContestState.decision==0 && BugContestState::TimerSeconds>0 +Events.onMapSceneChange += proc { |_sender, e| + scene = e[0] + if pbInBugContest? && pbBugContestState.decision == 0 && BugContestState::TimerSeconds > 0 scene.spriteset.addUserSprite(TimerDisplay.new( pbBugContestState.timer, - BugContestState::TimerSeconds*Graphics.frame_rate)) + BugContestState::TimerSeconds * Graphics.frame_rate)) 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? @@ -321,8 +321,8 @@ Events.onMapUpdate += proc { |_sender,_e| end } -Events.onMapChanging += proc { |_sender,e| - newmapID=e[0] +Events.onMapChanging += proc { |_sender, e| + newmapID = e[0] if pbInBugContest? if pbBugContestState.pbOffLimits?(newmapID) # Clear bug contest if player flies/warps/teleports out of the contest @@ -340,21 +340,21 @@ def pbBugContestStartOver pbBugContestState.pbStartJudging end -Events.onWildBattleOverride += proc { |_sender,e| +Events.onWildBattleOverride += proc { |_sender, e| species = e[0] level = e[1] handled = e[2] - next if handled[0]!=nil + next if handled[0] != nil next if !pbInBugContest? - handled[0] = pbBugContestBattle(species,level) + handled[0] = pbBugContestBattle(species, level) } -def pbBugContestBattle(species,level) +def pbBugContestBattle(species, level) # Record information about party Pokémon to be used at the end of battle (e.g. # comparing levels for an evolution check) Events.onStartBattle.trigger(nil) # Generate a wild Pokémon based on the species and level - pkmn = pbGenerateWildPokemon(species,level) + pkmn = pbGenerateWildPokemon(species, level) foeParty = [pkmn] # Calculate who the trainers and their party are playerTrainer = [$player] @@ -363,17 +363,17 @@ def pbBugContestBattle(species,level) # Create the battle scene (the visual side of it) scene = pbNewBattleScene # Create the battle class (the mechanics side of it) - battle = BugContestBattle.new(scene,playerParty,foeParty,playerTrainer,nil) + battle = BugContestBattle.new(scene, playerParty, foeParty, playerTrainer, nil) battle.party1starts = playerPartyStarts battle.ballCount = pbBugContestState.ballcount setBattleRule("single") pbPrepareBattle(battle) # Perform the battle itself decision = 0 - pbBattleAnimation(pbGetWildBattleBGM(foeParty),0,foeParty) { + pbBattleAnimation(pbGetWildBattleBGM(foeParty), 0, foeParty) { decision = battle.pbStartBattle - pbAfterBattle(decision,true) - if decision==2 || decision==5 # Lost or drew + pbAfterBattle(decision, true) + if decision == 2 || decision == 5 # Lost or drew $game_system.bgm_unpause $game_system.bgs_unpause pbBugContestStartOver @@ -382,7 +382,7 @@ def pbBugContestBattle(species,level) Input.update # Update Bug Contest game data based on result of battle pbBugContestState.ballcount = battle.ballCount - if pbBugContestState.ballcount==0 + if pbBugContestState.ballcount == 0 pbMessage(_INTL("ANNOUNCER: The Bug-Catching Contest is over!")) pbBugContestState.pbStartJudging end @@ -399,9 +399,9 @@ def pbBugContestBattle(species,level) when 2, 3, 5 # Lost, fled, draw $stats.wild_battles_lost += 1 end - pbSet(1,decision) + pbSet(1, decision) # Used by the Poké Radar to update/break the chain - Events.onWildBattleEnd.trigger(nil,species,level,decision) + Events.onWildBattleEnd.trigger(nil, species, level, decision) # Return false if the player lost or drew the battle, and true if any other result - return (decision!=2 && decision!=5) + return (decision != 2 && decision != 5) end diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb index 901edae3f..4de6fe621 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/001_ChallengeGenerator_Data.rb @@ -211,9 +211,9 @@ def pbGenerateChallenge(rule, tag) for j in 0...teams[i].length party.push(teams[i][j]) end - teams[i] = RuledTeam.new(party,rule) + teams[i] = RuledTeam.new(party, rule) elsif teams[i].rating < toolowrating - teams[i] = RuledTeam.new(party,rule) + teams[i] = RuledTeam.new(party, rule) end i += 1 end diff --git a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb index c91df467f..429240e85 100644 --- a/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb +++ b/Data/Scripts/018_Alternate battle modes/003_Battle Frontier generator/004_ChallengeGenerator_BattleSim.rb @@ -49,7 +49,7 @@ class RuledTeam (@totalGames || 0) + self.games end - def addMatch(other,score) + def addMatch(other, score) @history.addMatch(other.ratingData, score) end @@ -309,7 +309,7 @@ def pbDecideWinnerEffectiveness(move, otype1, otype2, ability, scores) data = GameData::Move.get(move) return 0 if data.base_damage == 0 atype = data.type - typemod = Effectiveness::NORMAL_EFFECTIVE_ONE ** 2 + typemod = Effectiveness::NORMAL_EFFECTIVE_ONE**2 if ability != :LEVITATE || data.type != :GROUND mod1 = Effectiveness.calculate_one(atype, otype1) mod2 = (otype1 == otype2) ? Effectiveness::NORMAL_EFFECTIVE_ONE : Effectiveness.calculate_one(atype, otype2) diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index f4b97f383..a4833d0d2 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -1,35 +1,35 @@ #=============================================================================== # General purpose utilities #=============================================================================== -def _pbNextComb(comb,length) - i = comb.length-1 +def _pbNextComb(comb, length) + i = comb.length - 1 begin valid = true for j in i...comb.length - if j==i + if j == i comb[j] += 1 else - comb[j] = comb[i]+(j-i) + comb[j] = comb[i] + (j - i) end - if comb[j]>=length + if comb[j] >= length valid = false break end end return true if valid i -= 1 - end while i>=0 + end while i >= 0 return false end # Iterates through the array and yields each combination of _num_ elements in # the array. -def pbEachCombination(array,num) - return if array.length=0 +def pbTimeEvent(variableNumber, secs = 86400) + if variableNumber && variableNumber >= 0 if $game_variables - secs = 0 if secs<0 + secs = 0 if secs < 0 timenow = pbGetTimeNow - $game_variables[variableNumber] = [timenow.to_f,secs] + $game_variables[variableNumber] = [timenow.to_f, secs] $game_map.refresh if $game_map end end end -def pbTimeEventDays(variableNumber,days = 0) - if variableNumber && variableNumber>=0 +def pbTimeEventDays(variableNumber, days = 0) + if variableNumber && variableNumber >= 0 if $game_variables - days = 0 if days<0 + days = 0 if days < 0 timenow = pbGetTimeNow time = timenow.to_f - expiry = (time%86400.0)+(days*86400.0) - $game_variables[variableNumber] = [time,expiry-time] + expiry = (time % 86400.0) + (days * 86400.0) + $game_variables[variableNumber] = [time, expiry - time] $game_map.refresh if $game_map end end @@ -158,12 +158,12 @@ end def pbTimeEventValid(variableNumber) retval = false - if variableNumber && variableNumber>=0 && $game_variables + if variableNumber && variableNumber >= 0 && $game_variables value = $game_variables[variableNumber] if value.is_a?(Array) timenow = pbGetTimeNow retval = (timenow.to_f - value[0] > value[1]) # value[1] is age in seconds - retval = false if value[1]<=0 # zero age + retval = false if value[1] <= 0 # zero age end if !retval $game_variables[variableNumber] = 0 @@ -173,18 +173,18 @@ def pbTimeEventValid(variableNumber) return retval end -def pbExclaim(event,id = Settings::EXCLAMATION_ANIMATION_ID,tinting = false) +def pbExclaim(event, id = Settings::EXCLAMATION_ANIMATION_ID, tinting = false) if event.is_a?(Array) sprite = nil done = [] for i in event if !done.include?(i.id) - sprite = $scene.spriteset.addUserAnimation(id,i.x,i.y,tinting,2) + sprite = $scene.spriteset.addUserAnimation(id, i.x, i.y, tinting, 2) done.push(i.id) end end else - sprite = $scene.spriteset.addUserAnimation(id,event.x,event.y,tinting,2) + sprite = $scene.spriteset.addUserAnimation(id, event.x, event.y, tinting, 2) end while !sprite.disposed? Graphics.update @@ -194,10 +194,10 @@ def pbExclaim(event,id = Settings::EXCLAMATION_ANIMATION_ID,tinting = false) end def pbNoticePlayer(event) - if !pbFacingEachOther(event,$game_player) + if !pbFacingEachOther(event, $game_player) pbExclaim(event) end - pbTurnTowardEvent($game_player,event) + pbTurnTowardEvent($game_player, event) pbMoveTowardPlayer(event) end @@ -243,14 +243,14 @@ end def pbSuggestTrainerName(gender) userName = pbGetUserName() - userName = userName.gsub(/\s+.*$/,"") - if userName.length>0 && userName.length 0 && userName.length < Settings::MAX_PLAYER_NAME_SIZE + userName[0, 1] = userName[0, 1].upcase return userName end - userName = userName.gsub(/\d+$/,"") - if userName.length>0 && userName.length 0 && userName.length < Settings::MAX_PLAYER_NAME_SIZE + userName[0, 1] = userName[0, 1].upcase return userName end userName = System.user_name.capitalize @@ -264,8 +264,8 @@ def pbGetUserName return System.user_name end -def getRandomNameEx(type,variable,upper,maxLength = 100) - return "" if maxLength<=0 +def getRandomNameEx(type, variable, upper, maxLength = 100) + return "" if maxLength <= 0 name = "" 50.times { name = "" @@ -295,12 +295,12 @@ def getRandomNameEx(type,variable,upper,maxLength = 100) set1 = %w[b c d f g h j k l l m n n p r r s s t t v w y z] set2 = %w[bl br ch cl cr dr fr fl gl gr kh kl kr ph pl pr sc sk sl sm sn sp st sw th tr tw vl zh] - name += (rand(3)>0) ? set1[rand(set1.length)] : set2[rand(set2.length)] + name += (rand(3) > 0) ? set1[rand(set1.length)] : set2[rand(set2.length)] when "E" # ending consonant set1 = %w[b c d f g h j k k l l m n n p r r s s t t v z] set2 = %w[bb bs ch cs ds fs ft gs gg ld ls nd ng nk rn kt ks ms ns ph pt ps sk sh sp ss st rd rn rp rm rt rk ns th zh] - name += (rand(3)>0) ? set1[rand(set1.length)] : set2[rand(set2.length)] + name += (rand(3) > 0) ? set1[rand(set1.length)] : set2[rand(set2.length)] when "f" # consonant and vowel set = %w[iz us or] name += set[rand(set.length)] @@ -325,9 +325,9 @@ def getRandomNameEx(type,variable,upper,maxLength = 100) name += set[rand(set.length)] end } - break if name.length<=maxLength + break if name.length <= maxLength } - name = name[0,maxLength] + name = name[0, maxLength] case upper when 0 then name = name.upcase when 1 then name[0, 1] = name[0, 1].upcase @@ -340,7 +340,7 @@ def getRandomNameEx(type,variable,upper,maxLength = 100) end def getRandomName(maxLength = 100) - return getRandomNameEx(2,nil,nil,maxLength) + return getRandomNameEx(2, nil, nil, maxLength) end @@ -396,8 +396,8 @@ end #=============================================================================== # Other utilities #=============================================================================== -def pbTextEntry(helptext,minlength,maxlength,variableNumber) - $game_variables[variableNumber] = pbEnterText(helptext,minlength,maxlength) +def pbTextEntry(helptext, minlength, maxlength, variableNumber) + $game_variables[variableNumber] = pbEnterText(helptext, minlength, maxlength) $game_map.need_refresh = true if $game_map end @@ -424,34 +424,34 @@ def pbMoveTutorAnnotations(move, movelist = nil) return ret end -def pbMoveTutorChoose(move,movelist = nil,bymachine = false,oneusemachine = false) +def pbMoveTutorChoose(move, movelist = nil, bymachine = false, oneusemachine = false) ret = false move = GameData::Move.get(move).id - if movelist!=nil && movelist.is_a?(Array) + if movelist != nil && movelist.is_a?(Array) for i in 0...movelist.length movelist[i] = GameData::Move.get(movelist[i]).id end end pbFadeOutIn { movename = GameData::Move.get(move).name - annot = pbMoveTutorAnnotations(move,movelist) + annot = pbMoveTutorAnnotations(move, movelist) scene = PokemonParty_Scene.new - screen = PokemonPartyScreen.new(scene,$player.party) - screen.pbStartScene(_INTL("Teach which Pokémon?"),false,annot) + screen = PokemonPartyScreen.new(scene, $player.party) + screen.pbStartScene(_INTL("Teach which Pokémon?"), false, annot) loop do chosen = screen.pbChoosePokemon - break if chosen<0 + break if chosen < 0 pokemon = $player.party[chosen] if pokemon.egg? pbMessage(_INTL("Eggs can't be taught any moves.")) { screen.pbUpdate } elsif pokemon.shadowPokemon? pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { screen.pbUpdate } - elsif movelist && !movelist.any? { |j| j==pokemon.species } - pbMessage(_INTL("{1} can't learn {2}.",pokemon.name,movename)) { screen.pbUpdate } + elsif movelist && !movelist.any? { |j| j == pokemon.species } + pbMessage(_INTL("{1} can't learn {2}.", pokemon.name, movename)) { screen.pbUpdate } elsif !pokemon.compatible_with_move?(move) - pbMessage(_INTL("{1} can't learn {2}.",pokemon.name,movename)) { screen.pbUpdate } + pbMessage(_INTL("{1} can't learn {2}.", pokemon.name, movename)) { screen.pbUpdate } else - if pbLearnMove(pokemon,move,false,bymachine) { screen.pbUpdate } + if pbLearnMove(pokemon, move, false, bymachine) { screen.pbUpdate } $stats.moves_taught_by_item += 1 if bymachine $stats.moves_taught_by_tutor += 1 if !bymachine pokemon.add_first_move(move) if oneusemachine @@ -468,7 +468,7 @@ end def pbConvertItemToItem(variable, array) item = GameData::Item.get(pbGet(variable)) pbSet(variable, nil) - for i in 0...(array.length/2) + for i in 0...(array.length / 2) next if item != array[2 * i] pbSet(variable, array[2 * i + 1]) return @@ -492,8 +492,8 @@ def pbGet(id) end # Sets the value of a variable. -def pbSet(id,value) - return if !id || id<0 +def pbSet(id, value) + return if !id || id < 0 $game_variables[id] = value if $game_variables $game_map.need_refresh = true if $game_map end @@ -501,12 +501,12 @@ end # Runs a common event and waits until the common event is finished. # Requires the script "Messages" def pbCommonEvent(id) - return false if id<0 + return false if id < 0 ce = $data_common_events[id] return false if !ce celist = ce.list interp = Interpreter.new - interp.setup(celist,0) + interp.setup(celist, 0) begin Graphics.update Input.update @@ -579,11 +579,11 @@ def pbLoadRpgxpScene(scene) end def pbChooseLanguage - commands=[] + commands = [] for lang in Settings::LANGUAGES commands.push(lang[0]) end - return pbShowCommands(nil,commands) + return pbShowCommands(nil, commands) end def pbScreenCapture diff --git a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb index 7064703b6..9b2a4b100 100644 --- a/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb +++ b/Data/Scripts/019_Utilities/003_Utilities_BattleAudio.rb @@ -14,7 +14,7 @@ def pbGetWildBattleBGM(_wildParty) # wildParty is an array of Pokémon objects if !ret # Check global metadata music = GameData::Metadata.get.wild_battle_BGM - ret = pbStringToAudioFile(music) if music && music!="" + ret = pbStringToAudioFile(music) if music && music != "" end ret = pbStringToAudioFile("Battle wild") if !ret return ret @@ -33,10 +33,10 @@ def pbGetWildVictoryME if !ret # Check global metadata music = GameData::Metadata.get.wild_victory_ME - ret = pbStringToAudioFile(music) if music && music!="" + ret = pbStringToAudioFile(music) if music && music != "" end ret = pbStringToAudioFile("Battle victory") if !ret - ret.name = "../../Audio/ME/"+ret.name + ret.name = "../../Audio/ME/" + ret.name return ret end @@ -53,10 +53,10 @@ def pbGetWildCaptureME if !ret # Check global metadata music = GameData::Metadata.get.wild_capture_ME - ret = pbStringToAudioFile(music) if music && music!="" + ret = pbStringToAudioFile(music) if music && music != "" end ret = pbStringToAudioFile("Battle capture success") if !ret - ret.name = "../../Audio/ME/"+ret.name + ret.name = "../../Audio/ME/" + ret.name return ret end @@ -81,7 +81,7 @@ def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array o trainer_type_data = GameData::TrainerType.get(t.trainer_type) music = trainer_type_data.battle_BGM if trainer_type_data.battle_BGM end - ret = pbStringToAudioFile(music) if music && music!="" + ret = pbStringToAudioFile(music) if music && music != "" if !ret # Check map metadata music = $game_map.metadata&.trainer_battle_BGM @@ -90,7 +90,7 @@ def pbGetTrainerBattleBGM(trainer) # can be a Player, NPCTrainer or an array o if !ret # Check global metadata music = GameData::Metadata.get.trainer_battle_BGM - if music && music!="" + if music && music != "" ret = pbStringToAudioFile(music) end end @@ -112,7 +112,7 @@ def pbGetTrainerBattleBGMFromType(trainertype) if !ret # Check global metadata music = GameData::Metadata.get.trainer_battle_BGM - ret = pbStringToAudioFile(music) if music && music!="" + ret = pbStringToAudioFile(music) if music && music != "" end ret = pbStringToAudioFile("Battle trainer") if !ret return ret @@ -129,7 +129,7 @@ def pbGetTrainerVictoryME(trainer) # can be a Player, NPCTrainer or an array o music = trainer_type_data.victory_ME if trainer_type_data.victory_ME end ret = nil - if music && music!="" + if music && music != "" ret = pbStringToAudioFile(music) end if !ret @@ -140,11 +140,11 @@ def pbGetTrainerVictoryME(trainer) # can be a Player, NPCTrainer or an array o if !ret # Check global metadata music = GameData::Metadata.get.trainer_victory_ME - if music && music!="" + if music && music != "" ret = pbStringToAudioFile(music) end end ret = pbStringToAudioFile("Battle victory") if !ret - ret.name = "../../Audio/ME/"+ret.name + ret.name = "../../Audio/ME/" + ret.name return ret end diff --git a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb index 4a9d76b26..c118bb53b 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb @@ -620,7 +620,7 @@ end # Trainer Pokémon editor #=============================================================================== module TrainerPokemonProperty - def self.set(settingname,initsetting) + def self.set(settingname, initsetting) initsetting = { :species => nil, :level => 10 } if !initsetting oldsetting = [ initsetting[:species], @@ -1248,7 +1248,7 @@ def pbRegionalDexEditor(dex) end else # Cancel case pbMessage(_INTL("Save changes?"), - [_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3) + [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) when 0 # Save all changes to Dex dex.slice!(-1) while !dex[-1] ret = dex @@ -1400,7 +1400,7 @@ def pbEvoFamiliesToStrings for fam in 0...families.length string = "" for p in 0...families[fam].length - if p>=3 + if p >= 3 string += " + #{families[fam].length - 3} more" break end @@ -1423,7 +1423,7 @@ def pbAnimationsOrganiser pbMessage(_INTL("No animations exist.")) return end - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 cmdwin = pbListWindow([]) cmdwin.viewport = viewport @@ -1437,43 +1437,43 @@ def pbAnimationsOrganiser commands = [] refreshlist = true oldsel = -1 - cmd = [0,0] + cmd = [0, 0] loop do if refreshlist commands = [] for i in 0...list.length - commands.push(sprintf("%d: %s",i,(list[i]) ? list[i].name : "???")) + commands.push(sprintf("%d: %s", i, (list[i]) ? list[i].name : "???")) end end refreshlist = false oldsel = -1 - cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true) - if cmd[0]==1 # Swap animation up - if cmd[1]>=0 && cmd[1]= 0 && cmd[1] < commands.length - 1 + list[cmd[1] + 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] + 1] refreshlist = true end - elsif cmd[0]==2 # Swap animation down - if cmd[1]>0 - list[cmd[1]-1],list[cmd[1]] = list[cmd[1]],list[cmd[1]-1] + elsif cmd[0] == 2 # Swap animation down + if cmd[1] > 0 + list[cmd[1] - 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] - 1] refreshlist = true end - elsif cmd[0]==3 # Delete spot + elsif cmd[0] == 3 # Delete spot list.delete_at(cmd[1]) - cmd[1] = [cmd[1],list.length-1].min + cmd[1] = [cmd[1], list.length - 1].min refreshlist = true - pbWait(Graphics.frame_rate*2/10) - elsif cmd[0]==4 # Insert spot - list.insert(cmd[1],PBAnimation.new) + pbWait(Graphics.frame_rate * 2 / 10) + elsif cmd[0] == 4 # Insert spot + list.insert(cmd[1], PBAnimation.new) refreshlist = true - pbWait(Graphics.frame_rate*2/10) - elsif cmd[0]==0 + pbWait(Graphics.frame_rate * 2 / 10) + elsif cmd[0] == 0 cmd2 = pbMessage(_INTL("Save changes?"), - [_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3) - if cmd2==0 || cmd2==1 - if cmd2==0 + [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) + if cmd2 == 0 || cmd2 == 1 + if cmd2 == 0 # Save animations here - save_data(list,"Data/PkmnAnimations.rxdata") + save_data(list, "Data/PkmnAnimations.rxdata") $game_temp.battle_animations_data = nil pbMessage(_INTL("Data saved.")) end diff --git a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb index e985bda78..542b95245 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb @@ -2,11 +2,11 @@ # Miniature game map drawing #=============================================================================== class MapSprite - def initialize(map,viewport = nil) - @sprite=Sprite.new(viewport) - @sprite.bitmap=createMinimap(map) - @sprite.x=(Graphics.width/2)-(@sprite.bitmap.width/2) - @sprite.y=(Graphics.height/2)-(@sprite.bitmap.height/2) + def initialize(map, viewport = nil) + @sprite = Sprite.new(viewport) + @sprite.bitmap = createMinimap(map) + @sprite.x = (Graphics.width / 2) - (@sprite.bitmap.width / 2) + @sprite.y = (Graphics.height / 2) - (@sprite.bitmap.height / 2) end def dispose @@ -15,22 +15,22 @@ class MapSprite end def z=(value) - @sprite.z=value + @sprite.z = value end def getXY return nil if !Input.trigger?(Input::MOUSELEFT) mouse = Mouse::getMousePos(true) return nil if !mouse - if mouse[0]<@sprite.x || mouse[0]>=@sprite.x+@sprite.bitmap.width + if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width return nil end - if mouse[1]<@sprite.y || mouse[1]>=@sprite.y+@sprite.bitmap.height + if mouse[1] < @sprite.y || mouse[1] >= @sprite.y + @sprite.bitmap.height return nil end - x = mouse[0]-@sprite.x - y = mouse[1]-@sprite.y - return [x/4,y/4] + x = mouse[0] - @sprite.x + y = mouse[1] - @sprite.y + return [x / 4, y / 4] end end @@ -39,10 +39,10 @@ end #=============================================================================== class SelectionSprite < Sprite def initialize(viewport = nil) - @sprite=Sprite.new(viewport) - @sprite.bitmap=nil - @sprite.z=2 - @othersprite=nil + @sprite = Sprite.new(viewport) + @sprite.bitmap = nil + @sprite.z = 2 + @othersprite = nil end def disposed? @@ -51,34 +51,34 @@ class SelectionSprite < Sprite def dispose @sprite.bitmap.dispose if @sprite.bitmap - @othersprite=nil + @othersprite = nil @sprite.dispose end def othersprite=(value) - @othersprite=value + @othersprite = value if @othersprite && !@othersprite.disposed? && @othersprite.bitmap && !@othersprite.bitmap.disposed? - @sprite.bitmap=pbDoEnsureBitmap( - @sprite.bitmap,@othersprite.bitmap.width,@othersprite.bitmap.height) - red=Color.new(255,0,0) + @sprite.bitmap = pbDoEnsureBitmap( + @sprite.bitmap, @othersprite.bitmap.width, @othersprite.bitmap.height) + red = Color.new(255, 0, 0) @sprite.bitmap.clear - @sprite.bitmap.fill_rect(0,0,@othersprite.bitmap.width,2,red) - @sprite.bitmap.fill_rect(0,@othersprite.bitmap.height-2, - @othersprite.bitmap.width,2,red) - @sprite.bitmap.fill_rect(0,0,2,@othersprite.bitmap.height,red) - @sprite.bitmap.fill_rect(@othersprite.bitmap.width-2,0,2, - @othersprite.bitmap.height,red) + @sprite.bitmap.fill_rect(0, 0, @othersprite.bitmap.width, 2, red) + @sprite.bitmap.fill_rect(0, @othersprite.bitmap.height - 2, + @othersprite.bitmap.width, 2, red) + @sprite.bitmap.fill_rect(0, 0, 2, @othersprite.bitmap.height, red) + @sprite.bitmap.fill_rect(@othersprite.bitmap.width - 2, 0, 2, + @othersprite.bitmap.height, red) end end def update if @othersprite && !@othersprite.disposed? - @sprite.visible=@othersprite.visible - @sprite.x=@othersprite.x - @sprite.y=@othersprite.y + @sprite.visible = @othersprite.visible + @sprite.x = @othersprite.x + @sprite.y = @othersprite.y else - @sprite.visible=false + @sprite.visible = false end end end @@ -87,11 +87,11 @@ end # #=============================================================================== class RegionMapSprite - def initialize(map,viewport = nil) - @sprite=Sprite.new(viewport) - @sprite.bitmap=createRegionMap(map) - @sprite.x=(Graphics.width/2)-(@sprite.bitmap.width/2) - @sprite.y=(Graphics.height/2)-(@sprite.bitmap.height/2) + def initialize(map, viewport = nil) + @sprite = Sprite.new(viewport) + @sprite.bitmap = createRegionMap(map) + @sprite.x = (Graphics.width / 2) - (@sprite.bitmap.width / 2) + @sprite.y = (Graphics.height / 2) - (@sprite.bitmap.height / 2) end def dispose @@ -100,18 +100,18 @@ class RegionMapSprite end def z=(value) - @sprite.z=value + @sprite.z = value end def createRegionMap(map) @mapdata = pbLoadTownMapData - @map=@mapdata[map] - bitmap=AnimatedBitmap.new("Graphics/Pictures/#{@map[1]}").deanimate - retbitmap=BitmapWrapper.new(bitmap.width/2,bitmap.height/2) + @map = @mapdata[map] + bitmap = AnimatedBitmap.new("Graphics/Pictures/#{@map[1]}").deanimate + retbitmap = BitmapWrapper.new(bitmap.width / 2, bitmap.height / 2) retbitmap.stretch_blt( - Rect.new(0,0,bitmap.width/2,bitmap.height/2), + Rect.new(0, 0, bitmap.width / 2, bitmap.height / 2), bitmap, - Rect.new(0,0,bitmap.width,bitmap.height) + Rect.new(0, 0, bitmap.width, bitmap.height) ) bitmap.dispose return retbitmap @@ -119,17 +119,17 @@ class RegionMapSprite def getXY return nil if !Input.trigger?(Input::MOUSELEFT) - mouse=Mouse::getMousePos(true) + mouse = Mouse::getMousePos(true) return nil if !mouse - if mouse[0]<@sprite.x||mouse[0]>=@sprite.x+@sprite.bitmap.width + if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width return nil end - if mouse[1]<@sprite.y||mouse[1]>=@sprite.y+@sprite.bitmap.height + if mouse[1] < @sprite.y || mouse[1] >= @sprite.y + @sprite.bitmap.height return nil end - x=mouse[0]-@sprite.x - y=mouse[1]-@sprite.y - return [x/8,y/8] + x = mouse[0] - @sprite.x + y = mouse[1] - @sprite.y + return [x / 8, y / 8] end end @@ -139,12 +139,12 @@ end class MapScreenScene def getMapSprite(id) if !@mapsprites[id] - @mapsprites[id]=Sprite.new(@viewport) - @mapsprites[id].z=0 - @mapsprites[id].bitmap=nil + @mapsprites[id] = Sprite.new(@viewport) + @mapsprites[id].z = 0 + @mapsprites[id].bitmap = nil end if !@mapsprites[id].bitmap || @mapsprites[id].bitmap.disposed? - @mapsprites[id].bitmap=createMinimap(id) + @mapsprites[id].bitmap = createMinimap(id) end return @mapsprites[id] end @@ -155,64 +155,64 @@ class MapScreenScene @viewport.dispose end - def setMapSpritePos(id,x,y) - sprite=getMapSprite(id) - sprite.x=x - sprite.y=y - sprite.visible=true + def setMapSpritePos(id, x, y) + sprite = getMapSprite(id) + sprite.x = x + sprite.y = y + sprite.visible = true end - def putNeighbors(id,sprites) - conns=@mapconns - mapsprite=getMapSprite(id) - dispx=mapsprite.x - dispy=mapsprite.y + def putNeighbors(id, sprites) + conns = @mapconns + mapsprite = getMapSprite(id) + dispx = mapsprite.x + dispy = mapsprite.y for conn in conns - if conn[0]==id - b=sprites.any? { |i| i==conn[3] } + if conn[0] == id + b = sprites.any? { |i| i == conn[3] } if !b - x=(conn[1]-conn[4])*4+dispx - y=(conn[2]-conn[5])*4+dispy - setMapSpritePos(conn[3],x,y) + x = (conn[1] - conn[4]) * 4 + dispx + y = (conn[2] - conn[5]) * 4 + dispy + setMapSpritePos(conn[3], x, y) sprites.push(conn[3]) - putNeighbors(conn[3],sprites) + putNeighbors(conn[3], sprites) end - elsif conn[3]==id - b=sprites.any? { |i| i==conn[0] } + elsif conn[3] == id + b = sprites.any? { |i| i == conn[0] } if !b - x=(conn[4]-conn[1])*4+dispx - y=(conn[5]-conn[2])*4+dispy - setMapSpritePos(conn[0],x,y) + x = (conn[4] - conn[1]) * 4 + dispx + y = (conn[5] - conn[2]) * 4 + dispy + setMapSpritePos(conn[0], x, y) sprites.push(conn[3]) - putNeighbors(conn[0],sprites) + putNeighbors(conn[0], sprites) end end end end - def hasConnections?(conns,id) + def hasConnections?(conns, id) for conn in conns - return true if conn[0]==id || conn[3]==id + return true if conn[0] == id || conn[3] == id end return false end - def connectionsSymmetric?(conn1,conn2) - if conn1[0]==conn2[0] + def connectionsSymmetric?(conn1, conn2) + if conn1[0] == conn2[0] # Equality - return false if conn1[1]!=conn2[1] - return false if conn1[2]!=conn2[2] - return false if conn1[3]!=conn2[3] - return false if conn1[4]!=conn2[4] - return false if conn1[5]!=conn2[5] + return false if conn1[1] != conn2[1] + return false if conn1[2] != conn2[2] + return false if conn1[3] != conn2[3] + return false if conn1[4] != conn2[4] + return false if conn1[5] != conn2[5] return true - elsif conn1[0]==conn2[3] + elsif conn1[0] == conn2[3] # Symmetry - return false if conn1[1]!=-conn2[1] - return false if conn1[2]!=-conn2[2] - return false if conn1[3]!=conn2[0] - return false if conn1[4]!=-conn2[4] - return false if conn1[5]!=-conn2[5] + return false if conn1[1] != -conn2[1] + return false if conn1[2] != -conn2[2] + return false if conn1[3] != conn2[0] + return false if conn1[4] != -conn2[4] + return false if conn1[5] != -conn2[5] return true end return false @@ -223,55 +223,55 @@ class MapScreenScene end # Returns the maps within _keys_ that are directly connected to this map, _map_. - def getDirectConnections(keys,map) - thissprite=getMapSprite(map) - thisdims=MapFactoryHelper.getMapDims(map) - ret=[] + def getDirectConnections(keys, map) + thissprite = getMapSprite(map) + thisdims = MapFactoryHelper.getMapDims(map) + ret = [] for i in keys - next if i==map - othersprite=getMapSprite(i) - otherdims=MapFactoryHelper.getMapDims(i) - x1=(thissprite.x-othersprite.x)/4 - y1=(thissprite.y-othersprite.y)/4 - if (x1==otherdims[0] || x1==-thisdims[0] || - y1==otherdims[1] || y1==-thisdims[1]) + next if i == map + othersprite = getMapSprite(i) + otherdims = MapFactoryHelper.getMapDims(i) + x1 = (thissprite.x - othersprite.x) / 4 + y1 = (thissprite.y - othersprite.y) / 4 + if (x1 == otherdims[0] || x1 == -thisdims[0] || + y1 == otherdims[1] || y1 == -thisdims[1]) ret.push(i) end end # If no direct connections, add an indirect connection - if ret.length==0 - key=(map==keys[0]) ? keys[1] : keys[0] + if ret.length == 0 + key = (map == keys[0]) ? keys[1] : keys[0] ret.push(key) end return ret end def generateConnectionData - ret=[] + ret = [] # Create a clone of current map connection for conn in @mapconns ret.push(conn.clone) end - keys=@mapsprites.keys - return ret if keys.length<2 + keys = @mapsprites.keys + return ret if keys.length < 2 # Remove all connections containing any sprites on the canvas from the array for i in keys - removeOldConnections(ret,i) + removeOldConnections(ret, i) end # Rebuild connections for i in keys - refs=getDirectConnections(keys,i) + refs = getDirectConnections(keys, i) for refmap in refs - othersprite=getMapSprite(i) - refsprite=getMapSprite(refmap) - c1=(refsprite.x-othersprite.x)/4 - c2=(refsprite.y-othersprite.y)/4 - conn=[refmap,0,0,i,c1,c2] - j=0 - while j 0 end - def onClick(mapid,x,y) - if @lastclick>0 && Graphics.frame_count - @lastclick < Graphics.frame_rate * 0.5 + def onClick(mapid, x, y) + if @lastclick > 0 && Graphics.frame_count - @lastclick < Graphics.frame_rate * 0.5 onDoubleClick(mapid) - @lastclick=-1 + @lastclick = -1 else - @lastclick=Graphics.frame_count - if mapid>=0 - @dragging=true - @dragmapid=mapid - sprite=getMapSprite(mapid) - @sprites["selsprite"].othersprite=sprite - @selmapid=mapid - @dragOffsetX=sprite.x-x - @dragOffsetY=sprite.y-y + @lastclick = Graphics.frame_count + if mapid >= 0 + @dragging = true + @dragmapid = mapid + sprite = getMapSprite(mapid) + @sprites["selsprite"].othersprite = sprite + @selmapid = mapid + @dragOffsetX = sprite.x - x + @dragOffsetY = sprite.y - y setTopSprite(mapid) else - @sprites["selsprite"].othersprite=nil - @dragging=true - @dragmapid=mapid - @selmapid=-1 - @dragOffsetX=x - @dragOffsetY=y + @sprites["selsprite"].othersprite = nil + @dragging = true + @dragmapid = mapid + @selmapid = -1 + @dragOffsetX = x + @dragOffsetY = y saveMapSpritePos end end end - def onRightClick(mapid,x,y) + def onRightClick(mapid, x, y) # echoln "rightclick (#{mapid})" end def onMouseUp(mapid) # echoln "mouseup (#{mapid})" - @dragging=false if @dragging + @dragging = false if @dragging end def onRightMouseUp(mapid) # echoln "rightmouseup (#{mapid})" end - def onMouseOver(mapid,x,y) + def onMouseOver(mapid, x, y) # echoln "mouseover (#{mapid},#{x},#{y})" end - def onMouseMove(mapid,x,y) + def onMouseMove(mapid, x, y) # echoln "mousemove (#{mapid},#{x},#{y})" if @dragging - if @dragmapid>=0 - sprite=getMapSprite(@dragmapid) - x=x+@dragOffsetX - y=y+@dragOffsetY - sprite.x=x&~3 - sprite.y=y&~3 - @sprites["title"].text=_ISPRINTF("D: Help [{1:03d}: {2:s}]",mapid,@mapinfos[@dragmapid].name) + if @dragmapid >= 0 + sprite = getMapSprite(@dragmapid) + x = x + @dragOffsetX + y = y + @dragOffsetY + sprite.x = x & ~3 + sprite.y = y & ~3 + @sprites["title"].text = _ISPRINTF("D: Help [{1:03d}: {2:s}]", mapid, @mapinfos[@dragmapid].name) else - xpos=x-@dragOffsetX - ypos=y-@dragOffsetY + xpos = x - @dragOffsetX + ypos = y - @dragOffsetY for i in @mapspritepos.keys - sprite=getMapSprite(i) - sprite.x=(@mapspritepos[i][0]+xpos)&~3 - sprite.y=(@mapspritepos[i][1]+ypos)&~3 + sprite = getMapSprite(i) + sprite.x = (@mapspritepos[i][0] + xpos) & ~3 + sprite.y = (@mapspritepos[i][1] + ypos) & ~3 end - @sprites["title"].text=_INTL("D: Help") + @sprites["title"].text = _INTL("D: Help") end else - if mapid>=0 - @sprites["title"].text=_ISPRINTF("D: Help [{1:03d}: {2:s}]",mapid,@mapinfos[mapid].name) + if mapid >= 0 + @sprites["title"].text = _ISPRINTF("D: Help [{1:03d}: {2:s}]", mapid, @mapinfos[mapid].name) else - @sprites["title"].text=_INTL("D: Help") + @sprites["title"].text = _INTL("D: Help") end end end - def hittest(x,y) + def hittest(x, y) for i in @mapsprites.keys - sx=@mapsprites[i].x - sy=@mapsprites[i].y - sr=sx+@mapsprites[i].bitmap.width - sb=sy+@mapsprites[i].bitmap.height - return i if x>=sx && x=sy && y= sx && x < sr && y >= sy && y < sb end return -1 end - def chooseMapScreen(title,currentmap) - return pbListScreen(title,MapLister.new(currentmap)) + def chooseMapScreen(title, currentmap) + return pbListScreen(title, MapLister.new(currentmap)) end def update - mousepos=Mouse::getMousePos + mousepos = Mouse::getMousePos if mousepos - hitmap=hittest(mousepos[0],mousepos[1]) + hitmap = hittest(mousepos[0], mousepos[1]) if Input.trigger?(Input::MOUSELEFT) - onClick(hitmap,mousepos[0],mousepos[1]) + onClick(hitmap, mousepos[0], mousepos[1]) elsif Input.trigger?(Input::MOUSERIGHT) - onRightClick(hitmap,mousepos[0],mousepos[1]) + onRightClick(hitmap, mousepos[0], mousepos[1]) elsif Input.release?(Input::MOUSELEFT) onMouseUp(hitmap) elsif Input.release?(Input::MOUSERIGHT) onRightMouseUp(hitmap) else - if @lasthitmap!=hitmap - onMouseOver(hitmap,mousepos[0],mousepos[1]) - @lasthitmap=hitmap + if @lasthitmap != hitmap + onMouseOver(hitmap, mousepos[0], mousepos[1]) + @lasthitmap = hitmap end - if @oldmousex!=mousepos[0] || @oldmousey!=mousepos[1] - onMouseMove(hitmap,mousepos[0],mousepos[1]) - @oldmousex=mousepos[0] - @oldmousey=mousepos[1] + if @oldmousex != mousepos[0] || @oldmousey != mousepos[1] + onMouseMove(hitmap, mousepos[0], mousepos[1]) + @oldmousex = mousepos[0] + @oldmousey = mousepos[1] end end end @@ -521,30 +521,30 @@ class MapScreenScene end end if Input.triggerex?(:A) - id=chooseMapScreen(_INTL("Add Map"),@currentmap) - if id>0 + id = chooseMapScreen(_INTL("Add Map"), @currentmap) + if id > 0 addSprite(id) setTopSprite(id) - @mapconns=generateConnectionData + @mapconns = generateConnectionData end elsif Input.triggerex?(:S) - id=chooseMapScreen(_INTL("Go to Map"),@currentmap) - if id>0 - @mapconns=generateConnectionData + id = chooseMapScreen(_INTL("Go to Map"), @currentmap) + if id > 0 + @mapconns = generateConnectionData pbDisposeSpriteHash(@mapsprites) @mapsprites.clear - @sprites["selsprite"].othersprite=nil - @selmapid=-1 + @sprites["selsprite"].othersprite = nil + @selmapid = -1 putSprite(id) - @currentmap=id + @currentmap = id end elsif Input.triggerex?(:DELETE) - if @mapsprites.keys.length>1 && @selmapid>=0 + if @mapsprites.keys.length > 1 && @selmapid >= 0 @mapsprites[@selmapid].bitmap.dispose @mapsprites[@selmapid].dispose @mapsprites.delete(@selmapid) - @sprites["selsprite"].othersprite=nil - @selmapid=-1 + @sprites["selsprite"].othersprite = nil + @selmapid = -1 end elsif Input.triggerex?(:D) helpWindow diff --git a/Data/Scripts/020_Debug/001_Editor_Utilities.rb b/Data/Scripts/020_Debug/001_Editor_Utilities.rb index ed8b2748d..147c26f1a 100644 --- a/Data/Scripts/020_Debug/001_Editor_Utilities.rb +++ b/Data/Scripts/020_Debug/001_Editor_Utilities.rb @@ -10,22 +10,22 @@ def pbGetLegalMoves(species) return moves end -def pbSafeCopyFile(x,y,z = nil) +def pbSafeCopyFile(x, y, z = nil) if safeExists?(x) safetocopy = true filedata = nil if safeExists?(y) different = false - if FileTest.size(x)!=FileTest.size(y) + if FileTest.size(x) != FileTest.size(y) different = true else filedata2 = "" - File.open(x,"rb") { |f| filedata = f.read } - File.open(y,"rb") { |f| filedata2 = f.read } - different = true if filedata!=filedata2 + File.open(x, "rb") { |f| filedata = f.read } + File.open(y, "rb") { |f| filedata2 = f.read } + different = true if filedata != filedata2 end if different - safetocopy=pbConfirmMessage(_INTL("A different file named '{1}' already exists. Overwrite it?",y)) + safetocopy = pbConfirmMessage(_INTL("A different file named '{1}' already exists. Overwrite it?", y)) else # No need to copy return @@ -33,14 +33,14 @@ def pbSafeCopyFile(x,y,z = nil) end if safetocopy if !filedata - File.open(x,"rb") { |f| filedata = f.read } + File.open(x, "rb") { |f| filedata = f.read } end - File.open((z) ? z : y,"wb") { |f| f.write(filedata) } + File.open((z) ? z : y, "wb") { |f| f.write(filedata) } end end end -def pbAllocateAnimation(animations,name) +def pbAllocateAnimation(animations, name) for i in 1...animations.length anim = animations[i] return i if !anim @@ -48,7 +48,7 @@ def pbAllocateAnimation(animations,name) # # use animation with same name # return i # end - if anim.length==1 && anim[0].length==2 && anim.name=="" + if anim.length == 1 && anim[0].length == 2 && anim.name == "" # assume empty return i end @@ -69,36 +69,36 @@ def pbMapTree info = mapinfos[info.parent_id] level += 1 end - if level>=0 + if level >= 0 info = mapinfos[i] - maplevels.push([i,level,info.parent_id,info.order]) + maplevels.push([i, level, info.parent_id, info.order]) end end - maplevels.sort! { |a,b| - next a[1]<=>b[1] if a[1]!=b[1] # level - next a[2]<=>b[2] if a[2]!=b[2] # parent ID - next a[3]<=>b[3] # order + maplevels.sort! { |a, b| + next a[1] <=> b[1] if a[1] != b[1] # level + next a[2] <=> b[2] if a[2] != b[2] # parent ID + next a[3] <=> b[3] # order } stack = [] - stack.push(0,0) - while stack.length>0 - parent = stack[stack.length-1] - index = stack[stack.length-2] - if index>=maplevels.length + stack.push(0, 0) + while stack.length > 0 + parent = stack[stack.length - 1] + index = stack[stack.length - 2] + if index >= maplevels.length stack.pop stack.pop next end maplevel = maplevels[index] - stack[stack.length-2] += 1 - if maplevel[2]!=parent + stack[stack.length - 2] += 1 + if maplevel[2] != parent stack.pop stack.pop next end - retarray.push([maplevel[0],mapinfos[maplevel[0]].name,maplevel[1]]) - for i in index+1...maplevels.length - if maplevels[i][2]==maplevel[0] + retarray.push([maplevel[0], mapinfos[maplevel[0]].name, maplevel[1]]) + for i in index + 1...maplevels.length + if maplevels[i][2] == maplevel[0] stack.push(i) stack.push(maplevel[0]) break @@ -245,17 +245,17 @@ end #=============================================================================== # General list methods #=============================================================================== -def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = false) +def pbCommands2(cmdwindow, commands, cmdIfCancel, defaultindex = -1, noresize = false) cmdwindow.commands = commands - cmdwindow.index = defaultindex if defaultindex>=0 + cmdwindow.index = defaultindex if defaultindex >= 0 cmdwindow.x = 0 cmdwindow.y = 0 if noresize cmdwindow.height = Graphics.height else - cmdwindow.width = Graphics.width/2 + cmdwindow.width = Graphics.width / 2 end - cmdwindow.height = Graphics.height if cmdwindow.height>Graphics.height + cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height cmdwindow.z = 99999 cmdwindow.visible = true cmdwindow.active = true @@ -265,10 +265,10 @@ def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = fals Input.update cmdwindow.update if Input.trigger?(Input::BACK) - if cmdIfCancel>0 - command = cmdIfCancel-1 + if cmdIfCancel > 0 + command = cmdIfCancel - 1 break - elsif cmdIfCancel<0 + elsif cmdIfCancel < 0 command = cmdIfCancel break end @@ -282,17 +282,17 @@ def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = fals return ret end -def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = false) +def pbCommands3(cmdwindow, commands, cmdIfCancel, defaultindex = -1, noresize = false) cmdwindow.commands = commands - cmdwindow.index = defaultindex if defaultindex>=0 + cmdwindow.index = defaultindex if defaultindex >= 0 cmdwindow.x = 0 cmdwindow.y = 0 if noresize cmdwindow.height = Graphics.height else - cmdwindow.width = Graphics.width/2 + cmdwindow.width = Graphics.width / 2 end - cmdwindow.height = Graphics.height if cmdwindow.height>Graphics.height + cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height cmdwindow.z = 99999 cmdwindow.visible = true cmdwindow.active = true @@ -302,32 +302,32 @@ def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = fals Input.update cmdwindow.update if Input.trigger?(Input::SPECIAL) - command = [5,cmdwindow.index] + command = [5, cmdwindow.index] break elsif Input.press?(Input::ACTION) if Input.repeat?(Input::UP) - command = [1,cmdwindow.index] + command = [1, cmdwindow.index] break elsif Input.repeat?(Input::DOWN) - command = [2,cmdwindow.index] + command = [2, cmdwindow.index] break elsif Input.trigger?(Input::LEFT) - command = [3,cmdwindow.index] + command = [3, cmdwindow.index] break elsif Input.trigger?(Input::RIGHT) - command = [4,cmdwindow.index] + command = [4, cmdwindow.index] break end elsif Input.trigger?(Input::BACK) - if cmdIfCancel>0 - command = [0,cmdIfCancel-1] + if cmdIfCancel > 0 + command = [0, cmdIfCancel - 1] break - elsif cmdIfCancel<0 - command = [0,cmdIfCancel] + elsif cmdIfCancel < 0 + command = [0, cmdIfCancel] break end elsif Input.trigger?(Input::USE) - command = [0,cmdwindow.index] + command = [0, cmdwindow.index] break end end @@ -378,7 +378,7 @@ def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1) return itemID end -def pbCommandsSortable(cmdwindow,commands,cmdIfCancel,defaultindex = -1,sortable = false) +def pbCommandsSortable(cmdwindow, commands, cmdIfCancel, defaultindex = -1, sortable = false) cmdwindow.commands = commands cmdwindow.index = defaultindex if defaultindex >= 0 cmdwindow.x = 0 @@ -393,13 +393,13 @@ def pbCommandsSortable(cmdwindow,commands,cmdIfCancel,defaultindex = -1,sortable Input.update cmdwindow.update if Input.trigger?(Input::ACTION) && sortable - command = [1,cmdwindow.index] + command = [1, cmdwindow.index] break elsif Input.trigger?(Input::BACK) - command = [0,(cmdIfCancel>0) ? cmdIfCancel-1 : cmdIfCancel] + command = [0, (cmdIfCancel > 0) ? cmdIfCancel - 1 : cmdIfCancel] break elsif Input.trigger?(Input::USE) - command = [0,cmdwindow.index] + command = [0, cmdwindow.index] break end end diff --git a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb index 62afa31c9..61d6eda57 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb @@ -2,37 +2,37 @@ # Controls ################################################################################ class Window_Menu < Window_CommandPokemon - def initialize(commands,x,y) - tempbitmap=Bitmap.new(32,32) - w=0 + def initialize(commands, x, y) + tempbitmap = Bitmap.new(32, 32) + w = 0 for i in commands - width=tempbitmap.text_size(i).width - w=width if w=self.x && x=self.y && y= self.x && x < self.x + self.width && + y >= self.y && y < self.y + self.height end end -def pbSpriteHitTest(sprite,x,y,usealpha = true,wholecanvas = false) +def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false) return false if !sprite || sprite.disposed? return false if !sprite.bitmap return false if !sprite.visible return false if sprite.bitmap.disposed? - width=sprite.src_rect.width - height=sprite.src_rect.height + width = sprite.src_rect.width + height = sprite.src_rect.height if !wholecanvas - xwidth=width-64 - xheight=height-64 - width=64 if width>64 && !usealpha - height=64 if height>64 && !usealpha + xwidth = width - 64 + xheight = height - 64 + width = 64 if width > 64 && !usealpha + height = 64 if height > 64 && !usealpha else - xwidth=0 - xheight=0 + xwidth = 0 + xheight = 0 end - width=sprite.bitmap.width if width>sprite.bitmap.width - height=sprite.bitmap.height if height>sprite.bitmap.height + width = sprite.bitmap.width if width > sprite.bitmap.width + height = sprite.bitmap.height if height > sprite.bitmap.height if usealpha - spritex=sprite.x-(sprite.ox*sprite.zoom_x) - spritey=sprite.y-(sprite.oy*sprite.zoom_y) - width*=sprite.zoom_x - height*=sprite.zoom_y + spritex = sprite.x - (sprite.ox * sprite.zoom_x) + spritey = sprite.y - (sprite.oy * sprite.zoom_y) + width *= sprite.zoom_x + height *= sprite.zoom_y else - spritex=sprite.x-sprite.ox - spritey=sprite.y-sprite.oy - spritex+=xwidth/2 - spritey+=xheight/2 + spritex = sprite.x - sprite.ox + spritey = sprite.y - sprite.oy + spritex += xwidth / 2 + spritey += xheight / 2 end - if !(x>=spritex && x<=spritex+width && y>=spritey && y<=spritey+height) + if !(x >= spritex && x <= spritex + width && y >= spritey && y <= spritey + height) return false end if usealpha # TODO: This should account for sprite.angle as well - bitmapX=sprite.src_rect.x - bitmapY=sprite.src_rect.y - bitmapX+=sprite.ox - bitmapY+=sprite.oy - bitmapX+=(x-sprite.x)/sprite.zoom_x if sprite.zoom_x>0 - bitmapY+=(y-sprite.y)/sprite.zoom_y if sprite.zoom_y>0 - bitmapX=bitmapX.round - bitmapY=bitmapY.round + bitmapX = sprite.src_rect.x + bitmapY = sprite.src_rect.y + bitmapX += sprite.ox + bitmapY += sprite.oy + bitmapX += (x - sprite.x) / sprite.zoom_x if sprite.zoom_x > 0 + bitmapY += (y - sprite.y) / sprite.zoom_y if sprite.zoom_y > 0 + bitmapX = bitmapX.round + bitmapY = bitmapY.round if sprite.mirror - xmirror=bitmapX-sprite.src_rect.x - bitmapX=sprite.src_rect.x+192-xmirror + xmirror = bitmapX - sprite.src_rect.x + bitmapX = sprite.src_rect.x + 192 - xmirror end - color=sprite.bitmap.get_pixel(bitmapX,bitmapY) - return false if (color.alpha==0) + color = sprite.bitmap.get_pixel(bitmapX, bitmapY) + return false if (color.alpha == 0) end return true end def pbTrackPopupMenu(commands) - mousepos=Mouse::getMousePos + mousepos = Mouse::getMousePos return -1 if !mousepos - menuwindow=Window_Menu.new(commands,mousepos[0],mousepos[1]) - menuwindow.z=99999 + menuwindow = Window_Menu.new(commands, mousepos[0], mousepos[1]) + menuwindow.z = 99999 loop do Graphics.update Input.update menuwindow.update - hit=menuwindow.hittest - menuwindow.index=hit if hit>=0 + hit = menuwindow.hittest + menuwindow.index = hit if hit >= 0 if Input.trigger?(Input::MOUSELEFT) || Input.trigger?(Input::MOUSERIGHT) # Left or right button menuwindow.dispose return hit end if Input.trigger?(Input::USE) - hit=menuwindow.index + hit = menuwindow.index menuwindow.dispose return hit end @@ -168,79 +168,79 @@ class AnimationWindow < SpriteWrapper attr_reader :start attr_reader :selected - NUMFRAMES=5 + NUMFRAMES = 5 - def initialize(x,y,width,height,viewport = nil) + def initialize(x, y, width, height, viewport = nil) super(viewport) - @animbitmap=nil - @arrows=AnimatedBitmap.new("Graphics/Pictures/arrows") - self.x=x - self.y=y - @start=0 - @selected=0 - @contents=Bitmap.new(width,height) - self.bitmap=@contents + @animbitmap = nil + @arrows = AnimatedBitmap.new("Graphics/Pictures/arrows") + self.x = x + self.y = y + @start = 0 + @selected = 0 + @contents = Bitmap.new(width, height) + self.bitmap = @contents refresh end def animbitmap=(val) - @animbitmap=val - @start=0 + @animbitmap = val + @start = 0 refresh end def selected=(val) - @selected=val + @selected = val refresh end def dispose @contents.dispose @arrows.dispose - @start=0 - @selected=0 - @changed=false + @start = 0 + @selected = 0 + @changed = false super end - def drawrect(bm,x,y,width,height,color) - bm.fill_rect(x,y,width,1,color) - bm.fill_rect(x,y+height-1,width,1,color) - bm.fill_rect(x,y,1,height,color) - bm.fill_rect(x+width-1,y,1,height,color) + def drawrect(bm, x, y, width, height, color) + bm.fill_rect(x, y, width, 1, color) + bm.fill_rect(x, y + height - 1, width, 1, color) + bm.fill_rect(x, y, 1, height, color) + bm.fill_rect(x + width - 1, y, 1, height, color) end - def drawborder(bm,x,y,width,height,color) - bm.fill_rect(x,y,width,2,color) - bm.fill_rect(x,y+height-2,width,2,color) - bm.fill_rect(x,y,2,height,color) - bm.fill_rect(x+width-2,y,2,height,color) + def drawborder(bm, x, y, width, height, color) + bm.fill_rect(x, y, width, 2, color) + bm.fill_rect(x, y + height - 2, width, 2, color) + bm.fill_rect(x, y, 2, height, color) + bm.fill_rect(x + width - 2, y, 2, height, color) end def refresh - arrowwidth=@arrows.bitmap.width/2 + arrowwidth = @arrows.bitmap.width / 2 @contents.clear - @contents.fill_rect(0,0,@contents.width,@contents.height,Color.new(180,180,180)) - @contents.blt(0,0,@arrows.bitmap,Rect.new(0,0,arrowwidth,96)) - @contents.blt(arrowwidth+NUMFRAMES*96,0,@arrows.bitmap, - Rect.new(arrowwidth,0,arrowwidth,96)) - havebitmap=(self.animbitmap && !self.animbitmap.disposed?) + @contents.fill_rect(0, 0, @contents.width, @contents.height, Color.new(180, 180, 180)) + @contents.blt(0, 0, @arrows.bitmap, Rect.new(0, 0, arrowwidth, 96)) + @contents.blt(arrowwidth + NUMFRAMES * 96, 0, @arrows.bitmap, + Rect.new(arrowwidth, 0, arrowwidth, 96)) + havebitmap = (self.animbitmap && !self.animbitmap.disposed?) if havebitmap - rect=Rect.new(0,0,0,0) - rectdst=Rect.new(0,0,0,0) - x=arrowwidth + rect = Rect.new(0, 0, 0, 0) + rectdst = Rect.new(0, 0, 0, 0) + x = arrowwidth for i in 0...NUMFRAMES - j=i+@start - rect.set((j%5)*192,(j/5)*192,192,192) - rectdst.set(x,0,96,96) - @contents.stretch_blt(rectdst,self.animbitmap,rect) - x+=96 + j = i + @start + rect.set((j % 5) * 192, (j / 5) * 192, 192, 192) + rectdst.set(x, 0, 96, 96) + @contents.stretch_blt(rectdst, self.animbitmap, rect) + x += 96 end end for i in 0...NUMFRAMES - drawrect(@contents,arrowwidth+i*96,0,96,96,Color.new(100,100,100)) - if @start+i==@selected && havebitmap - drawborder(@contents,arrowwidth+i*96,0,96,96,Color.new(255,0,0)) + drawrect(@contents, arrowwidth + i * 96, 0, 96, 96, Color.new(100, 100, 100)) + if @start + i == @selected && havebitmap + drawborder(@contents, arrowwidth + i * 96, 0, 96, 96, Color.new(255, 0, 0)) end end end @@ -250,50 +250,50 @@ class AnimationWindow < SpriteWrapper end def update - mousepos=Mouse::getMousePos - @changed=false + mousepos = Mouse::getMousePos + @changed = false return if !Input.repeat?(Input::MOUSELEFT) return if !mousepos return if !self.animbitmap - arrowwidth=@arrows.bitmap.width/2 - maxindex=(self.animbitmap.height/192)*5 - left=Rect.new(0,0,arrowwidth,96) - right=Rect.new(arrowwidth+NUMFRAMES*96,0,arrowwidth,96) - left.x+=self.x - left.y+=self.y - right.x+=self.x - right.y+=self.y - swatchrects=[] + arrowwidth = @arrows.bitmap.width / 2 + maxindex = (self.animbitmap.height / 192) * 5 + left = Rect.new(0, 0, arrowwidth, 96) + right = Rect.new(arrowwidth + NUMFRAMES * 96, 0, arrowwidth, 96) + left.x += self.x + left.y += self.y + right.x += self.x + right.y += self.y + swatchrects = [] repeattime = Input.time?(Input::MOUSELEFT) / 1000 for i in 0...NUMFRAMES - swatchrects.push(Rect.new(arrowwidth+i*96+self.x,self.y,96,96)) + swatchrects.push(Rect.new(arrowwidth + i * 96 + self.x, self.y, 96, 96)) end for i in 0...NUMFRAMES - if swatchrects[i].contains(mousepos[0],mousepos[1]) - @selected=@start+i - @changed=true + if swatchrects[i].contains(mousepos[0], mousepos[1]) + @selected = @start + i + @changed = true refresh return end end # Left arrow - if left.contains(mousepos[0],mousepos[1]) - if repeattime>750 - @start-=3 + if left.contains(mousepos[0], mousepos[1]) + if repeattime > 750 + @start -= 3 else - @start-=1 + @start -= 1 end - @start=0 if @start<0 + @start = 0 if @start < 0 refresh end # Right arrow - if right.contains(mousepos[0],mousepos[1]) - if repeattime>750 - @start+=3 + if right.contains(mousepos[0], mousepos[1]) + if repeattime > 750 + @start += 3 else - @start+=1 + @start += 1 end - @start=maxindex if @start>=maxindex + @start = maxindex if @start >= maxindex refresh end end @@ -306,9 +306,9 @@ class CanvasAnimationWindow < AnimationWindow return @canvas.animbitmap end - def initialize(canvas,x,y,width,height,viewport = nil) - @canvas=canvas - super(x,y,width,height,viewport) + def initialize(canvas, x, y, width, height, viewport = nil) + @canvas = canvas + super(x, y, width, height, viewport) end end @@ -320,12 +320,12 @@ end class InvalidatableSprite < Sprite def initialize(viewport = nil) super(viewport) - @invalid=false + @invalid = false end # Marks that the control must be redrawn to reflect current logic. def invalidate - @invalid=true + @invalid = true end # Determines whether the control is invalid @@ -335,7 +335,7 @@ class InvalidatableSprite < Sprite # Marks that the control is valid. Normally called only by repaint. def validate - @invalid=false + @invalid = false end # Redraws the sprite only if it is invalid, and then revalidates the sprite @@ -360,22 +360,22 @@ class SpriteFrame < InvalidatableSprite attr_reader :selected attr_reader :sprite - NUM_ROWS = (PBAnimation::MAX_SPRITES.to_f/10).ceil # 10 frame number icons in each row + NUM_ROWS = (PBAnimation::MAX_SPRITES.to_f / 10).ceil # 10 frame number icons in each row - def initialize(id,sprite,viewport,previous = false) + def initialize(id, sprite, viewport, previous = false) super(viewport) - @id=id - @sprite=sprite - @previous=previous - @locked=false - @selected=false - @selcolor=Color.new(0,0,0) - @unselcolor=Color.new(220,220,220) - @prevcolor=Color.new(64,128,192) - @contents=Bitmap.new(64,64) + @id = id + @sprite = sprite + @previous = previous + @locked = false + @selected = false + @selcolor = Color.new(0, 0, 0) + @unselcolor = Color.new(220, 220, 220) + @prevcolor = Color.new(64, 128, 192) + @contents = Bitmap.new(64, 64) self.z = (@previous) ? 49 : 50 - @iconbitmap=AnimatedBitmap.new("Graphics/Pictures/animFrameIcon") - self.bitmap=@contents + @iconbitmap = AnimatedBitmap.new("Graphics/Pictures/animFrameIcon") + self.bitmap = @contents self.invalidate end @@ -385,17 +385,17 @@ class SpriteFrame < InvalidatableSprite end def sprite=(value) - @sprite=value + @sprite = value self.invalidate end def locked=(value) - @locked=value + @locked = value self.invalidate end def selected=(value) - @selected=value + @selected = value self.invalidate end @@ -403,19 +403,19 @@ class SpriteFrame < InvalidatableSprite @contents.clear self.z = (@previous) ? 49 : (@selected) ? 51 : 50 # Draw frame - color=(@previous) ? @prevcolor : (@selected) ? @selcolor : @unselcolor - @contents.fill_rect(0,0,64,1,color) - @contents.fill_rect(0,63,64,1,color) - @contents.fill_rect(0,0,1,64,color) - @contents.fill_rect(63,0,1,64,color) + color = (@previous) ? @prevcolor : (@selected) ? @selcolor : @unselcolor + @contents.fill_rect(0, 0, 64, 1, color) + @contents.fill_rect(0, 63, 64, 1, color) + @contents.fill_rect(0, 0, 1, 64, color) + @contents.fill_rect(63, 0, 1, 64, color) # Determine frame number graphic to use from @iconbitmap - yoffset = (@previous) ? (NUM_ROWS+1)*16 : 0 # 1 is for padlock icon - bmrect=Rect.new((@id%10)*16,yoffset+(@id/10)*16,16,16) - @contents.blt(0,0,@iconbitmap.bitmap,bmrect) + yoffset = (@previous) ? (NUM_ROWS + 1) * 16 : 0 # 1 is for padlock icon + bmrect = Rect.new((@id % 10) * 16, yoffset + (@id / 10) * 16, 16, 16) + @contents.blt(0, 0, @iconbitmap.bitmap, bmrect) # Draw padlock if frame is locked if @locked && !@previous - bmrect=Rect.new(0,NUM_ROWS*16,16,16) - @contents.blt(16,0,@iconbitmap.bitmap,bmrect) + bmrect = Rect.new(0, NUM_ROWS * 16, 16, 16) + @contents.blt(16, 0, @iconbitmap.bitmap, bmrect) end end end @@ -434,73 +434,73 @@ class AnimationCanvas < Sprite attr_reader :animbitmap # Currently selected animation bitmap attr_accessor :pattern # Currently selected pattern - BORDERSIZE=64 + BORDERSIZE = 64 - def initialize(animation,viewport = nil) + def initialize(animation, viewport = nil) super(viewport) - @currentframe=0 - @currentcel=-1 - @pattern=0 - @sprites={} - @celsprites=[] - @framesprites=[] - @lastframesprites=[] - @dirty=[] - @viewport=viewport - @selecting=false - @selectOffsetX=0 - @selectOffsetY=0 - @playing=false - @playingframe=0 - @player=nil - @battle=MiniBattle.new - @user=AnimatedBitmap.new("Graphics/Pictures/testback").deanimate - @target=AnimatedBitmap.new("Graphics/Pictures/testfront").deanimate - @testscreen=AnimatedBitmap.new("Graphics/Pictures/testscreen") - self.bitmap=@testscreen.bitmap + @currentframe = 0 + @currentcel = -1 + @pattern = 0 + @sprites = {} + @celsprites = [] + @framesprites = [] + @lastframesprites = [] + @dirty = [] + @viewport = viewport + @selecting = false + @selectOffsetX = 0 + @selectOffsetY = 0 + @playing = false + @playingframe = 0 + @player = nil + @battle = MiniBattle.new + @user = AnimatedBitmap.new("Graphics/Pictures/testback").deanimate + @target = AnimatedBitmap.new("Graphics/Pictures/testfront").deanimate + @testscreen = AnimatedBitmap.new("Graphics/Pictures/testscreen") + self.bitmap = @testscreen.bitmap for i in 0...PBAnimation::MAX_SPRITES - @lastframesprites[i]=SpriteFrame.new(i,@celsprites[i],viewport,true) - @lastframesprites[i].selected=false - @lastframesprites[i].visible=false + @lastframesprites[i] = SpriteFrame.new(i, @celsprites[i], viewport, true) + @lastframesprites[i].selected = false + @lastframesprites[i].visible = false end for i in 0...PBAnimation::MAX_SPRITES - @celsprites[i]=Sprite.new(viewport) - @celsprites[i].visible=false - @celsprites[i].src_rect=Rect.new(0,0,0,0) - @celsprites[i].bitmap=nil - @framesprites[i]=SpriteFrame.new(i,@celsprites[i],viewport) - @framesprites[i].selected=false - @framesprites[i].visible=false - @dirty[i]=true + @celsprites[i] = Sprite.new(viewport) + @celsprites[i].visible = false + @celsprites[i].src_rect = Rect.new(0, 0, 0, 0) + @celsprites[i].bitmap = nil + @framesprites[i] = SpriteFrame.new(i, @celsprites[i], viewport) + @framesprites[i].selected = false + @framesprites[i].visible = false + @dirty[i] = true end loadAnimation(animation) end def loadAnimation(anim) - @animation=anim + @animation = anim @animbitmap.dispose if @animbitmap - if @animation.graphic=="" - @animbitmap=nil + if @animation.graphic == "" + @animbitmap = nil else begin - @animbitmap=AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic, + @animbitmap = AnimatedBitmap.new("Graphics/Animations/" + @animation.graphic, @animation.hue).deanimate rescue - @animbitmap=nil + @animbitmap = nil end end - @currentcel=-1 - self.currentframe=0 - @selecting=false - @pattern=0 + @currentcel = -1 + self.currentframe = 0 + @selecting = false + @pattern = 0 self.invalidate end def animbitmap=(value) @animbitmap.dispose if @animbitmap - @animbitmap=value + @animbitmap = value for i in 2...PBAnimation::MAX_SPRITES - @celsprites[i].bitmap=@animbitmap if @celsprites[i] + @celsprites[i].bitmap = @animbitmap if @celsprites[i] end self.invalidate end @@ -520,45 +520,45 @@ class AnimationCanvas < Sprite def play(oppmove = false) if !@playing - @sprites["pokemon_0"]=Sprite.new(@viewport) - @sprites["pokemon_0"].bitmap=@user - @sprites["pokemon_0"].z=21 - @sprites["pokemon_1"]=Sprite.new(@viewport) - @sprites["pokemon_1"].bitmap=@target - @sprites["pokemon_1"].z=16 + @sprites["pokemon_0"] = Sprite.new(@viewport) + @sprites["pokemon_0"].bitmap = @user + @sprites["pokemon_0"].z = 21 + @sprites["pokemon_1"] = Sprite.new(@viewport) + @sprites["pokemon_1"].bitmap = @target + @sprites["pokemon_1"].z = 16 pbSpriteSetAnimFrame(@sprites["pokemon_0"], pbCreateCel(Battle::Scene::FOCUSUSER_X, - Battle::Scene::FOCUSUSER_Y,-1,2), - @sprites["pokemon_0"],@sprites["pokemon_1"]) + Battle::Scene::FOCUSUSER_Y, -1, 2), + @sprites["pokemon_0"], @sprites["pokemon_1"]) pbSpriteSetAnimFrame(@sprites["pokemon_1"], pbCreateCel(Battle::Scene::FOCUSTARGET_X, - Battle::Scene::FOCUSTARGET_Y,-2,1), - @sprites["pokemon_0"],@sprites["pokemon_1"]) - usersprite=@sprites["pokemon_#{oppmove ? 1 : 0}"] - targetsprite=@sprites["pokemon_#{oppmove ? 0 : 1}"] - olduserx=usersprite ? usersprite.x : 0 - oldusery=usersprite ? usersprite.y : 0 - oldtargetx=targetsprite ? targetsprite.x : 0 - oldtargety=targetsprite ? targetsprite.y : 0 - @player=PBAnimationPlayerX.new(@animation, - @battle.battlers[oppmove ? 1 : 0],@battle.battlers[oppmove ? 0 : 1],self,oppmove,true) + Battle::Scene::FOCUSTARGET_Y, -2, 1), + @sprites["pokemon_0"], @sprites["pokemon_1"]) + usersprite = @sprites["pokemon_#{oppmove ? 1 : 0}"] + targetsprite = @sprites["pokemon_#{oppmove ? 0 : 1}"] + olduserx = usersprite ? usersprite.x : 0 + oldusery = usersprite ? usersprite.y : 0 + oldtargetx = targetsprite ? targetsprite.x : 0 + oldtargety = targetsprite ? targetsprite.y : 0 + @player = PBAnimationPlayerX.new(@animation, + @battle.battlers[oppmove ? 1 : 0], @battle.battlers[oppmove ? 0 : 1], self, oppmove, true) @player.setLineTransform( - Battle::Scene::FOCUSUSER_X,Battle::Scene::FOCUSUSER_Y, - Battle::Scene::FOCUSTARGET_X,Battle::Scene::FOCUSTARGET_Y, - olduserx,oldusery, - oldtargetx,oldtargety) + Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y, + Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y, + olduserx, oldusery, + oldtargetx, oldtargety) @player.start - @playing=true - @sprites["pokemon_0"].x+=BORDERSIZE - @sprites["pokemon_0"].y+=BORDERSIZE - @sprites["pokemon_1"].x+=BORDERSIZE - @sprites["pokemon_1"].y+=BORDERSIZE - oldstate=[] + @playing = true + @sprites["pokemon_0"].x += BORDERSIZE + @sprites["pokemon_0"].y += BORDERSIZE + @sprites["pokemon_1"].x += BORDERSIZE + @sprites["pokemon_1"].y += BORDERSIZE + oldstate = [] for i in 0...PBAnimation::MAX_SPRITES - oldstate.push([@celsprites[i].visible,@framesprites[i].visible,@lastframesprites[i].visible]) - @celsprites[i].visible=false - @framesprites[i].visible=false - @lastframesprites[i].visible=false + oldstate.push([@celsprites[i].visible, @framesprites[i].visible, @lastframesprites[i].visible]) + @celsprites[i].visible = false + @framesprites[i].visible = false + @lastframesprites[i].visible = false end loop do Graphics.update @@ -566,14 +566,14 @@ class AnimationCanvas < Sprite break if !@playing end for i in 0...PBAnimation::MAX_SPRITES - @celsprites[i].visible=oldstate[i][0] - @framesprites[i].visible=oldstate[i][1] - @lastframesprites[i].visible=oldstate[i][2] + @celsprites[i].visible = oldstate[i][0] + @framesprites[i].visible = oldstate[i][1] + @lastframesprites[i].visible = oldstate[i][2] end @sprites["pokemon_0"].dispose @sprites["pokemon_1"].dispose @player.dispose - @player=nil + @player = nil end end @@ -584,323 +584,323 @@ class AnimationCanvas < Sprite end def invalidateCel(i) - @dirty[i]=true + @dirty[i] = true end def currentframe=(value) - @currentframe=value + @currentframe = value invalidate end def getCurrentFrame - return nil if @currentframe>=@animation.length + return nil if @currentframe >= @animation.length return @animation[@currentframe] end def setFrame(i) if @celsprites[i] - @framesprites[i].ox=32 - @framesprites[i].oy=32 - @framesprites[i].selected=(i==@currentcel) - @framesprites[i].locked=self.locked?(i) - @framesprites[i].x=@celsprites[i].x - @framesprites[i].y=@celsprites[i].y - @framesprites[i].visible=@celsprites[i].visible + @framesprites[i].ox = 32 + @framesprites[i].oy = 32 + @framesprites[i].selected = (i == @currentcel) + @framesprites[i].locked = self.locked?(i) + @framesprites[i].x = @celsprites[i].x + @framesprites[i].y = @celsprites[i].y + @framesprites[i].visible = @celsprites[i].visible @framesprites[i].repaint end end def setPreviousFrame(i) - if @currentframe>0 - cel=@animation[@currentframe-1][i] - if cel!=nil - @lastframesprites[i].ox=32 - @lastframesprites[i].oy=32 - @lastframesprites[i].selected=false - @lastframesprites[i].locked=false - @lastframesprites[i].x=cel[AnimFrame::X]+64 - @lastframesprites[i].y=cel[AnimFrame::Y]+64 - @lastframesprites[i].visible=true + if @currentframe > 0 + cel = @animation[@currentframe - 1][i] + if cel != nil + @lastframesprites[i].ox = 32 + @lastframesprites[i].oy = 32 + @lastframesprites[i].selected = false + @lastframesprites[i].locked = false + @lastframesprites[i].x = cel[AnimFrame::X] + 64 + @lastframesprites[i].y = cel[AnimFrame::Y] + 64 + @lastframesprites[i].visible = true @lastframesprites[i].repaint else - @lastframesprites[i].visible=false + @lastframesprites[i].visible = false end else - @lastframesprites[i].visible=false + @lastframesprites[i].visible = false end end - def offsetFrame(frame,ox,oy) - if frame>=0 && frame<@animation.length + def offsetFrame(frame, ox, oy) + if frame >= 0 && frame < @animation.length for i in 0...PBAnimation::MAX_SPRITES if !self.locked?(i) && @animation[frame][i] - @animation[frame][i][AnimFrame::X]+=ox - @animation[frame][i][AnimFrame::Y]+=oy + @animation[frame][i][AnimFrame::X] += ox + @animation[frame][i][AnimFrame::Y] += oy end - @dirty[i]=true if frame==@currentframe + @dirty[i] = true if frame == @currentframe end end end # Clears all items in the frame except locked items def clearFrame(frame) - if frame>=0 && frame<@animation.length + if frame >= 0 && frame < @animation.length for i in 0...PBAnimation::MAX_SPRITES if self.deletable?(i) - @animation[frame][i]=nil + @animation[frame][i] = nil else pbResetCel(@animation[frame][i]) end - @dirty[i]=true if frame==@currentframe + @dirty[i] = true if frame == @currentframe end end end def insertFrame(frame) - return if frame>=@animation.length - @animation.insert(frame,@animation[frame].clone) + return if frame >= @animation.length + @animation.insert(frame, @animation[frame].clone) self.invalidate end - def copyFrame(src,dst) - return if dst>=@animation.length + def copyFrame(src, dst) + return if dst >= @animation.length for i in 0...PBAnimation::MAX_SPRITES - clonedframe=@animation[src][i] - clonedframe=clonedframe.clone if clonedframe && clonedframe!=true - @animation[dst][i]=clonedframe + clonedframe = @animation[src][i] + clonedframe = clonedframe.clone if clonedframe && clonedframe != true + @animation[dst][i] = clonedframe end - self.invalidate if dst==@currentframe + self.invalidate if dst == @currentframe end def pasteFrame(frame) - return if frame <0 || frame>=@animation.length - return if Clipboard.typekey!="PBAnimFrame" - @animation[frame]=Clipboard.data - self.invalidate if frame==@currentframe + return if frame < 0 || frame >= @animation.length + return if Clipboard.typekey != "PBAnimFrame" + @animation[frame] = Clipboard.data + self.invalidate if frame == @currentframe end def deleteFrame(frame) - return if frame<0 || frame>=@animation.length || @animation.length<=1 - self.currentframe-=1 if frame==@animation.length-1 + return if frame < 0 || frame >= @animation.length || @animation.length <= 1 + self.currentframe -= 1 if frame == @animation.length - 1 @animation.delete_at(frame) - @currentcel=-1 + @currentcel = -1 self.invalidate end # This frame becomes a copy of the previous frame def pasteLast - copyFrame(@currentframe-1,@currentframe) if @currentframe>0 + copyFrame(@currentframe - 1, @currentframe) if @currentframe > 0 end def currentCel - return nil if @currentcel<0 - return nil if @currentframe>=@animation.length + return nil if @currentcel < 0 + return nil if @currentframe >= @animation.length return @animation[@currentframe][@currentcel] end - def pasteCel(x,y) - return if @currentframe>=@animation.length - return if Clipboard.typekey!="PBAnimCel" + def pasteCel(x, y) + return if @currentframe >= @animation.length + return if Clipboard.typekey != "PBAnimCel" for i in 0...PBAnimation::MAX_SPRITES next if @animation[@currentframe][i] - @animation[@currentframe][i]=Clipboard.data - cel=@animation[@currentframe][i] - cel[AnimFrame::X]=x - cel[AnimFrame::Y]=y - cel[AnimFrame::LOCKED]=0 - @celsprites[i].bitmap=@user if cel[AnimFrame::PATTERN]==-1 - @celsprites[i].bitmap=@target if cel[AnimFrame::PATTERN]==-2 - @currentcel=i + @animation[@currentframe][i] = Clipboard.data + cel = @animation[@currentframe][i] + cel[AnimFrame::X] = x + cel[AnimFrame::Y] = y + cel[AnimFrame::LOCKED] = 0 + @celsprites[i].bitmap = @user if cel[AnimFrame::PATTERN] == -1 + @celsprites[i].bitmap = @target if cel[AnimFrame::PATTERN] == -2 + @currentcel = i break end invalidate end def deleteCel(cel) - return if cel<0 - return if @currentframe <0 || @currentframe>=@animation.length + return if cel < 0 + return if @currentframe < 0 || @currentframe >= @animation.length return if !deletable?(cel) - @animation[@currentframe][cel]=nil - @dirty[cel]=true + @animation[@currentframe][cel] = nil + @dirty[cel] = true end - def swapCels(cel1,cel2) - return if cel1<0 || cel2<0 - return if @currentframe<0 || @currentframe>=@animation.length - t=@animation[@currentframe][cel1] - @animation[@currentframe][cel1]=@animation[@currentframe][cel2] - @animation[@currentframe][cel2]=t - @currentcel=cel2 - @dirty[cel1]=true - @dirty[cel2]=true + def swapCels(cel1, cel2) + return if cel1 < 0 || cel2 < 0 + return if @currentframe < 0 || @currentframe >= @animation.length + t = @animation[@currentframe][cel1] + @animation[@currentframe][cel1] = @animation[@currentframe][cel2] + @animation[@currentframe][cel2] = t + @currentcel = cel2 + @dirty[cel1] = true + @dirty[cel2] = true end def locked?(celindex) - cel=@animation[self.currentframe] + cel = @animation[self.currentframe] return false if !cel - cel=cel[celindex] - return cel ? (cel[AnimFrame::LOCKED]!=0) : false + cel = cel[celindex] + return cel ? (cel[AnimFrame::LOCKED] != 0) : false end def deletable?(celindex) - cel=@animation[self.currentframe] + cel = @animation[self.currentframe] return true if !cel - cel=cel[celindex] + cel = cel[celindex] return true if !cel - return false if cel[AnimFrame::LOCKED]!=0 - if cel[AnimFrame::PATTERN]<0 - count=0 - pattern=cel[AnimFrame::PATTERN] + return false if cel[AnimFrame::LOCKED] != 0 + if cel[AnimFrame::PATTERN] < 0 + count = 0 + pattern = cel[AnimFrame::PATTERN] for i in 0...PBAnimation::MAX_SPRITES - othercel=@animation[self.currentframe][i] - count+=1 if othercel && othercel[AnimFrame::PATTERN]==pattern + othercel = @animation[self.currentframe][i] + count += 1 if othercel && othercel[AnimFrame::PATTERN] == pattern end - return false if count<=1 + return false if count <= 1 end return true end - def setBitmap(i,frame) + def setBitmap(i, frame) if @celsprites[i] - cel=@animation[frame][i] - @celsprites[i].bitmap=@animbitmap + cel = @animation[frame][i] + @celsprites[i].bitmap = @animbitmap if cel - @celsprites[i].bitmap=@user if cel[AnimFrame::PATTERN]==-1 - @celsprites[i].bitmap=@target if cel[AnimFrame::PATTERN]==-2 + @celsprites[i].bitmap = @user if cel[AnimFrame::PATTERN] == -1 + @celsprites[i].bitmap = @target if cel[AnimFrame::PATTERN] == -2 end end end - def setSpriteBitmap(sprite,cel) + def setSpriteBitmap(sprite, cel) if sprite && !sprite.disposed? - sprite.bitmap=@animbitmap + sprite.bitmap = @animbitmap if cel - sprite.bitmap=@user if cel[AnimFrame::PATTERN]==-1 - sprite.bitmap=@target if cel[AnimFrame::PATTERN]==-2 + sprite.bitmap = @user if cel[AnimFrame::PATTERN] == -1 + sprite.bitmap = @target if cel[AnimFrame::PATTERN] == -2 end end end - def addSprite(x,y) - return false if @currentframe>=@animation.length + def addSprite(x, y) + return false if @currentframe >= @animation.length for i in 0...PBAnimation::MAX_SPRITES next if @animation[@currentframe][i] - @animation[@currentframe][i]=pbCreateCel(x,y,@pattern,@animation.position) - @dirty[i]=true - @currentcel=i + @animation[@currentframe][i] = pbCreateCel(x, y, @pattern, @animation.position) + @dirty[i] = true + @currentcel = i return true end return false end def updateInput - cel=currentCel - mousepos=Mouse::getMousePos - if mousepos && pbSpriteHitTest(self,mousepos[0],mousepos[1],false,true) + cel = currentCel + mousepos = Mouse::getMousePos + if mousepos && pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true) if Input.trigger?(Input::MOUSELEFT) # Left mouse button - selectedcel=-1 - usealpha=(Input.press?(Input::ALT)) ? true : false + selectedcel = -1 + usealpha = (Input.press?(Input::ALT)) ? true : false for j in 0...PBAnimation::MAX_SPRITES - if pbSpriteHitTest(@celsprites[j],mousepos[0],mousepos[1],usealpha,false) - selectedcel=j + if pbSpriteHitTest(@celsprites[j], mousepos[0], mousepos[1], usealpha, false) + selectedcel = j end end - if selectedcel<0 - if @animbitmap && addSprite(mousepos[0]-BORDERSIZE,mousepos[1]-BORDERSIZE) - @selecting=true if !self.locked?(@currentcel) - @selectOffsetX=0 - @selectOffsetY=0 - cel=currentCel + if selectedcel < 0 + if @animbitmap && addSprite(mousepos[0] - BORDERSIZE, mousepos[1] - BORDERSIZE) + @selecting = true if !self.locked?(@currentcel) + @selectOffsetX = 0 + @selectOffsetY = 0 + cel = currentCel invalidate end else - @currentcel=selectedcel - @selecting=true if !self.locked?(@currentcel) - cel=currentCel - @selectOffsetX=cel[AnimFrame::X]-mousepos[0]+BORDERSIZE - @selectOffsetY=cel[AnimFrame::Y]-mousepos[1]+BORDERSIZE + @currentcel = selectedcel + @selecting = true if !self.locked?(@currentcel) + cel = currentCel + @selectOffsetX = cel[AnimFrame::X] - mousepos[0] + BORDERSIZE + @selectOffsetY = cel[AnimFrame::Y] - mousepos[1] + BORDERSIZE invalidate end end end - currentFrame=getCurrentFrame + currentFrame = getCurrentFrame if currentFrame && !@selecting && (Input.triggerex?(:TAB) || Input.repeatex?(:TAB)) currentFrame.length.times { - @currentcel+=1 - @currentcel=0 if @currentcel>=currentFrame.length + @currentcel += 1 + @currentcel = 0 if @currentcel >= currentFrame.length break if currentFrame[@currentcel] } invalidate return end if cel && @selecting && mousepos - cel[AnimFrame::X]=mousepos[0]-BORDERSIZE+@selectOffsetX - cel[AnimFrame::Y]=mousepos[1]-BORDERSIZE+@selectOffsetY - @dirty[@currentcel]=true + cel[AnimFrame::X] = mousepos[0] - BORDERSIZE + @selectOffsetX + cel[AnimFrame::Y] = mousepos[1] - BORDERSIZE + @selectOffsetY + @dirty[@currentcel] = true end if !Input.press?(Input::MOUSELEFT) && @selecting - @selecting=false + @selecting = false end if cel if (Input.triggerex?(:DELETE) || Input.repeatex?(:DELETE)) && self.deletable?(@currentcel) - @animation[@currentframe][@currentcel]=nil - @dirty[@currentcel]=true + @animation[@currentframe][@currentcel] = nil + @dirty[@currentcel] = true return end if Input.triggerex?(:P) || Input.repeatex?(:P) # Properties pbCellProperties(self) - @dirty[@currentcel]=true + @dirty[@currentcel] = true return end if Input.triggerex?(:L) || Input.repeatex?(:L) # Lock - cel[AnimFrame::LOCKED]=(cel[AnimFrame::LOCKED]==0) ? 1 : 0 - @dirty[@currentcel]=true + cel[AnimFrame::LOCKED] = (cel[AnimFrame::LOCKED] == 0) ? 1 : 0 + @dirty[@currentcel] = true end if Input.triggerex?(:R) || Input.repeatex?(:R) # Rotate right - cel[AnimFrame::ANGLE]+=10 - cel[AnimFrame::ANGLE]%=360 - @dirty[@currentcel]=true + cel[AnimFrame::ANGLE] += 10 + cel[AnimFrame::ANGLE] %= 360 + @dirty[@currentcel] = true end if Input.triggerex?(:E) || Input.repeatex?(:E) # Rotate left - cel[AnimFrame::ANGLE]-=10 - cel[AnimFrame::ANGLE]%=360 - @dirty[@currentcel]=true + cel[AnimFrame::ANGLE] -= 10 + cel[AnimFrame::ANGLE] %= 360 + @dirty[@currentcel] = true end if Input.triggerex?(:KP_PLUS) || Input.repeatex?(:KP_PLUS) # Zoom in - cel[AnimFrame::ZOOMX]+=10 - cel[AnimFrame::ZOOMX]=1000 if cel[AnimFrame::ZOOMX]>1000 - cel[AnimFrame::ZOOMY]+=10 - cel[AnimFrame::ZOOMY]=1000 if cel[AnimFrame::ZOOMY]>1000 - @dirty[@currentcel]=true + cel[AnimFrame::ZOOMX] += 10 + cel[AnimFrame::ZOOMX] = 1000 if cel[AnimFrame::ZOOMX] > 1000 + cel[AnimFrame::ZOOMY] += 10 + cel[AnimFrame::ZOOMY] = 1000 if cel[AnimFrame::ZOOMY] > 1000 + @dirty[@currentcel] = true end if Input.triggerex?(:KP_MINUS) || Input.repeatex?(:KP_MINUS) # Zoom out - cel[AnimFrame::ZOOMX]-=10 - cel[AnimFrame::ZOOMX]=10 if cel[AnimFrame::ZOOMX]<10 - cel[AnimFrame::ZOOMY]-=10 - cel[AnimFrame::ZOOMY]=10 if cel[AnimFrame::ZOOMY]<10 - @dirty[@currentcel]=true + cel[AnimFrame::ZOOMX] -= 10 + cel[AnimFrame::ZOOMX] = 10 if cel[AnimFrame::ZOOMX] < 10 + cel[AnimFrame::ZOOMY] -= 10 + cel[AnimFrame::ZOOMY] = 10 if cel[AnimFrame::ZOOMY] < 10 + @dirty[@currentcel] = true end if !self.locked?(@currentcel) if Input.trigger?(Input::UP) || Input.repeat?(Input::UP) - increment=(Input.press?(Input::ALT)) ? 1 : 8 - cel[AnimFrame::Y]-=increment - @dirty[@currentcel]=true + increment = (Input.press?(Input::ALT)) ? 1 : 8 + cel[AnimFrame::Y] -= increment + @dirty[@currentcel] = true end - if Input.trigger?(Input::DOWN) ||Input.repeat?(Input::DOWN) - increment=(Input.press?(Input::ALT)) ? 1 : 8 - cel[AnimFrame::Y]+=increment - @dirty[@currentcel]=true + if Input.trigger?(Input::DOWN) || Input.repeat?(Input::DOWN) + increment = (Input.press?(Input::ALT)) ? 1 : 8 + cel[AnimFrame::Y] += increment + @dirty[@currentcel] = true end if Input.trigger?(Input::LEFT) || Input.repeat?(Input::LEFT) - increment=(Input.press?(Input::ALT)) ? 1 : 8 - cel[AnimFrame::X]-=increment - @dirty[@currentcel]=true + increment = (Input.press?(Input::ALT)) ? 1 : 8 + cel[AnimFrame::X] -= increment + @dirty[@currentcel] = true end if Input.trigger?(Input::RIGHT) || Input.repeat?(Input::RIGHT) - increment=(Input.press?(Input::ALT)) ? 1 : 8 - cel[AnimFrame::X]+=increment - @dirty[@currentcel]=true + increment = (Input.press?(Input::ALT)) ? 1 : 8 + cel[AnimFrame::X] += increment + @dirty[@currentcel] = true end end end @@ -910,7 +910,7 @@ class AnimationCanvas < Sprite super if @playing if @player.animDone? - @playing=false + @playing = false invalidate else @player.update @@ -924,24 +924,24 @@ class AnimationCanvas < Sprite for i in 0...PBAnimation::MAX_SPRITES if @dirty[i] if @celsprites[i] - setBitmap(i,@currentframe) - pbSpriteSetAnimFrame(@celsprites[i],@animation[@currentframe][i],@celsprites[0],@celsprites[1],true) - @celsprites[i].x+=BORDERSIZE - @celsprites[i].y+=BORDERSIZE + setBitmap(i, @currentframe) + pbSpriteSetAnimFrame(@celsprites[i], @animation[@currentframe][i], @celsprites[0], @celsprites[1], true) + @celsprites[i].x += BORDERSIZE + @celsprites[i].y += BORDERSIZE end setPreviousFrame(i) setFrame(i) - @dirty[i]=false + @dirty[i] = false end end else for i in 0...PBAnimation::MAX_SPRITES - pbSpriteSetAnimFrame(@celsprites[i],nil,@celsprites[0],@celsprites[1],true) - @celsprites[i].x+=BORDERSIZE - @celsprites[i].y+=BORDERSIZE + pbSpriteSetAnimFrame(@celsprites[i], nil, @celsprites[0], @celsprites[1], true) + @celsprites[i].x += BORDERSIZE + @celsprites[i].y += BORDERSIZE setPreviousFrame(i) setFrame(i) - @dirty[i]=false + @dirty[i] = false end end end @@ -956,48 +956,48 @@ class BitmapDisplayWindow < SpriteWindow_Base attr_reader :bitmapname attr_reader :hue - def initialize(x,y,width,height) - super(x,y,width,height) - @bitmapname="" - @hue=0 - self.contents=Bitmap.new(width-32,height-32) + def initialize(x, y, width, height) + super(x, y, width, height) + @bitmapname = "" + @hue = 0 + self.contents = Bitmap.new(width - 32, height - 32) end def bitmapname=(value) - if @bitmapname!=value - @bitmapname=value + if @bitmapname != value + @bitmapname = value refresh end end def hue=(value) - if @hue!=value - @hue=value + if @hue != value + @hue = value refresh end end def refresh self.contents.clear - bmap=AnimatedBitmap.new("Graphics/Animations/"+@bitmapname,@hue).deanimate + bmap = AnimatedBitmap.new("Graphics/Animations/" + @bitmapname, @hue).deanimate return if !bmap - ww=bmap.width - wh=bmap.height - sx=self.contents.width*1.0/ww - sy=self.contents.height*1.0/wh - if sx>sy - ww=sy*ww - wh=self.contents.height + ww = bmap.width + wh = bmap.height + sx = self.contents.width * 1.0 / ww + sy = self.contents.height * 1.0 / wh + if sx > sy + ww = sy * ww + wh = self.contents.height else - wh=sx*wh - ww=self.contents.width + wh = sx * wh + ww = self.contents.width end - dest=Rect.new( - (self.contents.width-ww)/2, - (self.contents.height-wh)/2, - ww,wh) - src=Rect.new(0,0,bmap.width,bmap.height) - self.contents.stretch_blt(dest,bmap,src) + dest = Rect.new( + (self.contents.width - ww) / 2, + (self.contents.height - wh) / 2, + ww, wh) + src = Rect.new(0, 0, bmap.width, bmap.height) + self.contents.stretch_blt(dest, bmap, src) bmap.dispose end end @@ -1005,20 +1005,20 @@ end class AnimationNameWindow - def initialize(canvas,x,y,width,height,viewport = nil) - @canvas=canvas - @oldname=nil - @window=Window_UnformattedTextPokemon.newWithSize( - _INTL("Name: {1}",@canvas.animation.name),x,y,width,height,viewport) + def initialize(canvas, x, y, width, height, viewport = nil) + @canvas = canvas + @oldname = nil + @window = Window_UnformattedTextPokemon.newWithSize( + _INTL("Name: {1}", @canvas.animation.name), x, y, width, height, viewport) end - def viewport=(value); @window.viewport=value; end + def viewport=(value); @window.viewport = value; end def update - newtext=_INTL("Name: {1}",@canvas.animation.name) - if @oldname!=newtext - @window.text=newtext - @oldname=newtext + newtext = _INTL("Name: {1}", @canvas.animation.name) + if @oldname != newtext + @window.text = newtext + @oldname = newtext end @window.update end diff --git a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb index f505153d4..c3bba4e64 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb @@ -1,14 +1,14 @@ module ShadowText - def shadowtext(bitmap,x,y,w,h,t,disabled = false,align = 0) - width=bitmap.text_size(t).width - if align==2 - x+=(w-width) - elsif align==1 - x+=(w/2)-(width/2) + def shadowtext(bitmap, x, y, w, h, t, disabled = false, align = 0) + width = bitmap.text_size(t).width + if align == 2 + x += (w - width) + elsif align == 1 + x += (w / 2) - (width / 2) end - pbDrawShadowText(bitmap,x,y,w,h,t, - disabled ? Color.new(26*8,26*8,25*8) : Color.new(12*8,12*8,12*8), - Color.new(26*8,26*8,25*8)) + pbDrawShadowText(bitmap, x, y, w, h, t, + disabled ? Color.new(26 * 8, 26 * 8, 25 * 8) : Color.new(12 * 8, 12 * 8, 12 * 8), + Color.new(26 * 8, 26 * 8, 25 * 8)) end end @@ -31,38 +31,38 @@ class UIControl end def text=(value) - self.label=value + self.label = value end def initialize(label) - @label=label - @x=0 - @y=0 - @width=0 - @height=0 - @changed=false - @disabled=false - @invalid=true + @label = label + @x = 0 + @y = 0 + @width = 0 + @height = 0 + @changed = false + @disabled = false + @invalid = true end def toAbsoluteRect(rc) return Rect.new( - rc.x+self.parentX, - rc.y+self.parentY, - rc.width,rc.height) + rc.x + self.parentX, + rc.y + self.parentY, + rc.width, rc.height) end def parentX return 0 if !self.parent - return self.parent.x+self.parent.leftEdge if self.parent.is_a?(SpriteWindow) - return self.parent.x+16 if self.parent.is_a?(Window) + return self.parent.x + self.parent.leftEdge if self.parent.is_a?(SpriteWindow) + return self.parent.x + 16 if self.parent.is_a?(Window) return self.parent.x end def parentY return 0 if !self.parent - return self.parent.y+self.parent.topEdge if self.parent.is_a?(SpriteWindow) - return self.parent.y+16 if self.parent.is_a?(Window) + return self.parent.y + self.parent.topEdge if self.parent.is_a?(SpriteWindow) + return self.parent.y + 16 if self.parent.is_a?(Window) return self.parent.y end @@ -71,7 +71,7 @@ class UIControl end def invalidate # Marks that the control must be redrawn to reflect current logic - @invalid=true + @invalid = true end def update # Updates the logic on the control, invalidating it if necessary @@ -81,7 +81,7 @@ class UIControl end def validate # Makes the control no longer invalid - @invalid=false + @invalid = false end def repaint # Redraws the control only if it is invalid @@ -96,15 +96,15 @@ end class Label < UIControl def text=(value) - self.label=value + self.label = value refresh end def refresh - bitmap=self.bitmap - bitmap.fill_rect(self.x,self.y,self.width,self.height,Color.new(0,0,0,0)) - size=bitmap.text_size(self.label).width - shadowtext(bitmap,self.x+4,self.y,size,self.height,self.label,@disabled) + bitmap = self.bitmap + bitmap.fill_rect(self.x, self.y, self.width, self.height, Color.new(0, 0, 0, 0)) + size = bitmap.text_size(self.label).width + shadowtext(bitmap, self.x + 4, self.y, size, self.height, self.label, @disabled) end end @@ -115,44 +115,44 @@ class Button < UIControl def initialize(label) super - @captured=false - @label=label + @captured = false + @label = label end def update - mousepos=Mouse::getMousePos - self.changed=false + mousepos = Mouse::getMousePos + self.changed = false return if !mousepos - rect=Rect.new(self.x+1,self.y+1,self.width-2,self.height-2) - rect=toAbsoluteRect(rect) + rect = Rect.new(self.x + 1, self.y + 1, self.width - 2, self.height - 2) + rect = toAbsoluteRect(rect) if Input.trigger?(Input::MOUSELEFT) && - rect.contains(mousepos[0],mousepos[1]) && !@captured - @captured=true + rect.contains(mousepos[0], mousepos[1]) && !@captured + @captured = true self.invalidate end if Input.release?(Input::MOUSELEFT) && @captured - self.changed=true if rect.contains(mousepos[0],mousepos[1]) - @captured=false + self.changed = true if rect.contains(mousepos[0], mousepos[1]) + @captured = false self.invalidate end end def refresh - bitmap=self.bitmap - x=self.x - y=self.y - width=self.width - height=self.height - color=Color.new(120,120,120) - bitmap.fill_rect(x+1,y+1,width-2,height-2,color) - ret=Rect.new(x+1,y+1,width-2,height-2) + bitmap = self.bitmap + x = self.x + y = self.y + width = self.width + height = self.height + color = Color.new(120, 120, 120) + bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color) + ret = Rect.new(x + 1, y + 1, width - 2, height - 2) if !@captured - bitmap.fill_rect(x+2,y+2,width-4,height-4,Color.new(0,0,0,0)) + bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0)) else - bitmap.fill_rect(x+2,y+2,width-4,height-4,Color.new(120,120,120,80)) + bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80)) end - size=bitmap.text_size(self.label).width - shadowtext(bitmap,x+4,y,size,height,self.label,@disabled) + size = bitmap.text_size(self.label).width + shadowtext(bitmap, x + 4, y, size, height, self.label, @disabled) return ret end end @@ -167,47 +167,47 @@ class Checkbox < Button end def curvalue=(value) - self.checked=value + self.checked = value end def checked=(value) - @checked=value + @checked = value invalidate end def initialize(label) super - @checked=false + @checked = false end def update super if self.changed - @checked=!@checked + @checked = !@checked self.invalidate end end def refresh - bitmap=self.bitmap - x=self.x - y=self.y - width=[self.width,32].min - height=[self.height,32].min - color=Color.new(120,120,120) - bitmap.fill_rect(x+2,y+2,self.width-4,self.height-4,Color.new(0,0,0,0)) - bitmap.fill_rect(x+1,y+1,width-2,height-2,color) - ret=Rect.new(x+1,y+1,width-2,height-2) + bitmap = self.bitmap + x = self.x + y = self.y + width = [self.width, 32].min + height = [self.height, 32].min + color = Color.new(120, 120, 120) + bitmap.fill_rect(x + 2, y + 2, self.width - 4, self.height - 4, Color.new(0, 0, 0, 0)) + bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color) + ret = Rect.new(x + 1, y + 1, width - 2, height - 2) if !@captured - bitmap.fill_rect(x+2,y+2,width-4,height-4,Color.new(0,0,0,0)) + bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0)) else - bitmap.fill_rect(x+2,y+2,width-4,height-4,Color.new(120,120,120,80)) + bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80)) end if self.checked - shadowtext(bitmap,x,y,32,32,"X",@disabled,1) + shadowtext(bitmap, x, y, 32, 32, "X", @disabled, 1) end - size=bitmap.text_size(self.label).width - shadowtext(bitmap,x+36,y,size,height,self.label,@disabled) + size = bitmap.text_size(self.label).width + shadowtext(bitmap, x + 36, y, size, height, self.label, @disabled) return ret end end @@ -219,69 +219,69 @@ class TextField < UIControl attr_reader :text def text=(value) - @text=value + @text = value self.invalidate end - def initialize(label,text) + def initialize(label, text) super(label) - @frame=0 - @label=label - @text=text - @cursor=text.scan(/./m).length + @frame = 0 + @label = label + @text = text + @cursor = text.scan(/./m).length end def insert(ch) - chars=self.text.scan(/./m) - chars.insert(@cursor,ch) - @text="" + chars = self.text.scan(/./m) + chars.insert(@cursor, ch) + @text = "" for ch in chars - @text+=ch + @text += ch end - @cursor+=1 - @frame=0 - self.changed=true + @cursor += 1 + @frame = 0 + self.changed = true self.invalidate end def delete - chars=self.text.scan(/./m) - chars.delete_at(@cursor-1) - @text="" + chars = self.text.scan(/./m) + chars.delete_at(@cursor - 1) + @text = "" for ch in chars - @text+=ch + @text += ch end - @cursor-=1 - @frame=0 - self.changed=true + @cursor -= 1 + @frame = 0 + self.changed = true self.invalidate end def update - @frame+=1 - @frame%=20 - self.changed=false - self.invalidate if ((@frame%10)==0) + @frame += 1 + @frame %= 20 + self.changed = false + self.invalidate if ((@frame % 10) == 0) # Moving cursor if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT) if @cursor > 0 - @cursor-=1 - @frame=0 + @cursor -= 1 + @frame = 0 self.invalidate end return end if Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT) if @cursor < self.text.scan(/./m).length - @cursor+=1 - @frame=0 + @cursor += 1 + @frame = 0 self.invalidate end return end # Backspace if Input.triggerex?(:BACKSPACE) || Input.repeatex?(:BACKSPACE) || - Input.triggerex?(:DELETE) || Input.repeatex?(:DELETE) + Input.triggerex?(:DELETE) || Input.repeatex?(:DELETE) self.delete if @cursor > 0 return end @@ -290,53 +290,53 @@ class TextField < UIControl end def refresh - bitmap=self.bitmap - x=self.x - y=self.y - width=self.width - height=self.height - color=Color.new(120,120,120) - bitmap.font.color=color - bitmap.fill_rect(x,y,width,height,Color.new(0,0,0,0)) - size=bitmap.text_size(self.label).width - shadowtext(bitmap,x,y,size,height,self.label) - x+=size - width-=size - bitmap.fill_rect(x+1,y+1,width-2,height-2,color) - ret=Rect.new(x+1,y+1,width-2,height-2) + bitmap = self.bitmap + x = self.x + y = self.y + width = self.width + height = self.height + color = Color.new(120, 120, 120) + bitmap.font.color = color + bitmap.fill_rect(x, y, width, height, Color.new(0, 0, 0, 0)) + size = bitmap.text_size(self.label).width + shadowtext(bitmap, x, y, size, height, self.label) + x += size + width -= size + bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color) + ret = Rect.new(x + 1, y + 1, width - 2, height - 2) if !@captured - bitmap.fill_rect(x+2,y+2,width-4,height-4,Color.new(0,0,0,0)) + bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0)) else - bitmap.fill_rect(x+2,y+2,width-4,height-4,Color.new(120,120,120,80)) + bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80)) end - x+=4 - textscan=self.text.scan(/./m) - scanlength=textscan.length - @cursor=scanlength if @cursor>scanlength - @cursor=0 if @cursor<0 - startpos=@cursor - fromcursor=0 - while (startpos>0) - c=textscan[startpos-1] - fromcursor+=bitmap.text_size(c).width - break if fromcursor>width-4 - startpos-=1 + x += 4 + textscan = self.text.scan(/./m) + scanlength = textscan.length + @cursor = scanlength if @cursor > scanlength + @cursor = 0 if @cursor < 0 + startpos = @cursor + fromcursor = 0 + while (startpos > 0) + c = textscan[startpos - 1] + fromcursor += bitmap.text_size(c).width + break if fromcursor > width - 4 + startpos -= 1 end for i in startpos...scanlength - c=textscan[i] - textwidth=bitmap.text_size(c).width - next if c=="\n" + c = textscan[i] + textwidth = bitmap.text_size(c).width + next if c == "\n" # Draw text - shadowtext(bitmap,x,y, textwidth+4, 32, c) + shadowtext(bitmap, x, y, textwidth + 4, 32, c) # Draw cursor if necessary - if ((@frame/10)&1) == 0 && i==@cursor - bitmap.fill_rect(x,y+4,2,24,Color.new(120,120,120)) + if ((@frame / 10) & 1) == 0 && i == @cursor + bitmap.fill_rect(x, y + 4, 2, 24, Color.new(120, 120, 120)) end # Add x to drawn text width x += textwidth end - if ((@frame/10)&1) == 0 && textscan.length==@cursor - bitmap.fill_rect(x,y+4,2,24,Color.new(120,120,120)) + if ((@frame / 10) & 1) == 0 && textscan.length == @cursor + bitmap.fill_rect(x, y + 4, 2, 24, Color.new(120, 120, 120)) end return ret end @@ -351,120 +351,120 @@ class Slider < UIControl attr_accessor :label def curvalue=(value) - @curvalue=value - @curvalue=self.minvalue if self.minvalue && @curvalueself.maxvalue + @curvalue = value + @curvalue = self.minvalue if self.minvalue && @curvalue < self.minvalue + @curvalue = self.maxvalue if self.maxvalue && @curvalue > self.maxvalue self.invalidate end def minvalue=(value) - @minvalue=value - @curvalue=self.minvalue if self.minvalue && @curvalueself.maxvalue + @minvalue = value + @curvalue = self.minvalue if self.minvalue && @curvalue < self.minvalue + @curvalue = self.maxvalue if self.maxvalue && @curvalue > self.maxvalue self.invalidate end def maxvalue=(value) - @maxvalue=value - @curvalue=self.minvalue if self.minvalue && @curvalueself.maxvalue + @maxvalue = value + @curvalue = self.minvalue if self.minvalue && @curvalue < self.minvalue + @curvalue = self.maxvalue if self.maxvalue && @curvalue > self.maxvalue self.invalidate end - def initialize(label,minvalue,maxvalue,curval) + def initialize(label, minvalue, maxvalue, curval) super(label) - @minvalue=minvalue - @maxvalue=maxvalue - @curvalue=curval - @label=label - @leftarrow=Rect.new(0,0,0,0) - @rightarrow=Rect.new(0,0,0,0) - self.minvalue=minvalue - self.maxvalue=maxvalue - self.curvalue=curval + @minvalue = minvalue + @maxvalue = maxvalue + @curvalue = curval + @label = label + @leftarrow = Rect.new(0, 0, 0, 0) + @rightarrow = Rect.new(0, 0, 0, 0) + self.minvalue = minvalue + self.maxvalue = maxvalue + self.curvalue = curval end def update - mousepos=Mouse::getMousePos - self.changed=false - if self.minvalue2500 - self.curvalue-=10 - self.curvalue=self.curvalue.floor - elsif repeattime>1250 - self.curvalue-=5 - self.curvalue=self.curvalue.floor + if left.contains(mousepos[0], mousepos[1]) + if repeattime > 2500 + self.curvalue -= 10 + self.curvalue = self.curvalue.floor + elsif repeattime > 1250 + self.curvalue -= 5 + self.curvalue = self.curvalue.floor else - self.curvalue-=1 - self.curvalue=self.curvalue.floor + self.curvalue -= 1 + self.curvalue = self.curvalue.floor end - self.changed=(self.curvalue!=oldvalue) + self.changed = (self.curvalue != oldvalue) self.invalidate end # Right arrow - if right.contains(mousepos[0],mousepos[1]) - if repeattime>2500 - self.curvalue+=10 - self.curvalue=self.curvalue.floor - elsif repeattime>1250 - self.curvalue+=5 - self.curvalue=self.curvalue.floor + if right.contains(mousepos[0], mousepos[1]) + if repeattime > 2500 + self.curvalue += 10 + self.curvalue = self.curvalue.floor + elsif repeattime > 1250 + self.curvalue += 5 + self.curvalue = self.curvalue.floor else - self.curvalue+=1 - self.curvalue=self.curvalue.floor + self.curvalue += 1 + self.curvalue = self.curvalue.floor end - self.changed=(self.curvalue!=oldvalue) + self.changed = (self.curvalue != oldvalue) self.invalidate end end def refresh - bitmap=self.bitmap - x=self.x - y=self.y - width=self.width - height=self.height - color=Color.new(120,120,120) - 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(" << ")) - numbers=bitmap.text_size(" XXXX ").width - rightarrows=bitmap.text_size(_INTL(" >> ")) - bitmap.font.color=color - shadowtext(bitmap,x,y,size,height,self.label) - x+=size - shadowtext(bitmap,x,y,leftarrows.width,height,_INTL(" << "), - self.disabled || self.curvalue==self.minvalue) - @leftarrow=Rect.new(x,y,leftarrows.width,height) - x+=leftarrows.width + bitmap = self.bitmap + x = self.x + y = self.y + width = self.width + height = self.height + color = Color.new(120, 120, 120) + 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(" << ")) + numbers = bitmap.text_size(" XXXX ").width + rightarrows = bitmap.text_size(_INTL(" >> ")) + bitmap.font.color = color + shadowtext(bitmap, x, y, size, height, self.label) + x += size + shadowtext(bitmap, x, y, leftarrows.width, height, _INTL(" << "), + self.disabled || self.curvalue == self.minvalue) + @leftarrow = Rect.new(x, y, leftarrows.width, height) + x += leftarrows.width if !self.disabled - bitmap.font.color=color - shadowtext(bitmap,x,y,numbers,height," #{self.curvalue} ",false,1) + bitmap.font.color = color + shadowtext(bitmap, x, y, numbers, height, " #{self.curvalue} ", false, 1) end - x+=numbers - shadowtext(bitmap,x,y,rightarrows.width,height,_INTL(" >> "), - self.disabled || self.curvalue==self.maxvalue) - @rightarrow=Rect.new(x,y,rightarrows.width,height) + x += numbers + shadowtext(bitmap, x, y, rightarrows.width, height, _INTL(" >> "), + self.disabled || self.curvalue == self.maxvalue) + @rightarrow = Rect.new(x, y, rightarrows.width, height) end end class OptionalSlider < Slider - def initialize(label,minvalue,maxvalue,curvalue) - @slider=Slider.new(label,minvalue,maxvalue,curvalue) - @checkbox=Checkbox.new("") + def initialize(label, minvalue, maxvalue, curvalue) + @slider = Slider.new(label, minvalue, maxvalue, curvalue) + @checkbox = Checkbox.new("") end def curvalue @@ -472,7 +472,7 @@ class OptionalSlider < Slider end def curvalue=(value) - slider.curvalue=value + slider.curvalue = value end def checked @@ -480,7 +480,7 @@ class OptionalSlider < Slider end def checked=(value) - @checkbox.checked=value + @checkbox.checked = value end def invalid? @@ -506,7 +506,7 @@ class OptionalSlider < Slider end def minvalue=(value) - slider.minvalue=value + slider.minvalue = value end def maxvalue @@ -514,7 +514,7 @@ class OptionalSlider < Slider end def maxvalue=(value) - slider.maxvalue=value + slider.maxvalue = value end def update @@ -532,20 +532,20 @@ class OptionalSlider < Slider private def updatedefs - checkboxwidth=32 - @slider.bitmap=self.bitmap - @slider.parent=self.parent - @checkbox.x=self.x - @checkbox.y=self.y - @checkbox.width=checkboxwidth - @checkbox.height=self.height - @checkbox.bitmap=self.bitmap - @checkbox.parent=self.parent - @slider.x=self.x+checkboxwidth+4 - @slider.y=self.y - @slider.width=self.width-checkboxwidth - @slider.height=self.height - @slider.disabled=!@checkbox.checked + checkboxwidth = 32 + @slider.bitmap = self.bitmap + @slider.parent = self.parent + @checkbox.x = self.x + @checkbox.y = self.y + @checkbox.width = checkboxwidth + @checkbox.height = self.height + @checkbox.bitmap = self.bitmap + @checkbox.parent = self.parent + @slider.x = self.x + checkboxwidth + 4 + @slider.y = self.y + @slider.width = self.width - checkboxwidth + @slider.height = self.height + @slider.disabled = !@checkbox.checked end end @@ -553,12 +553,12 @@ end class ArrayCountSlider < Slider def maxvalue - return @array.length-1 + return @array.length - 1 end - def initialize(array,label) - @array=array - super(label,0,canvas.animation.length-1,0) + def initialize(array, label) + @array = array + super(label, 0, canvas.animation.length - 1, 0) end end @@ -570,8 +570,8 @@ class FrameCountSlider < Slider end def initialize(canvas) - @canvas=canvas - super(_INTL("Frame:"),1,canvas.animation.length,0) + @canvas = canvas + super(_INTL("Frame:"), 1, canvas.animation.length, 0) end end @@ -579,11 +579,11 @@ end class FrameCountButton < Button def label - return _INTL("Total Frames: {1}",@canvas.animation.length) + return _INTL("Total Frames: {1}", @canvas.animation.length) end def initialize(canvas) - @canvas=canvas + @canvas = canvas super(self.label) end end @@ -599,120 +599,120 @@ class TextSlider < UIControl attr_accessor :maxoptionwidth def curvalue=(value) - @curvalue=value - @curvalue=self.minvalue if self.minvalue && @curvalueself.maxvalue + @curvalue = value + @curvalue = self.minvalue if self.minvalue && @curvalue < self.minvalue + @curvalue = self.maxvalue if self.maxvalue && @curvalue > self.maxvalue self.invalidate end def minvalue=(value) - @minvalue=value - @curvalue=self.minvalue if self.minvalue && @curvalueself.maxvalue + @minvalue = value + @curvalue = self.minvalue if self.minvalue && @curvalue < self.minvalue + @curvalue = self.maxvalue if self.maxvalue && @curvalue > self.maxvalue self.invalidate end def maxvalue=(value) - @maxvalue=value - @curvalue=self.minvalue if self.minvalue && @curvalueself.maxvalue + @maxvalue = value + @curvalue = self.minvalue if self.minvalue && @curvalue < self.minvalue + @curvalue = self.maxvalue if self.maxvalue && @curvalue > self.maxvalue self.invalidate end - def initialize(label,options,curval) + def initialize(label, options, curval) super(label) - @label=label - @options=options - @minvalue=0 - @maxvalue=options.length-1 - @curvalue=curval - @leftarrow=Rect.new(0,0,0,0) - @rightarrow=Rect.new(0,0,0,0) - self.minvalue=@minvalue - self.maxvalue=@maxvalue - self.curvalue=@curvalue + @label = label + @options = options + @minvalue = 0 + @maxvalue = options.length - 1 + @curvalue = curval + @leftarrow = Rect.new(0, 0, 0, 0) + @rightarrow = Rect.new(0, 0, 0, 0) + self.minvalue = @minvalue + self.maxvalue = @maxvalue + self.curvalue = @curvalue end def update - mousepos=Mouse::getMousePos - self.changed=false - if self.minvalue2500 - self.curvalue-=10 - elsif repeattime>1250 - self.curvalue-=5 + if left.contains(mousepos[0], mousepos[1]) + if repeattime > 2500 + self.curvalue -= 10 + elsif repeattime > 1250 + self.curvalue -= 5 else - self.curvalue-=1 + self.curvalue -= 1 end - self.changed=(self.curvalue!=oldvalue) + self.changed = (self.curvalue != oldvalue) self.invalidate end # Right arrow - if right.contains(mousepos[0],mousepos[1]) - if repeattime>2500 - self.curvalue+=10 - elsif repeattime>1250 - self.curvalue+=5 + if right.contains(mousepos[0], mousepos[1]) + if repeattime > 2500 + self.curvalue += 10 + elsif repeattime > 1250 + self.curvalue += 5 else - self.curvalue+=1 + self.curvalue += 1 end - self.changed=(self.curvalue!=oldvalue) + self.changed = (self.curvalue != oldvalue) self.invalidate end end def refresh - bitmap=self.bitmap - if @maxoptionwidth==nil + bitmap = self.bitmap + if @maxoptionwidth == nil for i in 0...@options.length - w=self.bitmap.text_size(" "+@options[i]+" ").width - @maxoptionwidth=w if !@maxoptionwidth || @maxoptionwidth> ")) - bitmap.font.color=color - shadowtext(bitmap,x,y,size,height,self.label) - x+=size - shadowtext(bitmap,x,y,leftarrows.width,height,_INTL(" << "), - self.disabled || self.curvalue==self.minvalue) - @leftarrow=Rect.new(x,y,leftarrows.width,height) - x+=leftarrows.width + x = self.x + y = self.y + width = self.width + height = self.height + color = Color.new(120, 120, 120) + 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(" << ")) + rightarrows = bitmap.text_size(_INTL(" >> ")) + bitmap.font.color = color + shadowtext(bitmap, x, y, size, height, self.label) + x += size + shadowtext(bitmap, x, y, leftarrows.width, height, _INTL(" << "), + self.disabled || self.curvalue == self.minvalue) + @leftarrow = Rect.new(x, y, leftarrows.width, height) + x += leftarrows.width if !self.disabled - bitmap.font.color=color - shadowtext(bitmap,x,y,@maxoptionwidth,height," #{@options[self.curvalue]} ",false,1) + bitmap.font.color = color + shadowtext(bitmap, x, y, @maxoptionwidth, height, " #{@options[self.curvalue]} ", false, 1) end - x+=@maxoptionwidth - shadowtext(bitmap,x,y,rightarrows.width,height,_INTL(" >> "), - self.disabled || self.curvalue==self.maxvalue) - @rightarrow=Rect.new(x,y,rightarrows.width,height) + x += @maxoptionwidth + shadowtext(bitmap, x, y, rightarrows.width, height, _INTL(" >> "), + self.disabled || self.curvalue == self.maxvalue) + @rightarrow = Rect.new(x, y, rightarrows.width, height) end end class OptionalTextSlider < TextSlider - def initialize(label,options,curval) - @slider=TextSlider.new(label,options,curval) - @checkbox=Checkbox.new("") + def initialize(label, options, curval) + @slider = TextSlider.new(label, options, curval) + @checkbox = Checkbox.new("") end def curvalue @@ -720,7 +720,7 @@ class OptionalTextSlider < TextSlider end def curvalue=(value) - slider.curvalue=value + slider.curvalue = value end def checked @@ -728,7 +728,7 @@ class OptionalTextSlider < TextSlider end def checked=(value) - @checkbox.checked=value + @checkbox.checked = value end def invalid? @@ -754,7 +754,7 @@ class OptionalTextSlider < TextSlider end def minvalue=(value) - slider.minvalue=value + slider.minvalue = value end def maxvalue @@ -762,7 +762,7 @@ class OptionalTextSlider < TextSlider end def maxvalue=(value) - slider.maxvalue=value + slider.maxvalue = value end def update @@ -780,20 +780,20 @@ class OptionalTextSlider < TextSlider private def updatedefs - checkboxwidth=32 - @slider.bitmap=self.bitmap - @slider.parent=self.parent - @checkbox.x=self.x - @checkbox.y=self.y - @checkbox.width=checkboxwidth - @checkbox.height=self.height - @checkbox.bitmap=self.bitmap - @checkbox.parent=self.parent - @slider.x=self.x+checkboxwidth+4 - @slider.y=self.y - @slider.width=self.width-checkboxwidth - @slider.height=self.height - @slider.disabled=!@checkbox.checked + checkboxwidth = 32 + @slider.bitmap = self.bitmap + @slider.parent = self.parent + @checkbox.x = self.x + @checkbox.y = self.y + @checkbox.width = checkboxwidth + @checkbox.height = self.height + @checkbox.bitmap = self.bitmap + @checkbox.parent = self.parent + @slider.x = self.x + checkboxwidth + 4 + @slider.y = self.y + @slider.width = self.width - checkboxwidth + @slider.height = self.height + @slider.disabled = !@checkbox.checked end end @@ -801,11 +801,11 @@ end class ControlWindow < SpriteWindow_Base attr_reader :controls - def initialize(x,y,width,height) - super(x,y,width,height) - self.contents=Bitmap.new(width-32,height-32) + def initialize(x, y, width, height) + super(x, y, width, height) + self.contents = Bitmap.new(width - 32, height - 32) pbSetNarrowFont(self.contents) - @controls=[] + @controls = [] end def dispose @@ -832,27 +832,27 @@ class ControlWindow < SpriteWindow_Base end def hittest?(i) - mousepos=Mouse::getMousePos + mousepos = Mouse::getMousePos return false if !mousepos - return false if i<0 || i>=@controls.length - rc=Rect.new( + return false if i < 0 || i >= @controls.length + rc = Rect.new( @controls[i].parentX, @controls[i].parentY, @controls[i].width, @controls[i].height ) - return rc.contains(mousepos[0],mousepos[1]) + return rc.contains(mousepos[0], mousepos[1]) end def addControl(control) - i=@controls.length - @controls[i]=control - @controls[i].x=0 - @controls[i].y=i*32 - @controls[i].width=self.contents.width - @controls[i].height=32 - @controls[i].parent=self - @controls[i].bitmap=self.contents + i = @controls.length + @controls[i] = control + @controls[i].x = 0 + @controls[i].y = i * 32 + @controls[i].width = self.contents.width + @controls[i].height = 32 + @controls[i].parent = self + @controls[i].bitmap = self.contents @controls[i].invalidate refresh return i @@ -866,20 +866,20 @@ class ControlWindow < SpriteWindow_Base return addControl(Button.new(label)) end - def addSlider(label,minvalue,maxvalue,curvalue) - return addControl(Slider.new(label,minvalue,maxvalue,curvalue)) + def addSlider(label, minvalue, maxvalue, curvalue) + return addControl(Slider.new(label, minvalue, maxvalue, curvalue)) end - def addOptionalSlider(label,minvalue,maxvalue,curvalue) - return addControl(OptionalSlider.new(label,minvalue,maxvalue,curvalue)) + def addOptionalSlider(label, minvalue, maxvalue, curvalue) + return addControl(OptionalSlider.new(label, minvalue, maxvalue, curvalue)) end - def addTextSlider(label,options,curvalue) - return addControl(TextSlider.new(label,options,curvalue)) + def addTextSlider(label, options, curvalue) + return addControl(TextSlider.new(label, options, curvalue)) end - def addOptionalTextSlider(label,options,curvalue) - return addControl(OptionalTextSlider.new(label,options,curvalue)) + def addOptionalTextSlider(label, options, curvalue) + return addControl(OptionalTextSlider.new(label, options, curvalue)) end def addCheckbox(label) @@ -899,12 +899,12 @@ class ControlWindow < SpriteWindow_Base end def changed?(i) - return false if i<0 + return false if i < 0 return @controls[i].changed end def value(i) - return false if i<0 + return false if i < 0 return @controls[i].curvalue end end diff --git a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb index f43bfeecf..ed132bb2c 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb @@ -4,38 +4,38 @@ class ControlPointSprite < SpriteWrapper attr_accessor :dragging - def initialize(red,viewport = nil) + def initialize(red, viewport = nil) super(viewport) - self.bitmap=Bitmap.new(6,6) - self.bitmap.fill_rect(0,0,6,1,Color.new(0,0,0)) - self.bitmap.fill_rect(0,0,1,6,Color.new(0,0,0)) - self.bitmap.fill_rect(0,5,6,1,Color.new(0,0,0)) - self.bitmap.fill_rect(5,0,1,6,Color.new(0,0,0)) - color=(red) ? Color.new(255,0,0) : Color.new(0,0,0) - self.bitmap.fill_rect(2,2,2,2,color) - self.x=-6 - self.y=-6 - self.visible=false - @dragging=false + self.bitmap = Bitmap.new(6, 6) + self.bitmap.fill_rect(0, 0, 6, 1, Color.new(0, 0, 0)) + self.bitmap.fill_rect(0, 0, 1, 6, Color.new(0, 0, 0)) + self.bitmap.fill_rect(0, 5, 6, 1, Color.new(0, 0, 0)) + self.bitmap.fill_rect(5, 0, 1, 6, Color.new(0, 0, 0)) + color = (red) ? Color.new(255, 0, 0) : Color.new(0, 0, 0) + self.bitmap.fill_rect(2, 2, 2, 2, color) + self.x = -6 + self.y = -6 + self.visible = false + @dragging = false end def mouseover - if Input.time?(Input::MOUSELEFT)==0 || !@dragging - @dragging=false + if Input.time?(Input::MOUSELEFT) == 0 || !@dragging + @dragging = false return end - mouse=Mouse::getMousePos(true) + mouse = Mouse::getMousePos(true) return if !mouse - self.x=[[mouse[0],0].max,512].min - self.y=[[mouse[1],0].max,384].min + self.x = [[mouse[0], 0].max, 512].min + self.y = [[mouse[1], 0].max, 384].min end def hittest? return true if !self.visible - mouse=Mouse::getMousePos(true) + mouse = Mouse::getMousePos(true) return false if !mouse - return mouse[0]>=self.x && mouse[0]=self.y && mouse[1]= self.x && mouse[0] < self.x + 6 && + mouse[1] >= self.y && mouse[1] < self.y + 6 end def inspect @@ -51,12 +51,12 @@ end class PointSprite < SpriteWrapper - def initialize(x,y,viewport = nil) + def initialize(x, y, viewport = nil) super(viewport) - self.bitmap=Bitmap.new(2,2) - self.bitmap.fill_rect(0,0,2,2,Color.new(0,0,0)) - self.x=x - self.y=y + self.bitmap = Bitmap.new(2, 2) + self.bitmap.fill_rect(0, 0, 2, 2, Color.new(0, 0, 0)) + self.x = x + self.y = y end def dispose @@ -71,9 +71,9 @@ class PointPath include Enumerable def initialize - @points=[] - @distances=[] - @totaldist=0 + @points = [] + @distances = [] + @totaldist = 0 end def [](x) @@ -97,86 +97,86 @@ class PointPath end def inspect - p=[] + p = [] for point in @points - p.push([point[0].to_i,point[1].to_i]) + p.push([point[0].to_i, point[1].to_i]) end return p.inspect end - def isEndPoint?(x,y) - return false if @points.length==0 - index=@points.length-1 - return @points[index][0]==x && - @points[index][1]==y + def isEndPoint?(x, y) + return false if @points.length == 0 + index = @points.length - 1 + return @points[index][0] == x && + @points[index][1] == y end - def addPoint(x,y) - @points.push([x,y]) - if @points.length>1 - len=@points.length - dx=@points[len-2][0]-@points[len-1][0] - dy=@points[len-2][1]-@points[len-1][1] - dist=Math.sqrt(dx*dx+dy*dy) + def addPoint(x, y) + @points.push([x, y]) + if @points.length > 1 + len = @points.length + dx = @points[len - 2][0] - @points[len - 1][0] + dy = @points[len - 2][1] - @points[len - 1][1] + dist = Math.sqrt(dx * dx + dy * dy) @distances.push(dist) - @totaldist+=dist + @totaldist += dist end end def clear @points.clear @distances.clear - @totaldist=0 + @totaldist = 0 end - def smoothPointPath(frames,roundValues = false) - if frames<0 + def smoothPointPath(frames, roundValues = false) + if frames < 0 raise ArgumentError.new("frames out of range: #{frames}") end - ret=PointPath.new - if @points.length==0 + ret = PointPath.new + if @points.length == 0 return ret end - step=1.0/frames - t=0.0 - (frames+2).times do - point=pointOnPath(t) + step = 1.0 / frames + t = 0.0 + (frames + 2).times do + point = pointOnPath(t) if roundValues - ret.addPoint(point[0].round,point[1].round) + ret.addPoint(point[0].round, point[1].round) else - ret.addPoint(point[0],point[1]) + ret.addPoint(point[0], point[1]) end - t+=step - t=[1.0,t].min + t += step + t = [1.0, t].min end return ret end def pointOnPath(t) - if t<0 || t>1 + if t < 0 || t > 1 raise ArgumentError.new("t out of range for pointOnPath: #{t}") end - return nil if @points.length==0 - ret=@points[@points.length-1].clone - if @points.length==1 + return nil if @points.length == 0 + ret = @points[@points.length - 1].clone + if @points.length == 1 return ret end - curdist=0 - distForT=@totaldist*t - i=0 + curdist = 0 + distForT = @totaldist * t + i = 0 for dist in @distances - curdist+=dist - if dist>0.0 - if curdist>=distForT - distT=1.0-((curdist-distForT)/dist) - dx=@points[i+1][0]-@points[i][0] - dy=@points[i+1][1]-@points[i][1] - ret=[@points[i][0]+dx*distT, - @points[i][1]+dy*distT] + curdist += dist + if dist > 0.0 + if curdist >= distForT + distT = 1.0 - ((curdist - distForT) / dist) + dx = @points[i + 1][0] - @points[i][0] + dy = @points[i + 1][1] - @points[i][1] + ret = [@points[i][0] + dx * distT, + @points[i][1] + dy * distT] break end end - i+=1 + i += 1 end return ret end @@ -184,83 +184,83 @@ end -def catmullRom(p1,p2,p3,p4,t) +def catmullRom(p1, p2, p3, p4, t) # p1=prevPoint, p2=startPoint, p3=endPoint, p4=nextPoint, t is from 0 through 1 - t2=t*t - t3=t2*t - return 0.5*(2*p2+t*(p3-p1) + - t2*(2*p1-5*p2+4*p3-p4)+ - t3*(p4-3*p3+3*p2-p1)) + t2 = t * t + t3 = t2 * t + return 0.5 * (2 * p2 + t * (p3 - p1) + + t2 * (2 * p1 - 5 * p2 + 4 * p3 - p4) + + t3 * (p4 - 3 * p3 + 3 * p2 - p1)) end -def getCatmullRomPoint(src,t) - x=0,y=0 - t*=3.0 - if t<1.0 - x=catmullRom(src[0].x,src[0].x,src[1].x,src[2].x,t) - y=catmullRom(src[0].y,src[0].y,src[1].y,src[2].y,t) - elsif t<2.0 - t-=1.0 - x=catmullRom(src[0].x,src[1].x,src[2].x,src[3].x,t) - y=catmullRom(src[0].y,src[1].y,src[2].y,src[3].y,t) +def getCatmullRomPoint(src, t) + x = 0, y = 0 + t *= 3.0 + if t < 1.0 + x = catmullRom(src[0].x, src[0].x, src[1].x, src[2].x, t) + y = catmullRom(src[0].y, src[0].y, src[1].y, src[2].y, t) + elsif t < 2.0 + t -= 1.0 + x = catmullRom(src[0].x, src[1].x, src[2].x, src[3].x, t) + y = catmullRom(src[0].y, src[1].y, src[2].y, src[3].y, t) else - t-=2.0 - x=catmullRom(src[1].x,src[2].x,src[3].x,src[3].x,t) - y=catmullRom(src[1].y,src[2].y,src[3].y,src[3].y,t) + t -= 2.0 + x = catmullRom(src[1].x, src[2].x, src[3].x, src[3].x, t) + y = catmullRom(src[1].y, src[2].y, src[3].y, src[3].y, t) end - return [x,y] + return [x, y] end -def getCurvePoint(src,t) - return getCatmullRomPoint(src,t) +def getCurvePoint(src, t) + return getCatmullRomPoint(src, t) end -def curveToPointPath(curve,numpoints) - if numpoints<2 +def curveToPointPath(curve, numpoints) + if numpoints < 2 return nil end - path=PointPath.new - step=1.0/(numpoints-1) - t=0.0 + path = PointPath.new + step = 1.0 / (numpoints - 1) + t = 0.0 numpoints.times do - point=getCurvePoint(curve,t) - path.addPoint(point[0],point[1]) - t+=step + point = getCurvePoint(curve, t) + path.addPoint(point[0], point[1]) + t += step end return path end def pbDefinePath(canvas) - sliderwin2=ControlWindow.new(0,0,320,320) - sliderwin2.viewport=canvas.viewport - sliderwin2.addSlider(_INTL("Number of frames:"),2,500,20) - sliderwin2.opacity=200 - defcurvebutton=sliderwin2.addButton(_INTL("Define Smooth Curve")) - defpathbutton=sliderwin2.addButton(_INTL("Define Freehand Path")) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) - points=[] - path=nil + sliderwin2 = ControlWindow.new(0, 0, 320, 320) + sliderwin2.viewport = canvas.viewport + sliderwin2.addSlider(_INTL("Number of frames:"), 2, 500, 20) + sliderwin2.opacity = 200 + defcurvebutton = sliderwin2.addButton(_INTL("Define Smooth Curve")) + defpathbutton = sliderwin2.addButton(_INTL("Define Freehand Path")) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) + points = [] + path = nil loop do Graphics.update Input.update sliderwin2.update if sliderwin2.changed?(0) # Number of frames if path - path=path.smoothPointPath(sliderwin2.value(0),false) - i=0 + path = path.smoothPointPath(sliderwin2.value(0), false) + i = 0 for point in path - if icanvas.animation.length + neededsize = canvas.currentframe + sliderwin2.value(0) + if neededsize > canvas.animation.length canvas.animation.resize(neededsize) end - thiscel=canvas.currentCel - celnumber=canvas.currentcel + thiscel = canvas.currentCel + celnumber = canvas.currentcel for i in canvas.currentframe...neededsize - cel=canvas.animation[i][celnumber] + cel = canvas.animation[i][celnumber] if !canvas.animation[i][celnumber] - cel=pbCreateCel(0,0,thiscel[AnimFrame::PATTERN],canvas.animation.position) - canvas.animation[i][celnumber]=cel + cel = pbCreateCel(0, 0, thiscel[AnimFrame::PATTERN], canvas.animation.position) + canvas.animation[i][celnumber] = cel end - cel[AnimFrame::X]=path[i-canvas.currentframe][0] - cel[AnimFrame::Y]=path[i-canvas.currentframe][1] + cel[AnimFrame::X] = path[i - canvas.currentframe][0] + cel[AnimFrame::Y] = path[i - canvas.currentframe][1] end break elsif sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK) diff --git a/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb b/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb index 3c07ffd2a..8e8ba64c2 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/004_AnimEditor_ExportImport.rb @@ -14,7 +14,7 @@ def tryLoadData(file) end def dumpBase64Anim(s) - return [Zlib::Deflate.deflate(Marshal.dump(s))].pack("m").gsub(/\n/,"\r\n") + return [Zlib::Deflate.deflate(Marshal.dump(s))].pack("m").gsub(/\n/, "\r\n") end def loadBase64Anim(s) @@ -22,56 +22,56 @@ def loadBase64Anim(s) end def pbExportAnim(animations) - filename=pbMessageFreeText(_INTL("Enter a filename."),"",false,32) - if filename!="" + filename = pbMessageFreeText(_INTL("Enter a filename."), "", false, 32) + if filename != "" begin - filename+=".anm" - File.open(filename,"wb") { |f| + filename += ".anm" + File.open(filename, "wb") { |f| f.write(dumpBase64Anim(animations[animations.selected])) } - failed=false + failed = false rescue - pbMessage(_INTL("Couldn't save the animation to {1}.",filename)) - failed=true + pbMessage(_INTL("Couldn't save the animation to {1}.", filename)) + failed = true end if !failed - pbMessage(_INTL("Animation was saved to {1} in the game folder.",filename)) + pbMessage(_INTL("Animation was saved to {1} in the game folder.", filename)) pbMessage(_INTL("It's a text file, so it can be transferred to others easily.")) end end end -def pbImportAnim(animations,canvas,animwin) - animfiles=[] +def pbImportAnim(animations, canvas, animwin) + animfiles = [] pbRgssChdir(".") { animfiles.concat(Dir.glob("*.anm")) } - cmdwin=pbListWindow(animfiles,320) - cmdwin.opacity=200 - cmdwin.height=480 - cmdwin.viewport=canvas.viewport + cmdwin = pbListWindow(animfiles, 320) + cmdwin.opacity = 200 + cmdwin.height = 480 + cmdwin.viewport = canvas.viewport loop do Graphics.update Input.update cmdwin.update - if Input.trigger?(Input::USE) && animfiles.length>0 + if Input.trigger?(Input::USE) && animfiles.length > 0 begin - textdata=loadBase64Anim(IO.read(animfiles[cmdwin.index])) + textdata = loadBase64Anim(IO.read(animfiles[cmdwin.index])) throw "Bad data" if !textdata.is_a?(PBAnimation) - textdata.id=-1 # this is not an RPG Maker XP animation + textdata.id = -1 # this is not an RPG Maker XP animation pbConvertAnimToNewFormat(textdata) - animations[animations.selected]=textdata + animations[animations.selected] = textdata rescue pbMessage(_INTL("The animation is invalid or could not be loaded.")) next end - graphic=animations[animations.selected].graphic - graphic="Graphics/Animations/#{graphic}" - if graphic && graphic!="" && !FileTest.image_exist?(graphic) - pbMessage(_INTL("The animation file {1} was not found. The animation will load anyway.",graphic)) + graphic = animations[animations.selected].graphic + graphic = "Graphics/Animations/#{graphic}" + if graphic && graphic != "" && !FileTest.image_exist?(graphic) + pbMessage(_INTL("The animation file {1} was not found. The animation will load anyway.", graphic)) end canvas.loadAnimation(animations[animations.selected]) - animwin.animbitmap=canvas.animbitmap + animwin.animbitmap = canvas.animbitmap break end if Input.trigger?(Input::BACK) @@ -86,12 +86,12 @@ end # Format conversion ################################################################################ def pbConvertAnimToNewFormat(textdata) - needconverting=false + needconverting = false for i in 0...textdata.length next if !textdata[i] for j in 0...PBAnimation::MAX_SPRITES next if !textdata[i][j] - needconverting=true if textdata[i][j][AnimFrame::FOCUS]==nil + needconverting = true if textdata[i][j][AnimFrame::FOCUS] == nil break if needconverting end break if needconverting @@ -101,20 +101,20 @@ def pbConvertAnimToNewFormat(textdata) next if !textdata[i] for j in 0...PBAnimation::MAX_SPRITES next if !textdata[i][j] - textdata[i][j][AnimFrame::PRIORITY]=1 if textdata[i][j][AnimFrame::PRIORITY]==nil - if j==0 # User battler - textdata[i][j][AnimFrame::FOCUS]=2 - textdata[i][j][AnimFrame::X]=Battle::Scene::FOCUSUSER_X - textdata[i][j][AnimFrame::Y]=Battle::Scene::FOCUSUSER_Y - elsif j==1 # Target battler - textdata[i][j][AnimFrame::FOCUS]=1 - textdata[i][j][AnimFrame::X]=Battle::Scene::FOCUSTARGET_X - textdata[i][j][AnimFrame::Y]=Battle::Scene::FOCUSTARGET_Y + textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil + if j == 0 # User battler + textdata[i][j][AnimFrame::FOCUS] = 2 + textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSUSER_X + textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSUSER_Y + elsif j == 1 # Target battler + textdata[i][j][AnimFrame::FOCUS] = 1 + textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSTARGET_X + textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSTARGET_Y else - textdata[i][j][AnimFrame::FOCUS]=(textdata.position || 4) - if textdata.position==1 - textdata[i][j][AnimFrame::X]+=Battle::Scene::FOCUSTARGET_X - textdata[i][j][AnimFrame::Y]+=Battle::Scene::FOCUSTARGET_Y-2 + textdata[i][j][AnimFrame::FOCUS] = (textdata.position || 4) + if textdata.position == 1 + textdata[i][j][AnimFrame::X] += Battle::Scene::FOCUSTARGET_X + textdata[i][j][AnimFrame::Y] += Battle::Scene::FOCUSTARGET_Y - 2 end end end @@ -125,20 +125,20 @@ end def pbConvertAnimsToNewFormat pbMessage(_INTL("Will convert animations now.")) - count=0 - animations=pbLoadBattleAnimations + count = 0 + animations = pbLoadBattleAnimations if !animations || !animations[0] pbMessage(_INTL("No animations exist.")) return end for k in 0...animations.length next if !animations[k] - ret=pbConvertAnimToNewFormat(animations[k]) - count+=1 if ret + ret = pbConvertAnimToNewFormat(animations[k]) + count += 1 if ret end - if count>0 - save_data(animations,"Data/PkmnAnimations.rxdata") + if count > 0 + save_data(animations, "Data/PkmnAnimations.rxdata") $game_temp.battle_animations_data = nil end - pbMessage(_INTL("{1} animations converted to new format.",count)) + pbMessage(_INTL("{1} animations converted to new format.", count)) end diff --git a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb index bf06b9042..318ae5970 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb @@ -5,7 +5,7 @@ class MiniBattler attr_accessor :index attr_accessor :pokemon - def initialize(index); self.index=index; end + def initialize(index); self.index = index; end end @@ -14,7 +14,7 @@ class MiniBattle attr_accessor :battlers def initialize - @battlers=[] + @battlers = [] for i in 0...4 @battlers[i] = MiniBattler.new(i) end @@ -26,35 +26,35 @@ end ################################################################################ # Pop-up menus for buttons in bottom menu ################################################################################ -def pbSelectAnim(canvas,animwin) - animfiles=[] +def pbSelectAnim(canvas, animwin) + animfiles = [] pbRgssChdir(File.join("Graphics", "Animations")) { animfiles.concat(Dir.glob("*.png")) } - cmdwin=pbListWindow(animfiles,320) - cmdwin.opacity=200 - cmdwin.height=512 - bmpwin=BitmapDisplayWindow.new(320,0,320,448) - ctlwin=ControlWindow.new(320,448,320,64) - cmdwin.viewport=canvas.viewport - bmpwin.viewport=canvas.viewport - ctlwin.viewport=canvas.viewport - ctlwin.addSlider(_INTL("Hue:"),0,359,0) + cmdwin = pbListWindow(animfiles, 320) + cmdwin.opacity = 200 + cmdwin.height = 512 + bmpwin = BitmapDisplayWindow.new(320, 0, 320, 448) + ctlwin = ControlWindow.new(320, 448, 320, 64) + cmdwin.viewport = canvas.viewport + bmpwin.viewport = canvas.viewport + ctlwin.viewport = canvas.viewport + ctlwin.addSlider(_INTL("Hue:"), 0, 359, 0) loop do - bmpwin.bitmapname=cmdwin.commands[cmdwin.index] + bmpwin.bitmapname = cmdwin.commands[cmdwin.index] Graphics.update Input.update cmdwin.update bmpwin.update ctlwin.update - bmpwin.hue=ctlwin.value(0) if ctlwin.changed?(0) - if Input.trigger?(Input::USE) && animfiles.length>0 + bmpwin.hue = ctlwin.value(0) if ctlwin.changed?(0) + if Input.trigger?(Input::USE) && animfiles.length > 0 filename = cmdwin.commands[cmdwin.index] - bitmap=AnimatedBitmap.new("Graphics/Animations/" + filename, ctlwin.value(0)).deanimate + bitmap = AnimatedBitmap.new("Graphics/Animations/" + filename, ctlwin.value(0)).deanimate canvas.animation.graphic = File.basename(filename, ".png") - canvas.animation.hue=ctlwin.value(0) - canvas.animbitmap=bitmap - animwin.animbitmap=bitmap + canvas.animation.hue = ctlwin.value(0) + canvas.animbitmap = bitmap + animwin.animbitmap = bitmap break end if Input.trigger?(Input::BACK) @@ -68,12 +68,12 @@ def pbSelectAnim(canvas,animwin) end def pbChangeMaximum(canvas) - sliderwin2=ControlWindow.new(0,0,320,32*4) - sliderwin2.viewport=canvas.viewport - sliderwin2.addSlider(_INTL("Frames:"),1,1000,canvas.animation.length) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) - sliderwin2.opacity=200 + sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 4) + sliderwin2.viewport = canvas.viewport + sliderwin2.addSlider(_INTL("Frames:"), 1, 1000, canvas.animation.length) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) + sliderwin2.opacity = 200 loop do Graphics.update Input.update @@ -90,21 +90,21 @@ def pbChangeMaximum(canvas) return end -def pbAnimName(animation,cmdwin) - window=ControlWindow.new(320,128,320,32*4) - window.z=99999 - window.addControl(TextField.new(_INTL("New Name:"),animation.name)) +def pbAnimName(animation, cmdwin) + window = ControlWindow.new(320, 128, 320, 32 * 4) + window.z = 99999 + window.addControl(TextField.new(_INTL("New Name:"), animation.name)) Input.text_input = true - okbutton=window.addButton(_INTL("OK")) - cancelbutton=window.addButton(_INTL("Cancel")) - window.opacity=224 + okbutton = window.addButton(_INTL("OK")) + cancelbutton = window.addButton(_INTL("Cancel")) + window.opacity = 224 loop do Graphics.update Input.update window.update if window.changed?(okbutton) || Input.triggerex?(:RETURN) - cmdwin.commands[cmdwin.index]=_INTL("{1} {2}",cmdwin.index,window.controls[0].text) - animation.name=window.controls[0].text + cmdwin.commands[cmdwin.index] = _INTL("{1} {2}", cmdwin.index, window.controls[0].text) + animation.name = window.controls[0].text break end if window.changed?(cancelbutton) || Input.triggerex?(:ESCAPE) @@ -116,25 +116,25 @@ def pbAnimName(animation,cmdwin) return end -def pbAnimList(animations,canvas,animwin) - commands=[] +def pbAnimList(animations, canvas, animwin) + commands = [] for i in 0...animations.length - animations[i]=PBAnimation.new if !animations[i] - commands[commands.length]=_INTL("{1} {2}",i,animations[i].name) + animations[i] = PBAnimation.new if !animations[i] + commands[commands.length] = _INTL("{1} {2}", i, animations[i].name) end - cmdwin=pbListWindow(commands,320) - cmdwin.height=416 - cmdwin.opacity=224 - cmdwin.index=animations.selected - cmdwin.viewport=canvas.viewport - helpwindow=Window_UnformattedTextPokemon.newWithSize( + cmdwin = pbListWindow(commands, 320) + cmdwin.height = 416 + cmdwin.opacity = 224 + cmdwin.index = animations.selected + cmdwin.viewport = canvas.viewport + helpwindow = Window_UnformattedTextPokemon.newWithSize( _INTL("Enter: Load/rename an animation\nEsc: Cancel"), - 320,0,320,128,canvas.viewport) - maxsizewindow=ControlWindow.new(0,416,320,32*3) - maxsizewindow.addSlider(_INTL("Total Animations:"),1,2000,animations.length) + 320, 0, 320, 128, canvas.viewport) + maxsizewindow = ControlWindow.new(0, 416, 320, 32 * 3) + maxsizewindow.addSlider(_INTL("Total Animations:"), 1, 2000, animations.length) maxsizewindow.addButton(_INTL("Resize Animation List")) - maxsizewindow.opacity=224 - maxsizewindow.viewport=canvas.viewport + maxsizewindow.opacity = 224 + maxsizewindow.viewport = canvas.viewport loop do Graphics.update Input.update @@ -142,34 +142,34 @@ def pbAnimList(animations,canvas,animwin) maxsizewindow.update helpwindow.update if maxsizewindow.changed?(1) - newsize=maxsizewindow.value(0) + newsize = maxsizewindow.value(0) animations.resize(newsize) commands.clear for i in 0...animations.length - commands[commands.length]=_INTL("{1} {2}",i,animations[i].name) + commands[commands.length] = _INTL("{1} {2}", i, animations[i].name) end - cmdwin.commands=commands - cmdwin.index=animations.selected + cmdwin.commands = commands + cmdwin.index = animations.selected next end - if Input.trigger?(Input::USE) && animations.length>0 - cmd2=pbShowCommands(helpwindow,[ + if Input.trigger?(Input::USE) && animations.length > 0 + cmd2 = pbShowCommands(helpwindow, [ _INTL("Load Animation"), _INTL("Rename"), _INTL("Delete") - ],-1) - if cmd2==0 # Load Animation + ], -1) + if cmd2 == 0 # Load Animation canvas.loadAnimation(animations[cmdwin.index]) - animwin.animbitmap=canvas.animbitmap - animations.selected=cmdwin.index + animwin.animbitmap = canvas.animbitmap + animations.selected = cmdwin.index break - elsif cmd2==1 # Rename - pbAnimName(animations[cmdwin.index],cmdwin) + elsif cmd2 == 1 # Rename + pbAnimName(animations[cmdwin.index], cmdwin) cmdwin.refresh - elsif cmd2==2 # Delete + elsif cmd2 == 2 # Delete if pbConfirmMessage(_INTL("Are you sure you want to delete this animation?")) - animations[cmdwin.index]=PBAnimation.new - cmdwin.commands[cmdwin.index]=_INTL("{1} {2}",cmdwin.index,animations[cmdwin.index].name) + animations[cmdwin.index] = PBAnimation.new + cmdwin.commands[cmdwin.index] = _INTL("{1} {2}", cmdwin.index, animations[cmdwin.index].name) cmdwin.refresh end end @@ -187,23 +187,23 @@ end # Pop-up menus for individual cels ################################################################################ def pbChooseNum(cel) - ret=cel - sliderwin2=ControlWindow.new(0,0,320,32*5) - sliderwin2.z=99999 - sliderwin2.addLabel(_INTL("Old Number: {1}",cel)) - sliderwin2.addSlider(_INTL("New Number:"),2,PBAnimation::MAX_SPRITES,cel) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) + ret = cel + sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 5) + sliderwin2.z = 99999 + sliderwin2.addLabel(_INTL("Old Number: {1}", cel)) + sliderwin2.addSlider(_INTL("New Number:"), 2, PBAnimation::MAX_SPRITES, cel) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) loop do Graphics.update Input.update sliderwin2.update if sliderwin2.changed?(okbutton) - ret=sliderwin2.value(1) + ret = sliderwin2.value(1) break end if sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK) - ret=-1 + ret = -1 break end end @@ -211,15 +211,15 @@ def pbChooseNum(cel) return ret end -def pbSetTone(cel,previewsprite) - sliderwin2=ControlWindow.new(0,0,320,320) - sliderwin2.z=99999 - sliderwin2.addSlider(_INTL("Red Offset:"),-255,255,cel[AnimFrame::TONERED]) - sliderwin2.addSlider(_INTL("Green Offset:"),-255,255,cel[AnimFrame::TONEGREEN]) - sliderwin2.addSlider(_INTL("Blue Offset:"),-255,255,cel[AnimFrame::TONEBLUE]) - sliderwin2.addSlider(_INTL("Gray Tone:"),0,255,cel[AnimFrame::TONEGRAY]) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) +def pbSetTone(cel, previewsprite) + sliderwin2 = ControlWindow.new(0, 0, 320, 320) + sliderwin2.z = 99999 + sliderwin2.addSlider(_INTL("Red Offset:"), -255, 255, cel[AnimFrame::TONERED]) + sliderwin2.addSlider(_INTL("Green Offset:"), -255, 255, cel[AnimFrame::TONEGREEN]) + sliderwin2.addSlider(_INTL("Blue Offset:"), -255, 255, cel[AnimFrame::TONEBLUE]) + sliderwin2.addSlider(_INTL("Gray Tone:"), 0, 255, cel[AnimFrame::TONEGRAY]) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) loop do previewsprite.tone.set( sliderwin2.value(0), @@ -231,10 +231,10 @@ def pbSetTone(cel,previewsprite) Input.update sliderwin2.update if sliderwin2.changed?(okbutton) - cel[AnimFrame::TONERED]=sliderwin2.value(0) - cel[AnimFrame::TONEGREEN]=sliderwin2.value(1) - cel[AnimFrame::TONEBLUE]=sliderwin2.value(2) - cel[AnimFrame::TONEGRAY]=sliderwin2.value(3) + cel[AnimFrame::TONERED] = sliderwin2.value(0) + cel[AnimFrame::TONEGREEN] = sliderwin2.value(1) + cel[AnimFrame::TONEBLUE] = sliderwin2.value(2) + cel[AnimFrame::TONEGRAY] = sliderwin2.value(3) break end if sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK) @@ -245,15 +245,15 @@ def pbSetTone(cel,previewsprite) return end -def pbSetFlash(cel,previewsprite) - sliderwin2=ControlWindow.new(0,0,320,320) - sliderwin2.z=99999 - sliderwin2.addSlider(_INTL("Red:"),0,255,cel[AnimFrame::COLORRED]) - sliderwin2.addSlider(_INTL("Green:"),0,255,cel[AnimFrame::COLORGREEN]) - sliderwin2.addSlider(_INTL("Blue:"),0,255,cel[AnimFrame::COLORBLUE]) - sliderwin2.addSlider(_INTL("Alpha:"),0,255,cel[AnimFrame::COLORALPHA]) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) +def pbSetFlash(cel, previewsprite) + sliderwin2 = ControlWindow.new(0, 0, 320, 320) + sliderwin2.z = 99999 + sliderwin2.addSlider(_INTL("Red:"), 0, 255, cel[AnimFrame::COLORRED]) + sliderwin2.addSlider(_INTL("Green:"), 0, 255, cel[AnimFrame::COLORGREEN]) + sliderwin2.addSlider(_INTL("Blue:"), 0, 255, cel[AnimFrame::COLORBLUE]) + sliderwin2.addSlider(_INTL("Alpha:"), 0, 255, cel[AnimFrame::COLORALPHA]) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) loop do previewsprite.tone.set( sliderwin2.value(0), @@ -265,10 +265,10 @@ def pbSetFlash(cel,previewsprite) Input.update sliderwin2.update if sliderwin2.changed?(okbutton) - cel[AnimFrame::COLORRED]=sliderwin2.value(0) - cel[AnimFrame::COLORGREEN]=sliderwin2.value(1) - cel[AnimFrame::COLORBLUE]=sliderwin2.value(2) - cel[AnimFrame::COLORALPHA]=sliderwin2.value(3) + cel[AnimFrame::COLORRED] = sliderwin2.value(0) + cel[AnimFrame::COLORGREEN] = sliderwin2.value(1) + cel[AnimFrame::COLORBLUE] = sliderwin2.value(2) + cel[AnimFrame::COLORALPHA] = sliderwin2.value(3) break end if sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK) @@ -280,41 +280,41 @@ def pbSetFlash(cel,previewsprite) end def pbCellProperties(canvas) - cel=canvas.currentCel.clone # Clone cell, in case operation is canceled + cel = canvas.currentCel.clone # Clone cell, in case operation is canceled return if !cel - sliderwin2=ControlWindow.new(0,0,320,32*16) - previewwin=ControlWindow.new(320,0,192,192) - sliderwin2.viewport=canvas.viewport - previewwin.viewport=canvas.viewport - previewsprite=Sprite.new(canvas.viewport) - previewsprite.bitmap=canvas.animbitmap - previewsprite.z=previewwin.z+1 - sliderwin2.z=previewwin.z+2 - set0=sliderwin2.addSlider(_INTL("Pattern:"),-2,1000,cel[AnimFrame::PATTERN]) - set1=sliderwin2.addSlider(_INTL("X:"),-64,512+64,cel[AnimFrame::X]) - set2=sliderwin2.addSlider(_INTL("Y:"),-64,384+64,cel[AnimFrame::Y]) - set3=sliderwin2.addSlider(_INTL("Zoom X:"),5,1000,cel[AnimFrame::ZOOMX]) - set4=sliderwin2.addSlider(_INTL("Zoom Y:"),5,1000,cel[AnimFrame::ZOOMY]) - set5=sliderwin2.addSlider(_INTL("Angle:"),0,359,cel[AnimFrame::ANGLE]) - set6=sliderwin2.addSlider(_INTL("Opacity:"),0,255,cel[AnimFrame::OPACITY]) - set7=sliderwin2.addSlider(_INTL("Blending:"),0,2,cel[AnimFrame::BLENDTYPE]) - set8=sliderwin2.addTextSlider(_INTL("Flip:"),[_INTL("False"),_INTL("True")],cel[AnimFrame::MIRROR]) - prio=[_INTL("Back"),_INTL("Front"),_INTL("Behind focus"),_INTL("Above focus")] - set9=sliderwin2.addTextSlider(_INTL("Priority:"),prio,cel[AnimFrame::PRIORITY] || 1) - foc=[_INTL("User"),_INTL("Target"),_INTL("User and target"),_INTL("Screen")] - curfoc=[3,1,0,2,3][cel[AnimFrame::FOCUS] || canvas.animation.position || 4] - set10=sliderwin2.addTextSlider(_INTL("Focus:"),foc,curfoc) - flashbutton=sliderwin2.addButton(_INTL("Set Blending Color")) - tonebutton=sliderwin2.addButton(_INTL("Set Color Tone")) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) + sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 16) + previewwin = ControlWindow.new(320, 0, 192, 192) + sliderwin2.viewport = canvas.viewport + previewwin.viewport = canvas.viewport + previewsprite = Sprite.new(canvas.viewport) + previewsprite.bitmap = canvas.animbitmap + previewsprite.z = previewwin.z + 1 + sliderwin2.z = previewwin.z + 2 + set0 = sliderwin2.addSlider(_INTL("Pattern:"), -2, 1000, cel[AnimFrame::PATTERN]) + set1 = sliderwin2.addSlider(_INTL("X:"), -64, 512 + 64, cel[AnimFrame::X]) + set2 = sliderwin2.addSlider(_INTL("Y:"), -64, 384 + 64, cel[AnimFrame::Y]) + set3 = sliderwin2.addSlider(_INTL("Zoom X:"), 5, 1000, cel[AnimFrame::ZOOMX]) + set4 = sliderwin2.addSlider(_INTL("Zoom Y:"), 5, 1000, cel[AnimFrame::ZOOMY]) + set5 = sliderwin2.addSlider(_INTL("Angle:"), 0, 359, cel[AnimFrame::ANGLE]) + set6 = sliderwin2.addSlider(_INTL("Opacity:"), 0, 255, cel[AnimFrame::OPACITY]) + set7 = sliderwin2.addSlider(_INTL("Blending:"), 0, 2, cel[AnimFrame::BLENDTYPE]) + set8 = sliderwin2.addTextSlider(_INTL("Flip:"), [_INTL("False"), _INTL("True")], cel[AnimFrame::MIRROR]) + prio = [_INTL("Back"), _INTL("Front"), _INTL("Behind focus"), _INTL("Above focus")] + set9 = sliderwin2.addTextSlider(_INTL("Priority:"), prio, cel[AnimFrame::PRIORITY] || 1) + foc = [_INTL("User"), _INTL("Target"), _INTL("User and target"), _INTL("Screen")] + curfoc = [3, 1, 0, 2, 3][cel[AnimFrame::FOCUS] || canvas.animation.position || 4] + set10 = sliderwin2.addTextSlider(_INTL("Focus:"), foc, curfoc) + flashbutton = sliderwin2.addButton(_INTL("Set Blending Color")) + tonebutton = sliderwin2.addButton(_INTL("Set Color Tone")) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) # Set X and Y for preview sprite - cel[AnimFrame::X]=320+96 - cel[AnimFrame::Y]=96 - canvas.setSpriteBitmap(previewsprite,cel) - pbSpriteSetAnimFrame(previewsprite,cel,nil,nil) - previewsprite.z=previewwin.z+1 - sliderwin2.opacity=200 + cel[AnimFrame::X] = 320 + 96 + cel[AnimFrame::Y] = 96 + canvas.setSpriteBitmap(previewsprite, cel) + pbSpriteSetAnimFrame(previewsprite, cel, nil, nil) + previewsprite.z = previewwin.z + 1 + sliderwin2.opacity = 200 loop do Graphics.update Input.update @@ -329,44 +329,44 @@ def pbCellProperties(canvas) sliderwin2.changed?(set9) || sliderwin2.changed?(set10) # Update preview sprite - cel[AnimFrame::PATTERN]=sliderwin2.value(set0) if set0>=0 - cel[AnimFrame::ZOOMX]=sliderwin2.value(set3) - cel[AnimFrame::ZOOMY]=sliderwin2.value(set4) - cel[AnimFrame::ANGLE]=sliderwin2.value(set5) - cel[AnimFrame::OPACITY]=sliderwin2.value(set6) - cel[AnimFrame::BLENDTYPE]=sliderwin2.value(set7) - cel[AnimFrame::MIRROR]=sliderwin2.value(set8) - cel[AnimFrame::PRIORITY]=sliderwin2.value(set9) - cel[AnimFrame::FOCUS]=[2,1,3,4][sliderwin2.value(set10)] - canvas.setSpriteBitmap(previewsprite,cel) - pbSpriteSetAnimFrame(previewsprite,cel,nil,nil) - previewsprite.z=previewwin.z+1 + cel[AnimFrame::PATTERN] = sliderwin2.value(set0) if set0 >= 0 + cel[AnimFrame::ZOOMX] = sliderwin2.value(set3) + cel[AnimFrame::ZOOMY] = sliderwin2.value(set4) + cel[AnimFrame::ANGLE] = sliderwin2.value(set5) + cel[AnimFrame::OPACITY] = sliderwin2.value(set6) + cel[AnimFrame::BLENDTYPE] = sliderwin2.value(set7) + cel[AnimFrame::MIRROR] = sliderwin2.value(set8) + cel[AnimFrame::PRIORITY] = sliderwin2.value(set9) + cel[AnimFrame::FOCUS] = [2, 1, 3, 4][sliderwin2.value(set10)] + canvas.setSpriteBitmap(previewsprite, cel) + pbSpriteSetAnimFrame(previewsprite, cel, nil, nil) + previewsprite.z = previewwin.z + 1 end if sliderwin2.changed?(flashbutton) - pbSetFlash(cel,previewsprite) - pbSpriteSetAnimFrame(previewsprite,cel,nil,nil) - previewsprite.z=previewwin.z+1 + pbSetFlash(cel, previewsprite) + pbSpriteSetAnimFrame(previewsprite, cel, nil, nil) + previewsprite.z = previewwin.z + 1 end if sliderwin2.changed?(tonebutton) - pbSetTone(cel,previewsprite) - pbSpriteSetAnimFrame(previewsprite,cel,nil,nil) - previewsprite.z=previewwin.z+1 + pbSetTone(cel, previewsprite) + pbSpriteSetAnimFrame(previewsprite, cel, nil, nil) + previewsprite.z = previewwin.z + 1 end if sliderwin2.changed?(okbutton) - cel[AnimFrame::PATTERN]=sliderwin2.value(set0) if set0>=0 - cel[AnimFrame::X]=sliderwin2.value(set1) - cel[AnimFrame::Y]=sliderwin2.value(set2) - cel[AnimFrame::ZOOMX]=sliderwin2.value(set3) - cel[AnimFrame::ZOOMY]=sliderwin2.value(set4) - cel[AnimFrame::ANGLE]=sliderwin2.value(set5) - cel[AnimFrame::OPACITY]=sliderwin2.value(set6) - cel[AnimFrame::BLENDTYPE]=sliderwin2.value(set7) - cel[AnimFrame::MIRROR]=sliderwin2.value(set8) - cel[AnimFrame::PRIORITY]=sliderwin2.value(set9) - cel[AnimFrame::FOCUS]=[2,1,3,4][sliderwin2.value(set10)] - thiscel=canvas.currentCel + cel[AnimFrame::PATTERN] = sliderwin2.value(set0) if set0 >= 0 + cel[AnimFrame::X] = sliderwin2.value(set1) + cel[AnimFrame::Y] = sliderwin2.value(set2) + cel[AnimFrame::ZOOMX] = sliderwin2.value(set3) + cel[AnimFrame::ZOOMY] = sliderwin2.value(set4) + cel[AnimFrame::ANGLE] = sliderwin2.value(set5) + cel[AnimFrame::OPACITY] = sliderwin2.value(set6) + cel[AnimFrame::BLENDTYPE] = sliderwin2.value(set7) + cel[AnimFrame::MIRROR] = sliderwin2.value(set8) + cel[AnimFrame::PRIORITY] = sliderwin2.value(set9) + cel[AnimFrame::FOCUS] = [2, 1, 3, 4][sliderwin2.value(set10)] + thiscel = canvas.currentCel # Save by replacing current cell - thiscel[0,thiscel.length]=cel + thiscel[0, thiscel.length] = cel break end if sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK) @@ -383,124 +383,124 @@ end # Pop-up menus for buttons in right hand menu ################################################################################ def pbTimingList(canvas) - commands=[] - cmdNewSound=-1 - cmdNewBG=-1 - cmdEditBG=-1 - cmdNewFO=-1 - cmdEditFO=-1 + commands = [] + cmdNewSound = -1 + cmdNewBG = -1 + cmdEditBG = -1 + cmdNewFO = -1 + cmdEditFO = -1 for i in canvas.animation.timing - commands.push(sprintf("%s",i)) + commands.push(sprintf("%s", i)) end - commands[cmdNewSound=commands.length]=_INTL("Add: Play Sound...") - commands[cmdNewBG=commands.length]=_INTL("Add: Set Background Graphic...") - commands[cmdEditBG=commands.length]=_INTL("Add: Edit Background Color/Location...") - commands[cmdNewFO=commands.length]=_INTL("Add: Set Foreground Graphic...") - commands[cmdEditFO=commands.length]=_INTL("Add: Edit Foreground Color/Location...") - cmdwin=pbListWindow(commands,480) - cmdwin.x=0 - cmdwin.y=0 - cmdwin.width=640 - cmdwin.height=384 - cmdwin.opacity=200 - cmdwin.viewport=canvas.viewport - framewindow=ControlWindow.new(0,384,640,32*4) - framewindow.addSlider(_INTL("Frame:"),1,canvas.animation.length,canvas.currentframe+1) + commands[cmdNewSound = commands.length] = _INTL("Add: Play Sound...") + commands[cmdNewBG = commands.length] = _INTL("Add: Set Background Graphic...") + commands[cmdEditBG = commands.length] = _INTL("Add: Edit Background Color/Location...") + commands[cmdNewFO = commands.length] = _INTL("Add: Set Foreground Graphic...") + commands[cmdEditFO = commands.length] = _INTL("Add: Edit Foreground Color/Location...") + cmdwin = pbListWindow(commands, 480) + cmdwin.x = 0 + cmdwin.y = 0 + cmdwin.width = 640 + cmdwin.height = 384 + cmdwin.opacity = 200 + cmdwin.viewport = canvas.viewport + framewindow = ControlWindow.new(0, 384, 640, 32 * 4) + framewindow.addSlider(_INTL("Frame:"), 1, canvas.animation.length, canvas.currentframe + 1) framewindow.addButton(_INTL("Set Frame")) framewindow.addButton(_INTL("Delete Timing")) - framewindow.opacity=200 - framewindow.viewport=canvas.viewport + framewindow.opacity = 200 + framewindow.viewport = canvas.viewport loop do Graphics.update Input.update cmdwin.update framewindow.update - if cmdwin.index!=cmdNewSound && - cmdwin.index!=cmdNewBG && - cmdwin.index!=cmdEditBG && - cmdwin.index!=cmdNewFO && - cmdwin.index!=cmdEditFO + if cmdwin.index != cmdNewSound && + cmdwin.index != cmdNewBG && + cmdwin.index != cmdEditBG && + cmdwin.index != cmdNewFO && + cmdwin.index != cmdEditFO if framewindow.changed?(1) # Set Frame - canvas.animation.timing[cmdwin.index].frame=framewindow.value(0)-1 - cmdwin.commands[cmdwin.index]=sprintf("%s",canvas.animation.timing[cmdwin.index]) + canvas.animation.timing[cmdwin.index].frame = framewindow.value(0) - 1 + cmdwin.commands[cmdwin.index] = sprintf("%s", canvas.animation.timing[cmdwin.index]) cmdwin.refresh next end if framewindow.changed?(2) # Delete Timing canvas.animation.timing.delete_at(cmdwin.index) cmdwin.commands.delete_at(cmdwin.index) - cmdNewSound-=1 if cmdNewSound>=0 - cmdNewBG-=1 if cmdNewBG>=0 - cmdEditBG-=1 if cmdEditBG>=0 - cmdNewFO-=1 if cmdNewFO>=0 - cmdEditFO-=1 if cmdEditFO>=0 + cmdNewSound -= 1 if cmdNewSound >= 0 + cmdNewBG -= 1 if cmdNewBG >= 0 + cmdEditBG -= 1 if cmdEditBG >= 0 + cmdNewFO -= 1 if cmdNewFO >= 0 + cmdEditFO -= 1 if cmdEditFO >= 0 cmdwin.refresh next end end if Input.trigger?(Input::USE) - redrawcmds=false - if cmdwin.index==cmdNewSound # Add new sound - newaudio=PBAnimTiming.new(0) - if pbSelectSE(canvas,newaudio) - newaudio.frame=framewindow.value(0)-1 + redrawcmds = false + if cmdwin.index == cmdNewSound # Add new sound + newaudio = PBAnimTiming.new(0) + if pbSelectSE(canvas, newaudio) + newaudio.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newaudio) - redrawcmds=true + redrawcmds = true end - elsif cmdwin.index==cmdNewBG # Add new background graphic set - newtiming=PBAnimTiming.new(1) - if pbSelectBG(canvas,newtiming) - newtiming.frame=framewindow.value(0)-1 + elsif cmdwin.index == cmdNewBG # Add new background graphic set + newtiming = PBAnimTiming.new(1) + if pbSelectBG(canvas, newtiming) + newtiming.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newtiming) - redrawcmds=true + redrawcmds = true end - elsif cmdwin.index==cmdEditBG # Add new background edit - newtiming=PBAnimTiming.new(2) - if pbEditBG(canvas,newtiming) - newtiming.frame=framewindow.value(0)-1 + elsif cmdwin.index == cmdEditBG # Add new background edit + newtiming = PBAnimTiming.new(2) + if pbEditBG(canvas, newtiming) + newtiming.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newtiming) - redrawcmds=true + redrawcmds = true end - elsif cmdwin.index==cmdNewFO # Add new foreground graphic set - newtiming=PBAnimTiming.new(3) - if pbSelectBG(canvas,newtiming) - newtiming.frame=framewindow.value(0)-1 + elsif cmdwin.index == cmdNewFO # Add new foreground graphic set + newtiming = PBAnimTiming.new(3) + if pbSelectBG(canvas, newtiming) + newtiming.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newtiming) - redrawcmds=true + redrawcmds = true end - elsif cmdwin.index==cmdEditFO # Add new foreground edit - newtiming=PBAnimTiming.new(4) - if pbEditBG(canvas,newtiming) - newtiming.frame=framewindow.value(0)-1 + elsif cmdwin.index == cmdEditFO # Add new foreground edit + newtiming = PBAnimTiming.new(4) + if pbEditBG(canvas, newtiming) + newtiming.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newtiming) - redrawcmds=true + redrawcmds = true end else # Edit a timing here case canvas.animation.timing[cmdwin.index].timingType when 0 - pbSelectSE(canvas,canvas.animation.timing[cmdwin.index]) + pbSelectSE(canvas, canvas.animation.timing[cmdwin.index]) when 1, 3 - pbSelectBG(canvas,canvas.animation.timing[cmdwin.index]) + pbSelectBG(canvas, canvas.animation.timing[cmdwin.index]) when 2, 4 - pbEditBG(canvas,canvas.animation.timing[cmdwin.index]) + pbEditBG(canvas, canvas.animation.timing[cmdwin.index]) end - cmdwin.commands[cmdwin.index]=sprintf("%s",canvas.animation.timing[cmdwin.index]) + cmdwin.commands[cmdwin.index] = sprintf("%s", canvas.animation.timing[cmdwin.index]) cmdwin.refresh end if redrawcmds - cmdwin.commands[cmdNewSound]=nil if cmdNewSound>=0 - cmdwin.commands[cmdNewBG]=nil if cmdNewBG>=0 - cmdwin.commands[cmdEditBG]=nil if cmdEditBG>=0 - cmdwin.commands[cmdNewFO]=nil if cmdNewFO>=0 - cmdwin.commands[cmdEditFO]=nil if cmdEditFO>=0 + cmdwin.commands[cmdNewSound] = nil if cmdNewSound >= 0 + cmdwin.commands[cmdNewBG] = nil if cmdNewBG >= 0 + cmdwin.commands[cmdEditBG] = nil if cmdEditBG >= 0 + cmdwin.commands[cmdNewFO] = nil if cmdNewFO >= 0 + cmdwin.commands[cmdEditFO] = nil if cmdEditFO >= 0 cmdwin.commands.compact! - cmdwin.commands.push(sprintf("%s",canvas.animation.timing[canvas.animation.timing.length-1])) - cmdwin.commands[cmdNewSound=cmdwin.commands.length]=_INTL("Add: Play Sound...") - cmdwin.commands[cmdNewBG=cmdwin.commands.length]=_INTL("Add: Set Background Graphic...") - cmdwin.commands[cmdEditBG=cmdwin.commands.length]=_INTL("Add: Edit Background Color/Location...") - cmdwin.commands[cmdNewFO=cmdwin.commands.length]=_INTL("Add: Set Foreground Graphic...") - cmdwin.commands[cmdEditFO=cmdwin.commands.length]=_INTL("Add: Edit Foreground Color/Location...") + cmdwin.commands.push(sprintf("%s", canvas.animation.timing[canvas.animation.timing.length - 1])) + cmdwin.commands[cmdNewSound = cmdwin.commands.length] = _INTL("Add: Play Sound...") + cmdwin.commands[cmdNewBG = cmdwin.commands.length] = _INTL("Add: Set Background Graphic...") + cmdwin.commands[cmdEditBG = cmdwin.commands.length] = _INTL("Add: Edit Background Color/Location...") + cmdwin.commands[cmdNewFO = cmdwin.commands.length] = _INTL("Add: Set Foreground Graphic...") + cmdwin.commands[cmdEditFO = cmdwin.commands.length] = _INTL("Add: Edit Foreground Color/Location...") cmdwin.refresh end elsif Input.trigger?(Input::BACK) @@ -512,63 +512,63 @@ def pbTimingList(canvas) return end -def pbSelectSE(canvas,audio) - filename=(audio.name!="") ? audio.name : "" - displayname=(filename!="") ? filename : _INTL("") - animfiles=[] - ret=false +def pbSelectSE(canvas, audio) + filename = (audio.name != "") ? audio.name : "" + displayname = (filename != "") ? filename : _INTL("") + animfiles = [] + ret = false pbRgssChdir(File.join("Audio", "SE", "Anim")) { animfiles.concat(Dir.glob("*.wav")) # animfiles.concat(Dir.glob("*.mp3")) animfiles.concat(Dir.glob("*.ogg")) animfiles.concat(Dir.glob("*.wma")) } - animfiles.sort! { |a,b| a.upcase<=>b.upcase } - animfiles=[_INTL("[Play user's cry]")]+animfiles - cmdwin=pbListWindow(animfiles,320) - cmdwin.height=480 - cmdwin.opacity=200 - cmdwin.viewport=canvas.viewport - maxsizewindow=ControlWindow.new(320,0,320,32*8) - maxsizewindow.addLabel(_INTL("File: \"{1}\"",displayname)) - maxsizewindow.addSlider(_INTL("Volume:"),0,100,audio.volume) - maxsizewindow.addSlider(_INTL("Pitch:"),20,250,audio.pitch) + animfiles.sort! { |a, b| a.upcase <=> b.upcase } + animfiles = [_INTL("[Play user's cry]")] + animfiles + cmdwin = pbListWindow(animfiles, 320) + cmdwin.height = 480 + cmdwin.opacity = 200 + cmdwin.viewport = canvas.viewport + maxsizewindow = ControlWindow.new(320, 0, 320, 32 * 8) + maxsizewindow.addLabel(_INTL("File: \"{1}\"", displayname)) + maxsizewindow.addSlider(_INTL("Volume:"), 0, 100, audio.volume) + maxsizewindow.addSlider(_INTL("Pitch:"), 20, 250, audio.pitch) maxsizewindow.addButton(_INTL("Play Sound")) maxsizewindow.addButton(_INTL("Stop Sound")) maxsizewindow.addButton(_INTL("OK")) maxsizewindow.addButton(_INTL("Cancel")) - maxsizewindow.opacity=200 - maxsizewindow.viewport=canvas.viewport + maxsizewindow.opacity = 200 + maxsizewindow.viewport = canvas.viewport loop do Graphics.update Input.update cmdwin.update maxsizewindow.update - if maxsizewindow.changed?(3) && animfiles.length>0 # Play Sound - fname = (cmdwin.index==0) ? "Cries/001Cry" : "Anim/"+filename - pbSEPlay(RPG::AudioFile.new(fname,maxsizewindow.value(1),maxsizewindow.value(2))) + if maxsizewindow.changed?(3) && animfiles.length > 0 # Play Sound + fname = (cmdwin.index == 0) ? "Cries/001Cry" : "Anim/" + filename + pbSEPlay(RPG::AudioFile.new(fname, maxsizewindow.value(1), maxsizewindow.value(2))) end - if maxsizewindow.changed?(4) && animfiles.length>0 # Stop Sound + if maxsizewindow.changed?(4) && animfiles.length > 0 # Stop Sound pbSEStop end if maxsizewindow.changed?(5) # OK - filename = File.basename(filename,".wav") + filename = File.basename(filename, ".wav") # filename = File.basename(filename,".mp3") - filename = File.basename(filename,".ogg") - filename = File.basename(filename,".wma") - audio.name=filename - audio.volume=maxsizewindow.value(1) - audio.pitch=maxsizewindow.value(2) - ret=true + filename = File.basename(filename, ".ogg") + filename = File.basename(filename, ".wma") + audio.name = filename + audio.volume = maxsizewindow.value(1) + audio.pitch = maxsizewindow.value(2) + ret = true break end if maxsizewindow.changed?(6) # Cancel break end - if Input.trigger?(Input::USE) && animfiles.length>0 - filename=(cmdwin.index==0) ? "" : cmdwin.commands[cmdwin.index] - displayname=(filename!="") ? filename : _INTL("") - maxsizewindow.controls[0].text=_INTL("File: \"{1}\"",displayname) + if Input.trigger?(Input::USE) && animfiles.length > 0 + filename = (cmdwin.index == 0) ? "" : cmdwin.commands[cmdwin.index] + displayname = (filename != "") ? filename : _INTL("") + maxsizewindow.controls[0].text = _INTL("File: \"{1}\"", displayname) elsif Input.trigger?(Input::BACK) break end @@ -578,12 +578,12 @@ def pbSelectSE(canvas,audio) return ret end -def pbSelectBG(canvas,timing) - filename=timing.name - cmdErase=-1 - animfiles=[] - animfiles[cmdErase=animfiles.length]=_INTL("[Erase background graphic]") - ret=false +def pbSelectBG(canvas, timing) + filename = timing.name + cmdErase = -1 + animfiles = [] + animfiles[cmdErase = animfiles.length] = _INTL("[Erase background graphic]") + ret = false pbRgssChdir(File.join("Graphics", "Animations")) { animfiles.concat(Dir.glob("*.png")) animfiles.concat(Dir.glob("*.gif")) @@ -591,46 +591,46 @@ def pbSelectBG(canvas,timing) # animfiles.concat(Dir.glob("*.jpeg")) # animfiles.concat(Dir.glob("*.bmp")) } - cmdwin=pbListWindow(animfiles,320) - cmdwin.height=480 - cmdwin.opacity=200 - cmdwin.viewport=canvas.viewport - maxsizewindow=ControlWindow.new(320,0,320,32*11) - maxsizewindow.addLabel(_INTL("File: \"{1}\"",filename)) - maxsizewindow.addSlider(_INTL("X:"),-500,500,timing.bgX || 0) - maxsizewindow.addSlider(_INTL("Y:"),-500,500,timing.bgY || 0) - maxsizewindow.addSlider(_INTL("Opacity:"),0,255,timing.opacity || 0) - maxsizewindow.addSlider(_INTL("Red:"),0,255,timing.colorRed || 0) - maxsizewindow.addSlider(_INTL("Green:"),0,255,timing.colorGreen || 0) - maxsizewindow.addSlider(_INTL("Blue:"),0,255,timing.colorBlue || 0) - maxsizewindow.addSlider(_INTL("Alpha:"),0,255,timing.colorAlpha || 0) + cmdwin = pbListWindow(animfiles, 320) + cmdwin.height = 480 + cmdwin.opacity = 200 + cmdwin.viewport = canvas.viewport + maxsizewindow = ControlWindow.new(320, 0, 320, 32 * 11) + maxsizewindow.addLabel(_INTL("File: \"{1}\"", filename)) + maxsizewindow.addSlider(_INTL("X:"), -500, 500, timing.bgX || 0) + maxsizewindow.addSlider(_INTL("Y:"), -500, 500, timing.bgY || 0) + maxsizewindow.addSlider(_INTL("Opacity:"), 0, 255, timing.opacity || 0) + maxsizewindow.addSlider(_INTL("Red:"), 0, 255, timing.colorRed || 0) + maxsizewindow.addSlider(_INTL("Green:"), 0, 255, timing.colorGreen || 0) + maxsizewindow.addSlider(_INTL("Blue:"), 0, 255, timing.colorBlue || 0) + maxsizewindow.addSlider(_INTL("Alpha:"), 0, 255, timing.colorAlpha || 0) maxsizewindow.addButton(_INTL("OK")) maxsizewindow.addButton(_INTL("Cancel")) - maxsizewindow.opacity=200 - maxsizewindow.viewport=canvas.viewport + maxsizewindow.opacity = 200 + maxsizewindow.viewport = canvas.viewport loop do Graphics.update Input.update cmdwin.update maxsizewindow.update if maxsizewindow.changed?(8) # OK - timing.name=filename - timing.bgX=maxsizewindow.value(1) - timing.bgY=maxsizewindow.value(2) - timing.opacity=maxsizewindow.value(3) - timing.colorRed=maxsizewindow.value(4) - timing.colorGreen=maxsizewindow.value(5) - timing.colorBlue=maxsizewindow.value(6) - timing.colorAlpha=maxsizewindow.value(7) - ret=true + timing.name = filename + timing.bgX = maxsizewindow.value(1) + timing.bgY = maxsizewindow.value(2) + timing.opacity = maxsizewindow.value(3) + timing.colorRed = maxsizewindow.value(4) + timing.colorGreen = maxsizewindow.value(5) + timing.colorBlue = maxsizewindow.value(6) + timing.colorAlpha = maxsizewindow.value(7) + ret = true break end if maxsizewindow.changed?(9) # Cancel break end - if Input.trigger?(Input::USE) && animfiles.length>0 - filename=(cmdwin.index==cmdErase) ? "" : cmdwin.commands[cmdwin.index] - maxsizewindow.controls[0].text=_INTL("File: \"{1}\"",filename) + if Input.trigger?(Input::USE) && animfiles.length > 0 + filename = (cmdwin.index == cmdErase) ? "" : cmdwin.commands[cmdwin.index] + maxsizewindow.controls[0].text = _INTL("File: \"{1}\"", filename) elsif Input.trigger?(Input::BACK) break end @@ -640,28 +640,28 @@ def pbSelectBG(canvas,timing) return ret end -def pbEditBG(canvas,timing) - ret=false - maxsizewindow=ControlWindow.new(0,0,320,32*11) - maxsizewindow.addSlider(_INTL("Duration:"),0,50,timing.duration) - maxsizewindow.addOptionalSlider(_INTL("X:"),-500,500,timing.bgX || 0) - maxsizewindow.addOptionalSlider(_INTL("Y:"),-500,500,timing.bgY || 0) - maxsizewindow.addOptionalSlider(_INTL("Opacity:"),0,255,timing.opacity || 0) - maxsizewindow.addOptionalSlider(_INTL("Red:"),0,255,timing.colorRed || 0) - maxsizewindow.addOptionalSlider(_INTL("Green:"),0,255,timing.colorGreen || 0) - maxsizewindow.addOptionalSlider(_INTL("Blue:"),0,255,timing.colorBlue || 0) - maxsizewindow.addOptionalSlider(_INTL("Alpha:"),0,255,timing.colorAlpha || 0) +def pbEditBG(canvas, timing) + ret = false + maxsizewindow = ControlWindow.new(0, 0, 320, 32 * 11) + maxsizewindow.addSlider(_INTL("Duration:"), 0, 50, timing.duration) + maxsizewindow.addOptionalSlider(_INTL("X:"), -500, 500, timing.bgX || 0) + maxsizewindow.addOptionalSlider(_INTL("Y:"), -500, 500, timing.bgY || 0) + maxsizewindow.addOptionalSlider(_INTL("Opacity:"), 0, 255, timing.opacity || 0) + maxsizewindow.addOptionalSlider(_INTL("Red:"), 0, 255, timing.colorRed || 0) + maxsizewindow.addOptionalSlider(_INTL("Green:"), 0, 255, timing.colorGreen || 0) + maxsizewindow.addOptionalSlider(_INTL("Blue:"), 0, 255, timing.colorBlue || 0) + maxsizewindow.addOptionalSlider(_INTL("Alpha:"), 0, 255, timing.colorAlpha || 0) maxsizewindow.addButton(_INTL("OK")) maxsizewindow.addButton(_INTL("Cancel")) - maxsizewindow.controls[1].checked=(timing.bgX!=nil) - maxsizewindow.controls[2].checked=(timing.bgY!=nil) - maxsizewindow.controls[3].checked=(timing.opacity!=nil) - maxsizewindow.controls[4].checked=(timing.colorRed!=nil) - maxsizewindow.controls[5].checked=(timing.colorGreen!=nil) - maxsizewindow.controls[6].checked=(timing.colorBlue!=nil) - maxsizewindow.controls[7].checked=(timing.colorAlpha!=nil) - maxsizewindow.opacity=200 - maxsizewindow.viewport=canvas.viewport + maxsizewindow.controls[1].checked = (timing.bgX != nil) + maxsizewindow.controls[2].checked = (timing.bgY != nil) + maxsizewindow.controls[3].checked = (timing.opacity != nil) + maxsizewindow.controls[4].checked = (timing.colorRed != nil) + maxsizewindow.controls[5].checked = (timing.colorGreen != nil) + maxsizewindow.controls[6].checked = (timing.colorBlue != nil) + maxsizewindow.controls[7].checked = (timing.colorAlpha != nil) + maxsizewindow.opacity = 200 + maxsizewindow.viewport = canvas.viewport loop do Graphics.update Input.update @@ -674,15 +674,15 @@ def pbEditBG(canvas,timing) maxsizewindow.controls[5].checked || maxsizewindow.controls[6].checked || maxsizewindow.controls[7].checked - timing.duration=maxsizewindow.value(0) - timing.bgX=maxsizewindow.value(1) - timing.bgY=maxsizewindow.value(2) - timing.opacity=maxsizewindow.value(3) - timing.colorRed=maxsizewindow.value(4) - timing.colorGreen=maxsizewindow.value(5) - timing.colorBlue=maxsizewindow.value(6) - timing.colorAlpha=maxsizewindow.value(7) - ret=true + timing.duration = maxsizewindow.value(0) + timing.bgX = maxsizewindow.value(1) + timing.bgY = maxsizewindow.value(2) + timing.opacity = maxsizewindow.value(3) + timing.colorRed = maxsizewindow.value(4) + timing.colorGreen = maxsizewindow.value(5) + timing.colorBlue = maxsizewindow.value(6) + timing.colorAlpha = maxsizewindow.value(7) + ret = true break else break @@ -700,39 +700,39 @@ def pbEditBG(canvas,timing) end def pbCopyFrames(canvas) - sliderwin2=ControlWindow.new(0,0,320,32*6) - sliderwin2.viewport=canvas.viewport - sliderwin2.addSlider(_INTL("First Frame:"),1,canvas.animation.length,1) - sliderwin2.addSlider(_INTL("Last Frame:"),1,canvas.animation.length,canvas.animation.length) - sliderwin2.addSlider(_INTL("Copy to:"),1,canvas.animation.length,canvas.currentframe+1) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) - sliderwin2.opacity=200 + sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 6) + sliderwin2.viewport = canvas.viewport + sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1) + sliderwin2.addSlider(_INTL("Last Frame:"), 1, canvas.animation.length, canvas.animation.length) + sliderwin2.addSlider(_INTL("Copy to:"), 1, canvas.animation.length, canvas.currentframe + 1) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) + sliderwin2.opacity = 200 loop do Graphics.update Input.update sliderwin2.update if sliderwin2.changed?(okbutton) - startvalue=sliderwin2.value(0)-1 - endvalue=sliderwin2.value(1)-1 - dstvalue=sliderwin2.value(2)-1 - length=(endvalue-startvalue)+1 - if length>0 # Ensure correct overlap handling - if (startvalue 0 # Ensure correct overlap handling + if (startvalue < dstvalue) + startvalue += length + dstvalue += length + while length != 0 + canvas.copyFrame(startvalue - 1, dstvalue - 1) + startvalue -= 1 + dstvalue -= 1 + length -= 1 end - elsif startvalue!=dstvalue - while length!=0 - canvas.copyFrame(startvalue,dstvalue) - startvalue+=1 - dstvalue+=1 - length-=1 + elsif startvalue != dstvalue + while length != 0 + canvas.copyFrame(startvalue, dstvalue) + startvalue += 1 + dstvalue += 1 + length -= 1 end end end @@ -747,20 +747,20 @@ def pbCopyFrames(canvas) end def pbClearFrames(canvas) - sliderwin2=ControlWindow.new(0,0,320,32*5) - sliderwin2.viewport=canvas.viewport - sliderwin2.addSlider(_INTL("First Frame:"),1,canvas.animation.length,1) - sliderwin2.addSlider(_INTL("Last Frame:"),1,canvas.animation.length,canvas.animation.length) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) - sliderwin2.opacity=200 + sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 5) + sliderwin2.viewport = canvas.viewport + sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1) + sliderwin2.addSlider(_INTL("Last Frame:"), 1, canvas.animation.length, canvas.animation.length) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) + sliderwin2.opacity = 200 loop do Graphics.update Input.update sliderwin2.update if sliderwin2.changed?(okbutton) - startframe=sliderwin2.value(0)-1 - endframe=sliderwin2.value(1)-1 + startframe = sliderwin2.value(0) - 1 + endframe = sliderwin2.value(1) - 1 for i in startframe..endframe canvas.clearFrame(i) end @@ -775,69 +775,69 @@ def pbClearFrames(canvas) end def pbTweening(canvas) - sliderwin2=ControlWindow.new(0,0,320,32*10) - sliderwin2.viewport=canvas.viewport - sliderwin2.opacity=200 - s1set0=sliderwin2.addSlider(_INTL("Starting Frame:"),1,canvas.animation.length,1) - s1set1=sliderwin2.addSlider(_INTL("Ending Frame:"),1,canvas.animation.length,canvas.animation.length) - s1set2=sliderwin2.addSlider(_INTL("First Cel:"),0,PBAnimation::MAX_SPRITES-1,0) - s1set3=sliderwin2.addSlider(_INTL("Last Cel:"),0,PBAnimation::MAX_SPRITES-1,PBAnimation::MAX_SPRITES-1) - set0=sliderwin2.addCheckbox(_INTL("Pattern")) - set1=sliderwin2.addCheckbox(_INTL("Position/Zoom/Angle")) - set2=sliderwin2.addCheckbox(_INTL("Opacity/Blending")) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) + sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 10) + sliderwin2.viewport = canvas.viewport + sliderwin2.opacity = 200 + s1set0 = sliderwin2.addSlider(_INTL("Starting Frame:"), 1, canvas.animation.length, 1) + s1set1 = sliderwin2.addSlider(_INTL("Ending Frame:"), 1, canvas.animation.length, canvas.animation.length) + s1set2 = sliderwin2.addSlider(_INTL("First Cel:"), 0, PBAnimation::MAX_SPRITES - 1, 0) + s1set3 = sliderwin2.addSlider(_INTL("Last Cel:"), 0, PBAnimation::MAX_SPRITES - 1, PBAnimation::MAX_SPRITES - 1) + set0 = sliderwin2.addCheckbox(_INTL("Pattern")) + set1 = sliderwin2.addCheckbox(_INTL("Position/Zoom/Angle")) + set2 = sliderwin2.addCheckbox(_INTL("Opacity/Blending")) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) loop do Graphics.update Input.update sliderwin2.update if sliderwin2.changed?(okbutton) || Input.trigger?(Input::USE) - startframe=sliderwin2.value(s1set0)-1 - endframe=sliderwin2.value(s1set1)-1 - break if startframe>=endframe - frames=endframe-startframe - startcel=sliderwin2.value(s1set2) - endcel=sliderwin2.value(s1set3) + startframe = sliderwin2.value(s1set0) - 1 + endframe = sliderwin2.value(s1set1) - 1 + break if startframe >= endframe + frames = endframe - startframe + startcel = sliderwin2.value(s1set2) + endcel = sliderwin2.value(s1set3) for j in startcel..endcel - cel1=canvas.animation[startframe][j] - cel2=canvas.animation[endframe][j] - next if !cel1||!cel2 - diffPattern=cel2[AnimFrame::PATTERN]-cel1[AnimFrame::PATTERN] - diffX=cel2[AnimFrame::X]-cel1[AnimFrame::X] - diffY=cel2[AnimFrame::Y]-cel1[AnimFrame::Y] - diffZoomX=cel2[AnimFrame::ZOOMX]-cel1[AnimFrame::ZOOMX] - diffZoomY=cel2[AnimFrame::ZOOMY]-cel1[AnimFrame::ZOOMY] - diffAngle=cel2[AnimFrame::ANGLE]-cel1[AnimFrame::ANGLE] - diffOpacity=cel2[AnimFrame::OPACITY]-cel1[AnimFrame::OPACITY] - diffBlend=cel2[AnimFrame::BLENDTYPE]-cel1[AnimFrame::BLENDTYPE] - startPattern=cel1[AnimFrame::PATTERN] - startX=cel1[AnimFrame::X] - startY=cel1[AnimFrame::Y] - startZoomX=cel1[AnimFrame::ZOOMX] - startZoomY=cel1[AnimFrame::ZOOMY] - startAngle=cel1[AnimFrame::ANGLE] - startOpacity=cel1[AnimFrame::OPACITY] - startBlend=cel1[AnimFrame::BLENDTYPE] + cel1 = canvas.animation[startframe][j] + cel2 = canvas.animation[endframe][j] + next if !cel1 || !cel2 + diffPattern = cel2[AnimFrame::PATTERN] - cel1[AnimFrame::PATTERN] + diffX = cel2[AnimFrame::X] - cel1[AnimFrame::X] + diffY = cel2[AnimFrame::Y] - cel1[AnimFrame::Y] + diffZoomX = cel2[AnimFrame::ZOOMX] - cel1[AnimFrame::ZOOMX] + diffZoomY = cel2[AnimFrame::ZOOMY] - cel1[AnimFrame::ZOOMY] + diffAngle = cel2[AnimFrame::ANGLE] - cel1[AnimFrame::ANGLE] + diffOpacity = cel2[AnimFrame::OPACITY] - cel1[AnimFrame::OPACITY] + diffBlend = cel2[AnimFrame::BLENDTYPE] - cel1[AnimFrame::BLENDTYPE] + startPattern = cel1[AnimFrame::PATTERN] + startX = cel1[AnimFrame::X] + startY = cel1[AnimFrame::Y] + startZoomX = cel1[AnimFrame::ZOOMX] + startZoomY = cel1[AnimFrame::ZOOMY] + startAngle = cel1[AnimFrame::ANGLE] + startOpacity = cel1[AnimFrame::OPACITY] + startBlend = cel1[AnimFrame::BLENDTYPE] for k in 0..frames - cel=canvas.animation[startframe+k][j] - curcel=cel + cel = canvas.animation[startframe + k][j] + curcel = cel if !cel - cel=pbCreateCel(0,0,0) - canvas.animation[startframe+k][j]=cel + cel = pbCreateCel(0, 0, 0) + canvas.animation[startframe + k][j] = cel end if sliderwin2.value(set0) || !curcel - cel[AnimFrame::PATTERN]=startPattern+(diffPattern*k/frames) + cel[AnimFrame::PATTERN] = startPattern + (diffPattern * k / frames) end if sliderwin2.value(set1) || !curcel - cel[AnimFrame::X]=startX+(diffX*k/frames) - cel[AnimFrame::Y]=startY+(diffY*k/frames) - cel[AnimFrame::ZOOMX]=startZoomX+(diffZoomX*k/frames) - cel[AnimFrame::ZOOMY]=startZoomY+(diffZoomY*k/frames) - cel[AnimFrame::ANGLE]=startAngle+(diffAngle*k/frames) + cel[AnimFrame::X] = startX + (diffX * k / frames) + cel[AnimFrame::Y] = startY + (diffY * k / frames) + cel[AnimFrame::ZOOMX] = startZoomX + (diffZoomX * k / frames) + cel[AnimFrame::ZOOMY] = startZoomY + (diffZoomY * k / frames) + cel[AnimFrame::ANGLE] = startAngle + (diffAngle * k / frames) end if sliderwin2.value(set2) || !curcel - cel[AnimFrame::OPACITY]=startOpacity+(diffOpacity*k/frames) - cel[AnimFrame::BLENDTYPE]=startBlend+(diffBlend*k/frames) + cel[AnimFrame::OPACITY] = startOpacity + (diffOpacity * k / frames) + cel[AnimFrame::BLENDTYPE] = startBlend + (diffBlend * k / frames) end end end @@ -852,57 +852,57 @@ def pbTweening(canvas) end def pbCellBatch(canvas) - sliderwin1=ControlWindow.new(0,0,300,32*5) - sliderwin1.viewport=canvas.viewport - sliderwin1.opacity=200 - s1set0=sliderwin1.addSlider(_INTL("First Frame:"),1,canvas.animation.length,1) - s1set1=sliderwin1.addSlider(_INTL("Last Frame:"),1,canvas.animation.length,canvas.animation.length) - s1set2=sliderwin1.addSlider(_INTL("First Cel:"),0,PBAnimation::MAX_SPRITES-1,0) - s1set3=sliderwin1.addSlider(_INTL("Last Cel:"),0,PBAnimation::MAX_SPRITES-1,PBAnimation::MAX_SPRITES-1) - sliderwin2=ControlWindow.new(300,0,340,32*14) - sliderwin2.viewport=canvas.viewport - sliderwin2.opacity=200 - set0=sliderwin2.addOptionalSlider(_INTL("Pattern:"),-2,1000,0) - set1=sliderwin2.addOptionalSlider(_INTL("X:"),-64,512+64,0) - set2=sliderwin2.addOptionalSlider(_INTL("Y:"),-64,384+64,0) - set3=sliderwin2.addOptionalSlider(_INTL("Zoom X:"),5,1000,100) - set4=sliderwin2.addOptionalSlider(_INTL("Zoom Y:"),5,1000,100) - set5=sliderwin2.addOptionalSlider(_INTL("Angle:"),0,359,0) - set6=sliderwin2.addOptionalSlider(_INTL("Opacity:"),0,255,255) - set7=sliderwin2.addOptionalSlider(_INTL("Blending:"),0,2,0) - set8=sliderwin2.addOptionalTextSlider(_INTL("Flip:"),[_INTL("False"),_INTL("True")],0) - prio=[_INTL("Back"),_INTL("Front"),_INTL("Behind focus"),_INTL("Above focus")] - set9=sliderwin2.addOptionalTextSlider(_INTL("Priority:"),prio,1) - foc=[_INTL("User"),_INTL("Target"),_INTL("User and target"),_INTL("Screen")] - curfoc=[3,1,0,2,3][canvas.animation.position || 4] - set10=sliderwin2.addOptionalTextSlider(_INTL("Focus:"),foc,curfoc) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) + sliderwin1 = ControlWindow.new(0, 0, 300, 32 * 5) + sliderwin1.viewport = canvas.viewport + sliderwin1.opacity = 200 + s1set0 = sliderwin1.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1) + s1set1 = sliderwin1.addSlider(_INTL("Last Frame:"), 1, canvas.animation.length, canvas.animation.length) + s1set2 = sliderwin1.addSlider(_INTL("First Cel:"), 0, PBAnimation::MAX_SPRITES - 1, 0) + s1set3 = sliderwin1.addSlider(_INTL("Last Cel:"), 0, PBAnimation::MAX_SPRITES - 1, PBAnimation::MAX_SPRITES - 1) + sliderwin2 = ControlWindow.new(300, 0, 340, 32 * 14) + sliderwin2.viewport = canvas.viewport + sliderwin2.opacity = 200 + set0 = sliderwin2.addOptionalSlider(_INTL("Pattern:"), -2, 1000, 0) + set1 = sliderwin2.addOptionalSlider(_INTL("X:"), -64, 512 + 64, 0) + set2 = sliderwin2.addOptionalSlider(_INTL("Y:"), -64, 384 + 64, 0) + set3 = sliderwin2.addOptionalSlider(_INTL("Zoom X:"), 5, 1000, 100) + set4 = sliderwin2.addOptionalSlider(_INTL("Zoom Y:"), 5, 1000, 100) + set5 = sliderwin2.addOptionalSlider(_INTL("Angle:"), 0, 359, 0) + set6 = sliderwin2.addOptionalSlider(_INTL("Opacity:"), 0, 255, 255) + set7 = sliderwin2.addOptionalSlider(_INTL("Blending:"), 0, 2, 0) + set8 = sliderwin2.addOptionalTextSlider(_INTL("Flip:"), [_INTL("False"), _INTL("True")], 0) + prio = [_INTL("Back"), _INTL("Front"), _INTL("Behind focus"), _INTL("Above focus")] + set9 = sliderwin2.addOptionalTextSlider(_INTL("Priority:"), prio, 1) + foc = [_INTL("User"), _INTL("Target"), _INTL("User and target"), _INTL("Screen")] + curfoc = [3, 1, 0, 2, 3][canvas.animation.position || 4] + set10 = sliderwin2.addOptionalTextSlider(_INTL("Focus:"), foc, curfoc) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) loop do Graphics.update Input.update sliderwin1.update sliderwin2.update if sliderwin2.changed?(okbutton) || Input.trigger?(Input::USE) - startframe=sliderwin1.value(s1set0)-1 - endframe=sliderwin1.value(s1set1)-1 - startcel=sliderwin1.value(s1set2) - endcel=sliderwin1.value(s1set3) + startframe = sliderwin1.value(s1set0) - 1 + endframe = sliderwin1.value(s1set1) - 1 + startcel = sliderwin1.value(s1set2) + endcel = sliderwin1.value(s1set3) for i in startframe..endframe for j in startcel..endcel next if !canvas.animation[i][j] - cel=canvas.animation[i][j] - cel[AnimFrame::PATTERN]=sliderwin2.value(set0) if sliderwin2.value(set0) - cel[AnimFrame::X]=sliderwin2.value(set1) if sliderwin2.value(set1) - cel[AnimFrame::Y]=sliderwin2.value(set2) if sliderwin2.value(set2) - cel[AnimFrame::ZOOMX]=sliderwin2.value(set3) if sliderwin2.value(set3) - cel[AnimFrame::ZOOMY]=sliderwin2.value(set4) if sliderwin2.value(set4) - cel[AnimFrame::ANGLE]=sliderwin2.value(set5) if sliderwin2.value(set5) - cel[AnimFrame::OPACITY]=sliderwin2.value(set6) if sliderwin2.value(set6) - cel[AnimFrame::BLENDTYPE]=sliderwin2.value(set7) if sliderwin2.value(set7) - cel[AnimFrame::MIRROR]=sliderwin2.value(set8) if sliderwin2.value(set8) - cel[AnimFrame::PRIORITY]=sliderwin2.value(set9) if sliderwin2.value(set9) - cel[AnimFrame::FOCUS]=[2,1,3,4][sliderwin2.value(set10)] if sliderwin2.value(set10) + cel = canvas.animation[i][j] + cel[AnimFrame::PATTERN] = sliderwin2.value(set0) if sliderwin2.value(set0) + cel[AnimFrame::X] = sliderwin2.value(set1) if sliderwin2.value(set1) + cel[AnimFrame::Y] = sliderwin2.value(set2) if sliderwin2.value(set2) + cel[AnimFrame::ZOOMX] = sliderwin2.value(set3) if sliderwin2.value(set3) + cel[AnimFrame::ZOOMY] = sliderwin2.value(set4) if sliderwin2.value(set4) + cel[AnimFrame::ANGLE] = sliderwin2.value(set5) if sliderwin2.value(set5) + cel[AnimFrame::OPACITY] = sliderwin2.value(set6) if sliderwin2.value(set6) + cel[AnimFrame::BLENDTYPE] = sliderwin2.value(set7) if sliderwin2.value(set7) + cel[AnimFrame::MIRROR] = sliderwin2.value(set8) if sliderwin2.value(set8) + cel[AnimFrame::PRIORITY] = sliderwin2.value(set9) if sliderwin2.value(set9) + cel[AnimFrame::FOCUS] = [2, 1, 3, 4][sliderwin2.value(set10)] if sliderwin2.value(set10) end end canvas.invalidate @@ -917,26 +917,26 @@ def pbCellBatch(canvas) end def pbEntireSlide(canvas) - sliderwin2=ControlWindow.new(0,0,320,32*7) - sliderwin2.viewport=canvas.viewport - sliderwin2.addSlider(_INTL("First Frame:"),1,canvas.animation.length,1) - sliderwin2.addSlider(_INTL("Last Frame:"),1,canvas.animation.length,canvas.animation.length) - sliderwin2.addSlider(_INTL("X-Axis Movement"),-500,500,0) - sliderwin2.addSlider(_INTL("Y-Axis Movement"),-500,500,0) - okbutton=sliderwin2.addButton(_INTL("OK")) - cancelbutton=sliderwin2.addButton(_INTL("Cancel")) - sliderwin2.opacity=200 + sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 7) + sliderwin2.viewport = canvas.viewport + sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1) + sliderwin2.addSlider(_INTL("Last Frame:"), 1, canvas.animation.length, canvas.animation.length) + sliderwin2.addSlider(_INTL("X-Axis Movement"), -500, 500, 0) + sliderwin2.addSlider(_INTL("Y-Axis Movement"), -500, 500, 0) + okbutton = sliderwin2.addButton(_INTL("OK")) + cancelbutton = sliderwin2.addButton(_INTL("Cancel")) + sliderwin2.opacity = 200 loop do Graphics.update Input.update sliderwin2.update if sliderwin2.changed?(okbutton) - startvalue=sliderwin2.value(0)-1 - endvalue=sliderwin2.value(1)-1 - xoffset=sliderwin2.value(2) - yoffset=sliderwin2.value(3) + startvalue = sliderwin2.value(0) - 1 + endvalue = sliderwin2.value(1) - 1 + xoffset = sliderwin2.value(2) + yoffset = sliderwin2.value(3) for i in startvalue..endvalue - canvas.offsetFrame(i,xoffset,yoffset) + canvas.offsetFrame(i, xoffset, yoffset) end break end @@ -949,16 +949,16 @@ def pbEntireSlide(canvas) end def pbAnimEditorHelpWindow - helptext=""+ - "To add a cel to the scene, click on the canvas. The selected cel will have a black "+ - "frame. After a cel is selected, you can modify its properties using the keyboard:\n"+ - "E, R - Rotate left/right.\nP - Open properties screen.\nArrow keys - Move cel 8 pixels "+ - "(hold ALT for 2 pixels).\n+/- : Zoom in/out.\nL - Lock a cel. Locking a cel prevents it "+ - "from being moved or deleted.\nDEL - Deletes the cel.\nAlso press TAB to switch the selected cel." - cmdwin=Window_UnformattedTextPokemon.newWithSize("",0,0,640,512) - cmdwin.opacity=224 - cmdwin.z=99999 - cmdwin.text=helptext + helptext = "" + + "To add a cel to the scene, click on the canvas. The selected cel will have a black " + + "frame. After a cel is selected, you can modify its properties using the keyboard:\n" + + "E, R - Rotate left/right.\nP - Open properties screen.\nArrow keys - Move cel 8 pixels " + + "(hold ALT for 2 pixels).\n+/- : Zoom in/out.\nL - Lock a cel. Locking a cel prevents it " + + "from being moved or deleted.\nDEL - Deletes the cel.\nAlso press TAB to switch the selected cel." + cmdwin = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 640, 512) + cmdwin.opacity = 224 + cmdwin.z = 99999 + cmdwin.text = helptext loop do Graphics.update Input.update @@ -972,12 +972,12 @@ end # Main ################################################################################ def animationEditorMain(animation) - viewport=Viewport.new(0, 0, Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288) - viewport.z=99999 + viewport = Viewport.new(0, 0, Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288) + viewport.z = 99999 # Canvas - canvas=AnimationCanvas.new(animation[animation.selected],viewport) + canvas = AnimationCanvas.new(animation[animation.selected], viewport) # Right hand menu - sidewin=ControlWindow.new(512+128,0,160,384+128) + sidewin = ControlWindow.new(512 + 128, 0, 160, 384 + 128) sidewin.addButton(_INTL("SE and BG...")) sidewin.addButton(_INTL("Cel Focus...")) sidewin.addSpace @@ -993,18 +993,18 @@ def animationEditorMain(animation) sidewin.addButton(_INTL("Import Anim...")) sidewin.addButton(_INTL("Export Anim...")) sidewin.addButton(_INTL("Help")) - sidewin.viewport=canvas.viewport + sidewin.viewport = canvas.viewport # Bottom left menu - sliderwin=ControlWindow.new(0,384+128,240,160) + sliderwin = ControlWindow.new(0, 384 + 128, 240, 160) sliderwin.addControl(FrameCountSlider.new(canvas)) sliderwin.addControl(FrameCountButton.new(canvas)) sliderwin.addButton(_INTL("Set Animation Sheet")) sliderwin.addButton(_INTL("List of Animations")) - sliderwin.viewport=canvas.viewport + sliderwin.viewport = canvas.viewport # Animation sheet window - animwin=CanvasAnimationWindow.new(canvas,240,384+128,512,96,canvas.viewport) + animwin = CanvasAnimationWindow.new(canvas, 240, 384 + 128, 512, 96, canvas.viewport) # Name window - bottomwindow=AnimationNameWindow.new(canvas,240,384+128+96,512,64,canvas.viewport) + bottomwindow = AnimationNameWindow.new(canvas, 240, 384 + 128 + 96, 512, 64, canvas.viewport) loop do Graphics.update Input.update @@ -1014,11 +1014,11 @@ def animationEditorMain(animation) animwin.update bottomwindow.update if animwin.changed? - canvas.pattern=animwin.selected + canvas.pattern = animwin.selected end if Input.trigger?(Input::BACK) if pbConfirmMessage(_INTL("Save changes?")) - save_data(animation,"Data/PkmnAnimations.rxdata") + save_data(animation, "Data/PkmnAnimations.rxdata") end if pbConfirmMessage(_INTL("Exit from the editor?")) $game_temp.battle_animations_data = nil @@ -1029,21 +1029,21 @@ def animationEditorMain(animation) pbAnimEditorHelpWindow next elsif Input.trigger?(Input::MOUSERIGHT) && sliderwin.hittest?(0) # Right mouse button - commands=[ + commands = [ _INTL("Copy Frame"), _INTL("Paste Frame"), _INTL("Clear Frame"), _INTL("Insert Frame"), _INTL("Delete Frame") ] - hit=pbTrackPopupMenu(commands) + hit = pbTrackPopupMenu(commands) case hit when 0 # Copy - if canvas.currentframe>=0 - Clipboard.setData(canvas.animation[canvas.currentframe],"PBAnimFrame") + if canvas.currentframe >= 0 + Clipboard.setData(canvas.animation[canvas.currentframe], "PBAnimFrame") end when 1 # Paste - if canvas.currentframe>=0 + if canvas.currentframe >= 0 canvas.pasteFrame(canvas.currentframe) end when 2 # Clear Frame @@ -1053,7 +1053,7 @@ def animationEditorMain(animation) sliderwin.invalidate when 4 # Delete Frame canvas.deleteFrame(canvas.currentframe) - sliderwin.controls[0].curvalue=canvas.currentframe+1 + sliderwin.controls[0].curvalue = canvas.currentframe + 1 sliderwin.invalidate end next @@ -1064,9 +1064,9 @@ def animationEditorMain(animation) end next elsif Input.trigger?(Input::MOUSERIGHT) # Right mouse button - mousepos=Mouse::getMousePos - mousepos=[0,0] if !mousepos - commands=[ + mousepos = Mouse::getMousePos + mousepos = [0, 0] if !mousepos + commands = [ _INTL("Properties..."), _INTL("Cut"), _INTL("Copy"), @@ -1075,7 +1075,7 @@ def animationEditorMain(animation) _INTL("Renumber..."), _INTL("Extrapolate Path...") ] - hit=pbTrackPopupMenu(commands) + hit = pbTrackPopupMenu(commands) case hit when 0 # Properties if canvas.currentCel @@ -1084,23 +1084,23 @@ def animationEditorMain(animation) end when 1 # Cut if canvas.currentCel - Clipboard.setData(canvas.currentCel,"PBAnimCel") + Clipboard.setData(canvas.currentCel, "PBAnimCel") canvas.deleteCel(canvas.currentcel) end when 2 # Copy if canvas.currentCel - Clipboard.setData(canvas.currentCel,"PBAnimCel") + Clipboard.setData(canvas.currentCel, "PBAnimCel") end when 3 # Paste - canvas.pasteCel(mousepos[0],mousepos[1]) + canvas.pasteCel(mousepos[0], mousepos[1]) when 4 # Delete canvas.deleteCel(canvas.currentcel) when 5 # Renumber - if canvas.currentcel && canvas.currentcel>=2 - cel1=canvas.currentcel - cel2=pbChooseNum(cel1) - if cel2>=2 && cel1!=cel2 - canvas.swapCels(cel1,cel2) + if canvas.currentcel && canvas.currentcel >= 2 + cel1 = canvas.currentcel + cel2 = pbChooseNum(cel1) + if cel2 >= 2 && cel1 != cel2 + canvas.swapCels(cel1, cel2) end end when 6 # Extrapolate Path @@ -1112,7 +1112,7 @@ def animationEditorMain(animation) next end if sliderwin.changed?(0) # Current frame changed - canvas.currentframe=sliderwin.value(0)-1 + canvas.currentframe = sliderwin.value(0) - 1 end if sliderwin.changed?(1) # Change frame count pbChangeMaximum(canvas) @@ -1123,31 +1123,31 @@ def animationEditorMain(animation) sliderwin.refresh end if sliderwin.changed?(2) # Set Animation Sheet - pbSelectAnim(canvas,animwin) + pbSelectAnim(canvas, animwin) animwin.refresh sliderwin.refresh end if sliderwin.changed?(3) # List of Animations - pbAnimList(animation,canvas,animwin) - sliderwin.controls[0].curvalue=canvas.currentframe+1 + pbAnimList(animation, canvas, animwin) + sliderwin.controls[0].curvalue = canvas.currentframe + 1 bottomwindow.refresh animwin.refresh sliderwin.refresh end pbTimingList(canvas) if sidewin.changed?(0) if sidewin.changed?(1) - positions=[_INTL("User"),_INTL("Target"),_INTL("User and target"),_INTL("Screen")] - indexes=[2,1,3,4] # Keeping backwards compatibility + positions = [_INTL("User"), _INTL("Target"), _INTL("User and target"), _INTL("Screen")] + indexes = [2, 1, 3, 4] # Keeping backwards compatibility for i in 0...positions.length - selected="[ ]" - if animation[animation.selected].position==indexes[i] - selected="[x]" + selected = "[ ]" + if animation[animation.selected].position == indexes[i] + selected = "[x]" end - positions[i]=sprintf("%s %s",selected,positions[i]) + positions[i] = sprintf("%s %s", selected, positions[i]) end - pos=pbShowCommands(nil,positions,-1) - if pos>=0 - animation[animation.selected].position=indexes[pos] + pos = pbShowCommands(nil, positions, -1) + if pos >= 0 + animation[animation.selected].position = indexes[pos] canvas.update end end @@ -1160,8 +1160,8 @@ def animationEditorMain(animation) canvas.play if sidewin.changed?(10) canvas.play(true) if sidewin.changed?(11) if sidewin.changed?(12) - pbImportAnim(animation,canvas,animwin) - sliderwin.controls[0].curvalue=canvas.currentframe+1 + pbImportAnim(animation, canvas, animwin) + sliderwin.controls[0].curvalue = canvas.currentframe + 1 bottomwindow.refresh animwin.refresh sliderwin.refresh @@ -1188,10 +1188,10 @@ end ################################################################################ def pbAnimationEditor pbBGMStop() - animation=pbLoadBattleAnimations + animation = pbLoadBattleAnimations if !animation || !animation[0] - animation=PBAnimations.new - animation[0].graphic="" + animation = PBAnimations.new + animation[0].graphic = "" end Graphics.resize_screen(Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288) pbSetResizeFactor(1) diff --git a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb b/Data/Scripts/020_Debug/002_Editor_DataTypes.rb index 81e75e16c..86dcee99c 100644 --- a/Data/Scripts/020_Debug/002_Editor_DataTypes.rb +++ b/Data/Scripts/020_Debug/002_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 @@ -32,11 +32,11 @@ class UIntProperty @maxdigits = maxdigits end - def set(settingname,oldsetting) + def set(settingname, oldsetting) params = ChooseNumberParams.new params.setMaxDigits(@maxdigits) params.setDefaultValue(oldsetting || 0) - return pbMessageChooseNumber(_INTL("Set the value for {1}.",settingname),params) + return pbMessageChooseNumber(_INTL("Set the value for {1}.", settingname), params) end def defaultValue @@ -55,12 +55,12 @@ class LimitProperty @maxvalue = maxvalue end - def set(settingname,oldsetting) + def set(settingname, oldsetting) oldsetting = 1 if !oldsetting params = ChooseNumberParams.new - params.setRange(0,@maxvalue) + params.setRange(0, @maxvalue) params.setDefaultValue(oldsetting) - return pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).",settingname),params) + return pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).", settingname), params) end def defaultValue @@ -79,14 +79,14 @@ class LimitProperty2 @maxvalue = maxvalue end - def set(settingname,oldsetting) + def set(settingname, oldsetting) oldsetting = 0 if !oldsetting params = ChooseNumberParams.new - params.setRange(0,@maxvalue) + params.setRange(0, @maxvalue) params.setDefaultValue(oldsetting) params.setCancelValue(-1) - ret = pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).",settingname),params) - return (ret>=0) ? ret : nil + ret = pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).", settingname), params) + return (ret >= 0) ? ret : nil end def defaultValue @@ -105,12 +105,12 @@ class NonzeroLimitProperty @maxvalue = maxvalue end - def set(settingname,oldsetting) + def set(settingname, oldsetting) oldsetting = 1 if !oldsetting params = ChooseNumberParams.new - params.setRange(1,@maxvalue) + params.setRange(1, @maxvalue) params.setDefaultValue(oldsetting) - return pbMessageChooseNumber(_INTL("Set the value for {1}.",settingname),params) + return pbMessageChooseNumber(_INTL("Set the value for {1}.", settingname), params) end def defaultValue @@ -125,8 +125,8 @@ end module BooleanProperty - def self.set(settingname,_oldsetting) - return pbConfirmMessage(_INTL("Enable the setting {1}?",settingname)) ? true : false + def self.set(settingname, _oldsetting) + return pbConfirmMessage(_INTL("Enable the setting {1}?", settingname)) ? true : false end def self.format(value) @@ -137,9 +137,9 @@ end module BooleanProperty2 - def self.set(_settingname,_oldsetting) - ret = pbShowCommands(nil,[_INTL("True"),_INTL("False")],-1) - return (ret>=0) ? (ret==0) : nil + def self.set(_settingname, _oldsetting) + ret = pbShowCommands(nil, [_INTL("True"), _INTL("False")], -1) + return (ret >= 0) ? (ret == 0) : nil end def self.defaultValue @@ -147,16 +147,16 @@ module BooleanProperty2 end def self.format(value) - return (value) ? _INTL("True") : (value!=nil) ? _INTL("False") : "-" + return (value) ? _INTL("True") : (value != nil) ? _INTL("False") : "-" end end module StringProperty - def self.set(settingname,oldsetting) - return pbMessageFreeText(_INTL("Set the value for {1}.",settingname), - (oldsetting) ? oldsetting : "",false,250,Graphics.width) + def self.set(settingname, oldsetting) + return pbMessageFreeText(_INTL("Set the value for {1}.", settingname), + (oldsetting) ? oldsetting : "", false, 250, Graphics.width) end def self.format(value) @@ -175,9 +175,9 @@ class LimitStringProperty return value end - def set(settingname,oldsetting) - return pbMessageFreeText(_INTL("Set the value for {1}.",settingname), - (oldsetting) ? oldsetting : "",false,@limit) + def set(settingname, oldsetting) + return pbMessageFreeText(_INTL("Set the value for {1}.", settingname), + (oldsetting) ? oldsetting : "", false, @limit) end end @@ -188,13 +188,13 @@ class EnumProperty @values = values end - def set(settingname,oldsetting) + def set(settingname, oldsetting) commands = [] for value in @values commands.push(value) end - cmd = pbMessage(_INTL("Choose a value for {1}.",settingname),commands,-1) - return oldsetting if cmd<0 + cmd = pbMessage(_INTL("Choose a value for {1}.", settingname), commands, -1) + return oldsetting if cmd < 0 return cmd end @@ -215,7 +215,7 @@ class EnumProperty2 @module = value end - def set(settingname,oldsetting) + def set(settingname, oldsetting) commands = [] for i in 0..@module.maxValue commands.push(getConstantName(@module, i)) @@ -357,9 +357,9 @@ end module BGMProperty - def self.set(settingname,oldsetting) - chosenmap = pbListScreen(settingname,MusicFileLister.new(true,oldsetting)) - return (chosenmap && chosenmap!="") ? chosenmap : oldsetting + def self.set(settingname, oldsetting) + chosenmap = pbListScreen(settingname, MusicFileLister.new(true, oldsetting)) + return (chosenmap && chosenmap != "") ? chosenmap : oldsetting end def self.format(value) @@ -370,9 +370,9 @@ end module MEProperty - def self.set(settingname,oldsetting) - chosenmap = pbListScreen(settingname,MusicFileLister.new(false,oldsetting)) - return (chosenmap && chosenmap!="") ? chosenmap : oldsetting + def self.set(settingname, oldsetting) + chosenmap = pbListScreen(settingname, MusicFileLister.new(false, oldsetting)) + return (chosenmap && chosenmap != "") ? chosenmap : oldsetting end def self.format(value) @@ -383,9 +383,9 @@ end module WindowskinProperty - def self.set(settingname,oldsetting) - chosenmap = pbListScreen(settingname,GraphicsLister.new("Graphics/Windowskins/",oldsetting)) - return (chosenmap && chosenmap!="") ? chosenmap : oldsetting + def self.set(settingname, oldsetting) + chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Windowskins/", oldsetting)) + return (chosenmap && chosenmap != "") ? chosenmap : oldsetting end def self.format(value) @@ -409,7 +409,7 @@ end module SpeciesProperty - def self.set(_settingname,oldsetting) + def self.set(_settingname, oldsetting) ret = pbChooseSpeciesList(oldsetting || nil) return ret || oldsetting end @@ -430,7 +430,7 @@ class SpeciesFormProperty @default_value = default_value end - def set(_settingname,oldsetting) + def set(_settingname, oldsetting) ret = pbChooseSpeciesFormList(oldsetting || nil) return ret || oldsetting end @@ -510,9 +510,9 @@ end module GenderProperty - def self.set(_settingname,_oldsetting) - ret = pbShowCommands(nil,[_INTL("Male"),_INTL("Female")],-1) - return (ret>=0) ? ret : nil + def self.set(_settingname, _oldsetting) + ret = pbShowCommands(nil, [_INTL("Male"), _INTL("Female")], -1) + return (ret >= 0) ? ret : nil end def self.defaultValue @@ -521,7 +521,7 @@ module GenderProperty def self.format(value) return _INTL("-") if !value - return (value==0) ? _INTL("Male") : (value==1) ? _INTL("Female") : "-" + return (value == 0) ? _INTL("Male") : (value == 1) ? _INTL("Female") : "-" end end @@ -635,7 +635,7 @@ class BallProperty @pokemondata = pokemondata end - def set(_settingname,oldsetting) + def set(_settingname, oldsetting) return pbChooseBallList(oldsetting) end @@ -651,9 +651,9 @@ end module CharacterProperty - def self.set(settingname,oldsetting) - chosenmap = pbListScreen(settingname,GraphicsLister.new("Graphics/Characters/",oldsetting)) - return (chosenmap && chosenmap!="") ? chosenmap : oldsetting + def self.set(settingname, oldsetting) + chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Characters/", oldsetting)) + return (chosenmap && chosenmap != "") ? chosenmap : oldsetting end def self.format(value) @@ -664,13 +664,13 @@ end module MapSizeProperty - def self.set(settingname,oldsetting) - oldsetting = [0,""] if !oldsetting + def self.set(settingname, oldsetting) + oldsetting = [0, ""] if !oldsetting properties = [ [_INTL("Width"), NonzeroLimitProperty.new(30), _INTL("The width of this map in Region Map squares.")], [_INTL("Valid Squares"), StringProperty, _INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")], ] - pbPropertyList(settingname,oldsetting,properties,false) + pbPropertyList(settingname, oldsetting, properties, false) return oldsetting end @@ -681,29 +681,29 @@ end -def chooseMapPoint(map,rgnmap = false) - viewport=Viewport.new(0,0,Graphics.width,Graphics.height) - viewport.z=99999 +def chooseMapPoint(map, rgnmap = false) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) + viewport.z = 99999 title = Window_UnformattedTextPokemon.newWithSize(_INTL("Click a point on the map."), 0, Graphics.height - 64, Graphics.width, 64, viewport) title.z = 2 if rgnmap - sprite=RegionMapSprite.new(map,viewport) + sprite = RegionMapSprite.new(map, viewport) else - sprite=MapSprite.new(map,viewport) + sprite = MapSprite.new(map, viewport) end - sprite.z=2 - ret=nil + sprite.z = 2 + ret = nil loop do Graphics.update Input.update - xy=sprite.getXY + xy = sprite.getXY if xy - ret=xy + ret = xy break end if Input.trigger?(Input::BACK) - ret=nil + ret = nil break end end @@ -715,11 +715,11 @@ end module MapCoordsProperty - def self.set(settingname,oldsetting) - chosenmap = pbListScreen(settingname,MapLister.new((oldsetting) ? oldsetting[0] : 0)) - if chosenmap>=0 + def self.set(settingname, oldsetting) + chosenmap = pbListScreen(settingname, MapLister.new((oldsetting) ? oldsetting[0] : 0)) + if chosenmap >= 0 mappoint = chooseMapPoint(chosenmap) - return (mappoint) ? [chosenmap,mappoint[0],mappoint[1]] : oldsetting + return (mappoint) ? [chosenmap, mappoint[0], mappoint[1]] : oldsetting else return oldsetting end @@ -733,14 +733,14 @@ end module MapCoordsFacingProperty - def self.set(settingname,oldsetting) - chosenmap = pbListScreen(settingname,MapLister.new((oldsetting) ? oldsetting[0] : 0)) - if chosenmap>=0 + def self.set(settingname, oldsetting) + chosenmap = pbListScreen(settingname, MapLister.new((oldsetting) ? oldsetting[0] : 0)) + if chosenmap >= 0 mappoint = chooseMapPoint(chosenmap) if mappoint facing = pbMessage(_INTL("Choose the direction to face in."), - [_INTL("Down"),_INTL("Left"),_INTL("Right"),_INTL("Up")],-1) - return (facing>=0) ? [chosenmap,mappoint[0],mappoint[1],[2,4,6,8][facing]] : oldsetting + [_INTL("Down"), _INTL("Left"), _INTL("Right"), _INTL("Up")], -1) + return (facing >= 0) ? [chosenmap, mappoint[0], mappoint[1], [2, 4, 6, 8][facing]] : oldsetting else return oldsetting end @@ -757,28 +757,28 @@ end module RegionMapCoordsProperty - def self.set(_settingname,oldsetting) + def self.set(_settingname, oldsetting) regions = self.getMapNameList selregion = -1 - if regions.length==0 + if regions.length == 0 pbMessage(_INTL("No region maps are defined.")) return oldsetting - elsif regions.length==1 + elsif regions.length == 1 selregion = regions[0][0] else cmds = [] for region in regions cmds.push(region[1]) end - selcmd = pbMessage(_INTL("Choose a region map."),cmds,-1) - if selcmd>=0 + selcmd = pbMessage(_INTL("Choose a region map."), cmds, -1) + if selcmd >= 0 selregion = regions[selcmd][0] else return oldsetting end end - mappoint = chooseMapPoint(selregion,true) - return (mappoint) ? [selregion,mappoint[0],mappoint[1]] : oldsetting + mappoint = chooseMapPoint(selregion, true) + return (mappoint) ? [selregion, mappoint[0], mappoint[1]] : oldsetting end def self.format(value) @@ -787,11 +787,11 @@ module RegionMapCoordsProperty def self.getMapNameList mapdata = pbLoadTownMapData - ret=[] + ret = [] for i in 0...mapdata.length next if !mapdata[i] ret.push( - [i,pbGetMessage(MessageTypes::RegionNames,i)] + [i, pbGetMessage(MessageTypes::RegionNames, i)] ) end return ret @@ -801,7 +801,7 @@ end module WeatherEffectProperty - def self.set(_settingname,oldsetting) + def self.set(_settingname, oldsetting) oldsetting = [:None, 100] if !oldsetting options = [] ids = [] @@ -828,9 +828,9 @@ end module MapProperty - def self.set(settingname,oldsetting) - chosenmap = pbListScreen(settingname,MapLister.new(oldsetting ? oldsetting : 0)) - return (chosenmap>0) ? chosenmap : oldsetting + def self.set(settingname, oldsetting) + chosenmap = pbListScreen(settingname, MapLister.new(oldsetting ? oldsetting : 0)) + return (chosenmap > 0) ? chosenmap : oldsetting end def self.defaultValue @@ -846,8 +846,8 @@ end module ItemNameProperty def self.set(settingname, oldsetting) - return pbMessageFreeText(_INTL("Set the value for {1}.",settingname), - (oldsetting) ? oldsetting : "",false,30) + return pbMessageFreeText(_INTL("Set the value for {1}.", settingname), + (oldsetting) ? oldsetting : "", false, 30) end def self.defaultValue @@ -881,7 +881,7 @@ end module BaseStatsProperty - def self.set(settingname,oldsetting) + def self.set(settingname, oldsetting) return oldsetting if !oldsetting properties = [] data = [] @@ -920,7 +920,7 @@ end module EffortValuesProperty - def self.set(settingname,oldsetting) + def self.set(settingname, oldsetting) return oldsetting if !oldsetting properties = [] data = [] @@ -1152,7 +1152,7 @@ module LevelUpMovesProperty params.setRange(0, GameData::GrowthRate.max_level) params.setDefaultValue(1) params.setCancelValue(-1) - newlevel = pbMessageChooseNumber(_INTL("Choose a level."),params) + newlevel = pbMessageChooseNumber(_INTL("Choose a level."), params) if newlevel >= 0 newmove = pbChooseMoveList if newmove @@ -1294,24 +1294,24 @@ class EvolutionsProperty return ret end - def set(_settingname,oldsetting) + def set(_settingname, oldsetting) ret = oldsetting cmdwin = pbListWindow([]) commands = [] realcmds = [] - realcmds.push([-1,0,0,-1]) + realcmds.push([-1, 0, 0, -1]) for i in 0...oldsetting.length - realcmds.push([oldsetting[i][0],oldsetting[i][1],oldsetting[i][2],i]) + realcmds.push([oldsetting[i][0], oldsetting[i][1], oldsetting[i][2], i]) end refreshlist = true oldsel = -1 - cmd = [0,0] + cmd = [0, 0] loop do if refreshlist - realcmds.sort! { |a,b| a[3]<=>b[3] } + realcmds.sort! { |a, b| a[3] <=> b[3] } commands = [] for i in 0...realcmds.length - if realcmds[i][3]<0 + if realcmds[i][3] < 0 commands.push(_INTL("[ADD EVOLUTION]")) else level = realcmds[i][2] @@ -1329,47 +1329,47 @@ class EvolutionsProperty GameData::Species.get(realcmds[i][0]).name, evo_method_data.real_name, level.to_s)) end end - cmd[1] = i if oldsel>=0 && realcmds[i][3]==oldsel + cmd[1] = i if oldsel >= 0 && realcmds[i][3] == oldsel end end refreshlist = false oldsel = -1 - cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true) - if cmd[0]==1 # Swap evolution up - if cmd[1]>0 && cmd[1] 0 && cmd[1] < realcmds.length - 1 + realcmds[cmd[1] + 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] + 1][3] refreshlist = true end - elsif cmd[0]==2 # Swap evolution down - if cmd[1]>1 - realcmds[cmd[1]-1][3],realcmds[cmd[1]][3] = realcmds[cmd[1]][3],realcmds[cmd[1]-1][3] + elsif cmd[0] == 2 # Swap evolution down + if cmd[1] > 1 + realcmds[cmd[1] - 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] - 1][3] refreshlist = true end - elsif cmd[0]==0 - if cmd[1]>=0 + elsif cmd[0] == 0 + if cmd[1] >= 0 entry = realcmds[cmd[1]] - if entry[3]==-1 # Add new evolution path + if entry[3] == -1 # Add new evolution path pbMessage(_INTL("Choose an evolved form, method and parameter.")) newspecies = pbChooseSpeciesList if newspecies - newmethodindex = pbMessage(_INTL("Choose an evolution method."),@methods,-1) + newmethodindex = pbMessage(_INTL("Choose an evolution method."), @methods, -1) if newmethodindex >= 0 newmethod = @evo_ids[newmethodindex] newparam = edit_parameter(newmethod) if newparam || GameData::Evolution.get(newmethod).parameter.nil? existing_evo = -1 for i in 0...realcmds.length - existing_evo = realcmds[i][3] if realcmds[i][0]==newspecies && - realcmds[i][1]==newmethod && - realcmds[i][2]==newparam + existing_evo = realcmds[i][3] if realcmds[i][0] == newspecies && + realcmds[i][1] == newmethod && + realcmds[i][2] == newparam end if existing_evo >= 0 oldsel = existing_evo else maxid = -1 - realcmds.each { |i| maxid = [maxid,i[3]].max } - realcmds.push([newspecies,newmethod,newparam,maxid+1]) - oldsel = maxid+1 + realcmds.each { |i| maxid = [maxid, i[3]].max } + realcmds.push([newspecies, newmethod, newparam, maxid + 1]) + oldsel = maxid + 1 end refreshlist = true end @@ -1377,16 +1377,16 @@ class EvolutionsProperty end else # Edit evolution case pbMessage(_INTL("\\ts[]Do what with this evolution?"), - [_INTL("Change species"),_INTL("Change method"), - _INTL("Change parameter"),_INTL("Delete"),_INTL("Cancel")],5) + [_INTL("Change species"), _INTL("Change method"), + _INTL("Change parameter"), _INTL("Delete"), _INTL("Cancel")], 5) when 0 # Change species newspecies = pbChooseSpeciesList(entry[0]) if newspecies existing_evo = -1 for i in 0...realcmds.length - existing_evo = realcmds[i][3] if realcmds[i][0]==newspecies && - realcmds[i][1]==entry[1] && - realcmds[i][2]==entry[2] + existing_evo = realcmds[i][3] if realcmds[i][0] == newspecies && + realcmds[i][1] == entry[1] && + realcmds[i][2] == entry[2] end if existing_evo >= 0 realcmds.delete_at(cmd[1]) @@ -1400,14 +1400,14 @@ class EvolutionsProperty when 1 # Change method default_index = 0 @evo_ids.each_with_index { |evo, i| default_index = i if evo == entry[1] } - newmethodindex = pbMessage(_INTL("Choose an evolution method."),@methods,-1,nil,default_index) + newmethodindex = pbMessage(_INTL("Choose an evolution method."), @methods, -1, nil, default_index) if newmethodindex >= 0 newmethod = @evo_ids[newmethodindex] existing_evo = -1 for i in 0...realcmds.length - existing_evo = realcmds[i][3] if realcmds[i][0]==entry[0] && - realcmds[i][1]==newmethod && - realcmds[i][2]==entry[2] + existing_evo = realcmds[i][3] if realcmds[i][0] == entry[0] && + realcmds[i][1] == newmethod && + realcmds[i][2] == entry[2] end if existing_evo >= 0 realcmds.delete_at(cmd[1]) @@ -1427,9 +1427,9 @@ class EvolutionsProperty if newparam existing_evo = -1 for i in 0...realcmds.length - existing_evo = realcmds[i][3] if realcmds[i][0]==entry[0] && - realcmds[i][1]==entry[1] && - realcmds[i][2]==newparam + existing_evo = realcmds[i][3] if realcmds[i][0] == entry[0] && + realcmds[i][1] == entry[1] && + realcmds[i][2] == newparam end if existing_evo >= 0 realcmds.delete_at(cmd[1]) @@ -1443,18 +1443,18 @@ class EvolutionsProperty end when 3 # Delete realcmds.delete_at(cmd[1]) - cmd[1] = [cmd[1],realcmds.length-1].min + cmd[1] = [cmd[1], realcmds.length - 1].min refreshlist = true end end else cmd2 = pbMessage(_INTL("Save changes?"), - [_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3) - if cmd2==0 || cmd2==1 - if cmd2==0 + [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) + if cmd2 == 0 || cmd2 == 1 + if cmd2 == 0 for i in 0...realcmds.length realcmds[i].pop - realcmds[i] = nil if realcmds[i][0]==-1 + realcmds[i] = nil if realcmds[i][0] == -1 end realcmds.compact! ret = realcmds @@ -1546,8 +1546,8 @@ end #=============================================================================== # Core property editor script #=============================================================================== -def pbPropertyList(title,data,properties,saveprompt = false) - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) +def pbPropertyList(title, data, properties, saveprompt = false) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 list = pbListWindow([], Graphics.width / 2) list.viewport = viewport @@ -1563,7 +1563,7 @@ def pbPropertyList(title,data,properties,saveprompt = false) commands = [] for i in 0...properties.length propobj = properties[i][1] - commands.push(sprintf("%s=%s",properties[i][0],propobj.format(data[i]))) + commands.push(sprintf("%s=%s", properties[i][0], propobj.format(data[i]))) end list.commands = commands list.index = 0 @@ -1573,14 +1573,14 @@ def pbPropertyList(title,data,properties,saveprompt = false) Input.update list.update desc.update - if list.index!=selectedmap + if list.index != selectedmap desc.text = properties[list.index][2] selectedmap = list.index end if Input.trigger?(Input::ACTION) propobj = properties[selectedmap][1] - if propobj!=ReadOnlyProperty && !propobj.is_a?(ReadOnlyProperty) && - pbConfirmMessage(_INTL("Reset the setting {1}?",properties[selectedmap][0])) + if propobj != ReadOnlyProperty && !propobj.is_a?(ReadOnlyProperty) && + pbConfirmMessage(_INTL("Reset the setting {1}?", properties[selectedmap][0])) if propobj.respond_to?("defaultValue") data[selectedmap] = propobj.defaultValue else @@ -1590,7 +1590,7 @@ def pbPropertyList(title,data,properties,saveprompt = false) commands.clear for i in 0...properties.length propobj = properties[i][1] - commands.push(sprintf("%s=%s",properties[i][0],propobj.format(data[i]))) + commands.push(sprintf("%s=%s", properties[i][0], propobj.format(data[i]))) end list.commands = commands elsif Input.trigger?(Input::BACK) @@ -1599,27 +1599,27 @@ def pbPropertyList(title,data,properties,saveprompt = false) elsif Input.trigger?(Input::USE) propobj = properties[selectedmap][1] oldsetting = data[selectedmap] - newsetting = propobj.set(properties[selectedmap][0],oldsetting) + newsetting = propobj.set(properties[selectedmap][0], oldsetting) data[selectedmap] = newsetting commands.clear for i in 0...properties.length propobj = properties[i][1] - commands.push(sprintf("%s=%s",properties[i][0],propobj.format(data[i]))) + commands.push(sprintf("%s=%s", properties[i][0], propobj.format(data[i]))) end list.commands = commands break end end - if selectedmap==-1 && saveprompt + if selectedmap == -1 && saveprompt cmd = pbMessage(_INTL("Save changes?"), - [_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3) - if cmd==2 + [_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3) + if cmd == 2 selectedmap = list.index else - retval = (cmd==0) + retval = (cmd == 0) end end - end while selectedmap!=-1 + end while selectedmap != -1 title.dispose list.dispose desc.dispose diff --git a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb index fadc35012..ed273a28d 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb @@ -882,7 +882,7 @@ DebugMenuCommands.register("randomid", { "name" => _INTL("Randomize Player ID"), "description" => _INTL("Generate a random new ID for the player."), "effect" => proc { - $player.id = rand(2 ** 16) | rand(2 ** 16) << 16 + $player.id = rand(2**16) | rand(2**16) << 16 pbMessage(_INTL("The player's ID was changed to {1} (full ID: {2}).", $player.public_ID, $player.id)) } }) diff --git a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb index 96bad89b4..d5d9f6f30 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb @@ -8,8 +8,8 @@ def pbDefaultMap end def pbWarpToMap - mapid = pbListScreen(_INTL("WARP TO MAP"),MapLister.new(pbDefaultMap)) - if mapid>0 + mapid = pbListScreen(_INTL("WARP TO MAP"), MapLister.new(pbDefaultMap)) + if mapid > 0 map = Game_Map.new map.setup(mapid) success = false @@ -18,7 +18,7 @@ def pbWarpToMap 100.times do x = rand(map.width) y = rand(map.height) - next if !map.passableStrict?(x,y,0,$game_player) + next if !map.passableStrict?(x, y, 0, $game_player) blocked = false for event in map.events.values if event.at_coordinate?(x, y) && !event.through @@ -33,7 +33,7 @@ def pbWarpToMap x = rand(map.width) y = rand(map.height) end - return [mapid,x,y] + return [mapid, x, y] end return nil end @@ -47,11 +47,11 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand attr_reader :mode def initialize(viewport) - super(0,0,Graphics.width,Graphics.height,viewport) + super(0, 0, Graphics.width, Graphics.height, viewport) end def itemCount - return (@mode==0) ? $data_system.switches.size-1 : $data_system.variables.size-1 + return (@mode == 0) ? $data_system.switches.size - 1 : $data_system.variables.size - 1 end def mode=(mode) @@ -59,30 +59,30 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand refresh end - def shadowtext(x,y,w,h,t,align = 0,colors = 0) + def shadowtext(x, y, w, h, t, align = 0, colors = 0) width = self.contents.text_size(t).width - if align==1 # Right aligned - x += (w-width) - elsif align==2 # Centre aligned - x += (w/2)-(width/2) + if align == 1 # Right aligned + x += (w - width) + elsif align == 2 # Centre aligned + x += (w / 2) - (width / 2) end - base = Color.new(12*8,12*8,12*8) - if colors==1 # Red - base = Color.new(168,48,56) - elsif colors==2 # Green - base = Color.new(0,144,0) + base = Color.new(12 * 8, 12 * 8, 12 * 8) + if colors == 1 # Red + base = Color.new(168, 48, 56) + elsif colors == 2 # Green + base = Color.new(0, 144, 0) end - pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8)) + 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 - name = $data_system.switches[index+1] + if @mode == 0 + name = $data_system.switches[index + 1] codeswitch = (name[/^s\:/]) - val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index+1] + val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index + 1] if val.nil? status = "[-]" colors = 0 @@ -95,31 +95,31 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand colors = 1 end else - name = $data_system.variables[index+1] - status = $game_variables[index+1].to_s + name = $data_system.variables[index + 1] + status = $game_variables[index + 1].to_s status = "\"__\"" if nil_or_empty?(status) end - name = '' if name==nil - id_text = sprintf("%04d:",index+1) - rect = drawCursor(index,rect) + name = '' if name == nil + id_text = sprintf("%04d:", index + 1) + rect = drawCursor(index, rect) totalWidth = rect.width - idWidth = totalWidth*15/100 - nameWidth = totalWidth*65/100 - statusWidth = totalWidth*20/100 - self.shadowtext(rect.x,rect.y,idWidth,rect.height,id_text) - self.shadowtext(rect.x+idWidth,rect.y,nameWidth,rect.height,name,0,(codeswitch) ? 1 : 0) - self.shadowtext(rect.x+idWidth+nameWidth,rect.y,statusWidth,rect.height,status,1,colors) + idWidth = totalWidth * 15 / 100 + nameWidth = totalWidth * 65 / 100 + statusWidth = totalWidth * 20 / 100 + self.shadowtext(rect.x, rect.y, idWidth, rect.height, id_text) + self.shadowtext(rect.x + idWidth, rect.y, nameWidth, rect.height, name, 0, (codeswitch) ? 1 : 0) + self.shadowtext(rect.x + idWidth + nameWidth, rect.y, statusWidth, rect.height, status, 1, colors) end end -def pbDebugSetVariable(id,diff) - $game_variables[id] = 0 if $game_variables[id]==nil +def pbDebugSetVariable(id, diff) + $game_variables[id] = 0 if $game_variables[id] == nil if $game_variables[id].is_a?(Numeric) pbPlayCursorSE - $game_variables[id] = [$game_variables[id]+diff,99999999].min - $game_variables[id] = [$game_variables[id],-99999999].max + $game_variables[id] = [$game_variables[id] + diff, 99999999].min + $game_variables[id] = [$game_variables[id], -99999999].max $game_map.need_refresh = true end end @@ -131,20 +131,20 @@ def pbDebugVariableScreen(id) params.setDefaultValue(value) params.setMaxDigits(8) params.setNegativesAllowed(true) - value = pbMessageChooseNumber(_INTL("Set variable {1}.",id),params) - $game_variables[id] = [value,99999999].min - $game_variables[id] = [$game_variables[id],-99999999].max + value = pbMessageChooseNumber(_INTL("Set variable {1}.", id), params) + $game_variables[id] = [value, 99999999].min + $game_variables[id] = [$game_variables[id], -99999999].max $game_map.need_refresh = true elsif $game_variables[id].is_a?(String) - value = pbMessageFreeText(_INTL("Set variable {1}.",id), - $game_variables[id],false,250,Graphics.width) + value = pbMessageFreeText(_INTL("Set variable {1}.", id), + $game_variables[id], false, 250, Graphics.width) $game_variables[id] = value $game_map.need_refresh = true end end def pbDebugVariables(mode) - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 sprites = {} sprites["right_window"] = SpriteWindow_DebugVariables.new(viewport) @@ -159,25 +159,25 @@ def pbDebugVariables(mode) pbPlayCancelSE break end - current_id = right_window.index+1 - if mode==0 # Switches + current_id = right_window.index + 1 + if mode == 0 # Switches if Input.trigger?(Input::USE) pbPlayDecisionSE $game_switches[current_id] = !$game_switches[current_id] right_window.refresh $game_map.need_refresh = true end - elsif mode==1 # Variables + elsif mode == 1 # Variables if Input.repeat?(Input::LEFT) - pbDebugSetVariable(current_id,-1) + pbDebugSetVariable(current_id, -1) right_window.refresh elsif Input.repeat?(Input::RIGHT) - pbDebugSetVariable(current_id,1) + pbDebugSetVariable(current_id, 1) right_window.refresh elsif Input.trigger?(Input::ACTION) - if $game_variables[current_id]==0 + if $game_variables[current_id] == 0 $game_variables[current_id] = "" - elsif $game_variables[current_id]=="" + elsif $game_variables[current_id] == "" $game_variables[current_id] = 0 elsif $game_variables[current_id].is_a?(Numeric) $game_variables[current_id] = 0 @@ -353,7 +353,7 @@ end #=============================================================================== class SpriteWindow_DebugRoamers < Window_DrawableCommand def initialize(viewport) - super(0,0,Graphics.width,Graphics.height,viewport) + super(0, 0, Graphics.width, Graphics.height, viewport) end def roamerCount @@ -361,44 +361,44 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand end def itemCount - return self.roamerCount+2 + return self.roamerCount + 2 end - def shadowtext(t,x,y,w,h,align = 0,colors = 0) + def shadowtext(t, x, y, w, h, align = 0, colors = 0) width = self.contents.text_size(t).width - if align==1 - x += (w-width) # Right aligned - elsif align==2 - x += (w/2)-(width/2) # Centre aligned + if align == 1 + x += (w - width) # Right aligned + elsif align == 2 + x += (w / 2) - (width / 2) # Centre aligned end - base = Color.new(12*8,12*8,12*8) - if colors==1 - base = Color.new(168,48,56) # Red - elsif colors==2 - base = Color.new(0,144,0) # Green + base = Color.new(12 * 8, 12 * 8, 12 * 8) + if colors == 1 + base = Color.new(168, 48, 56) # Red + elsif colors == 2 + base = Color.new(0, 144, 0) # Green end - pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8)) + 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 - statusWidth = rect.width*50/100 - if index==self.itemCount-2 + rect = drawCursor(index, rect) + nameWidth = rect.width * 50 / 100 + statusWidth = rect.width * 50 / 100 + if index == self.itemCount - 2 # Advance roaming - self.shadowtext(_INTL("[All roam to new locations]"),rect.x,rect.y,nameWidth,rect.height) - elsif index==self.itemCount-1 + self.shadowtext(_INTL("[All roam to new locations]"), rect.x, rect.y, nameWidth, rect.height) + elsif index == self.itemCount - 1 # Advance roaming - self.shadowtext(_INTL("[Clear all current roamer locations]"),rect.x,rect.y,nameWidth,rect.height) + self.shadowtext(_INTL("[Clear all current roamer locations]"), rect.x, rect.y, nameWidth, rect.height) else pkmn = Settings::ROAMING_SPECIES[index] name = GameData::Species.get(pkmn[0]).name + " (Lv. #{pkmn[1]})" status = "" statuscolor = 0 - if pkmn[2]<=0 || $game_switches[pkmn[2]] + if pkmn[2] <= 0 || $game_switches[pkmn[2]] status = $PokemonGlobal.roamPokemon[index] - if status==true + if status == true if $PokemonGlobal.roamPokemonCaught[index] status = "[CAUGHT]" else @@ -419,8 +419,8 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand else status = "[NOT ROAMING][Switch #{pkmn[2]} is off]" end - self.shadowtext(name,rect.x,rect.y,nameWidth,rect.height) - self.shadowtext(status,rect.x+nameWidth,rect.y,statusWidth,rect.height,1,statuscolor) + self.shadowtext(name, rect.x, rect.y, nameWidth, rect.height) + self.shadowtext(status, rect.x + nameWidth, rect.y, statusWidth, rect.height, 1, statuscolor) end end end @@ -428,23 +428,23 @@ end def pbDebugRoamers - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 sprites = {} sprites["cmdwindow"] = SpriteWindow_DebugRoamers.new(viewport) cmdwindow = sprites["cmdwindow"] - cmdwindow.active = true + cmdwindow.active = true loop do Graphics.update Input.update pbUpdateSpriteHash(sprites) - if Input.trigger?(Input::ACTION) && cmdwindow.index0 && !$game_switches[pkmn[2]] + if pkmn[2] > 0 && !$game_switches[pkmn[2]] # not roaming -> roaming $game_switches[pkmn[2]] = true - elsif $PokemonGlobal.roamPokemon[cmdwindow.index]!=true + elsif $PokemonGlobal.roamPokemon[cmdwindow.index] != true # roaming -> defeated $PokemonGlobal.roamPokemon[cmdwindow.index] = true $PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false @@ -478,15 +478,15 @@ def pbDebugRoamers !$PokemonGlobal.roamPokemonCaught[cmdwindow.index] # defeated -> caught $PokemonGlobal.roamPokemonCaught[cmdwindow.index] = true - elsif pkmn[2]>0 + elsif pkmn[2] > 0 # caught -> not roaming (or roaming if Switch ID is 0 - $game_switches[pkmn[2]] = false if pkmn[2]>0 + $game_switches[pkmn[2]] = false if pkmn[2] > 0 $PokemonGlobal.roamPokemon[cmdwindow.index] = nil $PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false end cmdwindow.refresh - elsif cmdwindow.index==cmdwindow.itemCount-2 # All roam - if Settings::ROAMING_SPECIES.length==0 + elsif cmdwindow.index == cmdwindow.itemCount - 2 # All roam + if Settings::ROAMING_SPECIES.length == 0 pbPlayBuzzerSE else pbPlayDecisionSE @@ -495,7 +495,7 @@ def pbDebugRoamers cmdwindow.refresh end else # Clear all roaming locations - if Settings::ROAMING_SPECIES.length==0 + if Settings::ROAMING_SPECIES.length == 0 pbPlayBuzzerSE else pbPlayDecisionSE @@ -524,23 +524,23 @@ def pbExtractText pbDisposeMessageWindow(msgwindow) return end - pbMessageDisplay(msgwindow,_INTL("Please wait.\\wtnp[0]")) + pbMessageDisplay(msgwindow, _INTL("Please wait.\\wtnp[0]")) MessageTypes.extract("intl.txt") - pbMessageDisplay(msgwindow,_INTL("All text in the game was extracted and saved to intl.txt.\1")) - pbMessageDisplay(msgwindow,_INTL("To localize the text for a particular language, translate every second line in the file.\1")) - pbMessageDisplay(msgwindow,_INTL("After translating, choose \"Compile Text.\"")) + pbMessageDisplay(msgwindow, _INTL("All text in the game was extracted and saved to intl.txt.\1")) + pbMessageDisplay(msgwindow, _INTL("To localize the text for a particular language, translate every second line in the file.\1")) + pbMessageDisplay(msgwindow, _INTL("After translating, choose \"Compile Text.\"")) pbDisposeMessageWindow(msgwindow) end def pbCompileTextUI msgwindow = pbCreateMessageWindow - pbMessageDisplay(msgwindow,_INTL("Please wait.\\wtnp[0]")) + pbMessageDisplay(msgwindow, _INTL("Please wait.\\wtnp[0]")) begin pbCompileText - pbMessageDisplay(msgwindow,_INTL("Successfully compiled text and saved it to intl.dat.\1")) - pbMessageDisplay(msgwindow,_INTL("To use the file in a game, place the file in the Data folder under a different name, and edit the Settings::LANGUAGES array in the scripts.")) + pbMessageDisplay(msgwindow, _INTL("Successfully compiled text and saved it to intl.dat.\1")) + pbMessageDisplay(msgwindow, _INTL("To use the file in a game, place the file in the Data folder under a different name, and edit the Settings::LANGUAGES array in the scripts.")) rescue RuntimeError - pbMessageDisplay(msgwindow,_INTL("Failed to compile text: {1}",$!.message)) + pbMessageDisplay(msgwindow, _INTL("Failed to compile text: {1}", $!.message)) end pbDisposeMessageWindow(msgwindow) end @@ -555,28 +555,28 @@ def pbExportAllAnimations if animations msgwindow = pbCreateMessageWindow for anim in animations - next if !anim || anim.length==0 || anim.name=="" - pbMessageDisplay(msgwindow,anim.name,false) + next if !anim || anim.length == 0 || anim.name == "" + pbMessageDisplay(msgwindow, anim.name, false) Graphics.update - safename = anim.name.gsub(/\W/,"_") + safename = anim.name.gsub(/\W/, "_") Dir.mkdir("Animations/#{safename}") rescue nil - File.open("Animations/#{safename}/#{safename}.anm","wb") { |f| + File.open("Animations/#{safename}/#{safename}.anm", "wb") { |f| f.write(dumpBase64Anim(anim)) } - if anim.graphic && anim.graphic!="" - graphicname = RTP.getImagePath("Graphics/Animations/"+anim.graphic) - pbSafeCopyFile(graphicname,"Animations/#{safename}/"+File.basename(graphicname)) + if anim.graphic && anim.graphic != "" + graphicname = RTP.getImagePath("Graphics/Animations/" + anim.graphic) + pbSafeCopyFile(graphicname, "Animations/#{safename}/" + File.basename(graphicname)) end for timing in anim.timing - if !timing.timingType || timing.timingType==0 - if timing.name && timing.name!="" - audioName = RTP.getAudioPath("Audio/SE/Anim/"+timing.name) - pbSafeCopyFile(audioName,"Animations/#{safename}/"+File.basename(audioName)) + if !timing.timingType || timing.timingType == 0 + if timing.name && timing.name != "" + audioName = RTP.getAudioPath("Audio/SE/Anim/" + timing.name) + pbSafeCopyFile(audioName, "Animations/#{safename}/" + File.basename(audioName)) end - elsif timing.timingType==1 || timing.timingType==3 - if timing.name && timing.name!="" - graphicname = RTP.getImagePath("Graphics/Animations/"+timing.name) - pbSafeCopyFile(graphicname,"Animations/#{safename}/"+File.basename(graphicname)) + elsif timing.timingType == 1 || timing.timingType == 3 + if timing.name && timing.name != "" + graphicname = RTP.getImagePath("Graphics/Animations/" + timing.name) + pbSafeCopyFile(graphicname, "Animations/#{safename}/" + File.basename(graphicname)) end end end @@ -587,7 +587,7 @@ def pbExportAllAnimations pbMessage(_INTL("There are no animations to export.")) end rescue - p $!.message,$!.backtrace + p $!.message, $!.backtrace pbMessage(_INTL("The export failed.")) end end @@ -596,59 +596,59 @@ def pbImportAllAnimations animationFolders = [] if safeIsDirectory?("Animations") Dir.foreach("Animations") { |fb| - f = "Animations/"+fb - if safeIsDirectory?(f) && fb!="." && fb!=".." + f = "Animations/" + fb + if safeIsDirectory?(f) && fb != "." && fb != ".." animationFolders.push(f) end } end - if animationFolders.length==0 + if animationFolders.length == 0 pbMessage(_INTL("There are no animations to import. Put each animation in a folder within the Animations folder.")) else msgwindow = pbCreateMessageWindow animations = pbLoadBattleAnimations animations = PBAnimations.new if !animations for folder in animationFolders - pbMessageDisplay(msgwindow,folder,false) + pbMessageDisplay(msgwindow, folder, false) Graphics.update audios = [] - files = Dir.glob(folder+"/*.*") + files = Dir.glob(folder + "/*.*") %w[wav ogg mid wma].each { |ext| # mp3 upext = ext.upcase - audios.concat(files.find_all { |f| f[f.length-3,3]==ext }) - audios.concat(files.find_all { |f| f[f.length-3,3]==upext }) + audios.concat(files.find_all { |f| f[f.length - 3, 3] == ext }) + audios.concat(files.find_all { |f| f[f.length - 3, 3] == upext }) } for audio in audios - pbSafeCopyFile(audio,RTP.getAudioPath("Audio/SE/Anim/"+File.basename(audio)),"Audio/SE/Anim/"+File.basename(audio)) + pbSafeCopyFile(audio, RTP.getAudioPath("Audio/SE/Anim/" + File.basename(audio)), "Audio/SE/Anim/" + File.basename(audio)) end images = [] %w[png gif].each { |ext| # jpg jpeg bmp upext = ext.upcase - images.concat(files.find_all { |f| f[f.length-3,3]==ext }) - images.concat(files.find_all { |f| f[f.length-3,3]==upext }) + images.concat(files.find_all { |f| f[f.length - 3, 3] == ext }) + images.concat(files.find_all { |f| f[f.length - 3, 3] == upext }) } for image in images - pbSafeCopyFile(image,RTP.getImagePath("Graphics/Animations/"+File.basename(image)),"Graphics/Animations/"+File.basename(image)) + pbSafeCopyFile(image, RTP.getImagePath("Graphics/Animations/" + File.basename(image)), "Graphics/Animations/" + File.basename(image)) end - Dir.glob(folder+"/*.anm") { |f| + Dir.glob(folder + "/*.anm") { |f| textdata = loadBase64Anim(IO.read(f)) rescue nil if textdata && textdata.is_a?(PBAnimation) - index = pbAllocateAnimation(animations,textdata.name) + index = pbAllocateAnimation(animations, textdata.name) missingFiles = [] - textdata.name = File.basename(folder) if textdata.name=="" + textdata.name = File.basename(folder) if textdata.name == "" textdata.id = -1 # This is not an RPG Maker XP animation pbConvertAnimToNewFormat(textdata) - if textdata.graphic && textdata.graphic!="" - if !safeExists?(folder+"/"+textdata.graphic) && - !FileTest.image_exist?("Graphics/Animations/"+textdata.graphic) + if textdata.graphic && textdata.graphic != "" + if !safeExists?(folder + "/" + textdata.graphic) && + !FileTest.image_exist?("Graphics/Animations/" + textdata.graphic) textdata.graphic = "" missingFiles.push(textdata.graphic) end end for timing in textdata.timing - if timing.name && timing.name!="" - if !safeExists?(folder+"/"+timing.name) && - !FileTest.audio_exist?("Audio/SE/Anim/"+timing.name) + if timing.name && timing.name != "" + if !safeExists?(folder + "/" + timing.name) && + !FileTest.audio_exist?("Audio/SE/Anim/" + timing.name) timing.name = "" missingFiles.push(timing.name) end @@ -658,7 +658,7 @@ def pbImportAllAnimations end } end - save_data(animations,"Data/PkmnAnimations.rxdata") + save_data(animations, "Data/PkmnAnimations.rxdata") $game_temp.battle_animations_data = nil pbDisposeMessageWindow(msgwindow) pbMessage(_INTL("All animations were imported.")) @@ -748,17 +748,17 @@ end #=============================================================================== class PokemonDebugPartyScreen def initialize - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @messageBox = Window_AdvancedTextPokemon.new("") @messageBox.viewport = @viewport @messageBox.visible = false @messageBox.letterbyletter = true - pbBottomLeftLines(@messageBox,2) + pbBottomLeftLines(@messageBox, 2) @helpWindow = Window_UnformattedTextPokemon.new("") @helpWindow.viewport = @viewport @helpWindow.visible = true - pbBottomLeftLines(@helpWindow,1) + pbBottomLeftLines(@helpWindow, 1) end def pbEndScreen @@ -796,11 +796,11 @@ class PokemonDebugPartyScreen @messageBox.text = text @messageBox.visible = true @helpWindow.visible = false - using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])) { + using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { cmdwindow.visible = false pbBottomRight(cmdwindow) cmdwindow.y -= @messageBox.height - cmdwindow.z = @viewport.z+1 + cmdwindow.z = @viewport.z + 1 loop do Graphics.update Input.update @@ -812,7 +812,7 @@ class PokemonDebugPartyScreen ret = false break elsif Input.trigger?(Input::USE) && @messageBox.resume - ret = (cmdwindow.index==0) + ret = (cmdwindow.index == 0) break end end @@ -823,14 +823,14 @@ class PokemonDebugPartyScreen return ret end - def pbShowCommands(text,commands,index = 0) + def pbShowCommands(text, commands, index = 0) ret = -1 @helpWindow.visible = true using(cmdwindow = Window_CommandPokemonColor.new(commands)) { - cmdwindow.z = @viewport.z+1 + cmdwindow.z = @viewport.z + 1 cmdwindow.index = index pbBottomRight(cmdwindow) - @helpWindow.resizeHeightToFit(text,Graphics.width-cmdwindow.width) + @helpWindow.resizeHeightToFit(text, Graphics.width - cmdwindow.width) @helpWindow.text = text pbBottomLeft(@helpWindow) loop do @@ -852,16 +852,16 @@ class PokemonDebugPartyScreen return ret end - def pbChooseMove(pkmn,text,index = 0) + def pbChooseMove(pkmn, text, index = 0) moveNames = [] for i in pkmn.moves - if i.total_pp<=0 - moveNames.push(_INTL("{1} (PP: ---)",i.name)) + if i.total_pp <= 0 + moveNames.push(_INTL("{1} (PP: ---)", i.name)) else - moveNames.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp)) + moveNames.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp)) end end - return pbShowCommands(text,moveNames,index) + return pbShowCommands(text, moveNames, index) end def pbRefreshSingle(index); end diff --git a/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb index 5af51f606..415fa77bf 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/005_Debug_PokemonCommands.rb @@ -354,7 +354,7 @@ PokemonDebugMenuCommands.register("hiddenvalues", { end end when 2 # Randomise pID - pkmn.personalID = rand(2 ** 16) | rand(2 ** 16) << 16 + pkmn.personalID = rand(2**16) | rand(2**16) << 16 pkmn.calc_stats screen.pbRefreshSingle(pkmnid) end diff --git a/Data/Scripts/020_Debug/003_Debug menus/007_Debug_BattleCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/007_Debug_BattleCommands.rb index 7108e0ffe..9ca5ae563 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/007_Debug_BattleCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/007_Debug_BattleCommands.rb @@ -154,10 +154,9 @@ BattleDebugMenuCommands.register("weather", { msg += _INTL("Duration : Infinite") end end - cmd = pbMessage("\\ts[]" + msg, [ - _INTL("Change type"), - _INTL("Change duration"), - _INTL("Clear weather")], -1, nil, cmd) + cmd = pbMessage("\\ts[]" + msg, [_INTL("Change type"), + _INTL("Change duration"), + _INTL("Clear weather")], -1, nil, cmd) break if cmd < 0 case cmd when 0 # Change type @@ -216,10 +215,9 @@ BattleDebugMenuCommands.register("terrain", { msg += _INTL("Duration : Infinite") end end - cmd = pbMessage("\\ts[]" + msg, [ - _INTL("Change type"), - _INTL("Change duration"), - _INTL("Clear terrain")], -1, nil, cmd) + cmd = pbMessage("\\ts[]" + msg, [_INTL("Change type"), + _INTL("Change duration"), + _INTL("Clear terrain")], -1, nil, cmd) break if cmd < 0 case cmd when 0 # Change type @@ -270,9 +268,8 @@ BattleDebugMenuCommands.register("environment", { msg = _INTL("Environment: {1}", environment_data.name || _INTL("Unknown")) msg += "\r\n" msg += _INTL("Time of day: {1}", [_INTL("Day"), _INTL("Evening"), _INTL("Night")][battle.time]) - cmd = pbMessage("\\ts[]" + msg, [ - _INTL("Change environment"), - _INTL("Change time of day")], -1, nil, cmd) + cmd = pbMessage("\\ts[]" + msg, [_INTL("Change environment"), + _INTL("Change time of day")], -1, nil, cmd) break if cmd < 0 case cmd when 0 # Change environment @@ -379,7 +376,6 @@ BattleDebugMenuCommands.register("speed_order", { "description" => _INTL("Show all battlers in order from fastest to slowest."), "always_show" => true, "effect" => proc { |battle| - battlers = [] battlers = battle.allBattlers.map { |b| [b, b.pbSpeed] } battlers.sort! { |a, b| b[1] <=> a[1] } commands = [] diff --git a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlerCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlerCommands.rb index 113b9d5b4..8f375f81b 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlerCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/008_Debug_BattlerCommands.rb @@ -255,9 +255,8 @@ BattlerDebugMenuCommands.register("hiddenvalues", { cmd = 0 loop do persid = sprintf("0x%08X", pkmn.personalID) - cmd = pbMessage("\\ts[]" + _INTL("Personal ID is {1}.", persid), [ - _INTL("Set EVs"), - _INTL("Set IVs")], -1, nil, cmd) + cmd = pbMessage("\\ts[]" + _INTL("Personal ID is {1}.", persid), + [_INTL("Set EVs"), _INTL("Set IVs")], -1, nil, cmd) break if cmd < 0 case cmd when 0 # Set EVs @@ -506,10 +505,8 @@ BattlerDebugMenuCommands.register("setmovepp", { cmd2 = 0 loop do msg = _INTL("{1}: PP {2}/{3} (PP Up {4}/3)", move_name, move.pp, move.total_pp, move.ppup) - cmd2 = pbMessage("\\ts[]" + msg, [ - _INTL("Set PP"), - _INTL("Full PP"), - _INTL("Set PP Up")], -1, nil, cmd2) + cmd2 = pbMessage("\\ts[]" + msg, + [_INTL("Set PP"), _INTL("Full PP"), _INTL("Set PP Up")], -1, nil, cmd2) break if cmd2 < 0 case cmd2 when 0 # Change PP @@ -680,10 +677,8 @@ BattlerDebugMenuCommands.register("setgender", { cmd = 0 loop do msg = [_INTL("Gender is male."), _INTL("Gender is female.")][pkmn.male? ? 0 : 1] - cmd = pbMessage("\\ts[]" + msg, [ - _INTL("Make male"), - _INTL("Make female"), - _INTL("Reset")], -1, nil, cmd) + cmd = pbMessage("\\ts[]" + msg, + [_INTL("Make male"), _INTL("Make female"), _INTL("Reset")], -1, nil, cmd) break if cmd < 0 case cmd when 0 # Make male @@ -747,11 +742,11 @@ BattlerDebugMenuCommands.register("setshininess", { loop do msg_idx = pkmn.shiny? ? (pkmn.super_shiny? ? 1 : 0) : 2 msg = [_INTL("Is shiny."), _INTL("Is super shiny."), _INTL("Is normal (not shiny).")][msg_idx] - cmd = pbMessage("\\ts[]" + msg, [ - _INTL("Make shiny"), - _INTL("Make super shiny"), - _INTL("Make normal"), - _INTL("Reset")], -1, nil, cmd) + cmd = pbMessage("\\ts[]" + msg, + [_INTL("Make shiny"), + _INTL("Make super shiny"), + _INTL("Make normal"), + _INTL("Reset")], -1, nil, cmd) break if cmd < 0 case cmd when 0 # Make shiny diff --git a/Data/Scripts/020_Debug/003_Editor_Listers.rb b/Data/Scripts/020_Debug/003_Editor_Listers.rb index 4c46f54b1..43a55e1f3 100644 --- a/Data/Scripts/020_Debug/003_Editor_Listers.rb +++ b/Data/Scripts/020_Debug/003_Editor_Listers.rb @@ -10,8 +10,8 @@ def pbListWindow(cmds, width = Graphics.width / 2) return list end -def pbListScreen(title,lister) - viewport = Viewport.new(0,0,Graphics.width,Graphics.height) +def pbListScreen(title, lister) + viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 list = pbListWindow([]) list.viewport = viewport @@ -23,7 +23,7 @@ def pbListScreen(title,lister) selectedmap = -1 commands = lister.commands selindex = lister.startIndex - if commands.length==0 + if commands.length == 0 value = lister.value(-1) lister.dispose title.dispose @@ -37,7 +37,7 @@ def pbListScreen(title,lister) Graphics.update Input.update list.update - if list.index!=selectedmap + if list.index != selectedmap lister.refresh(list.index) selectedmap = list.index end @@ -57,7 +57,7 @@ def pbListScreen(title,lister) return value end -def pbListScreenBlock(title,lister) +def pbListScreenBlock(title, lister) viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport.z = 99999 list = pbListWindow([], Graphics.width / 2) @@ -70,7 +70,7 @@ def pbListScreenBlock(title,lister) selectedmap = -1 commands = lister.commands selindex = lister.startIndex - if commands.length==0 + if commands.length == 0 value = lister.value(-1) lister.dispose title.dispose @@ -84,14 +84,14 @@ def pbListScreenBlock(title,lister) Graphics.update Input.update list.update - if list.index!=selectedmap + if list.index != selectedmap lister.refresh(list.index) selectedmap = list.index end if Input.trigger?(Input::ACTION) yield(Input::ACTION, lister.value(selectedmap)) list.commands = lister.commands - if list.index==list.commands.length + if list.index == list.commands.length list.index = list.commands.length end lister.refresh(list.index) @@ -100,7 +100,7 @@ def pbListScreenBlock(title,lister) elsif Input.trigger?(Input::USE) yield(Input::USE, lister.value(selectedmap)) list.commands = lister.commands - if list.index==list.commands.length + if list.index == list.commands.length list.index = list.commands.length end lister.refresh(list.index) @@ -117,8 +117,8 @@ end # #=============================================================================== class GraphicsLister - def initialize(folder,selection) - @sprite = IconSprite.new(0,0) + def initialize(folder, selection) + @sprite = IconSprite.new(0, 0) @sprite.bitmap = nil @sprite.x = Graphics.width * 3 / 4 @sprite.y = (Graphics.height - 64) / 2 + 64 @@ -158,26 +158,26 @@ class GraphicsLister } @commands.sort! @commands.length.times do |i| - @index = i if @commands[i]==@selection + @index = i if @commands[i] == @selection end - pbMessage(_INTL("There are no files.")) if @commands.length==0 + pbMessage(_INTL("There are no files.")) if @commands.length == 0 return @commands end def value(index) - return (index<0) ? "" : @commands[index] + return (index < 0) ? "" : @commands[index] end def refresh(index) - return if index<0 - @sprite.setBitmap(@folder+@commands[index]) + return if index < 0 + @sprite.setBitmap(@folder + @commands[index]) sprite_width = @sprite.bitmap.width sprite_height = @sprite.bitmap.height - @sprite.ox = sprite_width/2 - @sprite.oy = sprite_height/2 - scale_x = (Graphics.width/2).to_f/sprite_width - scale_y = (Graphics.height-64).to_f/sprite_height - if scale_x<1.0 || scale_y<1.0 + @sprite.ox = sprite_width / 2 + @sprite.oy = sprite_height / 2 + scale_x = (Graphics.width / 2).to_f / sprite_width + scale_y = (Graphics.height - 64).to_f / sprite_height + if scale_x < 1.0 || scale_y < 1.0 min_scale = [scale_x, scale_y].min @sprite.zoom_x = @sprite.zoom_y = min_scale else @@ -190,7 +190,7 @@ end # #=============================================================================== class MusicFileLister - def initialize(bgm,setting) + def initialize(bgm, setting) @oldbgm = getPlayingBGM @commands = [] @bgm = bgm @@ -234,22 +234,22 @@ class MusicFileLister } @commands.sort! @commands.length.times do |i| - @index = i if @commands[i]==@setting + @index = i if @commands[i] == @setting end - pbMessage(_INTL("There are no files.")) if @commands.length==0 + pbMessage(_INTL("There are no files.")) if @commands.length == 0 return @commands end def value(index) - return (index<0) ? "" : @commands[index] + return (index < 0) ? "" : @commands[index] end def refresh(index) - return if index<0 + return if index < 0 if @bgm pbPlayBGM(@commands[index]) else - pbPlayBGM("../../Audio/ME/"+@commands[index]) + pbPlayBGM("../../Audio/ME/" + @commands[index]) end end end @@ -302,7 +302,7 @@ end # #=============================================================================== class MapLister - def initialize(selmap,addGlobal = false) + def initialize(selmap, addGlobal = false) @sprite = SpriteWrapper.new @sprite.bitmap = nil @sprite.x = Graphics.width * 3 / 4 @@ -313,7 +313,7 @@ class MapLister @addGlobalOffset = (addGlobal) ? 1 : 0 @index = 0 for i in 0...@maps.length - @index = i+@addGlobalOffset if @maps[i][0]==selmap + @index = i + @addGlobalOffset if @maps[i][0] == selmap end end @@ -332,29 +332,29 @@ class MapLister def commands @commands.clear - if @addGlobalOffset==1 + if @addGlobalOffset == 1 @commands.push(_INTL("[GLOBAL]")) end for i in 0...@maps.length - @commands.push(sprintf("%s%03d %s",(" "*@maps[i][2]),@maps[i][0],@maps[i][1])) + @commands.push(sprintf("%s%03d %s", (" " * @maps[i][2]), @maps[i][0], @maps[i][1])) end return @commands end def value(index) - if @addGlobalOffset==1 - return 0 if index==0 + if @addGlobalOffset == 1 + return 0 if index == 0 end - return (index<0) ? -1 : @maps[index-@addGlobalOffset][0] + return (index < 0) ? -1 : @maps[index - @addGlobalOffset][0] end def refresh(index) @sprite.bitmap.dispose if @sprite.bitmap - return if index<0 - return if index==0 && @addGlobalOffset==1 - @sprite.bitmap = createMinimap(@maps[index-@addGlobalOffset][0]) - @sprite.ox = @sprite.bitmap.width/2 - @sprite.oy = @sprite.bitmap.height/2 + return if index < 0 + return if index == 0 && @addGlobalOffset == 1 + @sprite.bitmap = createMinimap(@maps[index - @addGlobalOffset][0]) + @sprite.ox = @sprite.bitmap.width / 2 + @sprite.oy = @sprite.bitmap.height / 2 end end @@ -549,7 +549,7 @@ end # #=============================================================================== class TrainerBattleLister - def initialize(selection,includeNew) + def initialize(selection, includeNew) @sprite = IconSprite.new(Graphics.width * 3 / 4, (Graphics.height / 2) + 32) @sprite.z = 2 @pkmnList = Window_UnformattedTextPokemon.newWithSize("", @@ -653,7 +653,7 @@ class TrainerBattleLister end end @pkmnList.text = text - @pkmnList.resizeHeightToFit(text,Graphics.width / 2) + @pkmnList.resizeHeightToFit(text, Graphics.width / 2) @pkmnList.y = Graphics.height - @pkmnList.height end end diff --git a/Data/Scripts/021_Compiler/001_Compiler.rb b/Data/Scripts/021_Compiler/001_Compiler.rb index d7344c6c4..49f435d40 100644 --- a/Data/Scripts/021_Compiler/001_Compiler.rb +++ b/Data/Scripts/021_Compiler/001_Compiler.rb @@ -21,31 +21,31 @@ module FileLineData @value = nil end - def self.setSection(section,key,value) + def self.setSection(section, key, value) @section = section @key = key - if value && value.length>200 - @value = _INTL("{1}...",value[0,200]) + if value && value.length > 200 + @value = _INTL("{1}...", value[0, 200]) else @value = (value) ? value.clone : "" end end - def self.setLine(line,lineno) + def self.setLine(line, lineno) @section = nil - @linedata = (line && line.length>200) ? sprintf("%s...",line[0,200]) : line.clone + @linedata = (line && line.length > 200) ? sprintf("%s...", line[0, 200]) : line.clone @lineno = lineno end def self.linereport if @section - if @key!=nil - return _INTL("File {1}, section {2}, key {3}\r\n{4}\r\n\r\n",@file,@section,@key,@value) + if @key != nil + return _INTL("File {1}, section {2}, key {3}\r\n{4}\r\n\r\n", @file, @section, @key, @value) else - return _INTL("File {1}, section {2}\r\n{3}\r\n\r\n",@file,@section,@value) + return _INTL("File {1}, section {2}\r\n{3}\r\n\r\n", @file, @section, @value) end else - return _INTL("File {1}, line {2}\r\n{3}\r\n\r\n",@file,@lineno,@linedata) + return _INTL("File {1}, line {2}\r\n{3}\r\n\r\n", @file, @lineno, @linedata) end end end @@ -70,23 +70,23 @@ module Compiler end def prepline(line) - line.sub!(/\s*\#.*$/,"") - line.sub!(/^\s+/,"") - line.sub!(/\s+$/,"") + line.sub!(/\s*\#.*$/, "") + line.sub!(/^\s+/, "") + line.sub!(/\s+$/, "") return line end - def csvQuote(str,always = false) + def csvQuote(str, always = false) return "" if nil_or_empty?(str) if always || str[/[,\"]/] # || str[/^\s/] || str[/\s$/] || str[/^#/] - str = str.gsub(/[\"]/,"\\\"") + str = str.gsub(/[\"]/, "\\\"") str = "\"#{str}\"" end return str end def csvQuoteAlways(str) - return csvQuote(str,true) + return csvQuote(str, true) end #============================================================================= @@ -98,54 +98,54 @@ module Compiler sectionname = nil lastsection = {} f.each_line { |line| - if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF - line = line[3,line.length-3] + if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF + line = line[3, line.length - 3] end if !line[/^\#/] && !line[/^\s*$/] line = prepline(line) if line[/^\s*\[\s*(.*)\s*\]\s*$/] # Of the format: [something] - yield lastsection,sectionname if havesection + yield lastsection, sectionname if havesection sectionname = $~[1] havesection = true lastsection = {} else - if sectionname==nil - FileLineData.setLine(line,lineno) - raise _INTL("Expected a section at the beginning of the file. This error may also occur if the file was not saved in UTF-8.\r\n{1}",FileLineData.linereport) + if sectionname == nil + FileLineData.setLine(line, lineno) + raise _INTL("Expected a section at the beginning of the file. This error may also occur if the file was not saved in UTF-8.\r\n{1}", FileLineData.linereport) end if !line[/^\s*(\w+)\s*=\s*(.*)$/] - FileLineData.setSection(sectionname,nil,line) - raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}",FileLineData.linereport) + FileLineData.setSection(sectionname, nil, line) + raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}", FileLineData.linereport) end r1 = $~[1] r2 = $~[2] - lastsection[r1] = r2.gsub(/\s+$/,"") + lastsection[r1] = r2.gsub(/\s+$/, "") end end lineno += 1 - Graphics.update if lineno%1000==0 + Graphics.update if lineno % 1000 == 0 } - yield lastsection,sectionname if havesection + yield lastsection, sectionname if havesection end # Used for types.txt, pokemon.txt, battle_facility_lists.txt and Battle Tower trainers PBS files def pbEachFileSection(f) - pbEachFileSectionEx(f) { |section,name| - yield section,name if block_given? && name[/^.+$/] + pbEachFileSectionEx(f) { |section, name| + yield section, name if block_given? && name[/^.+$/] } end # Used for metadata.txt and map_metadata.txt def pbEachFileSectionNumbered(f) - pbEachFileSectionEx(f) { |section,name| - yield section,name.to_i if block_given? && name[/^\d+$/] + pbEachFileSectionEx(f) { |section, name| + yield section, name.to_i if block_given? && name[/^\d+$/] } end # Used for pokemon_forms.txt def pbEachFileSectionPokemonForms(f) - pbEachFileSectionEx(f) { |section,name| - yield section,name if block_given? && name[/^\w+[-,\s]{1}\d+$/] + pbEachFileSectionEx(f) { |section, name| + yield section, name if block_given? && name[/^\w+[-,\s]{1}\d+$/] } end @@ -156,34 +156,34 @@ module Compiler sectionname = nil lastsection = [] f.each_line { |line| - if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF - line = line[3,line.length-3] + if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF + line = line[3, line.length - 3] end if !line[/^\#/] && !line[/^\s*$/] if line[/^\s*\[\s*(.+?)\s*\]\s*$/] - yield lastsection,sectionname if havesection + yield lastsection, sectionname if havesection sectionname = $~[1] lastsection = [] havesection = true else - if sectionname==nil - raise _INTL("Expected a section at the beginning of the file (line {1}). Sections begin with '[name of section]'",lineno) + if sectionname == nil + raise _INTL("Expected a section at the beginning of the file (line {1}). Sections begin with '[name of section]'", lineno) end - lastsection.push(line.gsub(/^\s+/,"").gsub(/\s+$/,"")) + lastsection.push(line.gsub(/^\s+/, "").gsub(/\s+$/, "")) end end lineno += 1 - Graphics.update if lineno%500==0 + Graphics.update if lineno % 500 == 0 } - yield lastsection,sectionname if havesection + yield lastsection, sectionname if havesection end # Unused def pbEachCommentedLine(f) lineno = 1 f.each_line { |line| - if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF - line = line[3,line.length-3] + if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF + line = line[3, line.length - 3] end yield line, lineno if !line[/^\#/] && !line[/^\s*$/] lineno += 1 @@ -192,15 +192,15 @@ module Compiler # Used for many PBS files def pbCompilerEachCommentedLine(filename) - File.open(filename,"rb") { |f| + File.open(filename, "rb") { |f| FileLineData.file = filename lineno = 1 f.each_line { |line| - if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF - line = line[3,line.length-3] + if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF + line = line[3, line.length - 3] end if !line[/^\#/] && !line[/^\s*$/] - FileLineData.setLine(line,lineno) + FileLineData.setLine(line, lineno) yield line, lineno end lineno += 1 @@ -212,8 +212,8 @@ module Compiler def pbEachPreppedLine(f) lineno = 1 f.each_line { |line| - if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF - line = line[3,line.length-3] + if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF + line = line[3, line.length - 3] end line = prepline(line) yield line, lineno if !line[/^\#/] && !line[/^\s*$/] @@ -223,16 +223,16 @@ module Compiler # Used for map_connections.txt, abilities.txt, moves.txt, regional_dexes.txt def pbCompilerEachPreppedLine(filename) - File.open(filename,"rb") { |f| + File.open(filename, "rb") { |f| FileLineData.file = filename lineno = 1 f.each_line { |line| - if lineno==1 && line[0].ord==0xEF && line[1].ord==0xBB && line[2].ord==0xBF - line = line[3,line.length-3] + if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF + line = line[3, line.length - 3] end line = prepline(line) if !line[/^\#/] && !line[/^\s*$/] - FileLineData.setLine(line,lineno) + FileLineData.setLine(line, lineno) yield line, lineno end lineno += 1 @@ -245,89 +245,89 @@ module Compiler #============================================================================= def csvfield!(str) ret = "" - str.sub!(/^\s*/,"") - if str[0,1]=="\"" - str[0,1] = "" + str.sub!(/^\s*/, "") + if str[0, 1] == "\"" + str[0, 1] = "" escaped = false fieldbytes = 0 str.scan(/./) do |s| fieldbytes += s.length - break if s=="\"" && !escaped - if s=="\\" && !escaped + break if s == "\"" && !escaped + if s == "\\" && !escaped escaped = true else ret += s escaped = false end end - str[0,fieldbytes] = "" + str[0, fieldbytes] = "" if !str[/^\s*,/] && !str[/^\s*$/] - raise _INTL("Invalid quoted field (in: {1})\r\n{2}",str,FileLineData.linereport) + raise _INTL("Invalid quoted field (in: {1})\r\n{2}", str, FileLineData.linereport) end - str[0,str.length] = $~.post_match + str[0, str.length] = $~.post_match else if str[/,/] - str[0,str.length] = $~.post_match + str[0, str.length] = $~.post_match ret = $~.pre_match else ret = str.clone - str[0,str.length] = "" + str[0, str.length] = "" end - ret.gsub!(/\s+$/,"") + ret.gsub!(/\s+$/, "") end 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 end - raise _INTL("Field {1} is not a Boolean value (true, false, 1, 0)\r\n{2}",field,FileLineData.linereport) + 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) + raise _INTL("Field {1} is not an integer\r\n{2}", ret, FileLineData.linereport) end 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) + raise _INTL("Field {1} is not a positive integer\r\n{2}", ret, FileLineData.linereport) end 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) + 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) + 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) + return checkEnumField(ret, enumer) end - def checkEnumField(ret,enumer) + def checkEnumField(ret, enumer) if enumer.is_a?(Module) begin if nil_or_empty?(ret) || !enumer.const_defined?(ret) - raise _INTL("Undefined value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport) + raise _INTL("Undefined value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport) end rescue NameError - raise _INTL("Incorrect value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport) + raise _INTL("Incorrect value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport) end return enumer.const_get(ret.to_sym) elsif enumer.is_a?(Symbol) || enumer.is_a?(String) @@ -345,29 +345,29 @@ module Compiler enumer = Object.const_get(enumer.to_sym) begin if nil_or_empty?(ret) || !enumer.const_defined?(ret) - raise _INTL("Undefined value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport) + raise _INTL("Undefined value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport) end rescue NameError - raise _INTL("Incorrect value {1} in {2}\r\n{3}",ret,enumer.name,FileLineData.linereport) + raise _INTL("Incorrect value {1} in {2}\r\n{3}", ret, enumer.name, FileLineData.linereport) end return enumer.const_get(ret.to_sym) elsif enumer.is_a?(Array) - idx = findIndex(enumer) { |item| ret==item } - if idx<0 - raise _INTL("Undefined value {1} (expected one of: {2})\r\n{3}",ret,enumer.inspect,FileLineData.linereport) + idx = findIndex(enumer) { |item| ret == item } + if idx < 0 + raise _INTL("Undefined value {1} (expected one of: {2})\r\n{3}", ret, enumer.inspect, FileLineData.linereport) end return idx elsif enumer.is_a?(Hash) value = enumer[ret] - if value==nil - raise _INTL("Undefined value {1} (expected one of: {2})\r\n{3}",ret,enumer.keys.inspect,FileLineData.linereport) + if value == nil + raise _INTL("Undefined value {1} (expected one of: {2})\r\n{3}", ret, enumer.keys.inspect, FileLineData.linereport) end return value end - raise _INTL("Enumeration not defined\r\n{1}",FileLineData.linereport) + raise _INTL("Enumeration not defined\r\n{1}", FileLineData.linereport) end - def checkEnumFieldOrNil(ret,enumer) + def checkEnumFieldOrNil(ret, enumer) if enumer.is_a?(Module) return nil if nil_or_empty?(ret) || !(enumer.const_defined?(ret) rescue false) return enumer.const_get(ret.to_sym) @@ -381,8 +381,8 @@ module Compiler return nil if nil_or_empty?(ret) || !(enumer.const_defined?(ret) rescue false) return enumer.const_get(ret.to_sym) elsif enumer.is_a?(Array) - idx = findIndex(enumer) { |item| ret==item } - return nil if idx<0 + idx = findIndex(enumer) { |item| ret == item } + return nil if idx < 0 return idx elsif enumer.is_a?(Hash) return enumer[ret] @@ -393,11 +393,11 @@ module Compiler #============================================================================= # Convert a string to values using a schema #============================================================================= - def pbGetCsvRecord(rec,lineno,schema) + def pbGetCsvRecord(rec, lineno, schema) record = [] repeat = false start = 0 - if schema[1][0,1]=="*" + if schema[1][0, 1] == "*" repeat = true start = 1 end @@ -405,49 +405,49 @@ module Compiler begin subrecord = [] for i in start...schema[1].length - chr = schema[1][i,1] + chr = schema[1][i, 1] case chr when "i" # Integer - subrecord.push(csvInt!(rec,lineno)) + subrecord.push(csvInt!(rec, lineno)) when "I" # Optional integer field = csvfield!(rec) if nil_or_empty?(field) subrecord.push(nil) elsif !field[/^\-?\d+$/] - raise _INTL("Field {1} is not an integer\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field {1} is not an integer\r\n{2}", field, FileLineData.linereport) else subrecord.push(field.to_i) end when "u" # Positive integer or zero - subrecord.push(csvPosInt!(rec,lineno)) + subrecord.push(csvPosInt!(rec, lineno)) when "U" # Optional positive integer or zero field = csvfield!(rec) if nil_or_empty?(field) subrecord.push(nil) elsif !field[/^\d+$/] - raise _INTL("Field '{1}' must be 0 or greater\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field '{1}' must be 0 or greater\r\n{2}", field, FileLineData.linereport) else subrecord.push(field.to_i) end when "v" # Positive integer - field = csvPosInt!(rec,lineno) - raise _INTL("Field '{1}' must be greater than 0\r\n{2}",field,FileLineData.linereport) if field==0 + field = csvPosInt!(rec, lineno) + raise _INTL("Field '{1}' must be greater than 0\r\n{2}", field, FileLineData.linereport) if field == 0 subrecord.push(field) when "V" # Optional positive integer field = csvfield!(rec) if nil_or_empty?(field) subrecord.push(nil) elsif !field[/^\d+$/] - raise _INTL("Field '{1}' must be greater than 0\r\n{2}",field,FileLineData.linereport) - elsif field.to_i==0 - raise _INTL("Field '{1}' must be greater than 0\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field '{1}' must be greater than 0\r\n{2}", field, FileLineData.linereport) + elsif field.to_i == 0 + raise _INTL("Field '{1}' must be greater than 0\r\n{2}", field, FileLineData.linereport) else subrecord.push(field.to_i) end when "x" # Hexadecimal number field = csvfield!(rec) if !field[/^[A-Fa-f0-9]+$/] - raise _INTL("Field '{1}' is not a hexadecimal number\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field '{1}' is not a hexadecimal number\r\n{2}", field, FileLineData.linereport) end subrecord.push(field.hex) when "X" # Optional hexadecimal number @@ -455,23 +455,23 @@ module Compiler if nil_or_empty?(field) subrecord.push(nil) elsif !field[/^[A-Fa-f0-9]+$/] - raise _INTL("Field '{1}' is not a hexadecimal number\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field '{1}' is not a hexadecimal number\r\n{2}", field, FileLineData.linereport) else subrecord.push(field.hex) end when "f" # Floating point number - subrecord.push(csvFloat!(rec,lineno)) + subrecord.push(csvFloat!(rec, lineno)) when "F" # Optional floating point number field = csvfield!(rec) if nil_or_empty?(field) subrecord.push(nil) elsif !field[/^\-?^\d*\.?\d*$/] - raise _INTL("Field {1} is not a floating point number\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field {1} is not a floating point number\r\n{2}", field, FileLineData.linereport) else subrecord.push(field.to_f) end when "b" # Boolean - subrecord.push(csvBoolean!(rec,lineno)) + subrecord.push(csvBoolean!(rec, lineno)) when "B" # Optional Boolean field = csvfield!(rec) if nil_or_empty?(field) @@ -484,7 +484,7 @@ module Compiler when "n" # Name field = csvfield!(rec) if !field[/^(?![0-9])\w+$/] - raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}", field, FileLineData.linereport) end subrecord.push(field) when "N" # Optional name @@ -492,7 +492,7 @@ module Compiler if nil_or_empty?(field) subrecord.push(nil) elsif !field[/^(?![0-9])\w+$/] - raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}",field,FileLineData.linereport) + raise _INTL("Field '{1}' must contain only letters, digits, and\r\nunderscores and can't begin with a number.\r\n{2}", field, FileLineData.linereport) else subrecord.push(field) end @@ -512,13 +512,13 @@ module Compiler rec = "" end when "e" # Enumerable - subrecord.push(csvEnumField!(rec,schema[2+i-start],"",FileLineData.linereport)) + subrecord.push(csvEnumField!(rec, schema[2 + i - start], "", FileLineData.linereport)) when "E" # Optional enumerable field = csvfield!(rec) - subrecord.push(checkEnumFieldOrNil(field,schema[2+i-start])) + subrecord.push(checkEnumFieldOrNil(field, schema[2 + i - start])) when "y" # Enumerable or integer field = csvfield!(rec) - subrecord.push(csvEnumFieldOrInt!(field,schema[2+i-start],"",FileLineData.linereport)) + subrecord.push(csvEnumFieldOrInt!(field, schema[2 + i - start], "", FileLineData.linereport)) when "Y" # Optional enumerable or integer field = csvfield!(rec) if nil_or_empty?(field) @@ -526,7 +526,7 @@ module Compiler elsif field[/^\-?\d+$/] subrecord.push(field.to_i) else - subrecord.push(checkEnumFieldOrNil(field,schema[2+i-start])) + subrecord.push(checkEnumFieldOrNil(field, schema[2 + i - start])) end end end @@ -545,7 +545,7 @@ module Compiler #============================================================================= # Write values to a file using a schema #============================================================================= - def pbWriteCsvRecord(record,file,schema) + def pbWriteCsvRecord(record, file, schema) rec = (record.is_a?(Array)) ? record.flatten : [record] start = (schema[1][0, 1] == "*") ? 1 : 0 index = -1 @@ -560,46 +560,46 @@ module Compiler file.write(csvQuote(value)) elsif value.is_a?(Symbol) file.write(csvQuote(value.to_s)) - elsif value==true + elsif value == true file.write("true") - elsif value==false + elsif value == false file.write("false") elsif value.is_a?(Numeric) case schema[1][i, 1] when "e", "E" # Enumerable - enumer = schema[2+i] + enumer = schema[2 + i] if enumer.is_a?(Array) file.write(enumer[value]) elsif enumer.is_a?(Symbol) || enumer.is_a?(String) mod = Object.const_get(enumer.to_sym) - file.write(getConstantName(mod,value)) + file.write(getConstantName(mod, value)) elsif enumer.is_a?(Module) - file.write(getConstantName(enumer,value)) + file.write(getConstantName(enumer, value)) elsif enumer.is_a?(Hash) for key in enumer.keys - if enumer[key]==value + if enumer[key] == value file.write(key) break end end end when "y", "Y" # Enumerable or integer - enumer = schema[2+i] + enumer = schema[2 + i] if enumer.is_a?(Array) - if enumer[value]!=nil + if enumer[value] != nil file.write(enumer[value]) else file.write(value) end elsif enumer.is_a?(Symbol) || enumer.is_a?(String) mod = Object.const_get(enumer.to_sym) - file.write(getConstantNameOrValue(mod,value)) + file.write(getConstantNameOrValue(mod, value)) elsif enumer.is_a?(Module) - file.write(getConstantNameOrValue(enumer,value)) + file.write(getConstantNameOrValue(enumer, value)) elsif enumer.is_a?(Hash) hasenum = false for key in enumer.keys - if enumer[key]==value + if enumer[key] == value file.write(key) hasenum = true break @@ -624,15 +624,15 @@ module Compiler # Last ditch attempt to figure out whether a constant is defined. #============================================================================= # Unused - def pbGetConst(mod,item,err) + def pbGetConst(mod, item, err) isDef = false begin mod = Object.const_get(mod) if mod.is_a?(Symbol) isDef = mod.const_defined?(item.to_sym) rescue - raise sprintf(err,item) + raise sprintf(err, item) end - raise sprintf(err,item) if !isDef + raise sprintf(err, item) if !isDef return mod.const_get(item.to_sym) end @@ -852,7 +852,7 @@ module Compiler compile_all(mustCompile) rescue Exception e = $! - raise e if "#{e.class}"=="Reset" || e.is_a?(Reset) || e.is_a?(SystemExit) + raise e if "#{e.class}" == "Reset" || e.is_a?(Reset) || e.is_a?(SystemExit) pbPrintException(e) for i in 0...dataFiles.length begin diff --git a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb index 4622edcf9..d458f8ce7 100644 --- a/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb +++ b/Data/Scripts/021_Compiler/002_Compiler_CompilePBS.rb @@ -16,24 +16,24 @@ module Compiler placenames = [] placedescs = [] sections = [] - pbCompilerEachCommentedLine(path) { |line,lineno| + pbCompilerEachCommentedLine(path) { |line, lineno| if line[/^\s*\[\s*(\d+)\s*\]\s*$/] currentmap = $~[1].to_i sections[currentmap] = [] else - if currentmap<0 - raise _INTL("Expected a section at the beginning of the file\r\n{1}",FileLineData.linereport) + if currentmap < 0 + raise _INTL("Expected a section at the beginning of the file\r\n{1}", FileLineData.linereport) end if !line[/^\s*(\w+)\s*=\s*(.*)$/] - raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}",FileLineData.linereport) + raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}", FileLineData.linereport) end settingname = $~[1] schema = nonglobaltypes[settingname] if schema - record = pbGetCsvRecord($~[2],lineno,schema) - if settingname=="Name" + record = pbGetCsvRecord($~[2], lineno, schema) + if settingname == "Name" rgnnames[currentmap] = record - elsif settingname=="Point" + elsif settingname == "Point" placenames.push(record[2]) placedescs.push(record[3]) sections[currentmap][schema[0]] = [] if !sections[currentmap][schema[0]] @@ -44,10 +44,10 @@ module Compiler end end } - save_data(sections,"Data/town_map.dat") - MessageTypes.setMessages(MessageTypes::RegionNames,rgnnames) - MessageTypes.setMessagesAsHash(MessageTypes::PlaceNames,placenames) - MessageTypes.setMessagesAsHash(MessageTypes::PlaceDescriptions,placedescs) + save_data(sections, "Data/town_map.dat") + MessageTypes.setMessages(MessageTypes::RegionNames, rgnnames) + MessageTypes.setMessagesAsHash(MessageTypes::PlaceNames, placenames) + MessageTypes.setMessagesAsHash(MessageTypes::PlaceDescriptions, placedescs) process_pbs_file_message_end end @@ -57,26 +57,26 @@ module Compiler def compile_connections(path = "PBS/map_connections.txt") compile_pbs_file_message_start(path) records = [] - pbCompilerEachPreppedLine(path) { |line,lineno| + pbCompilerEachPreppedLine(path) { |line, lineno| hashenum = { - "N" => "N","North" => "N", - "E" => "E","East" => "E", - "S" => "S","South" => "S", - "W" => "W","West" => "W" + "N" => "N", "North" => "N", + "E" => "E", "East" => "E", + "S" => "S", "South" => "S", + "W" => "W", "West" => "W" } record = [] thisline = line.dup - record.push(csvInt!(thisline,lineno)) - record.push(csvEnumFieldOrInt!(thisline,hashenum,"",sprintf("(line %d)",lineno))) - record.push(csvInt!(thisline,lineno)) - record.push(csvInt!(thisline,lineno)) - record.push(csvEnumFieldOrInt!(thisline,hashenum,"",sprintf("(line %d)",lineno))) - record.push(csvInt!(thisline,lineno)) - if !pbRgssExists?(sprintf("Data/Map%03d.rxdata",record[0])) - print _INTL("Warning: Map {1}, as mentioned in the map connection data, was not found.\r\n{2}",record[0],FileLineData.linereport) + record.push(csvInt!(thisline, lineno)) + record.push(csvEnumFieldOrInt!(thisline, hashenum, "", sprintf("(line %d)", lineno))) + record.push(csvInt!(thisline, lineno)) + record.push(csvInt!(thisline, lineno)) + record.push(csvEnumFieldOrInt!(thisline, hashenum, "", sprintf("(line %d)", lineno))) + record.push(csvInt!(thisline, lineno)) + if !pbRgssExists?(sprintf("Data/Map%03d.rxdata", record[0])) + print _INTL("Warning: Map {1}, as mentioned in the map connection data, was not found.\r\n{2}", record[0], FileLineData.linereport) end - if !pbRgssExists?(sprintf("Data/Map%03d.rxdata",record[3])) - print _INTL("Warning: Map {1}, as mentioned in the map connection data, was not found.\r\n{2}",record[3],FileLineData.linereport) + if !pbRgssExists?(sprintf("Data/Map%03d.rxdata", record[3])) + print _INTL("Warning: Map {1}, as mentioned in the map connection data, was not found.\r\n{2}", record[3], FileLineData.linereport) end case record[1] when "N" @@ -90,7 +90,7 @@ module Compiler end records.push(record) } - save_data(records,"Data/map_connections.dat") + save_data(records, "Data/map_connections.dat") process_pbs_file_message_end end @@ -103,34 +103,34 @@ module Compiler database = PhoneDatabase.new sections = [] File.open(path, "rb") { |f| - pbEachSection(f) { |section,name| + pbEachSection(f) { |section, name| case name when "" - database.generics=section + database.generics = section sections.concat(section) when "" - database.battleRequests=section + database.battleRequests = section sections.concat(section) when "" - database.greetingsMorning=section + database.greetingsMorning = section sections.concat(section) when "" - database.greetingsEvening=section + database.greetingsEvening = section sections.concat(section) when "" - database.greetings=section + database.greetings = section sections.concat(section) when "" - database.bodies1=section + database.bodies1 = section sections.concat(section) when "" - database.bodies2=section + database.bodies2 = section sections.concat(section) end } } - MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages,sections) - save_data(database,"Data/phone.dat") + MessageTypes.setMessagesAsHash(MessageTypes::PhoneMessages, sections) + save_data(database, "Data/phone.dat") process_pbs_file_message_end end @@ -1529,44 +1529,44 @@ module Compiler } end sections = [] - MessageTypes.setMessagesAsHash(MessageTypes::BeginSpeech,[]) - MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechWin,[]) - MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechLose,[]) + MessageTypes.setMessagesAsHash(MessageTypes::BeginSpeech, []) + MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechWin, []) + MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechLose, []) File.open(path, "rb") { |f| FileLineData.file = path idx = 0 - pbEachFileSection(f) { |section,name| + pbEachFileSection(f) { |section, name| echo "." idx += 1 Graphics.update - next if name!="DefaultTrainerList" && name!="TrainerList" + next if name != "DefaultTrainerList" && name != "TrainerList" rsection = [] for key in section.keys - FileLineData.setSection(name,key,section[key]) + FileLineData.setSection(name, key, section[key]) schema = btTrainersRequiredTypes[key] - next if key=="Challenges" && name=="DefaultTrainerList" + next if key == "Challenges" && name == "DefaultTrainerList" next if !schema - record = pbGetCsvRecord(section[key],0,schema) + record = pbGetCsvRecord(section[key], 0, schema) rsection[schema[0]] = record end if !rsection[0] - raise _INTL("No trainer data file given in section {1}.\r\n{2}",name,FileLineData.linereport) + raise _INTL("No trainer data file given in section {1}.\r\n{2}", name, FileLineData.linereport) end if !rsection[1] - raise _INTL("No trainer data file given in section {1}.\r\n{2}",name,FileLineData.linereport) + raise _INTL("No trainer data file given in section {1}.\r\n{2}", name, FileLineData.linereport) end rsection[3] = rsection[0] rsection[4] = rsection[1] - rsection[5] = (name=="DefaultTrainerList") - if safeExists?("PBS/"+rsection[0]) - rsection[0] = compile_battle_tower_trainers("PBS/"+rsection[0]) + rsection[5] = (name == "DefaultTrainerList") + if safeExists?("PBS/" + rsection[0]) + rsection[0] = compile_battle_tower_trainers("PBS/" + rsection[0]) else rsection[0] = [] end - if safeExists?("PBS/"+rsection[1]) - filename = "PBS/"+rsection[1] + if safeExists?("PBS/" + rsection[1]) + filename = "PBS/" + rsection[1] rsection[1] = [] - pbCompilerEachCommentedLine(filename) { |line,_lineno| + pbCompilerEachCommentedLine(filename) { |line, _lineno| rsection[1].push(PBPokemon.fromInspected(line)) } else @@ -1580,7 +1580,7 @@ module Compiler sections.push(rsection) } } - save_data(sections,"Data/trainer_lists.dat") + save_data(sections, "Data/trainer_lists.dat") process_pbs_file_message_end end @@ -1599,15 +1599,15 @@ module Compiler endspeechwin = [] endspeechlose = [] if safeExists?(filename) - File.open(filename,"rb") { |f| + File.open(filename, "rb") { |f| FileLineData.file = filename - pbEachFileSection(f) { |section,name| + pbEachFileSection(f) { |section, name| rsection = [] for key in section.keys - FileLineData.setSection(name,key,section[key]) + FileLineData.setSection(name, key, section[key]) schema = requiredtypes[key] next if !schema - record = pbGetCsvRecord(section[key],0,schema) + record = pbGetCsvRecord(section[key], 0, schema) rsection[schema[0]] = record end trainernames.push(rsection[1]) @@ -1618,10 +1618,10 @@ module Compiler } } end - MessageTypes.addMessagesAsHash(MessageTypes::TrainerNames,trainernames) - MessageTypes.addMessagesAsHash(MessageTypes::BeginSpeech,beginspeech) - MessageTypes.addMessagesAsHash(MessageTypes::EndSpeechWin,endspeechwin) - MessageTypes.addMessagesAsHash(MessageTypes::EndSpeechLose,endspeechlose) + MessageTypes.addMessagesAsHash(MessageTypes::TrainerNames, trainernames) + MessageTypes.addMessagesAsHash(MessageTypes::BeginSpeech, beginspeech) + MessageTypes.addMessagesAsHash(MessageTypes::EndSpeechWin, endspeechwin) + MessageTypes.addMessagesAsHash(MessageTypes::EndSpeechLose, endspeechlose) return sections end @@ -1815,8 +1815,8 @@ module Compiler end end if changed - save_data(move2anim,"Data/move2anim.dat") - save_data(pbanims,"Data/PkmnAnimations.rxdata") + save_data(move2anim, "Data/move2anim.dat") + save_data(pbanims, "Data/PkmnAnimations.rxdata") end process_pbs_file_message_end end diff --git a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb index a4e9efaa5..25ec65ac6 100644 --- a/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb +++ b/Data/Scripts/021_Compiler/003_Compiler_WritePBS.rb @@ -25,14 +25,14 @@ module Compiler map = mapdata[i] next if !map f.write("\#-------------------------------\r\n") - f.write(sprintf("[%d]\r\n",i)) - rname = pbGetMessage(MessageTypes::RegionNames,i) + f.write(sprintf("[%d]\r\n", i)) + rname = pbGetMessage(MessageTypes::RegionNames, i) f.write(sprintf("Name = %s\r\nFilename = %s\r\n", - (rname && rname!="") ? rname : _INTL("Unnamed"), + (rname && rname != "") ? rname : _INTL("Unnamed"), csvQuote((map[1].is_a?(Array)) ? map[1][0] : map[1]))) for loc in map[2] f.write("Point = ") - pbWriteCsvRecord(loc,f,[nil,"uussUUUU"]) + pbWriteCsvRecord(loc, f, [nil, "uussUUUU"]) f.write("\r\n") end end @@ -708,12 +708,12 @@ module Compiler for tr in trainerlists echo "." f.write("\#-------------------------------\r\n") - f.write(((tr[5]) ? "[DefaultTrainerList]" : "[TrainerList]")+"\r\n") - f.write("Trainers = "+tr[3]+"\r\n") - f.write("Pokemon = "+tr[4]+"\r\n") - f.write("Challenges = "+tr[2].join(",")+"\r\n") if !tr[5] - write_battle_tower_trainers(tr[0],"PBS/"+tr[3]) - write_battle_tower_pokemon(tr[1],"PBS/"+tr[4]) + f.write(((tr[5]) ? "[DefaultTrainerList]" : "[TrainerList]") + "\r\n") + f.write("Trainers = " + tr[3] + "\r\n") + f.write("Pokemon = " + tr[4] + "\r\n") + f.write("Challenges = " + tr[2].join(",") + "\r\n") if !tr[5] + write_battle_tower_trainers(tr[0], "PBS/" + tr[3]) + write_battle_tower_pokemon(tr[1], "PBS/" + tr[4]) end } process_pbs_file_message_end @@ -732,23 +732,23 @@ module Compiler "EndSpeechLose" => [4, "s"], "PokemonNos" => [5, "*u"] } - File.open(filename,"wb") { |f| + File.open(filename, "wb") { |f| add_PBS_header_to_file(f) for i in 0...bttrainers.length next if !bttrainers[i] f.write("\#-------------------------------\r\n") - f.write(sprintf("[%03d]\r\n",i)) + f.write(sprintf("[%03d]\r\n", i)) for key in btTrainersRequiredTypes.keys schema = btTrainersRequiredTypes[key] record = bttrainers[i][schema[0]] - next if record==nil - f.write(sprintf("%s = ",key)) - if key=="Type" + next if record == nil + f.write(sprintf("%s = ", key)) + if key == "Type" f.write(record.to_s) - elsif key=="PokemonNos" + elsif key == "PokemonNos" f.write(record.join(",")) # pbWriteCsvRecord somehow won't work here else - pbWriteCsvRecord(record,f,schema) + pbWriteCsvRecord(record, f, schema) end f.write(sprintf("\r\n")) end @@ -760,7 +760,7 @@ module Compiler #============================================================================= # Save Battle Tower Pokémon data to PBS file #============================================================================= - def write_battle_tower_pokemon(btpokemon,filename) + def write_battle_tower_pokemon(btpokemon, filename) return if !btpokemon || !filename species = {} moves = {} @@ -774,7 +774,7 @@ module Compiler :SPECIAL_DEFENSE => "SD", :SPEED => "SPD" } - File.open(filename,"wb") { |f| + File.open(filename, "wb") { |f| add_PBS_header_to_file(f) f.write("\#-------------------------------\r\n") for i in 0...btpokemon.length diff --git a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb index 0498d16b9..bf91af9fe 100644 --- a/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb +++ b/Data/Scripts/021_Compiler/004_Compiler_MapsAndEvents.rb @@ -55,26 +55,26 @@ module Compiler for id in mapinfos.keys next if !mapinfos[id] mapfiles.delete(id) if mapfiles[id] - maxOrder = [maxOrder,mapinfos[id].order].max + maxOrder = [maxOrder, mapinfos[id].order].max end # Import maps not found in mapinfos maxOrder += 1 imported = false count = 0 for id in mapfiles.keys - next if id==999 # Ignore 999 (random dungeon map) + next if id == 999 # Ignore 999 (random dungeon map) mapinfo = RPG::MapInfo.new mapinfo.order = maxOrder - mapinfo.name = sprintf("MAP%03d",id) + mapinfo.name = sprintf("MAP%03d", id) maxOrder += 1 mapinfos[id] = mapinfo imported = true count += 1 end if imported - save_data(mapinfos,"Data/MapInfos.rxdata") + save_data(mapinfos, "Data/MapInfos.rxdata") $game_temp.map_infos = nil - pbMessage(_INTL("{1} new map(s) copied to the Data folder were successfully imported.",count)) + pbMessage(_INTL("{1} new map(s) copied to the Data folder were successfully imported.", count)) end return imported end @@ -88,22 +88,22 @@ module Compiler route.skippable = true route.list.clear i = 0 - while i=map.width || y<0 || y>=map.height - passages = getTilesetPassages(map,mapID) - priorities = getTilesetPriorities(map,mapID) + return false if x < 0 || x >= map.width || y < 0 || y >= map.height + passages = getTilesetPassages(map, mapID) + priorities = getTilesetPriorities(map, mapID) for i in [2, 1, 0] tile_id = map.data[x, y, i] - return false if tile_id==nil + return false if tile_id == nil passage = passages[tile_id] if !passage - raise "The tile used on map #{mapID} at coordinates (#{x}, #{y}) on layer #{i+1} doesn't exist in the tileset. " + + raise "The tile used on map #{mapID} at coordinates (#{x}, #{y}) on layer #{i + 1} doesn't exist in the tileset. " + "It should be deleted to prevent errors." end - return false if passage&0x0f==0x0f - return true if priorities[tile_id]==0 + return false if passage & 0x0f == 0x0f + return true if priorities[tile_id] == 0 end return true end - def isCounterTile?(mapID,x,y) + def isCounterTile?(mapID, x, y) map = getMap(mapID) return false if !map - passages = getTilesetPassages(map,mapID) + passages = getTilesetPassages(map, mapID) for i in [2, 1, 0] tile_id = map.data[x, y, i] - return false if tile_id==nil + return false if tile_id == nil passage = passages[tile_id] if !passage - raise "The tile used on map #{mapID} at coordinates (#{x}, #{y}) on layer #{i+1} doesn't exist in the tileset. " + + raise "The tile used on map #{mapID} at coordinates (#{x}, #{y}) on layer #{i + 1} doesn't exist in the tileset. " + "It should be deleted to prevent errors." end - return true if passage&0x80==0x80 + return true if passage & 0x80 == 0x80 end return false end - def setCounterTile(mapID,x,y) + def setCounterTile(mapID, x, y) map = getMap(mapID) return if !map - passages = getTilesetPassages(map,mapID) + passages = getTilesetPassages(map, mapID) for i in [2, 1, 0] tile_id = map.data[x, y, i] - next if tile_id==0 + next if tile_id == 0 passages[tile_id] |= 0x80 break end @@ -397,7 +397,7 @@ module Compiler return @registeredSwitches[switch] if @registeredSwitches[switch] for id in 1..5000 name = @system.switches[id] - next if name && name!="" && name!=switch + next if name && name != "" && name != switch @system.switches[id] = switch @registeredSwitches[switch] = id return id @@ -406,7 +406,7 @@ module Compiler end def saveMap(mapID) - save_data(getMap(mapID),mapFilename(mapID)) rescue nil + save_data(getMap(mapID), mapFilename(mapID)) rescue nil end def saveTilesets @@ -451,28 +451,28 @@ module Compiler #============================================================================= # Convert trainer comments to trainer event. #============================================================================= - def convert_to_trainer_event(event,trainerChecker) - return nil if !event || event.pages.length==0 + def convert_to_trainer_event(event, trainerChecker) + return nil if !event || event.pages.length == 0 list = event.pages[0].list - return nil if list.length<2 + return nil if list.length < 2 commands = [] isFirstCommand = false # Find all the trainer comments in the event for i in 0...list.length - next if list[i].code!=108 # Comment (first line) + next if list[i].code != 108 # Comment (first line) command = list[i].parameters[0] - for j in (i+1)...list.length - break if list[j].code!=408 # Comment (continuation line) - command += "\r\n"+list[j].parameters[0] + for j in (i + 1)...list.length + break if list[j].code != 408 # Comment (continuation line) + command += "\r\n" + list[j].parameters[0] end if command[/^(Battle\:|Type\:|Name\:|BattleID\:|DoubleBattle\:|Backdrop\:|EndSpeech\:|Outcome\:|Continue\:|EndBattle\:|EndIfSwitch\:|VanishIfSwitch\:|RegSpeech\:)/i] commands.push(command) - isFirstCommand = true if i==0 + isFirstCommand = true if i == 0 end end - return nil if commands.length==0 + return nil if commands.length == 0 # Found trainer comments; create a new Event object to replace this event - ret = RPG::Event.new(event.x,event.y) + ret = RPG::Event.new(event.x, event.y) ret.name = event.name ret.id = event.id firstpage = Marshal::load(Marshal.dump(event.pages[0])) # Copy event's first page @@ -504,90 +504,90 @@ module Compiler for command in commands if command[/^Battle\:\s*([\s\S]+)$/i] battles.push($~[1]) - push_comment(firstpage.list,command) if rewriteComments + push_comment(firstpage.list, command) if rewriteComments elsif command[/^Type\:\s*([\s\S]+)$/i] - trtype = $~[1].gsub(/^\s+/,"").gsub(/\s+$/,"") - push_comment(firstpage.list,command) if rewriteComments + trtype = $~[1].gsub(/^\s+/, "").gsub(/\s+$/, "") + push_comment(firstpage.list, command) if rewriteComments elsif command[/^Name\:\s*([\s\S]+)$/i] - trname = $~[1].gsub(/^\s+/,"").gsub(/\s+$/,"") - push_comment(firstpage.list,command) if rewriteComments + trname = $~[1].gsub(/^\s+/, "").gsub(/\s+$/, "") + push_comment(firstpage.list, command) if rewriteComments elsif command[/^BattleID\:\s*(\d+)$/i] battleid = $~[1].to_i - push_comment(firstpage.list,command) if rewriteComments + push_comment(firstpage.list, command) if rewriteComments elsif command[/^DoubleBattle\:\s*([\s\S]+)$/i] - value = $~[1].gsub(/^\s+/,"").gsub(/\s+$/,"") - doublebattle = true if value.upcase=="TRUE" || value.upcase=="YES" - push_comment(firstpage.list,command) if rewriteComments + value = $~[1].gsub(/^\s+/, "").gsub(/\s+$/, "") + doublebattle = true if value.upcase == "TRUE" || value.upcase == "YES" + push_comment(firstpage.list, command) if rewriteComments elsif command[/^Backdrop\:\s*([\s\S]+)$/i] - backdrop = $~[1].gsub(/^\s+/,"").gsub(/\s+$/,"") - push_comment(firstpage.list,command) if rewriteComments + backdrop = $~[1].gsub(/^\s+/, "").gsub(/\s+$/, "") + push_comment(firstpage.list, command) if rewriteComments elsif command[/^EndSpeech\:\s*([\s\S]+)$/i] - endspeeches.push($~[1].gsub(/^\s+/,"").gsub(/\s+$/,"")) - push_comment(firstpage.list,command) if rewriteComments + endspeeches.push($~[1].gsub(/^\s+/, "").gsub(/\s+$/, "")) + push_comment(firstpage.list, command) if rewriteComments elsif command[/^Outcome\:\s*(\d+)$/i] outcome = $~[1].to_i - push_comment(firstpage.list,command) if rewriteComments + push_comment(firstpage.list, command) if rewriteComments elsif command[/^Continue\:\s*([\s\S]+)$/i] - value = $~[1].gsub(/^\s+/,"").gsub(/\s+$/,"") - continue = true if value.upcase=="TRUE" || value.upcase=="YES" - push_comment(firstpage.list,command) if rewriteComments + value = $~[1].gsub(/^\s+/, "").gsub(/\s+$/, "") + continue = true if value.upcase == "TRUE" || value.upcase == "YES" + push_comment(firstpage.list, command) if rewriteComments elsif command[/^EndBattle\:\s*([\s\S]+)$/i] - endbattles.push($~[1].gsub(/^\s+/,"").gsub(/\s+$/,"")) - push_comment(firstpage.list,command) if rewriteComments + endbattles.push($~[1].gsub(/^\s+/, "").gsub(/\s+$/, "")) + push_comment(firstpage.list, command) if rewriteComments elsif command[/^EndIfSwitch\:\s*([\s\S]+)$/i] - endifswitch.push(($~[1].gsub(/^\s+/,"").gsub(/\s+$/,"")).to_i) - push_comment(firstpage.list,command) if rewriteComments + endifswitch.push(($~[1].gsub(/^\s+/, "").gsub(/\s+$/, "")).to_i) + push_comment(firstpage.list, command) if rewriteComments elsif command[/^VanishIfSwitch\:\s*([\s\S]+)$/i] - vanishifswitch.push(($~[1].gsub(/^\s+/,"").gsub(/\s+$/,"")).to_i) - push_comment(firstpage.list,command) if rewriteComments + vanishifswitch.push(($~[1].gsub(/^\s+/, "").gsub(/\s+$/, "")).to_i) + push_comment(firstpage.list, command) if rewriteComments elsif command[/^RegSpeech\:\s*([\s\S]+)$/i] - regspeech = $~[1].gsub(/^\s+/,"").gsub(/\s+$/,"") - push_comment(firstpage.list,command) if rewriteComments + regspeech = $~[1].gsub(/^\s+/, "").gsub(/\s+$/, "") + push_comment(firstpage.list, command) if rewriteComments end end - return nil if battles.length<=0 + return nil if battles.length <= 0 # Run trainer check now, except in editor - trainerChecker.pbTrainerBattleCheck(trtype,trname,battleid) + trainerChecker.pbTrainerBattleCheck(trtype, trname, battleid) # Set the event's charset to one depending on the trainer type if the event # doesn't have a charset - if firstpage.graphic.character_name=="" && GameData::TrainerType.exists?(trtype) + if firstpage.graphic.character_name == "" && GameData::TrainerType.exists?(trtype) trainerid = GameData::TrainerType.get(trtype).id filename = GameData::TrainerType.charset_filename_brief(trainerid) - if FileTest.image_exist?("Graphics/Characters/"+filename) + if FileTest.image_exist?("Graphics/Characters/" + filename) firstpage.graphic.character_name = sprintf(filename) end end # Create strings that will be used repeatedly - safetrcombo = sprintf(":%s,\"%s\"",trtype,safequote(trname)) # :YOUNGSTER,"Joey" - introplay = sprintf("pbTrainerIntro(:%s)",trtype) + safetrcombo = sprintf(":%s,\"%s\"", trtype, safequote(trname)) # :YOUNGSTER,"Joey" + introplay = sprintf("pbTrainerIntro(:%s)", trtype) # Write first page - push_script(firstpage.list,introplay) # pbTrainerIntro - push_script(firstpage.list,"pbNoticePlayer(get_self)") - push_text(firstpage.list,battles[0]) - if battles.length>1 # Has rematches - push_script(firstpage.list,sprintf("pbTrainerCheck(%s,%d,%d)",safetrcombo,battles.length,battleid)) + push_script(firstpage.list, introplay) # pbTrainerIntro + push_script(firstpage.list, "pbNoticePlayer(get_self)") + push_text(firstpage.list, battles[0]) + if battles.length > 1 # Has rematches + push_script(firstpage.list, sprintf("pbTrainerCheck(%s,%d,%d)", safetrcombo, battles.length, battleid)) end - push_script(firstpage.list,"setBattleRule(\"double\")") if doublebattle - push_script(firstpage.list,sprintf("setBattleRule(\"backdrop\",\"%s\")",safequote(backdrop))) if backdrop - push_script(firstpage.list,sprintf("setBattleRule(\"outcomeVar\",%d)",outcome)) if outcome>1 - push_script(firstpage.list,"setBattleRule(\"canLose\")") if continue - espeech = (endspeeches[0]) ? sprintf("_I(\"%s\")",safequote2(endspeeches[0])) : "nil" - if battleid>0 - battleString = sprintf("pbTrainerBattle(%s,%s,nil,%d)",safetrcombo,espeech,battleid) + push_script(firstpage.list, "setBattleRule(\"double\")") if doublebattle + push_script(firstpage.list, sprintf("setBattleRule(\"backdrop\",\"%s\")", safequote(backdrop))) if backdrop + push_script(firstpage.list, sprintf("setBattleRule(\"outcomeVar\",%d)", outcome)) if outcome > 1 + push_script(firstpage.list, "setBattleRule(\"canLose\")") if continue + espeech = (endspeeches[0]) ? sprintf("_I(\"%s\")", safequote2(endspeeches[0])) : "nil" + if battleid > 0 + battleString = sprintf("pbTrainerBattle(%s,%s,nil,%d)", safetrcombo, espeech, battleid) elsif endspeeches[0] - battleString = sprintf("pbTrainerBattle(%s,%s)",safetrcombo,espeech) + battleString = sprintf("pbTrainerBattle(%s,%s)", safetrcombo, espeech) else - battleString = sprintf("pbTrainerBattle(%s)",safetrcombo) + battleString = sprintf("pbTrainerBattle(%s)", safetrcombo) end - push_branch(firstpage.list,battleString) - if battles.length>1 # Has rematches + push_branch(firstpage.list, battleString) + if battles.length > 1 # Has rematches push_script(firstpage.list, sprintf("pbPhoneRegisterBattle(_I(\"%s\"),get_self,%s,%d)", - regspeech,safetrcombo,battles.length),1) + regspeech, safetrcombo, battles.length), 1) end - push_self_switch(firstpage.list,"A",true,1) - push_branch_end(firstpage.list,1) - push_script(firstpage.list,"pbTrainerEnd",0) + push_self_switch(firstpage.list, "A", true, 1) + push_branch_end(firstpage.list, 1) + push_script(firstpage.list, "pbTrainerEnd", 0) push_end(firstpage.list) # Copy first page to last page and make changes to its properties lastpage = Marshal::load(Marshal.dump(firstpage)) @@ -605,62 +605,62 @@ module Compiler # Write rematch and last pages for i in 1...battles.length # Run trainer check now, except in editor - trainerChecker.pbTrainerBattleCheck(trtype,trname,battleid+i) - if i==battles.length-1 - push_branch(rematchpage.list,sprintf("pbPhoneBattleCount(%s)>=%d",safetrcombo,i)) - push_branch(lastpage.list,sprintf("pbPhoneBattleCount(%s)>%d",safetrcombo,i)) + trainerChecker.pbTrainerBattleCheck(trtype, trname, battleid + i) + if i == battles.length - 1 + push_branch(rematchpage.list, sprintf("pbPhoneBattleCount(%s)>=%d", safetrcombo, i)) + push_branch(lastpage.list, sprintf("pbPhoneBattleCount(%s)>%d", safetrcombo, i)) else - push_branch(rematchpage.list,sprintf("pbPhoneBattleCount(%s)==%d",safetrcombo,i)) - push_branch(lastpage.list,sprintf("pbPhoneBattleCount(%s)==%d",safetrcombo,i)) + push_branch(rematchpage.list, sprintf("pbPhoneBattleCount(%s)==%d", safetrcombo, i)) + push_branch(lastpage.list, sprintf("pbPhoneBattleCount(%s)==%d", safetrcombo, i)) end # Rematch page - push_script(rematchpage.list,introplay,1) # pbTrainerIntro - push_text(rematchpage.list,battles[i],1) - push_script(rematchpage.list,"setBattleRule(\"double\")",1) if doublebattle - push_script(rematchpage.list,sprintf("setBattleRule(\"backdrop\",%s)",safequote(backdrop)),1) if backdrop - push_script(rematchpage.list,sprintf("setBattleRule(\"outcomeVar\",%d)",outcome),1) if outcome>1 - push_script(rematchpage.list,"setBattleRule(\"canLose\")",1) if continue + push_script(rematchpage.list, introplay, 1) # pbTrainerIntro + push_text(rematchpage.list, battles[i], 1) + push_script(rematchpage.list, "setBattleRule(\"double\")", 1) if doublebattle + push_script(rematchpage.list, sprintf("setBattleRule(\"backdrop\",%s)", safequote(backdrop)), 1) if backdrop + push_script(rematchpage.list, sprintf("setBattleRule(\"outcomeVar\",%d)", outcome), 1) if outcome > 1 + push_script(rematchpage.list, "setBattleRule(\"canLose\")", 1) if continue espeech = nil - if endspeeches.length>0 - espeech = (endspeeches[i]) ? endspeeches[i] : endspeeches[endspeeches.length-1] + if endspeeches.length > 0 + espeech = (endspeeches[i]) ? endspeeches[i] : endspeeches[endspeeches.length - 1] end - espeech = (espeech) ? sprintf("_I(\"%s\")",safequote2(espeech)) : "nil" - battleString = sprintf("pbTrainerBattle(%s,%s,nil,%d)",safetrcombo,espeech,battleid+i) - push_branch(rematchpage.list,battleString,1) - push_script(rematchpage.list,sprintf("pbPhoneIncrement(%s,%d)",safetrcombo,battles.length),2) - push_self_switch(rematchpage.list,"A",true,2) - push_self_switch(rematchpage.list,"B",false,2) - push_script(rematchpage.list,"pbTrainerEnd",2) - push_branch_end(rematchpage.list,2) - push_exit(rematchpage.list,1) # Exit Event Processing - push_branch_end(rematchpage.list,1) + espeech = (espeech) ? sprintf("_I(\"%s\")", safequote2(espeech)) : "nil" + battleString = sprintf("pbTrainerBattle(%s,%s,nil,%d)", safetrcombo, espeech, battleid + i) + push_branch(rematchpage.list, battleString, 1) + push_script(rematchpage.list, sprintf("pbPhoneIncrement(%s,%d)", safetrcombo, battles.length), 2) + push_self_switch(rematchpage.list, "A", true, 2) + push_self_switch(rematchpage.list, "B", false, 2) + push_script(rematchpage.list, "pbTrainerEnd", 2) + push_branch_end(rematchpage.list, 2) + push_exit(rematchpage.list, 1) # Exit Event Processing + push_branch_end(rematchpage.list, 1) # Last page - if endbattles.length>0 - ebattle = (endbattles[i]) ? endbattles[i] : endbattles[endbattles.length-1] - push_text(lastpage.list,ebattle,1) + if endbattles.length > 0 + ebattle = (endbattles[i]) ? endbattles[i] : endbattles[endbattles.length - 1] + push_text(lastpage.list, ebattle, 1) end push_script(lastpage.list, sprintf("pbPhoneRegisterBattle(_I(\"%s\"),get_self,%s,%d)", - regspeech,safetrcombo,battles.length),1) - push_exit(lastpage.list,1) # Exit Event Processing - push_branch_end(lastpage.list,1) + regspeech, safetrcombo, battles.length), 1) + push_exit(lastpage.list, 1) # Exit Event Processing + push_branch_end(lastpage.list, 1) end # Finish writing rematch page push_end(rematchpage.list) # Finish writing last page ebattle = (endbattles[0]) ? endbattles[0] : "..." - push_text(lastpage.list,ebattle) - if battles.length>1 + push_text(lastpage.list, ebattle) + if battles.length > 1 push_script(lastpage.list, sprintf("pbPhoneRegisterBattle(_I(\"%s\"),get_self,%s,%d)", - regspeech,safetrcombo,battles.length)) + regspeech, safetrcombo, battles.length)) end push_end(lastpage.list) # Add pages to the new event - if battles.length==1 # Only one battle - ret.pages = [firstpage,lastpage] + if battles.length == 1 # Only one battle + ret.pages = [firstpage, lastpage] else # Has rematches - ret.pages = [firstpage,rematchpage,lastpage] + ret.pages = [firstpage, rematchpage, lastpage] end # Copy last page to endIfSwitch page for endswitch in endifswitch @@ -676,7 +676,7 @@ module Compiler endIfSwitchPage.condition.self_switch_valid = false endIfSwitchPage.list = [] # Clear page's commands ebattle = (endbattles[0]) ? endbattles[0] : "..." - push_text(endIfSwitchPage.list,ebattle) + push_text(endIfSwitchPage.list, ebattle) push_end(endIfSwitchPage.list) ret.pages.push(endIfSwitchPage) end @@ -707,9 +707,9 @@ module Compiler # that item when interacted with. #============================================================================= def convert_to_item_event(event) - return nil if !event || event.pages.length==0 + return nil if !event || event.pages.length == 0 name = event.name - ret = RPG::Event.new(event.x,event.y) + ret = RPG::Event.new(event.x, event.y) ret.name = event.name ret.id = event.id ret.pages = [] @@ -731,10 +731,10 @@ module Compiler page = RPG::Event::Page.new page.graphic.character_name = "Object ball" if !hidden page.list = [] - push_branch(page.list,sprintf("pbItemBall(:%s)",itemName)) - push_self_switch(page.list,"A",true,1) - push_else(page.list,1) - push_branch_end(page.list,1) + push_branch(page.list, sprintf("pbItemBall(:%s)", itemName)) + push_self_switch(page.list, "A", true, 1) + push_else(page.list, 1) + push_branch_end(page.list, 1) push_end(page.list) ret.pages.push(page) # Event page 2 @@ -750,7 +750,7 @@ module Compiler # include animating the event as though it was a door opening and closing as the # player passes through. #============================================================================= - def update_door_event(event,mapData) + def update_door_event(event, mapData) changed = false return false if event.is_a?(RPG::CommonEvent) # Check if event has 2+ pages and the last page meets all of these criteria: @@ -758,17 +758,17 @@ module Compiler # - The event has a charset graphic # - There are more than 5 commands in that page, the first of which is a # Conditional Branch - lastPage = event.pages[event.pages.length-1] - if event.pages.length>=2 && + lastPage = event.pages[event.pages.length - 1] + if event.pages.length >= 2 && lastPage.condition.switch1_valid && - lastPage.graphic.character_name!="" && - lastPage.list.length>5 && - lastPage.list[0].code==111 + lastPage.graphic.character_name != "" && + lastPage.list.length > 5 && + lastPage.list[0].code == 111 # This bit of code is just in case Switch 22 has been renamed/repurposed, # which is highly unlikely. It changes the Switch used in the condition to # whichever is named 's:tsOff?("A")'. - if lastPage.condition.switch1_id==22 && - mapData.switchName(lastPage.condition.switch1_id)!='s:tsOff?("A")' + if lastPage.condition.switch1_id == 22 && + mapData.switchName(lastPage.condition.switch1_id) != 's:tsOff?("A")' lastPage.condition.switch1_id = mapData.registerSwitch('s:tsOff?("A")') changed = true end @@ -776,53 +776,53 @@ module Compiler # check the penultimate page. If it contains exactly 1 "Transfer Player" # command and does NOT contain a "Change Transparent Flag" command, rewrite # both the penultimate page and the last page. - if mapData.switchName(lastPage.condition.switch1_id)=='s:tsOff?("A")' - list = event.pages[event.pages.length-2].list - transferCommand = list.find_all { |cmd| cmd.code==201 } # Transfer Player - if transferCommand.length==1 && !list.any? { |cmd| cmd.code==208 } # Change Transparent Flag + if mapData.switchName(lastPage.condition.switch1_id) == 's:tsOff?("A")' + list = event.pages[event.pages.length - 2].list + transferCommand = list.find_all { |cmd| cmd.code == 201 } # Transfer Player + if transferCommand.length == 1 && !list.any? { |cmd| cmd.code == 208 } # Change Transparent Flag # Rewrite penultimate page list.clear - push_move_route_and_wait(list,0,[ # Move Route for door opening - PBMoveRoute::PlaySE,RPG::AudioFile.new("Door enter"),PBMoveRoute::Wait,2, - PBMoveRoute::TurnLeft,PBMoveRoute::Wait,2, - PBMoveRoute::TurnRight,PBMoveRoute::Wait,2, - PBMoveRoute::TurnUp,PBMoveRoute::Wait,2 + push_move_route_and_wait(list, 0, [ # Move Route for door opening + PBMoveRoute::PlaySE, RPG::AudioFile.new("Door enter"), PBMoveRoute::Wait, 2, + PBMoveRoute::TurnLeft, PBMoveRoute::Wait, 2, + PBMoveRoute::TurnRight, PBMoveRoute::Wait, 2, + PBMoveRoute::TurnUp, PBMoveRoute::Wait, 2 ]) - push_move_route_and_wait(list,-1,[ # Move Route for player entering door - PBMoveRoute::ThroughOn,PBMoveRoute::Up,PBMoveRoute::ThroughOff + push_move_route_and_wait(list, -1, [ # Move Route for player entering door + PBMoveRoute::ThroughOn, PBMoveRoute::Up, PBMoveRoute::ThroughOff ]) - push_event(list,208,[0]) # Change Transparent Flag (invisible) + push_event(list, 208, [0]) # Change Transparent Flag (invisible) push_script(list, "Followers.follow_into_door") push_event(list, 210, [], indent) # Wait for Move's Completion - push_move_route_and_wait(list,0,[PBMoveRoute::Wait,2, # Move Route for door closing - PBMoveRoute::TurnRight,PBMoveRoute::Wait,2, - PBMoveRoute::TurnLeft,PBMoveRoute::Wait,2, - PBMoveRoute::TurnDown,PBMoveRoute::Wait,2]) - push_event(list,223,[Tone.new(-255,-255,-255),6]) # Change Screen Color Tone - push_wait(list,8) # Wait - push_event(list,208,[1]) # Change Transparent Flag (visible) - push_event(list,transferCommand[0].code,transferCommand[0].parameters) # Transfer Player - push_event(list,223,[Tone.new(0,0,0),6]) # Change Screen Color Tone + push_move_route_and_wait(list, 0, [PBMoveRoute::Wait, 2, # Move Route for door closing + PBMoveRoute::TurnRight, PBMoveRoute::Wait, 2, + PBMoveRoute::TurnLeft, PBMoveRoute::Wait, 2, + PBMoveRoute::TurnDown, PBMoveRoute::Wait, 2]) + push_event(list, 223, [Tone.new(-255, -255, -255), 6]) # Change Screen Color Tone + push_wait(list, 8) # Wait + push_event(list, 208, [1]) # Change Transparent Flag (visible) + push_event(list, transferCommand[0].code, transferCommand[0].parameters) # Transfer Player + push_event(list, 223, [Tone.new(0, 0, 0), 6]) # Change Screen Color Tone push_end(list) # Rewrite last page list = lastPage.list list.clear - push_branch(list,"get_self.onEvent?") # Conditional Branch - push_event(list,208,[0],1) # Change Transparent Flag (invisible) + push_branch(list, "get_self.onEvent?") # Conditional Branch + push_event(list, 208, [0], 1) # Change Transparent Flag (invisible) push_script(list, "Followers.hide_followers", 1) - push_move_route_and_wait(list,0,[ # Move Route for setting door to open - PBMoveRoute::TurnLeft,PBMoveRoute::Wait,6 - ],1) - push_event(list,208,[1],1) # Change Transparent Flag (visible) - push_move_route_and_wait(list,-1,[PBMoveRoute::Down],1) # Move Route for player exiting door + push_move_route_and_wait(list, 0, [ # Move Route for setting door to open + PBMoveRoute::TurnLeft, PBMoveRoute::Wait, 6 + ], 1) + push_event(list, 208, [1], 1) # Change Transparent Flag (visible) + push_move_route_and_wait(list, -1, [PBMoveRoute::Down], 1) # Move Route for player exiting door push_script(list, "Followers.put_followers_on_player", 1) - push_move_route_and_wait(list,0,[ # Move Route for door closing - PBMoveRoute::TurnUp,PBMoveRoute::Wait,2, - PBMoveRoute::TurnRight,PBMoveRoute::Wait,2, - PBMoveRoute::TurnDown,PBMoveRoute::Wait,2 - ],1) - push_branch_end(list,1) - push_script(list,"setTempSwitchOn(\"A\")") + push_move_route_and_wait(list, 0, [ # Move Route for door closing + PBMoveRoute::TurnUp, PBMoveRoute::Wait, 2, + PBMoveRoute::TurnRight, PBMoveRoute::Wait, 2, + PBMoveRoute::TurnDown, PBMoveRoute::Wait, 2 + ], 1) + push_branch_end(list, 1) + push_script(list, "setTempSwitchOn(\"A\")") push_end(list) changed = true end @@ -837,7 +837,7 @@ module Compiler def event_is_empty?(e) return true if !e return false if e.is_a?(RPG::CommonEvent) - return e.pages.length==0 + return e.pages.length == 0 end # Checks if the event has exactly 1 page, said page has no graphic, it has @@ -845,18 +845,18 @@ module Compiler # to the left/right/upper left/upper right are not passable but the event's # tile is. Causes a second page to be added to the event which is the "is # player on me?" check that occurs when the map is entered. - def likely_passage?(thisEvent,mapID,mapData) - return false if !thisEvent || thisEvent.pages.length==0 - return false if thisEvent.pages.length!=1 - if thisEvent.pages[0].graphic.character_name=="" && - thisEvent.pages[0].list.length<=12 && - thisEvent.pages[0].list.any? { |cmd| cmd.code==201 } && # Transfer Player + def likely_passage?(thisEvent, mapID, mapData) + return false if !thisEvent || thisEvent.pages.length == 0 + return false if thisEvent.pages.length != 1 + if thisEvent.pages[0].graphic.character_name == "" && + thisEvent.pages[0].list.length <= 12 && + thisEvent.pages[0].list.any? { |cmd| cmd.code == 201 } && # Transfer Player # mapData.isPassable?(mapID,thisEvent.x,thisEvent.y+1) && - mapData.isPassable?(mapID,thisEvent.x,thisEvent.y) && - !mapData.isPassable?(mapID,thisEvent.x-1,thisEvent.y) && - !mapData.isPassable?(mapID,thisEvent.x+1,thisEvent.y) && - !mapData.isPassable?(mapID,thisEvent.x-1,thisEvent.y-1) && - !mapData.isPassable?(mapID,thisEvent.x+1,thisEvent.y-1) + mapData.isPassable?(mapID, thisEvent.x, thisEvent.y) && + !mapData.isPassable?(mapID, thisEvent.x - 1, thisEvent.y) && + !mapData.isPassable?(mapID, thisEvent.x + 1, thisEvent.y) && + !mapData.isPassable?(mapID, thisEvent.x - 1, thisEvent.y - 1) && + !mapData.isPassable?(mapID, thisEvent.x + 1, thisEvent.y - 1) return true end return false @@ -902,18 +902,18 @@ module Compiler return ret end - def fix_event_use(event,_mapID,mapData) + def fix_event_use(event, _mapID, mapData) return nil if event_is_empty?(event) changed = false trainerMoneyRE = /^\s*\$player\.money\s*(<|<=|>|>=)\s*(\d+)\s*$/ itemBallRE = /^\s*(Kernel\.)?pbItemBall/ # Rewrite event if it looks like a door - changed = true if update_door_event(event,mapData) + changed = true if update_door_event(event, mapData) # Check through each page of the event in turn pbEachPage(event) do |page| i = 0 list = page.list - while i=2 && list[i].parameters[0].length>0 && list[i].parameters[0].length<=20 && + if lines >= 2 && list[i].parameters[0].length > 0 && list[i].parameters[0].length <= 20 && !list[i].parameters[0][/\\n/] # Very short line - list[i].parameters[0] += "\\n"+list[i+1].parameters[0] - list.delete_at(i+1) + list[i].parameters[0] += "\\n" + list[i + 1].parameters[0] + list.delete_at(i + 1) i -= 1 # revisit this text command changed = true # Check whether this Show Text command has 3+ lines and the next command # is also a Show Text - elsif lines>=3 && list[i+lines] && list[i+lines].code==101 # Show Text + elsif lines >= 3 && list[i + lines] && list[i + lines].code == 101 # Show Text # Check whether a sentence is being broken midway between two Text # commands (i.e. the first Show Text doesn't end in certain punctuation) - lastLine = list[i+lines-1].parameters[0].sub(/\s+$/,"") - if lastLine.length>0 && !lastLine[/[\\<]/] && lastLine[/[^\.,\!\?\;\-\"]$/] + lastLine = list[i + lines - 1].parameters[0].sub(/\s+$/, "") + if lastLine.length > 0 && !lastLine[/[\\<]/] && lastLine[/[^\.,\!\?\;\-\"]$/] message = list[i].parameters[0] - j = i+1 - while j=0 - list.insert(i,RPG::EventCommand.new((j==0) ? 101 : 401,indent,[nextMessage[j]])) - j-=1 + j = nextMessage.length - 1 + while j >= 0 + list.insert(i, RPG::EventCommand.new((j == 0) ? 101 : 401, indent, [nextMessage[j]])) + j -= 1 end - j = newMessage.length-1 - while j>=0 - list.insert(i,RPG::EventCommand.new((j==0) ? 101 : 401,indent,[newMessage[j]])) + j = newMessage.length - 1 + while j >= 0 + list.insert(i, RPG::EventCommand.new((j == 0) ? 101 : 401, indent, [newMessage[j]])) j -= 1 end changed = true @@ -1269,67 +1269,67 @@ module Compiler end end when 111 # Conditional Branch - if list[i].parameters[0]==12 # script + if list[i].parameters[0] == 12 # script script = list[i].parameters[1] if script[trainerMoneyRE] # Compares $player.money with a value # Checking money directly operator = $1 amount = $2.to_i - if operator=="<" + if operator == "<" params[0] = 7 # gold params[2] = 1 - params[1] = amount-1 + params[1] = amount - 1 changed = true - elsif operator=="<=" + elsif operator == "<=" params[0] = 7 # gold params[2] = 1 params[1] = amount changed = true - elsif operator==">" + elsif operator == ">" params[0] = 7 # gold params[2] = 0 - params[1] = amount+1 + params[1] = amount + 1 changed = true - elsif operator==">=" + elsif operator == ">=" params[0] = 7 # gold params[2] = 0 params[1] = amount changed = true end - elsif script[itemBallRE] && i>0 # Contains pbItemBall after another command + elsif script[itemBallRE] && i > 0 # Contains pbItemBall after another command # Using pbItemBall on non-item events, change it - list[i].parameters[1] = script.sub(/pbItemBall/,"pbReceiveItem") + list[i].parameters[1] = script.sub(/pbItemBall/, "pbReceiveItem") changed = true elsif script[/^\s*(Kernel\.)?(pbTrainerBattle|pbDoubleTrainerBattle)/] # Check if trainer battle conditional branch is empty - j = i+1 + j = i + 1 isempty = true elseIndex = -1 # Check if page is empty - while j=0 - list.insert(elseIndex+1, - RPG::EventCommand.new(115,list[i].indent+1,[]) # Exit Event Processing + if elseIndex >= 0 + list.insert(elseIndex + 1, + RPG::EventCommand.new(115, list[i].indent + 1, []) # Exit Event Processing ) else - list.insert(i+1, - RPG::EventCommand.new(0,list[i].indent+1,[]), # Empty Event - RPG::EventCommand.new(411,list[i].indent,[]), # Else - RPG::EventCommand.new(115,list[i].indent+1,[]) # Exit Event Processing + list.insert(i + 1, + RPG::EventCommand.new(0, list[i].indent + 1, []), # Empty Event + RPG::EventCommand.new(411, list[i].indent, []), # Else + RPG::EventCommand.new(115, list[i].indent + 1, []) # Exit Event Processing ) end changed = true @@ -1350,13 +1350,13 @@ module Compiler # and whose movement type is "Fixed". def plain_event?(event) return false unless event - return false if event.pages.length>1 - return false if event.pages[0].move_type!=0 + return false if event.pages.length > 1 + return false if event.pages[0].move_type != 0 return false if event.pages[0].condition.switch1_valid || event.pages[0].condition.switch2_valid || event.pages[0].condition.variable_valid || event.pages[0].condition.self_switch_valid - return true if event.pages[0].list.length<=1 + return true if event.pages[0].list.length <= 1 return false end @@ -1365,23 +1365,23 @@ module Compiler # like a simple Mart or a Poké Center nurse event. def plain_event_or_mart?(event) return false unless event - return false if event.pages.length>1 - return false if event.pages[0].move_type!=0 + return false if event.pages.length > 1 + return false if event.pages[0].move_type != 0 return false if event.pages[0].condition.switch1_valid || event.pages[0].condition.switch2_valid || event.pages[0].condition.variable_valid || event.pages[0].condition.self_switch_valid # No commands in the event - return true if event.pages[0].list.length<=1 + return true if event.pages[0].list.length <= 1 # pbPokemonMart events - return true if event.pages[0].list.length<=12 && - event.pages[0].graphic.character_name!="" && # Has charset - event.pages[0].list[0].code==355 && # First line is Script + return true if event.pages[0].list.length <= 12 && + event.pages[0].graphic.character_name != "" && # Has charset + event.pages[0].list[0].code == 355 && # First line is Script event.pages[0].list[0].parameters[0][/^pbPokemonMart/] # pbSetPokemonCenter events - return true if event.pages[0].list.length>8 && - event.pages[0].graphic.character_name!="" && # Has charset - event.pages[0].list[0].code==355 && # First line is Script + return true if event.pages[0].list.length > 8 && + event.pages[0].graphic.character_name != "" && # Has charset + event.pages[0].list[0].code == 355 && # First line is Script event.pages[0].list[0].parameters[0][/^pbSetPokemonCenter/] return false end @@ -1390,19 +1390,19 @@ module Compiler # likely to be a "counter event", i.e. is placed on a tile with the Counter # flag, or is on a non-passable tile between two passable tiles (e.g. a desk) # where one of those two tiles is occupied by thisEvent. - def likely_counter?(thisEvent,otherEvent,mapID,mapData) + def likely_counter?(thisEvent, otherEvent, mapID, mapData) # Check whether otherEvent is on a counter tile - return true if mapData.isCounterTile?(mapID,otherEvent.x,otherEvent.y) + return true if mapData.isCounterTile?(mapID, otherEvent.x, otherEvent.y) # Check whether otherEvent is between an event with a graphic (e.g. an NPC) # and a spot where the player can be yonderX = otherEvent.x + (otherEvent.x - thisEvent.x) yonderY = otherEvent.y + (otherEvent.y - thisEvent.y) - return thisEvent.pages[0].graphic.character_name!="" && # Has charset - otherEvent.pages[0].graphic.character_name=="" && # Has no charset - otherEvent.pages[0].trigger==0 && # Action trigger - mapData.isPassable?(mapID,thisEvent.x,thisEvent.y) && - !mapData.isPassable?(mapID,otherEvent.x,otherEvent.y) && - mapData.isPassable?(mapID,yonderX,yonderY) + return thisEvent.pages[0].graphic.character_name != "" && # Has charset + otherEvent.pages[0].graphic.character_name == "" && # Has no charset + otherEvent.pages[0].trigger == 0 && # Action trigger + mapData.isPassable?(mapID, thisEvent.x, thisEvent.y) && + !mapData.isPassable?(mapID, otherEvent.x, otherEvent.y) && + mapData.isPassable?(mapID, yonderX, yonderY) end # Checks all events in the given map to see if any look like they've been @@ -1413,7 +1413,7 @@ module Compiler # Any events found to be like this have their contents merged into the NPC # event and the counter event itself is deleted. The tile below the counter # event gets its counter flag set (if it isn't already). - def check_counters(map,mapID,mapData) + def check_counters(map, mapID, mapData) toDelete = [] changed = false for key in map.events.keys @@ -1422,21 +1422,21 @@ module Compiler # Found an event that is empty or looks like a simple Mart or a Poké # Center nurse. Check adjacent events to see if they are "counter events". neighbors = [] - neighbors.push(mapData.getEventFromXY(mapID,event.x,event.y-1)) - neighbors.push(mapData.getEventFromXY(mapID,event.x,event.y+1)) - neighbors.push(mapData.getEventFromXY(mapID,event.x-1,event.y)) - neighbors.push(mapData.getEventFromXY(mapID,event.x+1,event.y)) + neighbors.push(mapData.getEventFromXY(mapID, event.x, event.y - 1)) + neighbors.push(mapData.getEventFromXY(mapID, event.x, event.y + 1)) + neighbors.push(mapData.getEventFromXY(mapID, event.x - 1, event.y)) + neighbors.push(mapData.getEventFromXY(mapID, event.x + 1, event.y)) neighbors.compact! for otherEvent in neighbors next if plain_event?(otherEvent) # Blank/cosmetic-only event - next if !likely_counter?(event,otherEvent,mapID,mapData) + next if !likely_counter?(event, otherEvent, mapID, mapData) # Found an adjacent event that looks like it's supposed to be a counter. # Set the counter flag of the tile beneath the counter event, copy the # counter event's pages to the NPC event, and delete the counter event. - mapData.setCounterTile(mapID,otherEvent.x,otherEvent.y) + mapData.setCounterTile(mapID, otherEvent.x, otherEvent.y) savedPage = event.pages[0] event.pages = otherEvent.pages - apply_pages(savedPage,event.pages) # Apply NPC's visuals to new event pages + apply_pages(savedPage, event.pages) # Apply NPC's visuals to new event pages toDelete.push(otherEvent.id) changed = true end @@ -1464,11 +1464,11 @@ module Compiler map = mapData.getMap(id) next if !map || !mapData.mapinfos[id] for key in map.events.keys - if Time.now.to_i-t>=5 + if Time.now.to_i - t >= 5 Graphics.update t = Time.now.to_i end - newevent = convert_to_trainer_event(map.events[key],trainerChecker) + newevent = convert_to_trainer_event(map.events[key], trainerChecker) if newevent map.events[key] = newevent changed = true @@ -1480,17 +1480,17 @@ module Compiler end changed = true if fix_event_name(map.events[key]) changed = true if fix_event_scripts(map.events[key]) - newevent = fix_event_use(map.events[key],id,mapData) + newevent = fix_event_use(map.events[key], id, mapData) if newevent map.events[key] = newevent changed = true end end - if Time.now.to_i-t>=5 + if Time.now.to_i - t >= 5 Graphics.update t = Time.now.to_i end - changed = true if check_counters(map,id,mapData) + changed = true if check_counters(map, id, mapData) if changed mapData.saveMap(id) mapData.saveTilesets @@ -1504,13 +1504,13 @@ module Compiler commonEvents = load_data("Data/CommonEvents.rxdata") Console.echo_li _INTL("Processing common events...") for key in 0...commonEvents.length - newevent = fix_event_use(commonEvents[key],0,mapData) + newevent = fix_event_use(commonEvents[key], 0, mapData) if newevent commonEvents[key] = newevent changed = true end end - save_data(commonEvents,"Data/CommonEvents.rxdata") if changed + save_data(commonEvents, "Data/CommonEvents.rxdata") if changed Console.echo_done(true) if change_record.length > 0 || changed Console.echo_warn _INTL("RMXP data was altered. Close RMXP now to ensure changes are applied.")