diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index c17633d49..fe813737a 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -87,8 +87,8 @@ NO_SIGNPOSTS = [] # * The maximum length, in characters, that the player's name can be. #=============================================================================== INITIAL_MONEY = 3000 -MAX_MONEY = 999999 -MAX_COINS = 99999 +MAX_MONEY = 999_999 +MAX_COINS = 99_999 MAX_PLAYER_NAME_SIZE = 10 #=============================================================================== @@ -97,9 +97,9 @@ MAX_PLAYER_NAME_SIZE = 10 # associated trainer type will be named as whatever is in that variable. #=============================================================================== RIVAL_NAMES = [ - [:RIVAL1,12], - [:RIVAL2,12], - [:CHAMPION,12] + [:RIVAL1, 12], + [:RIVAL2, 12], + [:CHAMPION, 12] ] #=============================================================================== @@ -155,7 +155,7 @@ SCALED_EXP_FORMULA = true SPLIT_EXP_BETWEEN_GAINERS = false ENABLE_CRITICAL_CAPTURES = false GAIN_EXP_FOR_CAPTURE = true -MEGA_RINGS = [:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM] +MEGA_RINGS = [:MEGARING, :MEGABRACELET, :MEGACUFF, :MEGACHARM] #=============================================================================== # * The names of each pocket of the Bag. Leave the first entry blank. @@ -166,18 +166,18 @@ MEGA_RINGS = [:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM] # first entry (the 0). #=============================================================================== def pbPocketNames; return ["", - _INTL("Items"), - _INTL("Medicine"), - _INTL("Poké Balls"), - _INTL("TMs & HMs"), - _INTL("Berries"), - _INTL("Mail"), - _INTL("Battle Items"), - _INTL("Key Items") + _INTL("Items"), + _INTL("Medicine"), + _INTL("Poké Balls"), + _INTL("TMs & HMs"), + _INTL("Berries"), + _INTL("Mail"), + _INTL("Battle Items"), + _INTL("Key Items") ]; end -BAG_MAX_POCKET_SIZE = [0,-1,-1,-1,-1,-1,-1,-1,-1] +BAG_MAX_POCKET_SIZE = [0, -1, -1, -1, -1, -1, -1, -1, -1] BAG_MAX_PER_SLOT = 999 -BAG_POCKET_AUTO_SORT = [0,false,false,false,true,true,false,false,false] +BAG_POCKET_AUTO_SORT = [0, false, false, false, true, true, false, false, false] #=============================================================================== # * A set of arrays each containing details of a graphic to be shown on the @@ -190,8 +190,8 @@ BAG_POCKET_AUTO_SORT = [0,false,false,false,true,true,false,false,false] # - The graphic will always (true) or never (false) be shown on a wall map. #=============================================================================== REGION_MAP_EXTRAS = [ - [0,51,16,15,"mapHiddenBerth",false], - [0,52,20,14,"mapHiddenFaraday",false] + [0, 51, 16, 15, "mapHiddenBerth", false], + [0, 52, 20, 14, "mapHiddenFaraday", false] ] #=============================================================================== @@ -229,9 +229,9 @@ NUM_STORAGE_BOXES = 30 #=============================================================================== USE_CURRENT_REGION_DEX = false def pbDexNames; return [ - [_INTL("Kanto Pokédex"),0], - [_INTL("Johto Pokédex"),1], - _INTL("National Pokédex") + [_INTL("Kanto Pokédex"), 0], + [_INTL("Johto Pokédex"), 1], + _INTL("National Pokédex") ]; end DEX_SHOWS_ALL_FORMS = false DEXES_WITH_OFFSETS = [] @@ -250,27 +250,27 @@ DEXES_WITH_OFFSETS = [] # - Roaming areas specifically for this Pokémon (optional). #=============================================================================== RoamingAreas = { - 5 => [21,28,31,39,41,44,47,66,69], - 21 => [5,28,31,39,41,44,47,66,69], - 28 => [5,21,31,39,41,44,47,66,69], - 31 => [5,21,28,39,41,44,47,66,69], - 39 => [5,21,28,31,41,44,47,66,69], - 41 => [5,21,28,31,39,44,47,66,69], - 44 => [5,21,28,31,39,41,47,66,69], - 47 => [5,21,28,31,39,41,44,66,69], - 66 => [5,21,28,31,39,41,44,47,69], - 69 => [5,21,28,31,39,41,44,47,66] + 5 => [ 21, 28, 31, 39, 41, 44, 47, 66, 69], + 21 => [5, 28, 31, 39, 41, 44, 47, 66, 69], + 28 => [5, 21, 31, 39, 41, 44, 47, 66, 69], + 31 => [5, 21, 28, 39, 41, 44, 47, 66, 69], + 39 => [5, 21, 28, 31, 41, 44, 47, 66, 69], + 41 => [5, 21, 28, 31, 39, 44, 47, 66, 69], + 44 => [5, 21, 28, 31, 39, 41, 47, 66, 69], + 47 => [5, 21, 28, 31, 39, 41, 44, 66, 69], + 66 => [5, 21, 28, 31, 39, 41, 44, 47, 69], + 69 => [5, 21, 28, 31, 39, 41, 44, 47, 66 ] } RoamingSpecies = [ - [:LATIAS, 30, 53, 0, "Battle roaming"], - [:LATIOS, 30, 53, 0, "Battle roaming"], - [:KYOGRE, 40, 54, 2, nil, { - 2 => [21,31], - 21 => [2,31,69], - 31 => [2,21,69], - 69 => [21,31] - }], - [:ENTEI, 40, 55, 1, nil] + [:LATIAS, 30, 53, 0, "Battle roaming"], + [:LATIOS, 30, 53, 0, "Battle roaming"], + [:KYOGRE, 40, 54, 2, nil, { + 2 => [ 21, 31 ], + 21 => [2, 31, 69], + 31 => [2, 21, 69], + 69 => [ 21, 31 ] + }], + [:ENTEI, 40, 55, 1, nil] ] #=============================================================================== @@ -283,10 +283,10 @@ RoamingSpecies = [ # - Maximum possible level (optional). #=============================================================================== POKE_RADAR_ENCOUNTERS = [ - [5, 20, :STARLY, 12, 15], - [21, 10, :STANTLER, 14], - [28, 20, :BUTTERFREE, 15, 18], - [28, 20, :BEEDRILL, 15, 18] + [5, 20, :STARLY, 12, 15], + [21, 10, :STANTLER, 14], + [28, 20, :BUTTERFREE, 15, 18], + [28, 20, :BEEDRILL, 15, 18] ] #=============================================================================== @@ -348,6 +348,6 @@ PLANT_SPARKLE_ANIMATION_ID = 7 # languages to choose from. #=============================================================================== LANGUAGES = [ -# ["English","english.dat"], -# ["Deutsch","deutsch.dat"] +# ["English", "english.dat"], +# ["Deutsch", "deutsch.dat"] ] diff --git a/Data/Scripts/001_Technical/001_Ruby Utilities.rb b/Data/Scripts/001_Technical/001_Ruby Utilities.rb index 37878fe6f..d59d5ca63 100644 --- a/Data/Scripts/001_Technical/001_Ruby Utilities.rb +++ b/Data/Scripts/001_Technical/001_Ruby Utilities.rb @@ -7,24 +7,20 @@ class Class end end - - #=============================================================================== # module Comparable #=============================================================================== unless Comparable.method_defined? :clamp module Comparable def clamp(min, max) - if max-min<0 + if max - min < 0 raise ArgumentError("min argument must be smaller than max argument") end - return (self>max) ? max : (self max) ? max : (self < min) ? min : self end end end - - #=============================================================================== # class Boolean #=============================================================================== @@ -34,32 +30,30 @@ class Boolean end end - - #=============================================================================== # class String #=============================================================================== class String def starts_with?(str) proc = (self[0...str.length] == str) if self.length >= str.length - return proc ? proc : false + return proc || false end def ends_with?(str) e = self.length - 1 proc = (self[(e-str.length)...e] == str) if self.length >= str.length - return proc ? proc : false + return proc || false end def starts_with_vowel? - return ['a','e','i','o','u'].include?(self[0,1].downcase) + return ['a', 'e', 'i', 'o', 'u'].include?(self[0, 1].downcase) end - def first(n=1) + def first(n = 1) return self[0...n] end - def last(n=1) + def last(n = 1) return self[-n..-1] || self end @@ -90,14 +84,14 @@ class String return blank end - def cut(bitmap,width) + def cut(bitmap, width) string = self width -= bitmap.text_size("...").width string_width = 0 text = [] for char in string.scan(/./) wdh = bitmap.text_size(char).width - next if (wdh+string_width) > width + next if (wdh + string_width) > width string_width += wdh text.push(char) end @@ -110,8 +104,6 @@ class String end end - - #=============================================================================== # class Numeric #=============================================================================== @@ -122,21 +114,17 @@ class Numeric end end - - #=============================================================================== # class Integer #=============================================================================== class Integer # Returns an array containing each digit of the number in turn. - def digits(base=10) + def digits(base = 10) quotient, remainder = divmod(base) - (quotient==0) ? [remainder] : quotient.digits(base).push(remainder) + return (quotient == 0) ? [remainder] : quotient.digits(base).push(remainder) end end - - #=============================================================================== # class Array #=============================================================================== @@ -150,7 +138,7 @@ class Array end def ^(other) # xor of two arrays - return (self|other)-(self&other) + return (self|other) - (self&other) end def shuffle @@ -158,15 +146,14 @@ class Array end unless method_defined? :shuffle def shuffle! - (size-1).times do |i| - r = i+rand(size-i) + (size - 1).times do |i| + r = i + rand(size - i) self[i], self[r] = self[r], self[i] end self end unless method_defined? :shuffle! end - #=============================================================================== # module Enumerable #=============================================================================== @@ -178,8 +165,6 @@ module Enumerable end end - - #=============================================================================== # Kernel methods #=============================================================================== diff --git a/Data/Scripts/018_Minigames/001_PMinigame_Duel.rb b/Data/Scripts/018_Minigames/001_PMinigame_Duel.rb index 265035df8..99942e94a 100644 --- a/Data/Scripts/018_Minigames/001_PMinigame_Duel.rb +++ b/Data/Scripts/018_Minigames/001_PMinigame_Duel.rb @@ -1,308 +1,302 @@ -################################################################################ +#=============================================================================== # "Duel" mini-game # Based on the Duel minigame by Alael -################################################################################ -begin - +#=============================================================================== class DuelWindow < Window_AdvancedTextPokemon - attr_accessor :hp - attr_accessor :name - attr_accessor :isEnemy + attr_reader :hp + attr_reader :name + attr_reader :is_enemy - def initialize(name,isEnemy) - @hp = 10 - @name = name - @isEnemy = isEnemy - super("") + def initialize(name, is_enemy) + @hp = 10 + @name = name + @is_enemy = is_enemy + super() self.width = 160 self.height = 96 - duelRefresh + duel_refresh end def hp=(value) @hp = value - duelRefresh + duel_refresh end def name=(value) @name = value - duelRefresh + duel_refresh end - def isEnemy=(value) - @isEnemy = value - duelRefresh + def is_enemy=(value) + @is_enemy = value + duel_refresh end - def duelRefresh - nameColor = @isEnemy ? "" : "" - hpColor = "" - self.text = _INTL("{1}{2}\r\n{3}HP: {4}",nameColor,fmtescape(@name),hpColor,@hp) + def duel_refresh + name_color = @is_enemy ? "" : "" + hp_color = "" + self.text = _INTL("{1}{2}\r\n{3}HP: {4}", name_color, fmtescape(@name), hp_color, @hp) end end - - +#=============================================================================== +# +#=============================================================================== class PokemonDuel - def pbStartDuel(opponent,event) - @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) + def pbStartDuel(opponent, event) + @event = event + @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 @sprites = {} - @event = event - @sprites["player"] = IconSprite.new(-128-32,96,@viewport) + @sprites["player"] = IconSprite.new(-128 - 32, 96, @viewport) @sprites["player"].setBitmap(pbTrainerSpriteFile($Trainer.trainertype)) - @sprites["opponent"] = IconSprite.new(Graphics.width+32,96,@viewport) + @sprites["opponent"] = IconSprite.new(Graphics.width + 32, 96, @viewport) @sprites["opponent"].setBitmap(pbTrainerSpriteFile(opponent.trainertype)) - @sprites["playerwindow"] = DuelWindow.new($Trainer.name,false) + @sprites["playerwindow"] = DuelWindow.new($Trainer.name, false) @sprites["playerwindow"].x = -@sprites["playerwindow"].width @sprites["playerwindow"].viewport = @viewport - @sprites["opponentwindow"] = DuelWindow.new(opponent.name,true) + @sprites["opponentwindow"] = DuelWindow.new(opponent.name, true) @sprites["opponentwindow"].x = Graphics.width @sprites["opponentwindow"].viewport = @viewport - pbWait(Graphics.frame_rate/2) - distancePerFrame = 8*20/Graphics.frame_rate - while @sprites["player"].x<0 - @sprites["player"].x += distancePerFrame - @sprites["playerwindow"].x += distancePerFrame - @sprites["opponent"].x -= distancePerFrame - @sprites["opponentwindow"].x -= distancePerFrame + pbWait(Graphics.frame_rate / 2) + distance_per_frame = 8 * 20 / Graphics.frame_rate + while @sprites["player"].x < 0 + @sprites["player"].x += distance_per_frame + @sprites["playerwindow"].x += distance_per_frame + @sprites["opponent"].x -= distance_per_frame + @sprites["opponentwindow"].x -= distandistance_per_framecePerFrame Graphics.update Input.update pbUpdateSceneMap end - @oldmovespeed = $game_player.move_speed + @oldmovespeed = $game_player.move_speed @oldeventspeed = event.move_speed - pbMoveRoute($game_player,[ - PBMoveRoute::ChangeSpeed,2, - PBMoveRoute::DirectionFixOn]) - pbMoveRoute(event,[ - PBMoveRoute::ChangeSpeed,2, - PBMoveRoute::DirectionFixOn]) - pbWait(Graphics.frame_rate*3/4) + pbMoveRoute($game_player, [ + PBMoveRoute::ChangeSpeed, 2, + PBMoveRoute::DirectionFixOn]) + pbMoveRoute(event, [ + PBMoveRoute::ChangeSpeed, 2, + PBMoveRoute::DirectionFixOn]) + pbWait(Graphics.frame_rate * 3 / 4) end - def pbDuel(opponent,event,speeches) - pbStartDuel(opponent,event) - @hp = [10,10] - @special = [false,false] + def pbDuel(opponent, event, speeches) + pbStartDuel(opponent, event) + @hp = [10, 10] + @special = [false, false] decision = nil loop do - @hp[0] = 0 if @hp[0]<0 - @hp[1] = 0 if @hp[1]<0 + @hp[0] = 0 if @hp[0] < 0 + @hp[1] = 0 if @hp[1] < 0 pbRefresh - if @hp[0]<=0 + if @hp[0] <= 0 decision = false break - elsif @hp[1]<=0 + elsif @hp[1] <= 0 decision = true break end action = 0 - scores = [3,4,4,2] + scores = [3, 4, 4, 2] choices = (@special[1]) ? 3 : 4 scores[3] = 0 if @special[1] - total = scores[0]+scores[1]+scores[2]+scores[3] - if total<=0 + total = scores[0] + scores[1] + scores[2] + scores[3] + if total <= 0 action = rand(choices) else num = rand(total) cumtotal = 0 for i in 0...4 cumtotal += scores[i] - if num=prex+prewidth || provy+provheight<=prey || provy>=prey+preheight - dx=prex-provx - dy=prey-provy for j in 0...prepattern.length next if prepattern[j]==0 xco=prex+(j%prewidth) @@ -359,8 +357,6 @@ class MiningGameScene prepattern=IRON[i[0]][4] next if provx+provwidth<=prex || provx>=prex+prewidth || provy+provheight<=prey || provy>=prey+preheight - dx=prex-provx - dy=prey-provy for j in 0...prepattern.length next if prepattern[j]==0 xco=prex+(j%prewidth)