Resolved many Rubocop warnings

This commit is contained in:
Maruno17
2020-09-06 17:31:12 +01:00
parent 6c4670eaa3
commit 681a8331ab
137 changed files with 921 additions and 1200 deletions
@@ -4,8 +4,9 @@ $scene = nil
Font.default_shadow = false if Font.respond_to?(:default_shadow) Font.default_shadow = false if Font.respond_to?(:default_shadow)
Graphics.frame_rate = 40 Graphics.frame_rate = 40
#===============================================================================
#
#===============================================================================
=begin =begin
class Win32API class Win32API
class << self class << self
@@ -14,9 +15,9 @@ class Win32API
end end
def new(*args) def new(*args)
File.open("winapi.txt","ab") { |f| f.write("new(#{args[0]},#{args[1]})\r\n") } File.open("winapi.txt", "ab") { |f| f.write("new(#{args[0]},#{args[1]})\r\n") }
b=debug_new(*args) b = debug_new(*args)
b.setDllName(args[0],args[1]) b.setDllName(args[0], args[1])
return b return b
end end
end end
@@ -26,13 +27,13 @@ class Win32API
end end
def setDllName(a,b) def setDllName(a,b)
@w32dll=a @w32dll = a
@w32name=b @w32name = b
end end
def call(*args) def call(*args)
if @w32name!="GetAsyncKeyState" if @w32name != "GetAsyncKeyState"
File.open("winapi.txt","ab") { |f| File.open("winapi.txt", "ab") { |f|
f.write("call(#{@w32dll},#{@w32name},#{args.inspect})\r\n") f.write("call(#{@w32dll},#{@w32name},#{args.inspect})\r\n")
} }
end end
@@ -47,8 +48,8 @@ class Bitmap
end end
def new(*args) def new(*args)
if args.length==1 if args.length == 1
File.open("winapib.txt","ab") { |f| f.write("new(#{args[0]})\r\n") } File.open("winapib.txt", "ab") { |f| f.write("new(#{args[0]})\r\n") }
end end
debug_new(*args) debug_new(*args)
end end
@@ -58,31 +59,28 @@ end
alias debug_load_data load_data alias debug_load_data load_data
def load_data(*args) def load_data(*args)
File.open("winapif.txt","ab") { |f| f.write("load(#{args[0]})\r\n") } File.open("winapif.txt", "ab") { |f| f.write("load(#{args[0]})\r\n") }
debug_load_data(*args) debug_load_data(*args)
end end
=end =end
class Hangup < Exception; end class Hangup < Exception; end
if false if false
p (Tilemap.instance_methods-Kernel.instance_methods-Object.instance_methods).sort p (Tilemap.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
# no changes # no changes
p (Plane.instance_methods-Kernel.instance_methods-Object.instance_methods).sort p (Plane.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
# no changes # no changes
p (Viewport.instance_methods-Kernel.instance_methods-Object.instance_methods).sort p (Viewport.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
p (Bitmap.instance_methods-Kernel.instance_methods-Object.instance_methods).sort p (Bitmap.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
# openness(=) # openness(=)
p (Window.instance_methods-Kernel.instance_methods-Object.instance_methods).sort p (Window.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
p (Sprite.instance_methods-Kernel.instance_methods-Object.instance_methods).sort p (Sprite.instance_methods - Kernel.instance_methods - Object.instance_methods).sort
end end
#===============================================================================
#
#===============================================================================
module RPG module RPG
class Animation class Animation
attr_accessor :id attr_accessor :id
@@ -107,8 +105,6 @@ module RPG
end end
end end
module RPG module RPG
class Animation class Animation
class Frame class Frame
@@ -123,8 +119,6 @@ module RPG
end end
end end
module RPG module RPG
class Animation class Animation
class Timing class Timing
@@ -139,7 +133,7 @@ module RPG
@frame = 0 @frame = 0
@se = RPG::AudioFile.new("", 80) @se = RPG::AudioFile.new("", 80)
@flash_scope = 0 @flash_scope = 0
@flash_color = Color.new(255,255,255,255) @flash_color = Color.new(255, 255, 255, 255)
@flash_duration = 5 @flash_duration = 5
@condition = 0 @condition = 0
end end
@@ -147,8 +141,6 @@ module RPG
end end
end end
module RPG module RPG
class System class System
attr_accessor :magic_number attr_accessor :magic_number
@@ -227,8 +219,6 @@ module RPG
end end
end end
module RPG module RPG
class Tileset class Tileset
attr_accessor :id attr_accessor :id
@@ -253,7 +243,7 @@ module RPG
@id = 0 @id = 0
@name = "" @name = ""
@tileset_name = "" @tileset_name = ""
@autotile_names = [""]*7 @autotile_names = [""] * 7
@panorama_name = "" @panorama_name = ""
@panorama_hue = 0 @panorama_hue = 0
@fog_name = "" @fog_name = ""
@@ -272,8 +262,6 @@ module RPG
end end
end end
module RPG module RPG
class CommonEvent class CommonEvent
attr_accessor :id attr_accessor :id
@@ -292,8 +280,6 @@ module RPG
end end
end end
module RPG module RPG
class Map class Map
attr_accessor :tileset_id attr_accessor :tileset_id
@@ -324,8 +310,6 @@ module RPG
end end
end end
module RPG module RPG
class MapInfo class MapInfo
attr_accessor :name attr_accessor :name
@@ -346,8 +330,6 @@ module RPG
end end
end end
module RPG module RPG
class Event class Event
attr_accessor :id attr_accessor :id
@@ -366,8 +348,6 @@ module RPG
end end
end end
module RPG module RPG
class Event class Event
class Page class Page
@@ -404,8 +384,6 @@ module RPG
end end
end end
module RPG module RPG
class Event class Event
class Page class Page
@@ -436,8 +414,6 @@ module RPG
end end
end end
module RPG module RPG
class Event class Event
class Page class Page
@@ -464,8 +440,6 @@ module RPG
end end
end end
module RPG module RPG
class EventCommand class EventCommand
attr_accessor :code attr_accessor :code
@@ -480,8 +454,6 @@ module RPG
end end
end end
module RPG module RPG
class MoveRoute class MoveRoute
attr_accessor :repeat attr_accessor :repeat
@@ -496,8 +468,6 @@ module RPG
end end
end end
module RPG module RPG
class MoveCommand class MoveCommand
attr_accessor :code attr_accessor :code
@@ -510,8 +480,6 @@ module RPG
end end
end end
module RPG module RPG
class System class System
class Words class Words
@@ -562,8 +530,6 @@ module RPG
end end
end end
module RPG module RPG
class System class System
class TestBattler class TestBattler
@@ -588,8 +554,6 @@ module RPG
end end
end end
module RPG module RPG
class AudioFile class AudioFile
attr_accessor :name attr_accessor :name
@@ -8,7 +8,7 @@ class SpriteAnimation
%w[ %w[
x y ox oy viewport flash src_rect opacity tone x y ox oy viewport flash src_rect opacity tone
].each_with_index do |s, i| ].each_with_index do |s, _i|
eval <<-__END__ eval <<-__END__
def #{s}(*arg) def #{s}(*arg)
@@ -49,7 +49,7 @@ class SpriteAnimation
end end
@_animation_sprites = [] @_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation) if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15 16.times do
sprite = ::Sprite.new(self.viewport) sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap sprite.bitmap = bitmap
sprite.visible = false sprite.visible = false
@@ -82,7 +82,7 @@ class SpriteAnimation
@@_reference_count[bitmap] = 1 @@_reference_count[bitmap] = 1
end end
@_loop_animation_sprites = [] @_loop_animation_sprites = []
for i in 0..15 16.times do
sprite = ::Sprite.new(self.viewport) sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap sprite.bitmap = bitmap
sprite.visible = false sprite.visible = false
+6 -6
View File
@@ -1,8 +1,8 @@
class Win32API class Win32API
@@RGSSWINDOW = nil @@RGSSWINDOW = nil
@@GetCurrentThreadId = Win32API.new('kernel32','GetCurrentThreadId', '%w()','l') @@GetCurrentThreadId = Win32API.new('kernel32', 'GetCurrentThreadId', '%w()', 'l')
@@GetWindowThreadProcessId = Win32API.new('user32','GetWindowThreadProcessId', '%w(l p)','l') @@GetWindowThreadProcessId = Win32API.new('user32', 'GetWindowThreadProcessId', '%w(l p)', 'l')
@@FindWindowEx = Win32API.new('user32','FindWindowEx', '%w(l l p p)','l') @@FindWindowEx = Win32API.new('user32', 'FindWindowEx', '%w(l l p p)', 'l')
def Win32API.SetWindowText(text) def Win32API.SetWindowText(text)
hWnd = pbFindRgssWindow hWnd = pbFindRgssWindow
@@ -16,7 +16,7 @@ class Win32API
processid = [0].pack('l') processid = [0].pack('l')
threadid = @@GetCurrentThreadId.call threadid = @@GetCurrentThreadId.call
nextwindow = 0 nextwindow = 0
begin loop do
nextwindow = @@FindWindowEx.call(0,nextwindow,"RGSS Player",0) nextwindow = @@FindWindowEx.call(0,nextwindow,"RGSS Player",0)
if nextwindow!=0 if nextwindow!=0
wndthreadid = @@GetWindowThreadProcessId.call(nextwindow,processid) wndthreadid = @@GetWindowThreadProcessId.call(nextwindow,processid)
@@ -25,9 +25,9 @@ class Win32API
return @@RGSSWINDOW return @@RGSSWINDOW
end end
end end
end until nextwindow==0 break if nextwindow==0
end
raise "Can't find RGSS player window" raise "Can't find RGSS player window"
return 0
end end
def Win32API.SetWindowPos(w, h) def Win32API.SetWindowPos(w, h)
@@ -48,7 +48,6 @@ module Console
@apiSetConsoleTitle = Win32API.new("kernel32","SetConsoleTitle","p","s") @apiSetConsoleTitle = Win32API.new("kernel32","SetConsoleTitle","p","s")
access = (GENERIC_READ | GENERIC_WRITE) access = (GENERIC_READ | GENERIC_WRITE)
sharemode = (FILE_SHARE_READ | FILE_SHARE_WRITE) sharemode = (FILE_SHARE_READ | FILE_SHARE_WRITE)
returnCode = AllocConsole()
@bufferHandle = CreateConsoleScreenBuffer(access,sharemode,CONSOLE_TEXTMODE_BUFFER) @bufferHandle = CreateConsoleScreenBuffer(access,sharemode,CONSOLE_TEXTMODE_BUFFER)
f = File.open("Game.ini") f = File.open("Game.ini")
lines = f.readlines() lines = f.readlines()
@@ -94,7 +93,7 @@ module Console
offset=0 offset=0
events=eventsread.unpack("V") events=eventsread.unpack("V")
echo("got input [eventsread #{events}") echo("got input [eventsread #{events}")
for i in 0...events[0] events[0].length.times do
keyevent=buffer[offset,20] keyevent=buffer[offset,20]
keyevent=keyevent.unpack("vCvvvvV") keyevent=keyevent.unpack("vCvvvvV")
if keyevent[0]==1 && keyevent[1]>0 if keyevent[0]==1 && keyevent[1]>0
@@ -121,7 +120,6 @@ module Console
echo(sprintf("failed (%d)\r\n",getlast.call())) echo(sprintf("failed (%d)\r\n",getlast.call()))
break break
end end
offset=0
events=eventsread.unpack("V") events=eventsread.unpack("V")
if events[0]>0 if events[0]>0
echo("got input [eventsread #{events}][buffer #{buffer}]\r\n") echo("got input [eventsread #{events}][buffer #{buffer}]\r\n")
@@ -157,7 +157,7 @@ module Graphics
def self.wait(frames) def self.wait(frames)
return if frames<=0 return if frames<=0
frames.times do |i| frames.times do
self.update self.update
end end
end end
@@ -675,16 +675,16 @@ class Bitmap
end end
def swap32(x) def swap32(x)
return ((x>>24)&0x000000FF)| return ((x >> 24) & 0x000000FF) |
((x>>8)&0x0000FF00)| ((x >> 8) & 0x0000FF00) |
((x<<8)&0x00FF0000)| ((x << 8) & 0x00FF0000) |
((x<<24)&0xFF000000) ((x << 24) & 0xFF000000)
end end
def asOpaque def asOpaque
data=getData data=getData
j=3 j=3
for i in 0...width*height (width*height).times do
data[j]=0xFF data[j]=0xFF
j+=4 j+=4
end end
@@ -705,7 +705,6 @@ class Bitmap
row=(self.height-1)*bytesPerScan row=(self.height-1)*bytesPerScan
data=self.getData data=self.getData
data2=data.clone data2=data.clone
width=self.width
x="" x=""
len=bytesPerScan*self.height len=bytesPerScan*self.height
ttt=Time.now ttt=Time.now
@@ -713,13 +712,14 @@ class Bitmap
SwapRgb.call(data2,data2.length) SwapRgb.call(data2,data2.length)
else else
# the following is considerably slower # the following is considerably slower
b=0;c=2;while b!=len b=0; c=2
while b!=len
data2[b]=data[c] data2[b]=data[c]
data2[c]=data[b] data2[c]=data[b]
b+=4;c+=4; b+=4; c+=4;
end end
end end
#$times.push(Time.now-ttt) # $times.push(Time.now-ttt)
filter="\0" filter="\0"
while row>=0 while row>=0
thisRow=data2[row,bytesPerScan] thisRow=data2[row,bytesPerScan]
@@ -22,7 +22,7 @@ class Game_Character
attr_accessor :transparent attr_accessor :transparent
attr_reader :move_speed attr_reader :move_speed
attr_accessor :walk_anime attr_accessor :walk_anime
attr_accessor :bob_height attr_writer :bob_height
def initialize(map=nil) def initialize(map=nil)
@map = map @map = map
@@ -415,7 +415,7 @@ class Game_Character
when 42; @opacity = command.parameters[0] when 42; @opacity = command.parameters[0]
when 43; @blend_type = command.parameters[0] when 43; @blend_type = command.parameters[0]
when 44; pbSEPlay(command.parameters[0]) when 44; pbSEPlay(command.parameters[0])
when 45; result = eval(command.parameters[0]) when 45; eval(command.parameters[0])
end end
@move_route_index += 1 @move_route_index += 1
end end
@@ -225,8 +225,6 @@ class Game_Player < Game_Character
def center(x, y) def center(x, y)
center_x = (Graphics.width/2 - Game_Map::TILE_WIDTH/2) * Game_Map::X_SUBPIXELS center_x = (Graphics.width/2 - Game_Map::TILE_WIDTH/2) * Game_Map::X_SUBPIXELS
center_y = (Graphics.height/2 - Game_Map::TILE_HEIGHT/2) * Game_Map::Y_SUBPIXELS center_y = (Graphics.height/2 - Game_Map::TILE_HEIGHT/2) * Game_Map::Y_SUBPIXELS
max_x = (self.map.width - Graphics.width*1.0/Game_Map::TILE_WIDTH) * Game_Map::REAL_RES_X
max_y = (self.map.height - Graphics.height*1.0/Game_Map::TILE_HEIGHT) * Game_Map::REAL_RES_Y
dispx = x * Game_Map::REAL_RES_X - center_x dispx = x * Game_Map::REAL_RES_X - center_x
dispy = y * Game_Map::REAL_RES_Y - center_y dispy = y * Game_Map::REAL_RES_Y - center_y
self.map.display_x = dispx self.map.display_x = dispx
@@ -464,7 +462,6 @@ end
def pbUpdateVehicle def pbUpdateVehicle
meta = pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID) meta = pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
if meta if meta
newCharName = nil
charset = 1 # Regular graphic charset = 1 # Regular graphic
if $PokemonGlobal.diving; charset = 5 # Diving graphic if $PokemonGlobal.diving; charset = 5 # Diving graphic
elsif $PokemonGlobal.surfing; charset = 3 # Surfing graphic elsif $PokemonGlobal.surfing; charset = 3 # Surfing graphic
@@ -25,8 +25,8 @@ class Game_Map
attr_reader :fog_oy # fog y-coordinate starting point attr_reader :fog_oy # fog y-coordinate starting point
attr_reader :fog_tone # fog color tone attr_reader :fog_tone # fog color tone
attr_accessor :battleback_name # battleback file name attr_accessor :battleback_name # battleback file name
attr_accessor :display_x # display x-coordinate * 128 attr_reader :display_x # display x-coordinate * 128
attr_accessor :display_y # display y-coordinate * 128 attr_reader :display_y # display y-coordinate * 128
attr_accessor :need_refresh # refresh request flag attr_accessor :need_refresh # refresh request flag
TILE_WIDTH = 32 TILE_WIDTH = 32
@@ -1,13 +1,13 @@
class Spriteset_Global class Spriteset_Global
attr_reader :playersprite attr_reader :playersprite
@@viewport2 = Viewport.new(0,0,Graphics.width,Graphics.height) @@viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
@@viewport2.z = 200 @@viewport2.z = 200
def initialize def initialize
@playersprite = Sprite_Character.new(Spriteset_Map.viewport,$game_player) @playersprite = Sprite_Character.new(Spriteset_Map.viewport, $game_player)
@picture_sprites = [] @picture_sprites = []
for i in 1..100 for i in 1..100
@picture_sprites.push(Sprite_Picture.new(@@viewport2,$game_screen.pictures[i])) @picture_sprites.push(Sprite_Picture.new(@@viewport2, $game_screen.pictures[i]))
end end
@timer_sprite = Sprite_Timer.new @timer_sprite = Sprite_Timer.new
update update
@@ -15,9 +15,7 @@ class Spriteset_Global
def dispose def dispose
@playersprite.dispose @playersprite.dispose
for sprite in @picture_sprites @picture_sprites.each { |sprite| sprite.dispose }
sprite.dispose
end
@timer_sprite.dispose @timer_sprite.dispose
@playersprite = nil @playersprite = nil
@picture_sprites.clear @picture_sprites.clear
@@ -26,9 +24,7 @@ class Spriteset_Global
def update def update
@playersprite.update @playersprite.update
for sprite in @picture_sprites @picture_sprites.each { |sprite| sprite.update }
sprite.update
end
@timer_sprite.update @timer_sprite.update
end end
end end
@@ -117,7 +117,8 @@ end
class ParticleSprite class ParticleSprite
attr_accessor :x, :y, :z, :ox, :oy, :opacity, :bitmap, :blend_type attr_accessor :x, :y, :z, :ox, :oy, :opacity, :blend_type
attr_reader :bitmap
def initialize(viewport) def initialize(viewport)
@viewport = viewport @viewport = viewport
+30 -27
View File
@@ -41,24 +41,24 @@ class CustomTilemap
attr_reader :viewport attr_reader :viewport
attr_reader :graphicsWidth attr_reader :graphicsWidth
attr_reader :graphicsHeight attr_reader :graphicsHeight
attr_accessor :ox attr_reader :ox
attr_accessor :oy attr_reader :oy
attr_accessor :tone attr_accessor :tone
attr_accessor :color attr_accessor :color
Autotiles = [ Autotiles = [
[ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34], [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34],
[27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ], [27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ],
[ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34], [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34],
[27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ], [27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ],
[ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12], [ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12],
[15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ], [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
[ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36], [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
[39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ], [39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ],
[ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12], [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
[17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ], [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
[ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44], [ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
[37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ] [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ]
] ]
Animated_Autotiles_Frames = 5*Graphics.frame_rate/20 # Frequency of updating animated autotiles Animated_Autotiles_Frames = 5*Graphics.frame_rate/20 # Frequency of updating animated autotiles
FlashOpacity = [100,90,80,70,80,90] FlashOpacity = [100,90,80,70,80,90]
@@ -132,26 +132,30 @@ class CustomTilemap
return if disposed? return if disposed?
@help.dispose if @help @help.dispose if @help
@help = nil @help = nil
i = 0; len = @autotileInfo.length; while i<len i = 0; len = @autotileInfo.length
while i<len
if @autotileInfo[i] if @autotileInfo[i]
@autotileInfo[i].dispose @autotileInfo[i].dispose
@autotileInfo[i] = nil @autotileInfo[i] = nil
end end
i += 1 i += 1
end end
i = 0; len = @regularTileInfo.length; while i<len i = 0; len = @regularTileInfo.length
while i<len
if @regularTileInfo[i] if @regularTileInfo[i]
@regularTileInfo[i].dispose @regularTileInfo[i].dispose
@regularTileInfo[i] = nil @regularTileInfo[i] = nil
end end
i += 1 i += 1
end end
i = 0; len = @tiles.length; while i<len i = 0; len = @tiles.length
while i<len
@tiles[i].dispose @tiles[i].dispose
@tiles[i] = nil @tiles[i] = nil
i += 2 i += 2
end end
i = 0; len = @autosprites.length; while i<len i = 0; len = @autosprites.length
while i<len
@autosprites[i].dispose @autosprites[i].dispose
@autosprites[i] = nil @autosprites[i] = nil
i += 2 i += 2
@@ -449,7 +453,6 @@ class CustomTilemap
bitmap = @flash.bitmap bitmap = @flash.bitmap
ysize = @map_data.ysize ysize = @map_data.ysize
xsize = @map_data.xsize xsize = @map_data.xsize
zsize = @map_data.zsize
@firsttimeflash = false @firsttimeflash = false
@oxFlash = @ox-(width>>2) @oxFlash = @ox-(width>>2)
@oyFlash = @oy-(height>>2) @oyFlash = @oy-(height>>2)
@@ -488,7 +491,8 @@ class CustomTilemap
end end
def refresh_tileset def refresh_tileset
i = 0; len = @regularTileInfo.length; while i<len i = 0; len = @regularTileInfo.length
while i<len
if @regularTileInfo[i] if @regularTileInfo[i]
@regularTileInfo[i].dispose @regularTileInfo[i].dispose
@regularTileInfo[i] = nil @regularTileInfo[i] = nil
@@ -518,14 +522,16 @@ class CustomTilemap
end end
def refresh_autotiles def refresh_autotiles
i = 0; len = @autotileInfo.length; while i<len i = 0; len = @autotileInfo.length
while i<len
if @autotileInfo[i] if @autotileInfo[i]
@autotileInfo[i].dispose @autotileInfo[i].dispose
@autotileInfo[i] = nil @autotileInfo[i] = nil
end end
i += 1 i += 1
end end
i = 0; len = @autosprites.length; while i<len i = 0; len = @autosprites.length
while i<len
if @autosprites[i] if @autosprites[i]
@autosprites[i].dispose @autosprites[i].dispose
@autosprites[i] = nil @autosprites[i] = nil
@@ -798,10 +804,6 @@ class CustomTilemap
usesprites = true usesprites = true
end end
refreshFlashSprite refreshFlashSprite
vpx = @viewport.rect.x
vpy = @viewport.rect.y
vpr = @viewport.rect.width+vpx
vpb = @viewport.rect.height+vpy
xsize = @map_data.xsize xsize = @map_data.xsize
ysize = @map_data.ysize ysize = @map_data.ysize
minX = (@ox/@tileWidth)-1 minX = (@ox/@tileWidth)-1
@@ -870,7 +872,8 @@ class CustomTilemap
end end
if count<@tiles.length if count<@tiles.length
bigchange = (count<=(@tiles.length*2/3)) && (@tiles.length*2/3)>25 bigchange = (count<=(@tiles.length*2/3)) && (@tiles.length*2/3)>25
j = count; len = @tiles.length; while j<len j = count; len = @tiles.length
while j<len
sprite = @tiles[j] sprite = @tiles[j]
@tiles[j+1] = -1 @tiles[j+1] = -1
if bigchange if bigchange
@@ -197,11 +197,11 @@ class Draw_Tilemap # This class controls a set of sprites, with
end end
def redrawmap def redrawmap
# Provide blank data in proper object form # Provide blank data in proper object form
self.clear self.clear
xsize=@map_data.xsize xsize=@map_data.xsize
ysize=@map_data.ysize ysize=@map_data.ysize
# Bitmaps used for each priority's drawing. Priorities 2-5 are combined. # Bitmaps used for each priority's drawing. Priorities 2-5 are combined.
@bitmaps = [Bitmap.new(xsize*32, ysize*32+StripSize), @bitmaps = [Bitmap.new(xsize*32, ysize*32+StripSize),
Bitmap.new(xsize*32, ysize*32+StripSize), Bitmap.new(xsize*32, ysize*32+StripSize),
Bitmap.new(xsize*32, ysize*32+StripSize)] Bitmap.new(xsize*32, ysize*32+StripSize)]
@@ -213,10 +213,10 @@ class Draw_Tilemap # This class controls a set of sprites, with
end end
@drawnstrips.clear @drawnstrips.clear
@contentstrips.clear @contentstrips.clear
# Generate blank sprites # Generate blank sprites
@sprites.clear @sprites.clear
@numsprites=ysize * (32 / StripSize) @numsprites=ysize * (32 / StripSize)
for i in 0...@map_data.zsize # For each layer @map_data.zsize.times do # For each layer
@sprites.push([]) @sprites.push([])
@contentstrips.push([]) @contentstrips.push([])
end end
@@ -227,7 +227,6 @@ class Draw_Tilemap # This class controls a set of sprites, with
end end
def update def update
oyunchanged=false
if !@flash_data.nil? && @sprites.length>0 if !@flash_data.nil? && @sprites.length>0
flashindex=@sprites.length-1 flashindex=@sprites.length-1
for j in 0...@numsprites for j in 0...@numsprites
@@ -249,8 +248,6 @@ class Draw_Tilemap # This class controls a set of sprites, with
@doredraw=false @doredraw=false
elsif @oldOx==@ox && @oldOy==@oy elsif @oldOx==@ox && @oldOy==@oy
return return
elsif @oldOy==@oy
oyunchanged=true
end end
@oldOx=@ox @oldOx=@ox
@oldOy=@oy @oldOy=@oy
@@ -274,7 +271,6 @@ class Draw_Tilemap # This class controls a set of sprites, with
end end
vpy=@viewport.rect.y vpy=@viewport.rect.y
vpr=@viewport.rect.x+@viewport.rect.width vpr=@viewport.rect.x+@viewport.rect.width
vpb=@viewport.rect.y+@viewport.rect.height
numsprites=0 numsprites=0
for i in @sprites for i in @sprites
numsprites+=i.compact.length numsprites+=i.compact.length
@@ -57,7 +57,6 @@ class SynchronizedTilemapAutotilesInternal
end end
def sync def sync
frameused = []
for i in 0...7 for i in 0...7
frames = [1,@atframes[i].length].max frames = [1,@atframes[i].length].max
frame = (Graphics.frame_count/15)%frames frame = (Graphics.frame_count/15)%frames
@@ -3,38 +3,38 @@ class TileDrawingHelper
attr_accessor :autotiles attr_accessor :autotiles
Autotiles = [ Autotiles = [
[ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34], [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27, 6, 33, 34], [ 5, 6, 33, 34],
[27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ], [27, 28, 33, 12], [ 5, 28, 33, 12], [27, 6, 33, 12], [ 5, 6, 33, 12] ],
[ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34], [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27, 6, 11, 34], [ 5, 6, 11, 34],
[27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ], [27, 28, 11, 12], [ 5, 28, 11, 12], [27, 6, 11, 12], [ 5, 6, 11, 12] ],
[ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12], [ [25, 26, 31, 32], [25, 6, 31, 32], [25, 26, 31, 12], [25, 6, 31, 12],
[15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ], [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
[ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36], [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
[39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ], [39, 40, 45, 46], [ 5, 40, 45, 46], [39, 6, 45, 46], [ 5, 6, 45, 46] ],
[ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12], [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
[17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ], [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
[ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44], [ [37, 38, 43, 44], [37, 6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
[37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ] [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1, 2, 7, 8] ]
] ]
# converts neighbors returned from tableNeighbors to tile indexes # converts neighbors returned from tableNeighbors to tile indexes
NeighborsToTiles = [ NeighborsToTiles = [
46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40,
42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16,
46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40,
42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16,
45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29,
37, 27, 37, 27, 23, 15, 23, 13, 37, 27, 37, 27, 22, 11, 22, 9, 37, 27, 37, 27, 23, 15, 23, 13, 37, 27, 37, 27, 22, 11, 22, 9,
45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29, 45, 39, 45, 39, 33, 31, 33, 29,
36, 26, 36, 26, 21, 7, 21, 5, 36, 26, 36, 26, 20, 3, 20, 1, 36, 26, 36, 26, 21, 7, 21, 5, 36, 26, 36, 26, 20, 3, 20, 1,
46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40,
42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16,
46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40, 46, 44, 46, 44, 43, 41, 43, 40,
42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16, 42, 32, 42, 32, 35, 19, 35, 18, 42, 32, 42, 32, 34, 17, 34, 16,
45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28,
37, 25, 37, 25, 23, 14, 23, 12, 37, 25, 37, 25, 22, 10, 22, 8, 37, 25, 37, 25, 23, 14, 23, 12, 37, 25, 37, 25, 22, 10, 22, 8,
45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28, 45, 38, 45, 38, 33, 30, 33, 28,
36, 24, 36, 24, 21, 6, 21, 4, 36, 24, 36, 24, 20, 2, 20, 0 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)
@@ -192,10 +192,6 @@ class Interpreter
$game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n } $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
end end
def command_dummy
return true
end
def pbExecuteScript(script) def pbExecuteScript(script)
begin begin
result = eval(script) result = eval(script)
@@ -234,7 +230,6 @@ class Interpreter
if e.is_a?(Hangup) if e.is_a?(Hangup)
$EVENTHANGUPMSG = err; raise $EVENTHANGUPMSG = err; raise
end end
raise err
elsif $game_map elsif $game_map
mapname = ($game_map.name rescue nil) || "???" mapname = ($game_map.name rescue nil) || "???"
err = "Script error within map #{$game_map.map_id} " err = "Script error within map #{$game_map.map_id} "
@@ -242,15 +237,13 @@ class Interpreter
if e.is_a?(Hangup) if e.is_a?(Hangup)
$EVENTHANGUPMSG = err; raise $EVENTHANGUPMSG = err; raise
end end
raise err
else else
err = "Script error in interpreter:\r\n#{message}\r\n#{s}" err = "Script error in interpreter:\r\n#{message}\r\n#{s}"
if e.is_a?(Hangup) if e.is_a?(Hangup)
$EVENTHANGUPMSG = err; raise $EVENTHANGUPMSG = err; raise
end end
raise err
end end
return false raise err
end end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -844,7 +837,7 @@ class Interpreter
value = $game_variables[@parameters[4]] value = $game_variables[@parameters[4]]
when 2 # random number when 2 # random number
value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1) value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1)
when 3, 4, 5 # item, actor, enemy # when 3, 4, 5 # item, actor, enemy
when 6 # character when 6 # character
character = get_character(@parameters[4]) character = get_character(@parameters[4])
if character != nil if character != nil
@@ -860,14 +853,13 @@ class Interpreter
when 7 # other when 7 # other
case @parameters[4] case @parameters[4]
when 0; value = $game_map.map_id # map ID when 0; value = $game_map.map_id # map ID
when 1, 3 # number of party members, steps # when 1, 3 # number of party members, steps
when 2; value = $Trainer.money # gold when 2; value = $Trainer.money # gold
when 4; value = Graphics.frame_count / Graphics.frame_rate # play time when 4; value = Graphics.frame_count / Graphics.frame_rate # play time
when 5; value = $game_system.timer / Graphics.frame_rate # timer when 5; value = $game_system.timer / Graphics.frame_rate # timer
when 6; value = $game_system.save_count # save count when 6; value = $game_system.save_count # save count
end end
end end
shouldRefresh = false
# Loop for group control # Loop for group control
for i in @parameters[0] .. @parameters[1] for i in @parameters[0] .. @parameters[1]
# Branch with control # Branch with control
@@ -1463,7 +1455,7 @@ class Interpreter
end end
@index += 1 @index += 1
end end
result = pbExecuteScript(script) pbExecuteScript(script)
return true return true
end end
end end
@@ -133,7 +133,7 @@ def getKnownFolder(guid)
coTaskMemFree = Win32API.new("ole32.dll","CoTaskMemFree","i","") rescue nil coTaskMemFree = Win32API.new("ole32.dll","CoTaskMemFree","i","") rescue nil
return "" if !(shGetKnownFolderPath && coTaskMemFree) return "" if !(shGetKnownFolderPath && coTaskMemFree)
path = "\0"*4 path = "\0"*4
ret = shGetKnownFolderPath.call(packedGuid,0,0,path) path = shGetKnownFolderPath.call(packedGuid,0,0,path)
path = path.unpack("V")[0] path = path.unpack("V")[0]
ret = getUnicodeString(path) ret = getUnicodeString(path)
coTaskMemFree.call(path) coTaskMemFree.call(path)
@@ -245,7 +245,7 @@ module RTP
return false if !dir || dir=="" return false if !dir || dir==""
loop do loop do
name = dir.gsub(/[\/\\]$/,"")+"/writetest" name = dir.gsub(/[\/\\]$/,"")+"/writetest"
for i in 0...12 12.times do
name += sprintf("%02X",rand(256)) name += sprintf("%02X",rand(256))
end end
name += ".tmp" name += ".tmp"
@@ -471,12 +471,12 @@ module MiniRegistry
type = type.unpack("V")[0] type = type.unpack("V")[0]
data = data[0,size.unpack("V")[0]] data = data[0,size.unpack("V")[0]]
case type case type
when 1; return data.chop # REG_SZ when 1; return data.chop # REG_SZ
when 2; return data.gsub(/%([^%]+)%/) { ENV[$1] || $& } # REG_EXPAND_SZ when 2; return data.gsub(/%([^%]+)%/) { ENV[$1] || $& } # REG_EXPAND_SZ
when 3; return data # REG_BINARY when 3; return data # REG_BINARY
when 4; return data.unpack("V")[0] # REG_DWORD when 4; return data.unpack("V")[0] # REG_DWORD
when 5; return data.unpack("V")[0] # REG_DWORD_BIG_ENDIAN when 5; return data.unpack("V")[0] # REG_DWORD_BIG_ENDIAN
when 11; qw = data.unpack("VV"); return (data[1]<<32|data[0]) # REG_QWORD when 11; data.unpack("VV"); return (data[1]<<32|data[0]) # REG_QWORD
else; raise "Type #{type} not supported." else; raise "Type #{type} not supported."
end end
end end
@@ -1,121 +1,113 @@
module FileInputMixin module FileInputMixin
def fgetb def fgetb
x=0 ret = 0
ret=0
each_byte do |i| each_byte do |i|
ret=i || 0 ret = i || 0
break break
end end
return ret return ret
end end
def fgetw def fgetw
x=0 x = 0
ret=0 ret = 0
each_byte do |i| each_byte do |i|
break if !i break if !i
ret|=(i<<x) ret |= (i << x)
x+=8 x += 8
break if x==16 break if x == 16
end end
return ret return ret
end end
def fgetdw def fgetdw
x=0 x = 0
ret=0 ret = 0
each_byte do |i| each_byte do |i|
break if !i break if !i
ret|=(i<<x) ret |= (i << x)
x+=8 x += 8
break if x==32 break if x == 32
end end
return ret return ret
end end
def fgetsb def fgetsb
ret=fgetb ret = fgetb
if (ret&0x80)!=0 ret -= 256 if (ret & 0x80) != 0
return ret-256 return ret
else
return ret
end
end end
def xfgetb(offset) def xfgetb(offset)
self.pos=offset self.pos = offset
return fgetb return fgetb
end end
def xfgetw(offset) def xfgetw(offset)
self.pos=offset self.pos = offset
return fgetw return fgetw
end end
def xfgetdw(offset) def xfgetdw(offset)
self.pos=offset self.pos = offset
return fgetdw return fgetdw
end end
def getOffset(index) def getOffset(index)
self.binmode self.binmode
self.pos=0 self.pos = 0
offset=fgetdw>>3 offset = fgetdw >> 3
return 0 if index>=offset return 0 if index >= offset
self.pos=index*8 self.pos = index * 8
return fgetdw return fgetdw
end end
def getLength(index) def getLength(index)
self.binmode self.binmode
self.pos=0 self.pos = 0
offset=fgetdw>>3 offset = fgetdw >> 3
return 0 if index>=offset return 0 if index >= offset
self.pos=index*8+4 self.pos = index * 8 + 4
return fgetdw return fgetdw
end end
def readName(index) def readName(index)
self.binmode self.binmode
self.pos=0 self.pos = 0
offset=fgetdw>>3 offset = fgetdw >> 3
return "" if index>=offset return "" if index >= offset
self.pos=index<<3 self.pos = index << 3
offset=fgetdw offset = fgetdw
length=fgetdw length = fgetdw
return "" if length==0 return "" if length == 0
self.pos=offset self.pos = offset
return read(length) return read(length)
end end
end end
module FileOutputMixin module FileOutputMixin
def fputb(b) def fputb(b)
b=b&0xFF b &= 0xFF
write(b.chr) write(b.chr)
end end
def fputw(w) def fputw(w)
2.times do 2.times do
b=w&0xFF b = w & 0xFF
write(b.chr) write(b.chr)
w>>=8 w >>= 8
end end
end end
def fputdw(w) def fputdw(w)
4.times do 4.times do
b=w&0xFF b = w & 0xFF
write(b.chr) write(b.chr)
w>>=8 w >>= 8
end end
end end
end end
class File < IO class File < IO
=begin =begin
unless defined?(debugopen) unless defined?(debugopen)
@@ -124,12 +116,12 @@ class File < IO
end end
end end
def open(f,m="r") def open(f, m = "r")
debugopen("debug.txt","ab") { |file| file.write([f,m,Time.now.to_f].inspect+"\r\n") } debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") }
if block_given? if block_given?
debugopen(f,m) { |file| yield file } debugopen(f, m) { |file| yield file }
else else
return debugopen(f,m) return debugopen(f, m)
end end
end end
=end =end
@@ -137,8 +129,6 @@ class File < IO
include FileOutputMixin include FileOutputMixin
end end
class StringInput class StringInput
include FileInputMixin include FileInputMixin
@@ -152,12 +142,9 @@ class StringInput
end end
end end
def binmode def binmode; end
end
end end
class StringOutput class StringOutput
include FileOutputMixin include FileOutputMixin
end end
@@ -228,7 +228,6 @@ def pbGetText(infile)
begin begin
pbEachIntlSection(file) { |section,name| pbEachIntlSection(file) { |section,name|
next if section.length==0 next if section.length==0
index=name
if !name[/^([Mm][Aa][Pp])?(\d+)$/] if !name[/^([Mm][Aa][Pp])?(\d+)$/]
raise _INTL("Invalid section name {1}",name) raise _INTL("Invalid section name {1}",name)
end end
@@ -335,7 +334,7 @@ class OrderedHash < Hash
return ret return ret
end end
def _dump(depth=100) def _dump(_depth=100)
values=[] values=[]
for key in @keys for key in @keys
values.push(self[key]) values.push(self[key])
@@ -476,7 +475,7 @@ class Messages
@messages[type]=arr @messages[type]=arr
end end
def self.createHash(type,array) def self.createHash(_type,array)
arr=OrderedHash.new arr=OrderedHash.new
for i in 0...array.length for i in 0...array.length
if array[i] if array[i]
@@ -487,10 +486,8 @@ class Messages
return arr return arr
end end
def self.addToHash(type,array,hash) def self.addToHash(_type,array,hash)
if !hash hash=OrderedHash.new if !hash
hash=OrderedHash.new
end
for i in 0...array.length for i in 0...array.length
if array[i] if array[i]
key=Messages.stringToKey(array[i]) key=Messages.stringToKey(array[i])
+2 -2
View File
@@ -1,11 +1,11 @@
class Thread class Thread
def Thread.exclusive def Thread.exclusive
_old = Thread.critical old_critical = Thread.critical
begin begin
Thread.critical = true Thread.critical = true
return yield return yield
ensure ensure
Thread.critical = _old Thread.critical = old_critical
end end
end end
end end
+1 -1
View File
@@ -220,7 +220,7 @@ end
def pbSEFade(x=0.0); pbSEStop(x);end def pbSEFade(x=0.0); pbSEStop(x);end
# Stops SE playback. # Stops SE playback.
def pbSEStop(timeInSeconds=0.0) def pbSEStop(_timeInSeconds=0.0)
if $game_system if $game_system
$game_system.se_stop $game_system.se_stop
elsif (RPG.const_defined?(:SE) rescue false) elsif (RPG.const_defined?(:SE) rescue false)
+34 -39
View File
@@ -99,7 +99,7 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025)
saveToTemp = proc { |samples,freq| saveToTemp = proc { |samples,freq|
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
ret = nil ret = nil
for i in 1...1000 999.times do
name="" name=""
8.times { name += chars[rand(chars.length),1] } 8.times { name += chars[rand(chars.length),1] }
name = ENV["TEMP"]+"\\"+name+"_tmp.wav" name = ENV["TEMP"]+"\\"+name+"_tmp.wav"
@@ -110,14 +110,14 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025)
end end
return ret return ret
} }
playThenDelete = proc { |path,volume,length,async| playThenDelete = proc { |path,volume,length,_async|
next if !path || !safeExists?(path) next if !path || !safeExists?(path)
thread=Thread.new{ thread=Thread.new{
Thread.stop Thread.stop
_path=Thread.current[:path] cur_path=Thread.current[:path]
_length=Thread.current[:length] cur_length=Thread.current[:length]
sleep(_length) sleep(cur_length)
File.delete(_path) rescue nil File.delete(cur_path) rescue nil
} }
thread[:path]=path thread[:path]=path
thread[:length]=length thread[:length]=length
@@ -132,14 +132,14 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025)
waveOutHandle=" "*4 waveOutHandle=" "*4
code=waveOutOpen.call(waveOutHandle,-1,waveFormat,0,0,0) code=waveOutOpen.call(waveOutHandle,-1,waveFormat,0,0,0)
if code!=0 if code!=0
timeLength=samples.length.to_f/sampleFreq timeLength=duration.to_f/sampleFreq
path=saveToTemp.call(samples,sampleFreq) path=saveToTemp.call(samples,sampleFreq)
playThenDelete.call(path,volume,timeLength,async) playThenDelete.call(path,volume,timeLength,async)
return return
end end
waveOutHandle=waveOutHandle.unpack("L")[0] waveOutHandle=waveOutHandle.unpack("L")[0]
volume=(volume*65535/100) volume=(volume*65535/100)
volume=(volume<<16)|volume volume=(volume << 16)|volume
waveOutSetVolume.call(waveOutHandle,volume) waveOutSetVolume.call(waveOutHandle,volume)
code=waveOutPrepareHeader.call(waveOutHandle,waveHdr,waveHdr.length) code=waveOutPrepareHeader.call(waveOutHandle,waveHdr,waveHdr.length)
if code!=0 if code!=0
@@ -150,7 +150,6 @@ def pbPlaySoundData(samples,volume,async=false,sampleFreq=11025)
Thread.stop Thread.stop
waveOut=Thread.current[:waveOut] waveOut=Thread.current[:waveOut]
waveHdr=Thread.current[:waveHeader] waveHdr=Thread.current[:waveHeader]
waveData=Thread.current[:waveData]
waveOutUnprepareHeader=Win32API.new("winmm.dll","waveOutUnprepareHeader","lpl","l") waveOutUnprepareHeader=Win32API.new("winmm.dll","waveOutUnprepareHeader","lpl","l")
waveOutClose=Win32API.new("winmm.dll","waveOutClose","l","l") waveOutClose=Win32API.new("winmm.dll","waveOutClose","l","l")
loop do loop do
@@ -272,7 +271,7 @@ class WaveData
return ret return ret
end end
def _dump(depth=100) def _dump(_depth=100)
return Marshal.dump([@freq,Zlib::Deflate.deflate(@samples)]) return Marshal.dump([@freq,Zlib::Deflate.deflate(@samples)])
end end
@@ -594,11 +593,17 @@ class WaveForm# :nodoc:
def lcm(x,y) def lcm(x,y)
return y if x==0; return x if y==0 return y if x==0; return x if y==0
return x if x==y return x if x==y
if x>y; incr=x if x>y
while x%y!=0; x+=incr; end incr=x
while x%y!=0
x+=incr
end
return x return x
else; incr=y else
while y%x!=0; y+=incr; end incr=y
while y%x!=0
y+=incr
end
return y return y
end end
end end
@@ -626,7 +631,6 @@ class WaveForm# :nodoc:
vol=@volumeIterator.getValue(fframe) vol=@volumeIterator.getValue(fframe)
end end
if @proc if @proc
updateBuffer=false
if @freqEnvelope.length>0 # Update frequency if @freqEnvelope.length>0 # Update frequency
freq=@freqIterator.getValue(fframe) freq=@freqIterator.getValue(fframe)
if freq!=@freq # update sample buffer if freq!=@freq # update sample buffer
@@ -843,8 +847,6 @@ module Audio
t2=852 if "7pqrs8tuv9wxyzC".include?(tone) t2=852 if "7pqrs8tuv9wxyzC".include?(tone)
t2=941 if "*0#D".include?(tone) t2=941 if "*0#D".include?(tone)
return if t1==0 || t2==0 return if t1==0 || t2==0
f1=Math::PI*2.0*t1/WaveForm::SAMPLEFREQ
f2=Math::PI*2.0*t2/WaveForm::SAMPLEFREQ
doubleSine(durationInMs,t1,t2,volume,volume,0.5,0.5,async) doubleSine(durationInMs,t1,t2,volume,volume,0.5,0.5,async)
end end
@@ -908,7 +910,7 @@ def callheld(duration,volume=95)
volume,volume) volume,volume)
end end
def loudFastBusy(duration,volume=95) def loudFastBusy(duration,_volume=95)
Audio.doubleSine(duration, Audio.doubleSine(duration,
SoundEnvelope.blink(480,250,250,duration), SoundEnvelope.blink(480,250,250,duration),
SoundEnvelope.blink(620,250,250,duration) SoundEnvelope.blink(620,250,250,duration)
@@ -1009,7 +1011,6 @@ end
# internal function # internal function
def getOggPage(file) def getOggPage(file)
pos=file.pos
fgetdw=proc { |file| fgetdw=proc { |file|
(file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) (file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0))
} }
@@ -1035,13 +1036,15 @@ def oggfiletime(file)
} }
pages=[] pages=[]
page=nil page=nil
begin loop do
page=getOggPage(file) page=getOggPage(file)
if page if page
pages.push(page) pages.push(page)
file.pos=page[3] file.pos=page[3]
else
break
end end
end while page end
if pages.length==0 if pages.length==0
return -1 return -1
end end
@@ -1054,30 +1057,23 @@ def oggfiletime(file)
serial=header[10,4].unpack("V") serial=header[10,4].unpack("V")
frame=header[2,8].unpack("C*") frame=header[2,8].unpack("C*")
frameno=frame[7] frameno=frame[7]
frameno=(frameno<<8)|frame[6] frameno=(frameno << 8)|frame[6]
frameno=(frameno<<8)|frame[5] frameno=(frameno << 8)|frame[5]
frameno=(frameno<<8)|frame[4] frameno=(frameno << 8)|frame[4]
frameno=(frameno<<8)|frame[3] frameno=(frameno << 8)|frame[3]
frameno=(frameno<<8)|frame[2] frameno=(frameno << 8)|frame[2]
frameno=(frameno<<8)|frame[1] frameno=(frameno << 8)|frame[1]
frameno=(frameno<<8)|frame[0] frameno=(frameno << 8)|frame[0]
if serial!=curserial if serial!=curserial
curserial=serial curserial=serial
file.pos=page[1] file.pos=page[1]
packtype=(file.read(1)[0] rescue 0) packtype=(file.read(1)[0] rescue 0)
string=file.read(6) string=file.read(6)
if string!="vorbis" return -1 if string!="vorbis"
return -1 return -1 if packtype!=1
end
if packtype!=1
return -1
end
i+=1 i+=1
version=fgetdw.call(file) version=fgetdw.call(file)
if version!=0 return -1 if version!=0
return -1
end
channels=(file.read(1)[0] rescue 0)
rates[i]=fgetdw.call(file) rates[i]=fgetdw.call(file)
end end
pcmlengths[i]=frameno pcmlengths[i]=frameno
@@ -1180,7 +1176,6 @@ end
# Creates wave data from the given WAV file path # Creates wave data from the given WAV file path
def getWaveData(filename) def getWaveData(filename)
time=-1
fgetdw=proc { |file| fgetdw=proc { |file|
(file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) (file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0))
} }
@@ -44,7 +44,7 @@ class WeakRef
@@id_map = {} @@id_map = {}
@@id_rev_map = {} @@id_rev_map = {}
@@final = lambda { |id| @@final = lambda { |id|
__old_status = Thread.critical old_thread_status = Thread.critical
Thread.critical = true Thread.critical = true
begin begin
rids = @@id_map[id] rids = @@id_map[id]
@@ -61,7 +61,7 @@ class WeakRef
@@id_map.delete(rid) if @@id_map[rid].empty? @@id_map.delete(rid) if @@id_map[rid].empty?
end end
ensure ensure
Thread.critical = __old_status Thread.critical = old_thread_status
end end
} }
@@ -83,7 +83,7 @@ class WeakRef
def __setobj__(obj) def __setobj__(obj)
@__id = obj.__id__ @__id = obj.__id__
__old_status = Thread.critical old_thread_status = Thread.critical
begin begin
Thread.critical = true Thread.critical = true
unless @@id_rev_map.key?(self) unless @@id_rev_map.key?(self)
@@ -92,7 +92,7 @@ class WeakRef
end end
@@id_map[@__id] = [] unless @@id_map[@__id] @@id_map[@__id] = [] unless @@id_map[@__id]
ensure ensure
Thread.critical = __old_status Thread.critical = old_thread_status
end end
@@id_map[@__id].push self.__id__ @@id_map[@__id].push self.__id__
@@id_rev_map[self.__id__] = @__id @@id_rev_map[self.__id__] = @__id
@@ -111,7 +111,7 @@ class WeakHashtable
include Enumerable include Enumerable
def initialize def initialize
@hash={} @hash = {}
end end
def clear def clear
@@ -277,12 +277,12 @@ end
# bitmap is freed when the reference count reaches 0. # bitmap is freed when the reference count reaches 0.
class Thread class Thread
def Thread.exclusive def Thread.exclusive
_old = Thread.critical old_thread_status = Thread.critical
begin begin
Thread.critical = true Thread.critical = true
return yield return yield
ensure ensure
Thread.critical = _old Thread.critical = old_thread_status
end end
end end
end end
@@ -519,10 +519,10 @@ end
# Fades and window activations for sprite hashes # Fades and window activations for sprite hashes
#=============================================================================== #===============================================================================
class Game_Temp class Game_Temp
attr_accessor :fadestate attr_writer :fadestate
def fadestate def fadestate
return (@fadestate) ? @fadestate : 0 return @fadestate || 0
end end
end end
@@ -390,7 +390,7 @@ class SpriteWindow < Window
attr_reader :skinformat attr_reader :skinformat
attr_reader :skinrect attr_reader :skinrect
def loadSkinFile(file) def loadSkinFile(_file)
if (self.windowskin.width==80 || self.windowskin.width==96) && if (self.windowskin.width==80 || self.windowskin.width==96) &&
self.windowskin.height==48 self.windowskin.height==48
# Body = X, Y, width, height of body rectangle within windowskin # Body = X, Y, width, height of body rectangle within windowskin
@@ -519,9 +519,9 @@ class SpriteWindow < Window
dstbitmap.blt(x+left,y+top,srcbitmap,srcrect) dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
x+=srcrect.width x+=srcrect.width
end end
y+=srcrect.height y+=srcrect.height
end end
end end
def privRefreshCursor def privRefreshCursor
contopac=self.contents_opacity contopac=self.contents_opacity
@@ -666,8 +666,6 @@ class SpriteWindow < Window
startX=@skinrect.x startX=@skinrect.x
# width of top end of window # width of top end of window
startY=@skinrect.y startY=@skinrect.y
backWidth=@skinrect.width
backHeight=@skinrect.height
cx=@skinrect.x+@skinrect.width # right side of BODY rect cx=@skinrect.x+@skinrect.width # right side of BODY rect
cy=@skinrect.y+@skinrect.height # bottom side of BODY rect cy=@skinrect.y+@skinrect.height # bottom side of BODY rect
# width of right end of window # width of right end of window
@@ -707,8 +705,6 @@ class SpriteWindow < Window
end end
end end
if @_windowskin && !@_windowskin.disposed? if @_windowskin && !@_windowskin.disposed?
backTrimX=startX+endX
backTrimY=startX+endX
borderX=startX+endX borderX=startX+endX
borderY=startY+endY borderY=startY+endY
@sprites["corner0"].x=@x @sprites["corner0"].x=@x
@@ -857,8 +853,6 @@ class SpriteWindow < Window
sprite.zoom_x=1.0 sprite.zoom_x=1.0
sprite.oy=0 sprite.oy=0
sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor
oldbitmap=sprite.bitmap
oldsrcrect=sprite.src_rect.clone
end end
else else
for k in @spritekeys for k in @spritekeys
@@ -1117,7 +1111,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
attr_reader :baseColor attr_reader :baseColor
attr_reader :shadowColor attr_reader :shadowColor
attr_accessor :letterbyletter attr_accessor :letterbyletter
attr_reader :lineHeight
attr_reader :waitcount attr_reader :waitcount
def initialize(text="") def initialize(text="")
@@ -1291,7 +1284,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
@curchar = 0 @curchar = 0
@drawncurchar = -1 @drawncurchar = -1
@lastDrawnChar = -1 @lastDrawnChar = -1
oldtext = @text
@text = value @text = value
@textlength = unformattedTextLength(value) @textlength = unformattedTextLength(value)
@scrollstate = 0 @scrollstate = 0
@@ -1466,7 +1458,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
self.oy = @scrollY self.oy = @scrollY
numchars = @numtextchars numchars = @numtextchars
numchars = [@curchar,@numtextchars].min if self.letterbyletter numchars = [@curchar,@numtextchars].min if self.letterbyletter
startchar = 0
return if busy? && @drawncurchar==@curchar && @scrollstate==0 return if busy? && @drawncurchar==@curchar && @scrollstate==0
if !self.letterbyletter || !oldcontents.equal?(self.contents) if !self.letterbyletter || !oldcontents.equal?(self.contents)
@drawncurchar = -1 @drawncurchar = -1
@@ -1614,7 +1605,6 @@ end
# #
#=============================================================================== #===============================================================================
class Window_InputNumberPokemon < SpriteWindow_Base class Window_InputNumberPokemon < SpriteWindow_Base
attr_reader :number
attr_reader :sign attr_reader :sign
def initialize(digits_max) def initialize(digits_max)
@@ -1643,13 +1633,6 @@ class Window_InputNumberPokemon < SpriteWindow_Base
@number*(@sign && @negative ? -1 : 1) @number*(@sign && @negative ? -1 : 1)
end end
def sign=(value)
@sign=value
self.width=@digits_max*24+8+self.borderX+(@sign ? 24 : 0)
@index=(@digits_max-1)+(@sign ? 1 : 0)
refresh
end
def number=(value) def number=(value)
value=0 if !value.is_a?(Numeric) value=0 if !value.is_a?(Numeric)
if @sign if @sign
@@ -1661,13 +1644,19 @@ class Window_InputNumberPokemon < SpriteWindow_Base
refresh refresh
end end
def sign=(value)
@sign=value
self.width=@digits_max*24+8+self.borderX+(@sign ? 24 : 0)
@index=(@digits_max-1)+(@sign ? 1 : 0)
refresh
end
def refresh def refresh
self.contents=pbDoEnsureBitmap(self.contents, self.contents=pbDoEnsureBitmap(self.contents,
self.width-self.borderX,self.height-self.borderY) self.width-self.borderX,self.height-self.borderY)
pbSetSystemFont(self.contents) pbSetSystemFont(self.contents)
self.contents.clear self.contents.clear
s=sprintf("%0*d",@digits_max,@number.abs) s=sprintf("%0*d",@digits_max,@number.abs)
x=0
if @sign if @sign
textHelper(0,0,@negative ? "-" : "+",0) textHelper(0,0,@negative ? "-" : "+",0)
end end
@@ -2080,7 +2069,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
end end
def textWidth(bitmap,text) def textWidth(bitmap,text)
return tmpbitmap.text_size(i).width return bitmap.text_size(text).width
end end
def getAutoDims(commands,dims,width=nil) def getAutoDims(commands,dims,width=nil)
@@ -2230,7 +2219,7 @@ class Window_CommandPokemon < Window_DrawableCommand
return @commands ? @commands.length : 0 return @commands ? @commands.length : 0
end end
def drawItem(index,count,rect) def drawItem(index,_count,rect)
pbSetSystemFont(self.contents) if @starting pbSetSystemFont(self.contents) if @starting
rect=drawCursor(index,rect) rect=drawCursor(index,rect)
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height, pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,
@@ -2344,7 +2333,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
return @commands ? @commands.length : 0 return @commands ? @commands.length : 0
end end
def drawItem(index,count,rect) def drawItem(index,_count,rect)
pbSetSystemFont(self.contents) pbSetSystemFont(self.contents)
rect=drawCursor(index,rect) rect=drawCursor(index,rect)
if toUnformattedText(@commands[index]).gsub(/\n/,"")==@commands[index] if toUnformattedText(@commands[index]).gsub(/\n/,"")==@commands[index]
@@ -111,7 +111,7 @@ class PngAnimatedBitmap
@currentFrame @currentFrame
end end
def frameDelay(index) def frameDelay(_index)
return @frameDelay return @frameDelay
end end
@@ -259,10 +259,6 @@ class GifBitmap
return @gifbitmaps[index] return @gifbitmaps[index]
end end
def width; self.bitmap.width; end
def height; self.bitmap.height; end
def deanimate def deanimate
for i in 1...@gifbitmaps.length for i in 1...@gifbitmaps.length
@gifbitmaps[i].dispose @gifbitmaps[i].dispose
@@ -349,7 +345,7 @@ end
def pbGetTileBitmap(filename, tile_id, hue) def pbGetTileBitmap(filename, tile_id, hue)
return BitmapCache.tileEx(filename, tile_id, hue) { |f| return BitmapCache.tileEx(filename, tile_id, hue) { |f|
AnimatedBitmap.new("Graphics/Tilesets/"+filename).deanimate; AnimatedBitmap.new("Graphics/Tilesets/"+filename).deanimate
} }
end end
@@ -1000,8 +996,10 @@ class LargePlane < Plane
top = (dstrect.y-@__oy/@__sprite.zoom_y).to_i top = (dstrect.y-@__oy/@__sprite.zoom_y).to_i
while left>0; left -= srcbitmap.width; end while left>0; left -= srcbitmap.width; end
while top>0; top -= srcbitmap.height; end while top>0; top -= srcbitmap.height; end
y = top; while y<dstrect.height y = top
x = left; while x<dstrect.width while y<dstrect.height
x = left
while x<dstrect.width
dstbitmap.blt(x+@borderX,y+@borderY,srcbitmap,srcrect) dstbitmap.blt(x+@borderX,y+@borderY,srcbitmap,srcrect)
x += srcrect.width x += srcrect.width
end end
@@ -2,9 +2,9 @@
# Text colours # Text colours
#=============================================================================== #===============================================================================
def ctag(color) def ctag(color)
ret=(color.red.to_i<<24) ret=(color.red.to_i << 24)
ret|=((color.green.to_i)<<16) ret|=((color.green.to_i) << 16)
ret|=((color.blue.to_i)<<8) ret|=((color.blue.to_i) << 8)
ret|=((color.alpha.to_i)) ret|=((color.alpha.to_i))
return sprintf("<c=%08X>",ret) return sprintf("<c=%08X>",ret)
end end
@@ -168,13 +168,9 @@ end
def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight, def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight,
newlineBreaks=true,explicitBreaksOnly=false) newlineBreaks=true,explicitBreaksOnly=false)
numchars=0
x=y=0 x=y=0
characters=[] characters=[]
charactersInternal=[]
textchunks=[] textchunks=[]
controls=[]
charsonline=0
textchunks.push(text) textchunks.push(text)
text=textchunks.join("") text=textchunks.join("")
textchars=text.scan(/./m) textchars=text.scan(/./m)
@@ -192,19 +188,18 @@ def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight,
end end
defaultfontname=defaultfontname.clone defaultfontname=defaultfontname.clone
havenl=false havenl=false
position=0;while position<textchars.length position=0
while position<textchars.length
yStart=0 yStart=0
xStart=0 xStart=0
width=isWaitChar(textchars[position]) ? 0 : bitmap.text_size(textchars[position]).width width=isWaitChar(textchars[position]) ? 0 : bitmap.text_size(textchars[position]).width
if textchars[position]=="\n" if textchars[position]=="\n"
if newlineBreaks # treat newline as break if newlineBreaks # treat newline as break
if true havenl=true
havenl=true characters.push(["\n",x,y*lineheight+yDst,0,lineheight,false,false,
characters.push(["\n",x,y*lineheight+yDst,0,lineheight,false,false, false,colorclone,nil,false,false,"",8,position,nil,0])
false,colorclone,nil,false,false,"",8,position,nil,0]) y+=1
y+=1 x=0
x=0
end
hadspace=true hadspace=true
hadnonspace=false hadnonspace=false
position+=1 position+=1
@@ -223,10 +218,8 @@ def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight,
elsif isspace elsif isspace
hadspace=true hadspace=true
end end
textx=x+xStart # independent of xDst
texty=(lineheight*y)+yDst+yStart texty=(lineheight*y)+yDst+yStart
oldx=x # Push character
# Push character, textx will be calculated later
if heightDst<0 || yStart<yDst+heightDst if heightDst<0 || yStart<yDst+heightDst
havenl=true if isWaitChar(textchars[position]) havenl=true if isWaitChar(textchars[position])
characters.push([ characters.push([
@@ -455,11 +448,9 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
dummybitmap.dispose if dummybitmap dummybitmap.dispose if dummybitmap
return ret return ret
end end
numchars=0
x=y=0 x=y=0
characters=[] characters=[]
charactersInternal=[] charactersInternal=[]
charsonline=0
realtext=nil realtext=nil
realtextStart="" realtextStart=""
if !explicitBreaksOnly && textchunks.join("").length==0 if !explicitBreaksOnly && textchunks.join("").length==0
@@ -511,7 +502,8 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
hadspace=false hadspace=false
hadnonspace=false hadnonspace=false
havenl=false havenl=false
position=0; while position<textchars.length position=0
while position<textchars.length
nextline=0 nextline=0
graphic=nil graphic=nil
graphicX=0 graphicX=0
@@ -712,11 +704,9 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
elsif isspace elsif isspace
hadspace=true hadspace=true
end end
textx=x+xStart # independent of xDst
texty=(lineheight*y)+yDst+yStart texty=(lineheight*y)+yDst+yStart
colors=getLastColors(colorstack,opacitystack,defaultcolors) colors=getLastColors(colorstack,opacitystack,defaultcolors)
oldx=x # Push character
# Push character, textx will be calculated later
if heightDst<0 || texty<yDst+heightDst if heightDst<0 || texty<yDst+heightDst
havenl=true if !graphic && isWaitChar(textchars[position]) havenl=true if !graphic && isWaitChar(textchars[position])
extraspace=(!graphic && italiccount>0) ? 2+(width/2) : 2 extraspace=(!graphic && italiccount>0) ? 2+(width/2) : 2
@@ -909,7 +899,6 @@ def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
reNoMatch=/<c=[^>]+>/ reNoMatch=/<c=[^>]+>/
return ret if !bitmap || bitmap.disposed? || width<=0 return ret if !bitmap || bitmap.disposed? || width<=0
textmsg=value.clone textmsg=value.clone
lines=0
color=Font.default_color color=Font.default_color
while (c = textmsg.slice!(/\n|[^ \r\t\f\n\-]*\-+|(\S*([ \r\t\f]?))/)) != nil while (c = textmsg.slice!(/\n|[^ \r\t\f\n\-]*\-+|(\S*([ \r\t\f]?))/)) != nil
break if c=="" break if c==""
@@ -1111,7 +1100,7 @@ def coloredToFormattedText(text,baseColor=nil,shadowColor=nil)
end end
# Deprecated -- not to be used in new code # Deprecated -- not to be used in new code
def drawColoredTextEx(bitmap,x,y,width,text,baseColor=nil,shadowColor=nil) def drawColoredTextEx(bitmap,x,y,width,text,_baseColor=nil,_shadowColor=nil)
chars=getFormattedText(bitmap,x,y,width,-1,coloredToFormattedText(text),32) chars=getFormattedText(bitmap,x,y,width,-1,coloredToFormattedText(text),32)
drawFormattedChars(bitmap,chars) drawFormattedChars(bitmap,chars)
end end
@@ -315,12 +315,13 @@ module InterpreterMixin
if common_event != nil if common_event != nil
interp = Interpreter.new interp = Interpreter.new
interp.setup(common_event.list,0) interp.setup(common_event.list,0)
begin loop do
Graphics.update Graphics.update
Input.update Input.update
interp.update interp.update
pbUpdateSceneMap pbUpdateSceneMap
end while interp.running? break if !interp.running?
end
end end
else else
$game_system.battle_interpreter.setup(common_event.list, 0) $game_system.battle_interpreter.setup(common_event.list, 0)
@@ -705,7 +706,7 @@ class ChooseNumberParams
ret=0 ret=0
if @maxDigits>0 if @maxDigits>0
ret=-((10**@maxDigits)-1) ret=-((10**@maxDigits)-1)
elsif else
ret=@minNumber ret=@minNumber
end end
ret=0 if !@negativeAllowed && ret<0 ret=0 if !@negativeAllowed && ret<0
@@ -716,7 +717,7 @@ class ChooseNumberParams
ret=0 ret=0
if @maxDigits>0 if @maxDigits>0
ret=((10**@maxDigits)-1) ret=((10**@maxDigits)-1)
elsif else
ret=@maxNumber ret=@maxNumber
end end
ret=0 if !@negativeAllowed && ret<0 ret=0 if !@negativeAllowed && ret<0
@@ -767,9 +768,7 @@ def pbChooseNumber(msgwindow,params)
cmdwindow.setSkin(params.skin) if params.skin cmdwindow.setSkin(params.skin) if params.skin
cmdwindow.sign=params.negativesAllowed # must be set before number cmdwindow.sign=params.negativesAllowed # must be set before number
cmdwindow.number=defaultNumber cmdwindow.number=defaultNumber
curnumber=defaultNumber
pbPositionNearMsgWindow(cmdwindow,msgwindow,:right) pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
command=0
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
@@ -1007,7 +1006,6 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
oldletterbyletter=msgwindow.letterbyletter oldletterbyletter=msgwindow.letterbyletter
msgwindow.letterbyletter=(letterbyletter) ? true : false msgwindow.letterbyletter=(letterbyletter) ? true : false
ret=nil ret=nil
count=0
commands=nil commands=nil
facewindow=nil facewindow=nil
goldwindow=nil goldwindow=nil
@@ -1048,17 +1046,19 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
m = $1.to_i m = $1.to_i
next getSkinColor(msgwindow.windowskin,m,isDarkSkin) next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
} }
begin loop do
last_text = text.clone last_text = text.clone
text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] } text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
end until text == last_text break if text == last_text
begin end
loop do
last_text = text.clone last_text = text.clone
text.gsub!(/\\l\[([0-9]+)\]/i) { text.gsub!(/\\l\[([0-9]+)\]/i) {
linecount = [1,$1.to_i].max linecount = [1,$1.to_i].max
next "" next ""
} }
end until text == last_text break if text == last_text
end
colortag = "" colortag = ""
if ($game_message && $game_message.background>0) || if ($game_message && $game_message.background>0) ||
($game_system && $game_system.respond_to?("message_frame") && ($game_system && $game_system.respond_to?("message_frame") &&
@@ -1156,7 +1156,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
########## Show text ############################# ########## Show text #############################
msgwindow.text = text msgwindow.text = text
Graphics.frame_reset if Graphics.frame_rate>40 Graphics.frame_reset if Graphics.frame_rate>40
begin loop do
if signWaitCount>0 if signWaitCount>0
signWaitCount -= 1 signWaitCount -= 1
if atTop if atTop
@@ -1256,7 +1256,8 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
pbUpdateSceneMap pbUpdateSceneMap
msgwindow.update msgwindow.update
yield if block_given? yield if block_given?
end until (!letterbyletter || commandProc || commands) && !msgwindow.busy? break if (!letterbyletter || commandProc || commands) && !msgwindow.busy?
end
Input.update # Must call Input.update again to avoid extra triggers Input.update # Must call Input.update again to avoid extra triggers
msgwindow.letterbyletter=oldletterbyletter msgwindow.letterbyletter=oldletterbyletter
if commands if commands
@@ -46,7 +46,7 @@ class Window_CharacterEntry < Window_DrawableCommand
return @charset.length+3 return @charset.length+3
end end
def drawItem(index,count,rect) def drawItem(index,_count,rect)
rect=drawCursor(index,rect) rect=drawCursor(index,rect)
if index==@charset.length # -1 if index==@charset.length # -1
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,"[ ]", pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,"[ ]",
@@ -70,9 +70,9 @@ end
# #
#=============================================================================== #===============================================================================
class CharacterEntryHelper class CharacterEntryHelper
attr_reader :text attr_reader :text
attr_reader :maxlength attr_accessor :maxlength
attr_reader :passwordChar attr_reader :passwordChar
attr_accessor :cursor attr_accessor :cursor
def initialize(text) def initialize(text)
@@ -80,12 +80,10 @@ class CharacterEntryHelper
@text=text @text=text
@passwordChar="" @passwordChar=""
@cursor=text.scan(/./m).length @cursor=text.scan(/./m).length
ensure
end end
def text=(value) def text=(value)
@text=value @text=value
ensure
end end
def textChars def textChars
@@ -100,11 +98,6 @@ class CharacterEntryHelper
@passwordChar=value ? value : "" @passwordChar=value ? value : ""
end end
def maxlength=(value)
@maxlength=value
ensure
end
def length def length
return self.text.scan(/./m).length return self.text.scan(/./m).length
end end
@@ -264,7 +257,6 @@ class Window_TextEntry < SpriteWindow_Base
end end
x+=4 x+=4
width=self.width-self.borderX width=self.width-self.borderX
height=self.height-self.borderY
cursorcolor=Color.new(16,24,32) cursorcolor=Color.new(16,24,32)
textscan=self.text.scan(/./m) textscan=self.text.scan(/./m)
scanlength=textscan.length scanlength=textscan.length
@@ -316,8 +308,6 @@ def getLineBrokenText(bitmap,value,width,dims)
column=0 column=0
return ret if !bitmap || bitmap.disposed? || width<=0 return ret if !bitmap || bitmap.disposed? || width<=0
textmsg=value.clone textmsg=value.clone
lines=0
color=Font.default_color
ret.push(["",0,0,0,bitmap.text_size("X").height,0,0,0,0]) ret.push(["",0,0,0,bitmap.text_size("X").height,0,0,0,0])
while ((c = textmsg.slice!(/\n|(\S*([ \r\t\f]?))/)) != nil) while ((c = textmsg.slice!(/\n|(\S*([ \r\t\f]?))/)) != nil)
break if c=="" break if c==""
@@ -334,7 +324,6 @@ def getLineBrokenText(bitmap,value,width,dims)
ret.push(["",x,y,0,textheight,line,position,column,0]) ret.push(["",x,y,0,textheight,line,position,column,0])
next next
end end
textcols=[]
words=[ccheck] words=[ccheck]
for i in 0...words.length for i in 0...words.length
word=words[i] word=words[i]
@@ -355,7 +344,6 @@ def getLineBrokenText(bitmap,value,width,dims)
x+=textwidth x+=textwidth
dims[0]=x if dims && dims[0]<x dims[0]=x if dims && dims[0]<x
end end
color=textcols[i] if textcols[i]
end end
position+=length position+=length
column+=length column+=length
@@ -451,87 +439,72 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getTotalLines def getTotalLines
textchars=getTextChars textchars=getTextChars
if textchars.length==0 return 1 if textchars.length==0
return 1 tchar=textchars[textchars.length-1]
else return tchar[5]+1
tchar=textchars[textchars.length-1]
return tchar[5]+1
end
end end
def getLineY(line) def getLineY(line)
textchars=getTextChars textchars=getTextChars
if textchars.length==0 return 0 if textchars.length==0
return 0 totallines=getTotalLines()
else line=0 if line<0
totallines=getTotalLines() line=totallines-1 if line>=totallines
line=0 if line<0 maximumY=0
line=totallines-1 if line>=totallines for i in 0...textchars.length
maximumY=0 thisline=textchars[i][5]
for i in 0...textchars.length y=textchars[i][2]
thisline=textchars[i][5] return y if thisline==line
y=textchars[i][2] maximumY=y if maximumY<y
return y if thisline==line
maximumY=y if maximumY<y
end
return maximumY
end end
return maximumY
end end
def getColumnsInLine(line) def getColumnsInLine(line)
textchars=getTextChars textchars=getTextChars
if textchars.length==0 return 0 if textchars.length==0
return 0 totallines=getTotalLines()
else line=0 if line<0
totallines=getTotalLines() line=totallines-1 if line>=totallines
line=0 if line<0 endpos=0
line=totallines-1 if line>=totallines for i in 0...textchars.length
endpos=0 thisline=textchars[i][5]
for i in 0...textchars.length thislength=textchars[i][8]
thisline=textchars[i][5] endpos+=thislength if thisline==line
thispos=textchars[i][6]
thislength=textchars[i][8]
if thisline==line
endpos+=thislength
end
end
return endpos
end end
return endpos
end end
def getPosFromLineAndColumn(line,column) def getPosFromLineAndColumn(line,column)
textchars=getTextChars textchars=getTextChars
if textchars.length==0 return 0 if textchars.length==0
return 0 totallines=getTotalLines()
else line=0 if line<0
totallines=getTotalLines() line=totallines-1 if line>=totallines
line=0 if line<0 endpos=0
line=totallines-1 if line>=totallines for i in 0...textchars.length
endpos=0 thisline=textchars[i][5]
for i in 0...textchars.length thispos=textchars[i][6]
thisline=textchars[i][5] thiscolumn=textchars[i][7]
thispos=textchars[i][6] thislength=textchars[i][8]
thiscolumn=textchars[i][7] if thisline==line
thislength=textchars[i][8] endpos=thispos+thislength
if thisline==line # echoln [endpos,thispos+(column-thiscolumn),textchars[i]]
endpos=thispos+thislength if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0
# echoln [endpos,thispos+(column-thiscolumn),textchars[i]] return thispos+(column-thiscolumn)
if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0
return thispos+(column-thiscolumn)
end
end end
end end
if endpos==0
# echoln [totallines,line,column]
# echoln textchars
end
# echoln "endpos=#{endpos}"
return endpos
end end
# if endpos==0
# echoln [totallines,line,column]
# echoln textchars
# end
# echoln "endpos=#{endpos}"
return endpos
end end
def getLastVisibleLine def getLastVisibleLine
textchars=getTextChars() getTextChars()
textheight=[1,self.contents.text_size("X").height].max textheight=[1,self.contents.text_size("X").height].max
lastVisible=@firstline+((self.height-self.borderY)/textheight)-1 lastVisible=@firstline+((self.height-self.borderY)/textheight)-1
return lastVisible return lastVisible
@@ -544,13 +517,9 @@ class Window_MultilineTextEntry < SpriteWindow_Base
@frame=0 @frame=0
self.refresh self.refresh
end end
if @cursorLine<@firstline @firstline=@cursorLine if @cursorLine<@firstline
@firstline=@cursorLine
end
lastVisible=getLastVisibleLine() lastVisible=getLastVisibleLine()
if @cursorLine>lastVisible @firstline+=(@cursorLine-lastVisible) if @cursorLine>lastVisible
@firstline+=(@cursorLine-lastVisible)
end
end end
def moveCursor(lineOffset, columnOffset) def moveCursor(lineOffset, columnOffset)
@@ -570,7 +539,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base
# Will happen if cursor is moved right from the end of a line # Will happen if cursor is moved right from the end of a line
@cursorLine+=1 @cursorLine+=1
@cursorColumn=0 @cursorColumn=0
updateColumns=true
end end
# Ensure column bounds # Ensure column bounds
totalColumns=getColumnsInLine(@cursorLine) totalColumns=getColumnsInLine(@cursorLine)
@@ -688,20 +656,13 @@ class Window_MultilineTextEntry < SpriteWindow_Base
self.contents=newContents self.contents=newContents
bitmap=self.contents bitmap=self.contents
bitmap.clear bitmap.clear
x=0
y=0
getTextChars getTextChars
x+=4
width=self.width-self.borderX
height=self.height-self.borderY height=self.height-self.borderY
cursorcolor=Color.new(0,0,0) cursorcolor=Color.new(0,0,0)
textchars=getTextChars() textchars=getTextChars()
scanlength=@helper.length
startY=getLineY(@firstline) startY=getLineY(@firstline)
lastheight=32
for i in 0...textchars.length for i in 0...textchars.length
thisline=textchars[i][5] thisline=textchars[i][5]
thispos=textchars[i][6]
thiscolumn=textchars[i][7] thiscolumn=textchars[i][7]
thislength=textchars[i][8] thislength=textchars[i][8]
textY=textchars[i][2]-startY textY=textchars[i][2]-startY
@@ -712,11 +673,10 @@ class Window_MultilineTextEntry < SpriteWindow_Base
c=textchars[i][0] c=textchars[i][0]
# Don't draw spaces # Don't draw spaces
next if c==" " next if c==" "
textwidth=textchars[i][3]+4 # add 4 to prevent draw_text from stretching text textwidth=textchars[i][3]+4 # add 4 to prevent draw_text from stretching text
textheight=textchars[i][4] textheight=textchars[i][4]
lastheight=textheight
# Draw text # Draw text
pbDrawShadowText(bitmap,textchars[i][1],textY, textwidth, textheight, c,@baseColor,@shadowColor) pbDrawShadowText(bitmap, textchars[i][1], textY, textwidth, textheight, c, @baseColor, @shadowColor)
end end
# Draw cursor # Draw cursor
if ((@frame/10)&1) == 0 if ((@frame/10)&1) == 0
@@ -725,7 +685,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base
cursorX=0 cursorX=0
for i in 0...textchars.length for i in 0...textchars.length
thisline=textchars[i][5] thisline=textchars[i][5]
thispos=textchars[i][6]
thiscolumn=textchars[i][7] thiscolumn=textchars[i][7]
thislength=textchars[i][8] thislength=textchars[i][8]
if thisline==@cursorLine && @cursorColumn>=thiscolumn && if thisline==@cursorLine && @cursorColumn>=thiscolumn &&
@@ -1560,7 +1519,6 @@ class Interpreter
if $game_actors && $data_actors && $data_actors[@parameters[0]] != nil if $game_actors && $data_actors && $data_actors[@parameters[0]] != nil
# Set battle abort flag # Set battle abort flag
$game_temp.battle_abort = true $game_temp.battle_abort = true
ret=""
pbFadeOutIn { pbFadeOutIn {
sscene=PokemonEntryScene.new sscene=PokemonEntryScene.new
sscreen=PokemonEntry.new(sscene) sscreen=PokemonEntry.new(sscene)
@@ -1583,7 +1541,6 @@ class Game_Interpreter
end end
if $game_actors && $data_actors && $data_actors[@params[0]] != nil if $game_actors && $data_actors && $data_actors[@params[0]] != nil
# Set battle abort flag # Set battle abort flag
ret=""
pbFadeOutIn { pbFadeOutIn {
sscene=PokemonEntryScene.new sscene=PokemonEntryScene.new
sscreen=PokemonEntry.new(sscene) sscreen=PokemonEntry.new(sscene)
@@ -385,7 +385,6 @@ class RandomStripeTransition
rect = Rect.new(0,0,(dir==0) ? size : Graphics.width,(dir==0) ? Graphics.height : size) rect = Rect.new(0,0,(dir==0) ? size : Graphics.width,(dir==0) ? Graphics.height : size)
buffer = @buffer buffer = @buffer
sprite = @sprite sprite = @sprite
phase = @numframes-@duration
count = (bands-bands*@duration/@numframes)-@rand_stripe_deleted_count count = (bands-bands*@duration/@numframes)-@rand_stripe_deleted_count
while count > 0 while count > 0
@rand_stripe_deleted[@rand_stripe_index_array.pop] = true @rand_stripe_deleted[@rand_stripe_index_array.pop] = true
@@ -53,7 +53,6 @@ end
def pbTextBitmap(text, maxwidth=Graphics.width) def pbTextBitmap(text, maxwidth=Graphics.width)
dims = []
tmp = Bitmap.new(maxwidth,Graphics.height) tmp = Bitmap.new(maxwidth,Graphics.height)
pbSetSystemFont(tmp) 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))
+5 -5
View File
@@ -3,7 +3,7 @@ class IntroEventScene < EventScene
TICKS_PER_ENTER_FLASH = 40 TICKS_PER_ENTER_FLASH = 40
FADE_TICKS = 8 FADE_TICKS = 8
def initialize(pics,splash,viewport=nil) def initialize(pics,splash,_viewport=nil)
super(nil) super(nil)
@pics = pics @pics = pics
@splash = splash @splash = splash
@@ -17,7 +17,7 @@ class IntroEventScene < EventScene
openPic(self,nil) openPic(self,nil)
end end
def openPic(scene,args) def openPic(_scene,_args)
onCTrigger.clear onCTrigger.clear
@pic.name = "Graphics/Titles/"+@pics[@index] @pic.name = "Graphics/Titles/"+@pics[@index]
# fade to opacity 255 in FADE_TICKS ticks after waiting 0 frames # fade to opacity 255 in FADE_TICKS ticks after waiting 0 frames
@@ -49,7 +49,7 @@ class IntroEventScene < EventScene
end end
end end
def openSplash(scene,args) def openSplash(_scene,_args)
onUpdate.clear onUpdate.clear
onCTrigger.clear onCTrigger.clear
@pic.name = "Graphics/Titles/"+@splash @pic.name = "Graphics/Titles/"+@splash
@@ -63,7 +63,7 @@ class IntroEventScene < EventScene
onCTrigger.set(method(:closeSplash)) # call closeSplash when C key is pressed onCTrigger.set(method(:closeSplash)) # call closeSplash when C key is pressed
end end
def closeSplash(scene,args) def closeSplash(scene,_args)
onUpdate.clear onUpdate.clear
onCTrigger.clear onCTrigger.clear
# Play random cry # Play random cry
@@ -83,7 +83,7 @@ class IntroEventScene < EventScene
sscreen.pbStartLoadScreen sscreen.pbStartLoadScreen
end end
def closeSplashDelete(scene,args) def closeSplashDelete(scene,_args)
onUpdate.clear onUpdate.clear
onCTrigger.clear onCTrigger.clear
# Play random cry # Play random cry
+18 -18
View File
@@ -6,30 +6,30 @@
# pbEventScreen(ButtonEventScene) # pbEventScreen(ButtonEventScene)
#============================================================================== #==============================================================================
class ButtonEventScene < EventScene class ButtonEventScene < EventScene
def initialize(viewport=nil) def initialize(viewport = nil)
super super
Graphics.freeze Graphics.freeze
addImage(0,0,"Graphics/Pictures/helpbg") addImage(0, 0, "Graphics/Pictures/helpbg")
@labels=[ @labels = [
addLabel(52*2,13*2,Graphics.width*3/4,_INTL("Moves the main character. Also used to scroll through list entries.")), addLabel(52 * 2, 13 * 2, Graphics.width * 3 / 4, _INTL("Moves the main character. Also used to scroll through list entries.")),
addLabel(52*2,53*2,Graphics.width*3/4,_INTL("Used to confirm a choice, check things, and talk to people.")), addLabel(52 * 2, 53 * 2, Graphics.width * 3 / 4, _INTL("Used to confirm a choice, check things, and talk to people.")),
addLabel(52*2,93*2,Graphics.width*3/4,_INTL("Used to exit, cancel a choice or mode, and open the pause menu.")), addLabel(52 * 2, 93 * 2, Graphics.width * 3 / 4, _INTL("Used to exit, cancel a choice or mode, and open the pause menu.")),
addLabel(52*2,133*2,Graphics.width*3/4,_INTL("Hold down while walking to run.")), addLabel(52 * 2, 133 * 2, Graphics.width * 3 / 4, _INTL("Hold down while walking to run.")),
addLabel(52*2,157*2,Graphics.width*3/4,_INTL("Press to use a registered Key Item.")) addLabel(52 * 2, 157 * 2, Graphics.width * 3 / 4, _INTL("Press to use a registered Key Item."))
] ]
@keys=[ @keys = [
addImage(26*2,18*2,"Graphics/Pictures/helpArrowKeys"), addImage(26 * 2, 18 * 2, "Graphics/Pictures/helpArrowKeys"),
addImage(26*2,59*2,"Graphics/Pictures/helpCkey"), addImage(26 * 2, 59 * 2, "Graphics/Pictures/helpCkey"),
addImage(26*2,99*2,"Graphics/Pictures/helpXkey"), addImage(26 * 2, 99 * 2, "Graphics/Pictures/helpXkey"),
addImage(26*2,130*2,"Graphics/Pictures/helpZkey"), addImage(26 * 2, 130 * 2, "Graphics/Pictures/helpZkey"),
addImage(26*2,154*2,"Graphics/Pictures/helpFkey") addImage(26 * 2, 154 * 2, "Graphics/Pictures/helpFkey")
] ]
for key in @keys for key in @keys
key.origin=PictureOrigin::Top key.origin = PictureOrigin::Top
end end
for i in 0...5 # Make everything show (almost) immediately for i in 0...5 # Make everything show (almost) immediately
@keys[i].setOrigin(0,PictureOrigin::Top) @keys[i].setOrigin(0, PictureOrigin::Top)
@keys[i].setOpacity(0,255) @keys[i].setOpacity(0, 255)
end end
pictureWait # Update event scene with the changes pictureWait # Update event scene with the changes
Graphics.transition(20) Graphics.transition(20)
@@ -37,7 +37,7 @@ class ButtonEventScene < EventScene
onCTrigger.set(method(:pbOnScreen1)) onCTrigger.set(method(:pbOnScreen1))
end end
def pbOnScreen1(scene,args) def pbOnScreen1(scene,_args)
# End scene # End scene
Graphics.freeze Graphics.freeze
scene.dispose scene.dispose
@@ -135,7 +135,6 @@ _END_
line = line.split("<s>") line = line.split("<s>")
# LINE ADDED: If you use in your own game, you should remove this line # LINE ADDED: If you use in your own game, you should remove this line
pbSetSystemFont(credit_bitmap) # <--- This line was added pbSetSystemFont(credit_bitmap) # <--- This line was added
x = 0
xpos = 0 xpos = 0
align = 1 # Centre align align = 1 # Centre align
linewidth = Graphics.width linewidth = Graphics.width
+2 -2
View File
@@ -15,7 +15,7 @@ class Scene_Movie
def main def main
@temp = Win32API.pbFindRgssWindow.to_s @temp = Win32API.pbFindRgssWindow.to_s
movie = Win32API.new('winmm','mciSendString','%w(p,p,l,l)','V') movie = Win32API.new('winmm','mciSendString','%w(p,p,l,l)','V')
x=movie.call("open \""+@movie_name+ movie.call("open \""+@movie_name+
"\" alias FILE style 1073741824 parent " + @temp.to_s,0,0,0) "\" alias FILE style 1073741824 parent " + @temp.to_s,0,0,0)
@message = Win32API.new('user32','SendMessage','%w(l,l,l,l)','V') @message = Win32API.new('user32','SendMessage','%w(l,l,l,l)','V')
@detector = Win32API.new('user32','GetSystemMetrics','%w(l)','L') @detector = Win32API.new('user32','GetSystemMetrics','%w(l)','L')
@@ -31,7 +31,7 @@ class Scene_Movie
#fullscreen #fullscreen
end end
status = " " * 255 status = " " * 255
x=movie.call("play FILE",0,0,0) movie.call("play FILE",0,0,0)
loop do loop do
sleep(0.1) sleep(0.1)
@message.call(@temp.to_i,11,0,0) @message.call(@temp.to_i,11,0,0)
+2 -2
View File
@@ -54,8 +54,8 @@ class PBMoveData
attr_reader :function,:basedamage,:type,:accuracy,:category attr_reader :function,:basedamage,:type,:accuracy,:category
attr_reader :totalpp,:addlEffect,:target,:priority,:flags attr_reader :totalpp,:addlEffect,:target,:priority,:flags
def initialize(moveid) def initialize(move_id)
moveData = pbGetMoveData(moveID) moveData = pbGetMoveData(move_id)
@function = moveData[MOVE_FUNCTION_CODE] @function = moveData[MOVE_FUNCTION_CODE]
@basedamage = moveData[MOVE_BASE_DAMAGE] @basedamage = moveData[MOVE_BASE_DAMAGE]
@type = moveData[MOVE_TYPE] @type = moveData[MOVE_TYPE]
+8 -7
View File
@@ -11,15 +11,16 @@ begin
def self.getName(id) def self.getName(id)
id = getID(PBStatuses,id) id = getID(PBStatuses,id)
names = [ names = [
_INTL("healthy"), _INTL("healthy"),
_INTL("asleep"), _INTL("asleep"),
_INTL("poisoned"), _INTL("poisoned"),
_INTL("burned"), _INTL("burned"),
_INTL("paralyzed"), _INTL("paralyzed"),
_INTL("frozen") _INTL("frozen")
] ]
return names[id] return names[id]
end end end
end
rescue Exception rescue Exception
if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset" if $!.is_a?(SystemExit) || "#{$!.class}"=="Reset"
+4 -6
View File
@@ -185,12 +185,10 @@ module PBExperience
mLevel = maxLevel mLevel = maxLevel
maxexp = pbGetExpInternal(mLevel,growth) maxexp = pbGetExpInternal(mLevel,growth)
exp = maxexp if exp>maxexp exp = maxexp if exp>maxexp
i = 0 for lvl in 0..mLevel
for j in 0..mLevel currentExp = pbGetExpInternal(lvl,growth)
currentExp = pbGetExpInternal(i,growth) return lvl if exp==currentExp
return i if exp==currentExp return lvl-1 if exp<currentExp
return i-1 if exp<currentExp
i += 1
end end
return mLevel return mLevel
end end
+15 -15
View File
@@ -21,21 +21,21 @@ module PBEggGroups
def self.getName(id) def self.getName(id)
id = getID(PBEggGroups,id) id = getID(PBEggGroups,id)
names = [ names = [
_INTL("Undiscovered"), _INTL("Undiscovered"),
_INTL("Monster"), _INTL("Monster"),
_INTL("Water 1"), _INTL("Water 1"),
_INTL("Bug"), _INTL("Bug"),
_INTL("Flying"), _INTL("Flying"),
_INTL("Field"), _INTL("Field"),
_INTL("Fairy"), _INTL("Fairy"),
_INTL("Grass"), _INTL("Grass"),
_INTL("Human-like"), _INTL("Human-like"),
_INTL("Water 3"), _INTL("Water 3"),
_INTL("Mineral"), _INTL("Mineral"),
_INTL("Amorphous"), _INTL("Amorphous"),
_INTL("Water 2"), _INTL("Water 2"),
_INTL("Ditto"), _INTL("Ditto"),
_INTL("Dragon") _INTL("Dragon")
] ]
return names[id] return names[id]
end end
+10 -10
View File
@@ -17,16 +17,16 @@ module PBColors
def self.getName(id) def self.getName(id)
id = getID(PBColors,id) id = getID(PBColors,id)
names = [ names = [
_INTL("Red"), _INTL("Red"),
_INTL("Blue"), _INTL("Blue"),
_INTL("Yellow"), _INTL("Yellow"),
_INTL("Green"), _INTL("Green"),
_INTL("Black"), _INTL("Black"),
_INTL("Brown"), _INTL("Brown"),
_INTL("Purple"), _INTL("Purple"),
_INTL("Gray"), _INTL("Gray"),
_INTL("White"), _INTL("White"),
_INTL("Pink") _INTL("Pink")
] ]
return names[id] return names[id]
end end
+10 -10
View File
@@ -16,16 +16,16 @@ module PBHabitats
def self.getName(id) def self.getName(id)
id = getID(PBHabitats,id) id = getID(PBHabitats,id)
names = [ names = [
_INTL("None"), _INTL("None"),
_INTL("Grassland"), _INTL("Grassland"),
_INTL("Forest"), _INTL("Forest"),
_INTL("Water's Edge"), _INTL("Water's Edge"),
_INTL("Sea"), _INTL("Sea"),
_INTL("Cave"), _INTL("Cave"),
_INTL("Mountain"), _INTL("Mountain"),
_INTL("Rough Terrain"), _INTL("Rough Terrain"),
_INTL("Urban"), _INTL("Urban"),
_INTL("Rare") _INTL("Rare")
] ]
return names[id] return names[id]
end end
@@ -351,7 +351,6 @@ class PokeBattle_Battler
:COMATOSE, :COMATOSE,
:RKSSYSTEM :RKSSYSTEM
] ]
failed = false
abilityBlacklist.each do |abil| abilityBlacklist.each do |abil|
return true if isConst?(@ability,PBAbilities,abil) return true if isConst?(@ability,PBAbilities,abil)
end end
@@ -31,7 +31,6 @@ class PokeBattle_Battler
def pbRecoverHPFromDrain(amt,target,msg=nil) def pbRecoverHPFromDrain(amt,target,msg=nil)
if target.hasActiveAbility?(:LIQUIDOOZE) if target.hasActiveAbility?(:LIQUIDOOZE)
oldHP = @hp
@battle.pbShowAbilitySplash(target) @battle.pbShowAbilitySplash(target)
pbReduceHP(amt) pbReduceHP(amt)
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",pbThis)) @battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",pbThis))
@@ -566,7 +566,7 @@ class PokeBattle_Battler
#============================================================================= #=============================================================================
# Flinching # Flinching
#============================================================================= #=============================================================================
def pbFlinch(user=nil) def pbFlinch(_user=nil)
return if hasActiveAbility?(:INNERFOCUS) && !@battle.moldBreaker return if hasActiveAbility?(:INNERFOCUS) && !@battle.moldBreaker
@effects[PBEffects::Flinch] = true @effects[PBEffects::Flinch] = true
end end
@@ -149,7 +149,7 @@ class PokeBattle_Battler
#============================================================================= #=============================================================================
# Held item consuming/removing # Held item consuming/removing
#============================================================================= #=============================================================================
def pbCanConsumeBerry?(item,alwaysCheckGluttony=true) def pbCanConsumeBerry?(_item,alwaysCheckGluttony=true)
return false if @battle.pbCheckOpposingAbility(:UNNERVE,@index) return false if @battle.pbCheckOpposingAbility(:UNNERVE,@index)
return true if @hp<=@totalhp/4 return true if @hp<=@totalhp/4
if alwaysCheckGluttony || NEWEST_BATTLE_MECHANICS if alwaysCheckGluttony || NEWEST_BATTLE_MECHANICS
@@ -67,7 +67,7 @@ class PokeBattle_Battler
#============================================================================= #=============================================================================
# #
#============================================================================= #=============================================================================
def pbBeginTurn(choice) def pbBeginTurn(_choice)
# Cancel some lingering effects which only apply until the user next moves # Cancel some lingering effects which only apply until the user next moves
@effects[PBEffects::BeakBlast] = false @effects[PBEffects::BeakBlast] = false
@effects[PBEffects::DestinyBondPrevious] = @effects[PBEffects::DestinyBond] @effects[PBEffects::DestinyBondPrevious] = @effects[PBEffects::DestinyBond]
@@ -105,7 +105,7 @@ class PokeBattle_Battler
@effects[PBEffects::FuryCutter] = 0 @effects[PBEffects::FuryCutter] = 0
end end
def pbEndTurn(choice) def pbEndTurn(_choice)
@lastRoundMoved = @battle.turnCount # Done something this round @lastRoundMoved = @battle.turnCount # Done something this round
if @effects[PBEffects::ChoiceBand]<0 && if @effects[PBEffects::ChoiceBand]<0 &&
hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF]) hasActiveItem?([:CHOICEBAND,:CHOICESPECS,:CHOICESCARF])
@@ -438,7 +438,6 @@ class PokeBattle_Battler
# NOTE: If a multi-hit move becomes disabled partway through doing those # NOTE: If a multi-hit move becomes disabled partway through doing those
# hits (e.g. by Cursed Body), the rest of the hits continue as # hits (e.g. by Cursed Body), the rest of the hits continue as
# normal. # normal.
notFainted = false
break if !targets.any? { |t| !t.fainted? } # All targets are fainted break if !targets.any? { |t| !t.fainted? } # All targets are fainted
end end
# Battle Arena only - attack is successful # Battle Arena only - attack is successful
@@ -479,7 +478,7 @@ class PokeBattle_Battler
newTargets = pbChangeTargets(move,b,newTargets) newTargets = pbChangeTargets(move,b,newTargets)
success = pbProcessMoveHit(move,b,newTargets,0,false) success = pbProcessMoveHit(move,b,newTargets,0,false)
b.lastMoveFailed = true if !success b.lastMoveFailed = true if !success
targets.each { |b| b.pbFaint if b && b.fainted? } targets.each { |otherB| otherB.pbFaint if otherB && otherB.fainted? }
user.pbFaint if user.fainted? user.pbFaint if user.fainted?
end end
# Magic Coat's bouncing back (move has no targets) # Magic Coat's bouncing back (move has no targets)
@@ -2,7 +2,7 @@ class PokeBattle_Battler
#============================================================================= #=============================================================================
# Get move's user # Get move's user
#============================================================================= #=============================================================================
def pbFindUser(choice,move) def pbFindUser(_choice,_move)
return self return self
end end
@@ -169,7 +169,7 @@ class PokeBattle_Battler
return true return true
end end
def pbAddTargetRandomAlly(targets,user,move,nearOnly=true) def pbAddTargetRandomAlly(targets,user,_move,nearOnly=true)
choices = [] choices = []
user.eachAlly do |b| user.eachAlly do |b|
next if nearOnly && !user.near?(b) next if nearOnly && !user.near?(b)
@@ -180,7 +180,7 @@ class PokeBattle_Battler
end end
end end
def pbAddTargetRandomFoe(targets,user,move,nearOnly=true) def pbAddTargetRandomFoe(targets,user,_move,nearOnly=true)
choices = [] choices = []
user.eachOpposing do |b| user.eachOpposing do |b|
next if nearOnly && !user.near?(b) next if nearOnly && !user.near?(b)
@@ -136,7 +136,7 @@ class PokeBattle_Battler
@battle.pbDisplay(_INTL("{1} ignored orders!",pbThis)) @battle.pbDisplay(_INTL("{1} ignored orders!",pbThis))
return false if !@battle.pbCanShowFightMenu?(@index) return false if !@battle.pbCanShowFightMenu?(@index)
otherMoves = [] otherMoves = []
eachMoveWithIndex do |m,i| eachMoveWithIndex do |_m,i|
next if i==choice[1] next if i==choice[1]
otherMoves[otherMoves.length] = i if @battle.pbCanChooseMove?(@index,i,false) otherMoves[otherMoves.length] = i if @battle.pbCanChooseMove?(@index,i,false)
end end
@@ -61,7 +61,7 @@ class PokeBattle_Move
#============================================================================= #=============================================================================
# About the move # About the move
#============================================================================= #=============================================================================
def pbTarget(user); return @target; end def pbTarget(_user); return @target; end
def totalpp def totalpp
return @totalpp if @totalpp && @totalpp>0 # Usually undefined return @totalpp if @totalpp && @totalpp>0 # Usually undefined
@@ -127,8 +127,8 @@ class PokeBattle_Move
def danceMove?; return @flags[/o/]; end def danceMove?; return @flags[/o/]; end
# Causes perfect accuracy (param=1) and double damage (param=2). # Causes perfect accuracy (param=1) and double damage (param=2).
def tramplesMinimize?(param=1); return false; end 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 def ignoresSubstitute?(user) # user is the Pokémon using this move
if NEWEST_BATTLE_MECHANICS if NEWEST_BATTLE_MECHANICS
@@ -30,8 +30,8 @@ class PokeBattle_Move
# attack in the same turn. # attack in the same turn.
# user.effects[PBEffects::TwoTurnAttack] is set to the move's ID during the # user.effects[PBEffects::TwoTurnAttack] is set to the move's ID during the
# charging turn, and is 0 during the attack turn. # charging turn, and is 0 during the attack turn.
def pbIsChargingTurn?(user); return false; end def pbIsChargingTurn?(user); return false; end
def pbDamagingMove?; return damagingMove?; end def pbDamagingMove?; return damagingMove?; end
def pbContactMove?(user) def pbContactMove?(user)
return false if user.hasActiveAbility?(:LONGREACH) return false if user.hasActiveAbility?(:LONGREACH)
@@ -92,7 +92,7 @@ class PokeBattle_Move
# Move failure checks # Move failure checks
#============================================================================= #=============================================================================
# Check whether the move fails completely due to move-specific requirements. # 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. # Checks whether the move will be ineffective against the target.
def pbFailsAgainstTarget?(user,target); return false; end def pbFailsAgainstTarget?(user,target); return false; end
@@ -543,8 +543,7 @@ class PokeBattle_Move_097 < PokeBattle_Move
def pbBaseDamage(baseDmg,user,target) def pbBaseDamage(baseDmg,user,target)
dmgs = [200,80,60,50,40] dmgs = [200,80,60,50,40]
ppLeft = [@pp,dmgs.length-1].min # PP is reduced before the move is used ppLeft = [@pp,dmgs.length-1].min # PP is reduced before the move is used
baseDmg = dmgs[ppLeft] return dmgs[ppLeft]
return baseDmg
end end
end end
@@ -897,7 +896,7 @@ class PokeBattle_Move_0A4 < PokeBattle_Move
PBEnvironment::Forest, PBEnvironment::ForestGrass PBEnvironment::Forest, PBEnvironment::ForestGrass
@secretPower = 2 # (Same as Grassy Terrain) @secretPower = 2 # (Same as Grassy Terrain)
when PBEnvironment::MovingWater, PBEnvironment::StillWater, when PBEnvironment::MovingWater, PBEnvironment::StillWater,
PBEnvironment::Puddle, PBEnvironment::Underwater PBEnvironment::Underwater
@secretPower = 5 # Water Pulse, lower Attack by 1 @secretPower = 5 # Water Pulse, lower Attack by 1
when PBEnvironment::Puddle when PBEnvironment::Puddle
@secretPower = 6 # Mud Shot, lower Speed by 1 @secretPower = 6 # Mud Shot, lower Speed by 1
@@ -1052,7 +1051,7 @@ class PokeBattle_Move_0A9 < PokeBattle_Move
end end
def pbGetDefenseStats(user,target) def pbGetDefenseStats(user,target)
ret1, ret2 = super ret1, _ret2 = super
return ret1, 6 # Def/SpDef stat stage return ret1, 6 # Def/SpDef stat stage
end end
end end
@@ -1321,7 +1320,6 @@ class PokeBattle_Move_0B3 < PokeBattle_Move
# turn into, but what self-respecting game wouldn't at least have Tri # turn into, but what self-respecting game wouldn't at least have Tri
# Attack in it? # Attack in it?
@npMove = getID(PBMoves,:TRIATTACK) @npMove = getID(PBMoves,:TRIATTACK)
m = nil
case @battle.field.terrain case @battle.field.terrain
when PBBattleTerrains::Electric when PBBattleTerrains::Electric
@npMove = getConst(PBMoves,:THUNDERBOLT) || @npMove @npMove = getConst(PBMoves,:THUNDERBOLT) || @npMove
@@ -2409,7 +2407,7 @@ class PokeBattle_Move_0D3 < PokeBattle_Move
def pbBaseDamage(baseDmg,user,target) def pbBaseDamage(baseDmg,user,target)
shift = (4-user.effects[PBEffects::Rollout]) # 0-4, where 0 is most powerful shift = (4-user.effects[PBEffects::Rollout]) # 0-4, where 0 is most powerful
shift += 1 if user.effects[PBEffects::DefenseCurl] shift += 1 if user.effects[PBEffects::DefenseCurl]
baseDmg = baseDmg<<shift baseDmg = baseDmg << shift
return baseDmg return baseDmg
end end
@@ -3013,7 +3011,7 @@ class PokeBattle_Move_0EB < PokeBattle_Move
end end
if @battle.trainerBattle? if @battle.trainerBattle?
canSwitch = false canSwitch = false
@battle.eachInTeamFromBattlerIndex(target.index) do |pkmn,i| @battle.eachInTeamFromBattlerIndex(target.index) do |_pkmn,i|
next if !@battle.pbCanSwitchLax?(target.index,i) next if !@battle.pbCanSwitchLax?(target.index,i)
canSwitch = true canSwitch = true
break break
@@ -3555,7 +3553,7 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
end end
return if pbIsMegaStone?(user.item) return if pbIsMegaStone?(user.item)
flingableItem = false flingableItem = false
@flingPowers.each do |power,items| @flingPowers.each do |_power,items|
items.each do |i| items.each do |i|
next if !isConst?(user.item,PBItems,i) next if !isConst?(user.item,PBItems,i)
flingableItem = true flingableItem = true
@@ -1029,7 +1029,7 @@ class PokeBattle_Move_133 < PokeBattle_Move
def pbMoveFailed?(user,targets) def pbMoveFailed?(user,targets)
hasAlly = false hasAlly = false
user.eachAlly do |b| user.eachAlly do |_b|
hasAlly = true hasAlly = true
break break
end end
@@ -307,7 +307,7 @@ class PokeBattle_Battle
# screen. # screen.
def pbPlayerDisplayParty(idxBattler=0) def pbPlayerDisplayParty(idxBattler=0)
partyOrders = pbPartyOrder(idxBattler) partyOrders = pbPartyOrder(idxBattler)
idxStart, idxEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler) idxStart, _idxEnd = pbTeamIndexRangeFromBattlerIndex(idxBattler)
ret = [] ret = []
eachInTeamFromBattlerIndex(idxBattler) { |pkmn,i| ret[partyOrders[i]-idxStart] = pkmn } eachInTeamFromBattlerIndex(idxBattler) { |pkmn,i| ret[partyOrders[i]-idxStart] = pkmn }
return ret return ret
@@ -408,7 +408,7 @@ class PokeBattle_Battle
# Used to calculate money gained/lost after winning/losing a battle. # Used to calculate money gained/lost after winning/losing a battle.
def pbMaxLevelInTeam(side,idxTrainer) def pbMaxLevelInTeam(side,idxTrainer)
ret = 1 ret = 1
eachInTeam(side,idxTrainer) do |pkmn,i| eachInTeam(side,idxTrainer) do |pkmn,_i|
ret = pkmn.level if pkmn.level>ret ret = pkmn.level if pkmn.level>ret
end end
return ret return ret
@@ -433,13 +433,13 @@ class PokeBattle_Battle
def pbSideBattlerCount(idxBattler=0) def pbSideBattlerCount(idxBattler=0)
ret = 0 ret = 0
eachSameSideBattler(idxBattler) { |b| ret += 1 } eachSameSideBattler(idxBattler) { |_b| ret += 1 }
return ret return ret
end end
def pbOpposingBattlerCount(idxBattler=0) def pbOpposingBattlerCount(idxBattler=0)
ret = 0 ret = 0
eachOtherSideBattler(idxBattler) { |b| ret += 1 } eachOtherSideBattler(idxBattler) { |_b| ret += 1 }
return ret return ret
end end
@@ -558,7 +558,7 @@ class PokeBattle_Battle
idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : party.length idxPartyEnd = (idxTrainer<partyStarts.length-1) ? partyStarts[idxTrainer+1] : party.length
origPartyPos = partyOrders[idxParty] # Position of erased Pokémon initially origPartyPos = partyOrders[idxParty] # Position of erased Pokémon initially
partyOrders[idxParty] = idxPartyEnd # Put erased Pokémon last in the team partyOrders[idxParty] = idxPartyEnd # Put erased Pokémon last in the team
party.each_with_index do |pkmn,i| party.each_with_index do |_pkmn,i|
next if i<idxPartyStart || i>=idxPartyEnd # Only check the team next if i<idxPartyStart || i>=idxPartyEnd # Only check the team
next if partyOrders[i]<origPartyPos # Appeared before erased Pokémon next if partyOrders[i]<origPartyPos # Appeared before erased Pokémon
partyOrders[i] -= 1 # Appeared after erased Pokémon; bump it up by 1 partyOrders[i] -= 1 # Appeared after erased Pokémon; bump it up by 1
@@ -756,8 +756,8 @@ class PokeBattle_Battle
@scene.pbAnimation(move,user,targets,hitNum) if @showAnims @scene.pbAnimation(move,user,targets,hitNum) if @showAnims
end end
def pbCommonAnimation(name,user=nil,targets=nil,hitNum=0) def pbCommonAnimation(name,user=nil,targets=nil)
@scene.pbCommonAnimation(name,user,targets,hitNum) if @showAnims @scene.pbCommonAnimation(name,user,targets) if @showAnims
end end
def pbShowAbilitySplash(battler,delay=false,logTrigger=true) def pbShowAbilitySplash(battler,delay=false,logTrigger=true)
@@ -58,7 +58,7 @@ class PokeBattle_Battle
raise _INTL("Error: def pbGetOwnerIndexFromBattlerIndex gives invalid owner index ({1} for battle type {2}v{3}, trainers {4}v{5})", 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 end
sideCounts.each_with_index do |count,i| sideCounts.each_with_index do |_count,i|
if !requireds[i] || requireds[i]==0 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)", 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
@@ -139,7 +139,7 @@ class PokeBattle_Battle
# For each trainer in turn, find the needed number of Pokémon for them to # For each trainer in turn, find the needed number of Pokémon for them to
# send out, and initialize them # send out, and initialize them
battlerNumber = 0 battlerNumber = 0
trainer.each_with_index do |t,idxTrainer| trainer.each_with_index do |_t,idxTrainer|
ret[side][idxTrainer] = [] ret[side][idxTrainer] = []
eachInTeam(side,idxTrainer) do |pkmn,idxPkmn| eachInTeam(side,idxTrainer) do |pkmn,idxPkmn|
next if !pkmn.able? next if !pkmn.able?
@@ -403,7 +403,7 @@ class PokeBattle_Battle
pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!",@opponent[0].fullname, pbDisplayPaused(_INTL("You defeated {1}, {2} and {3}!",@opponent[0].fullname,
@opponent[1].fullname,@opponent[2].fullname)) @opponent[1].fullname,@opponent[2].fullname))
end end
@opponent.each_with_index do |t,i| @opponent.each_with_index do |_t,i|
@scene.pbShowOpponent(i) @scene.pbShowOpponent(i)
msg = (@endSpeeches[i] && @endSpeeches[i]!="") ? @endSpeeches[i] : "..." msg = (@endSpeeches[i] && @endSpeeches[i]!="") ? @endSpeeches[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name)) pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name))
@@ -437,7 +437,7 @@ class PokeBattle_Battle
pbDisplayPaused(_INTL("You blacked out!")) if !@canLose pbDisplayPaused(_INTL("You blacked out!")) if !@canLose
elsif @decision==2 elsif @decision==2
if @opponent if @opponent
@opponent.each_with_index do |t,i| @opponent.each_with_index do |_t,i|
@scene.pbShowOpponent(i) @scene.pbShowOpponent(i)
msg = (@endSpeechesWin[i] && @endSpeechesWin[i]!="") ? @endSpeechesWin[i] : "..." msg = (@endSpeechesWin[i] && @endSpeechesWin[i]!="") ? @endSpeechesWin[i] : "..."
pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name)) pbDisplayPaused(msg.gsub(/\\[Pp][Nn]/,pbPlayer.name))
@@ -168,7 +168,6 @@ class PokeBattle_Battle
raise RuntimeError.new( raise RuntimeError.new(
_INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]", _INTL("{1}'s new level is less than its\r\ncurrent level, which shouldn't happen.\r\n[Debug: {2}]",
pkmn.name,debugInfo)) pkmn.name,debugInfo))
return
end end
# Give Exp # Give Exp
if pkmn.shadowPokemon? if pkmn.shadowPokemon?
@@ -94,7 +94,7 @@ class PokeBattle_Battle
end end
def pbCanChooseNonActive?(idxBattler) def pbCanChooseNonActive?(idxBattler)
pbParty(idxBattler).each_with_index do |pkmn,i| pbParty(idxBattler).each_with_index do |_pkmn,i|
return true if pbCanSwitchLax?(idxBattler,i) return true if pbCanSwitchLax?(idxBattler,i)
end end
return false return false
@@ -212,7 +212,7 @@ class PokeBattle_Battle
if random if random
return -1 if !pbCanSwitch?(idxBattler) # Can battler switch out? return -1 if !pbCanSwitch?(idxBattler) # Can battler switch out?
choices = [] # Find all Pokémon that can switch in choices = [] # Find all Pokémon that can switch in
eachInTeamFromBattlerIndex(idxBattler) do |pkmn,i| eachInTeamFromBattlerIndex(idxBattler) do |_pkmn,i|
choices.push(i) if pbCanSwitchLax?(idxBattler,i) choices.push(i) if pbCanSwitchLax?(idxBattler,i)
end end
return -1 if choices.length==0 return -1 if choices.length==0
@@ -45,7 +45,7 @@ class PokeBattle_Battle
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) # No moves that can be chosen (will Struggle instead)
usable = false usable = false
battler.eachMoveWithIndex do |m,i| battler.eachMoveWithIndex do |_m,i|
next if !pbCanChooseMove?(idxBattler,i,false) next if !pbCanChooseMove?(idxBattler,i,false)
usable = true usable = true
break break
@@ -297,7 +297,7 @@ class PokeBattle_Battle
next if !b.canHeal? next if !b.canHeal?
hpGain = b.totalhp/16 hpGain = b.totalhp/16
hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT) hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT)
hpGain = b.pbRecoverHP(hpGain) b.pbRecoverHP(hpGain)
pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",b.pbThis(true))) pbDisplay(_INTL("Aqua Ring restored {1}'s HP!",b.pbThis(true)))
end end
# Ingrain # Ingrain
@@ -306,7 +306,7 @@ class PokeBattle_Battle
next if !b.canHeal? next if !b.canHeal?
hpGain = b.totalhp/16 hpGain = b.totalhp/16
hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT) hpGain = (hpGain*1.3).floor if b.hasActiveItem?(:BIGROOT)
hpGain = b.pbRecoverHP(hpGain) b.pbRecoverHP(hpGain)
pbDisplay(_INTL("{1} absorbed nutrients with its roots!",b.pbThis)) pbDisplay(_INTL("{1} absorbed nutrients with its roots!",b.pbThis))
end end
# Leech Seed # Leech Seed
@@ -147,7 +147,7 @@ class PokeBattle_AI
#============================================================================= #=============================================================================
def pbDefaultChooseNewEnemy(idxBattler,party) def pbDefaultChooseNewEnemy(idxBattler,party)
enemies = [] enemies = []
party.each_with_index do |p,i| party.each_with_index do |_p,i|
enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i) enemies.push(i) if @battle.pbCanSwitchLax?(idxBattler,i)
end end
return -1 if enemies.length==0 return -1 if enemies.length==0
@@ -14,7 +14,7 @@ class PokeBattle_AI
# NOTE: A move is only added to the choices array if it has a non-zero # NOTE: A move is only added to the choices array if it has a non-zero
# score. # score.
choices = [] choices = []
user.eachMoveWithIndex do |m,i| user.eachMoveWithIndex do |_m,i|
next if !@battle.pbCanChooseMove?(idxBattler,i,false) next if !@battle.pbCanChooseMove?(idxBattler,i,false)
if wildBattler if wildBattler
pbRegisterMoveWild(user,i,choices) pbRegisterMoveWild(user,i,choices)
@@ -106,7 +106,7 @@ class PokeBattle_AI
# Get scores for the given move against each possible target # Get scores for the given move against each possible target
#============================================================================= #=============================================================================
# Wild Pokémon choose their moves randomly. # Wild Pokémon choose their moves randomly.
def pbRegisterMoveWild(user,idxMove,choices) def pbRegisterMoveWild(_user,idxMove,choices)
choices.push([idxMove,100,-1]) # Move index, score, target choices.push([idxMove,100,-1]) # Move index, score, target
end end
@@ -195,7 +195,6 @@ class PokeBattle_AI
end end
# If user is asleep, prefer moves that are usable while asleep # If user is asleep, prefer moves that are usable while asleep
if user.status==PBStatuses::SLEEP && !move.usableWhenAsleep? if user.status==PBStatuses::SLEEP && !move.usableWhenAsleep?
hasSleepMove = false
user.eachMove do |m| user.eachMove do |m|
next unless m.usableWhenAsleep? next unless m.usableWhenAsleep?
score -= 60 score -= 60
@@ -12,13 +12,13 @@ class PokeBattle_AI
@battle.eachBattler { |b| numTargets += 1 if b.near?(user) } @battle.eachBattler { |b| numTargets += 1 if b.near?(user) }
return numTargets>1 return numTargets>1
when PBTargets::UserAndAllies when PBTargets::UserAndAllies
@battle.eachSameSideBattler(user) { |b| numTargets += 1 } @battle.eachSameSideBattler(user) { |_b| numTargets += 1 }
return numTargets>1 return numTargets>1
when PBTargets::AllFoes when PBTargets::AllFoes
@battle.eachOtherSideBattler(user) { |b| numTargets += 1 } @battle.eachOtherSideBattler(user) { |_b| numTargets += 1 }
return numTargets>1 return numTargets>1
when PBTargets::AllBattlers when PBTargets::AllBattlers
@battle.eachBattler { |b| numTargets += 1 } @battle.eachBattler { |_b| numTargets += 1 }
return numTargets>1 return numTargets>1
end end
return false return false
@@ -75,7 +75,7 @@ class PokeBattle_AI
# For switching. Determines the effectiveness of a potential switch-in against # For switching. Determines the effectiveness of a potential switch-in against
# an opposing battler. # an opposing battler.
def pbCalcTypeModPokemon(battlerThis,battlerOther) def pbCalcTypeModPokemon(battlerThis,_battlerOther)
mod1 = PBTypes.getCombinedEffectiveness(battlerThis.type1,target.type1,target.type2) mod1 = PBTypes.getCombinedEffectiveness(battlerThis.type1,target.type1,target.type2)
mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE mod2 = PBTypeEffectiveness::NORMAL_EFFECTIVE
if battlerThis.type1!=battlerThis.type2 if battlerThis.type1!=battlerThis.type2
@@ -214,7 +214,7 @@ class PokeBattle_AI
end end
when "0C1" # Beat Up when "0C1" # Beat Up
mult = 0 mult = 0
@battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,i| @battle.eachInTeamFromBattlerIndex(user.index) do |pkmn,_i|
mult += 1 if pkmn && pkmn.able? && pkmn.status==PBStatuses::NONE mult += 1 if pkmn && pkmn.able? && pkmn.status==PBStatuses::NONE
end end
baseDmg *= mult baseDmg *= mult
@@ -18,16 +18,16 @@ class BattleIntroAnimation < PokeBattle_Animation
makeSlideSprite("base_0",1,appearTime,PictureOrigin::Bottom) makeSlideSprite("base_0",1,appearTime,PictureOrigin::Bottom)
makeSlideSprite("base_1",-1,appearTime,PictureOrigin::Center) makeSlideSprite("base_1",-1,appearTime,PictureOrigin::Center)
# Player sprite, partner trainer sprite # Player sprite, partner trainer sprite
@battle.player.each_with_index do |p,i| @battle.player.each_with_index do |_p,i|
makeSlideSprite("player_#{i+1}",1,appearTime,PictureOrigin::Bottom) makeSlideSprite("player_#{i+1}",1,appearTime,PictureOrigin::Bottom)
end end
# Opposing trainer sprite(s) or wild Pokémon sprite(s) # Opposing trainer sprite(s) or wild Pokémon sprite(s)
if @battle.trainerBattle? if @battle.trainerBattle?
@battle.opponent.each_with_index do |p,i| @battle.opponent.each_with_index do |_p,i|
makeSlideSprite("trainer_#{i+1}",-1,appearTime,PictureOrigin::Bottom) makeSlideSprite("trainer_#{i+1}",-1,appearTime,PictureOrigin::Bottom)
end end
else # Wild battle else # Wild battle
@battle.pbParty(1).each_with_index do |pkmn,i| @battle.pbParty(1).each_with_index do |_pkmn,i|
idxBattler = 2*i+1 idxBattler = 2*i+1
makeSlideSprite("pokemon_#{idxBattler}",-1,appearTime,PictureOrigin::Bottom) makeSlideSprite("pokemon_#{idxBattler}",-1,appearTime,PictureOrigin::Bottom)
end end
@@ -574,9 +574,7 @@ class BattlerRecallAnimation < PokeBattle_Animation
# Calculate the color to turn the battler sprite # Calculate the color to turn the battler sprite
col = getBattlerColorFromBallType(ballType) col = getBattlerColorFromBallType(ballType)
col.alpha = 0 col.alpha = 0
# Calculate start and end coordinates for battler sprite movement # Calculate end coordinates for battler sprite movement
battlerStartX = batSprite.x
battlerStartY = batSprite.y
ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,batSprite.sideSize) ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@idxBattler,batSprite.sideSize)
battlerEndX = ballPos[0] battlerEndX = ballPos[0]
battlerEndY = ballPos[1] battlerEndY = ballPos[1]
@@ -867,8 +865,6 @@ class PokeballThrowDeflectAnimation < PokeBattle_Animation
# Set up Poké Ball sprite # Set up Poké Ball sprite
ball = addBallSprite(ballStartX,ballStartY,@ballType) ball = addBallSprite(ballStartX,ballStartY,@ballType)
ball.setZ(0,90) ball.setZ(0,90)
# Set up battler sprite
battler = addSprite(batSprite,PictureOrigin::Bottom)
# Poké Ball arc animation # Poké Ball arc animation
ball.setSE(0,"Battle throw") ball.setSE(0,"Battle throw")
createBallTrajectory(ball,0,16, createBallTrajectory(ball,0,16,
@@ -293,7 +293,7 @@ class PokeBattle_Scene
def pbBeginEndOfRoundPhase def pbBeginEndOfRoundPhase
end end
def pbEndBattle(result) def pbEndBattle(_result)
@abortable = false @abortable = false
pbShowWindow(BLANK) pbShowWindow(BLANK)
# Fade out all sprites # Fade out all sprites
@@ -144,9 +144,8 @@ class PokeBattle_Scene
# Fade out and hide all sprites # Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites) visibleSprites = pbFadeOutAndHide(@sprites)
# Get player's party # Get player's party
party = @battle.pbParty(idxBattler)
partyPos = @battle.pbPartyOrder(idxBattler) partyPos = @battle.pbPartyOrder(idxBattler)
partyStart, partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) partyStart, _partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
modParty = @battle.pbPlayerDisplayParty(idxBattler) modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen # Start party screen
scene = PokemonParty_Scene.new scene = PokemonParty_Scene.new
@@ -190,7 +189,7 @@ class PokeBattle_Scene
#============================================================================= #=============================================================================
# Opens the Bag screen and chooses an item to use # Opens the Bag screen and chooses an item to use
#============================================================================= #=============================================================================
def pbItemMenu(idxBattler,firstAction) def pbItemMenu(idxBattler,_firstAction)
# Fade out and hide all sprites # Fade out and hide all sprites
visibleSprites = pbFadeOutAndHide(@sprites) visibleSprites = pbFadeOutAndHide(@sprites)
# Set Bag starting positions # Set Bag starting positions
@@ -250,7 +249,7 @@ class PokeBattle_Scene
# Get player's party # Get player's party
party = @battle.pbParty(idxBattler) party = @battle.pbParty(idxBattler)
partyPos = @battle.pbPartyOrder(idxBattler) partyPos = @battle.pbPartyOrder(idxBattler)
partyStart, partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler) partyStart, _partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)
modParty = @battle.pbPlayerDisplayParty(idxBattler) modParty = @battle.pbPlayerDisplayParty(idxBattler)
# Start party screen # Start party screen
pkmnScene = PokemonParty_Scene.new pkmnScene = PokemonParty_Scene.new
@@ -272,7 +272,7 @@ class PokeBattle_Scene
#============================================================================= #=============================================================================
# Shows stats windows upon a Pokémon levelling up # 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( pbTopRightWindow(
_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}", _INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
pkmn.totalhp-oldTotalHP,pkmn.attack-oldAttack,pkmn.defense-oldDefense, pkmn.totalhp-oldTotalHP,pkmn.attack-oldAttack,pkmn.defense-oldDefense,
@@ -482,7 +482,7 @@ class PokeBattle_Scene
end end
# Plays a common animation. # Plays a common animation.
def pbCommonAnimation(animName,user=nil,target=nil,hitNum=0) def pbCommonAnimation(animName,user=nil,target=nil)
return if !animName || animName=="" return if !animName || animName==""
target = target[0] if target && target.is_a?(Array) target = target[0] if target && target.is_a?(Array)
animations = pbLoadBattleAnimations animations = pbLoadBattleAnimations
@@ -119,7 +119,7 @@ def pbConvertRPGAnimation(animation)
pbAnim.graphic = animation.animation_name pbAnim.graphic = animation.animation_name
pbAnim.hue = animation.animation_hue pbAnim.hue = animation.animation_hue
pbAnim.array.clear pbAnim.array.clear
yoffset = 0 yOffset = 0
pbAnim.position = animation.position pbAnim.position = animation.position
yOffset = -64 if animation.position==0 yOffset = -64 if animation.position==0
yOffset = 64 if animation.position==2 yOffset = 64 if animation.position==2
@@ -240,7 +240,7 @@ end
#=============================================================================== #===============================================================================
class PBAnimTiming class PBAnimTiming
attr_accessor :frame attr_accessor :frame
attr_accessor :timingType # 0=play SE, 1=set bg, 2=bg mod attr_writer :timingType # 0=play SE, 1=set bg, 2=bg mod
attr_accessor :name # Name of SE file or BG file attr_accessor :name # Name of SE file or BG file
attr_accessor :volume attr_accessor :volume
attr_accessor :pitch attr_accessor :pitch
@@ -251,7 +251,7 @@ class PBAnimTiming
attr_accessor :colorGreen # Color of bg (or to change bg to) attr_accessor :colorGreen # Color of bg (or to change bg to)
attr_accessor :colorBlue # Color of bg (or to change bg to) attr_accessor :colorBlue # Color of bg (or to change bg to)
attr_accessor :colorAlpha # Color of bg (or to change bg to) attr_accessor :colorAlpha # Color of bg (or to change bg to)
attr_accessor :duration # How long to spend changing to the new bg coords/color attr_writer :duration # How long to spend changing to the new bg coords/color
attr_accessor :flashScope attr_accessor :flashScope
attr_accessor :flashColor attr_accessor :flashColor
attr_accessor :flashDuration attr_accessor :flashDuration
@@ -276,13 +276,11 @@ class PBAnimTiming
end end
def timingType def timingType
@timingType = 0 if !@timingType return @timingType || 0
return @timingType
end end
def duration def duration
@duration = 5 if !@duration return @duration || 5
return @duration
end end
def to_s def to_s
@@ -110,7 +110,6 @@ class ThrowBaitAnimation < PokeBattle_Animation
def createProcesses def createProcesses
# Calculate start and end coordinates for battler sprite movement # Calculate start and end coordinates for battler sprite movement
batSprite = @sprites["pokemon_#{@battler.index}"] batSprite = @sprites["pokemon_#{@battler.index}"]
shaSprite = @sprites["shadow_#{@battler.index}"]
traSprite = @sprites["player_1"] traSprite = @sprites["player_1"]
ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize) ballPos = PokeBattle_SceneConstants.pbBattlerPosition(@battler.index,batSprite.sideSize)
ballStartX = traSprite.x ballStartX = traSprite.x
@@ -177,7 +176,6 @@ class ThrowRockAnimation < PokeBattle_Animation
def createProcesses def createProcesses
# Calculate start and end coordinates for battler sprite movement # Calculate start and end coordinates for battler sprite movement
batSprite = @sprites["pokemon_#{@battler.index}"] batSprite = @sprites["pokemon_#{@battler.index}"]
shaSprite = @sprites["shadow_#{@battler.index}"]
traSprite = @sprites["player_1"] traSprite = @sprites["player_1"]
ballStartX = traSprite.x ballStartX = traSprite.x
ballStartY = traSprite.y-traSprite.bitmap.height/2 ballStartY = traSprite.y-traSprite.bitmap.height/2
@@ -431,7 +429,7 @@ class PokeBattle_SafariZone
catchFactor = [[catchFactor,3].max,20].min catchFactor = [[catchFactor,3].max,20].min
escapeFactor = (pbEscapeRate(rareness)*100)/1275 escapeFactor = (pbEscapeRate(rareness)*100)/1275
escapeFactor = [[escapeFactor,2].max,20].min escapeFactor = [[escapeFactor,2].max,20].min
begin loop do
cmd = @scene.pbSafariCommandMenu(0) cmd = @scene.pbSafariCommandMenu(0)
case cmd case cmd
when 0 # Ball when 0 # Ball
@@ -483,7 +481,8 @@ class PokeBattle_SafariZone
# Weather continues # Weather continues
@scene.pbCommonAnimation(PBWeather.animationName(@weather)) @scene.pbCommonAnimation(PBWeather.animationName(@weather))
end end
end while @decision==0 break if @decision > 0
end
@scene.pbEndBattle(@decision) @scene.pbEndBattle(@decision)
rescue BattleAbortedException rescue BattleAbortedException
@decision = 0 @decision = 0
@@ -40,11 +40,11 @@ class PokeBattle_BugContestBattle < PokeBattle_Battle
super(*arg) super(*arg)
end end
def pbItemMenu(idxBattler,firstAction) def pbItemMenu(idxBattler,_firstAction)
return pbRegisterItem(idxBattler,@ballConst,1) return pbRegisterItem(idxBattler,@ballConst,1)
end end
def pbCommandMenu(idxBattler,firstAction) def pbCommandMenu(idxBattler,_firstAction)
return @scene.pbCommandMenuEx(idxBattler,[ return @scene.pbCommandMenuEx(idxBattler,[
_INTL("Sport Balls: {1}",@ballCount), _INTL("Sport Balls: {1}",@ballCount),
_INTL("Fight"), _INTL("Fight"),
@@ -54,7 +54,7 @@ class PokeBattle_BugContestBattle < PokeBattle_Battle
],4) ],4)
end end
def pbConsumeItemInBag(item,idxBattler) def pbConsumeItemInBag(_item,_idxBattler)
@ballCount -= 1 if @ballCount>0 @ballCount -= 1 if @ballCount>0
end end
@@ -134,7 +134,7 @@ class PokeBattle_BattlePalace < PokeBattle_Battle
end end
end end
def pbRegisterMove(idxBattler,idxMove,showMessages=true) def pbRegisterMove(idxBattler,idxMove,_showMessages=true)
thispkmn = @battlers[idxBattler] thispkmn = @battlers[idxBattler]
if idxMove==-2 if idxMove==-2
@choices[idxPokemon][0] = :UseMove # Move @choices[idxPokemon][0] = :UseMove # Move
@@ -264,7 +264,7 @@ class PokeBattle_AI
end end
@justswitched[idxBattler] = shouldswitch @justswitched[idxBattler] = shouldswitch
if shouldswitch if shouldswitch
@battle.pbParty(idxBattler).each_with_index do |pkmn,i| @battle.pbParty(idxBattler).each_with_index do |_pkmn,i|
next if !@battle.pbCanSwitch?(idxBattler,i) next if !@battle.pbCanSwitch?(idxBattler,i)
@battle.pbRegisterSwitch(idxBattler,i) @battle.pbRegisterSwitch(idxBattler,i)
return true return true
@@ -13,7 +13,7 @@ class PokeBattle_BattleArena < PokeBattle_Battle
@battleAI.battleArena = true @battleAI.battleArena = true
end end
def pbCanSwitchLax?(idxBattler,idxParty,partyScene=nil) def pbCanSwitchLax?(idxBattler,_idxParty,partyScene=nil)
if partyScene 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 end
@@ -101,7 +101,6 @@ class PokeBattle_BattleArena < PokeBattle_Battle
end end
# PBDebug.log("[Mind: #{@mind.inspect}, Skill: #{@skill.inspect}]") # PBDebug.log("[Mind: #{@mind.inspect}, Skill: #{@skill.inspect}]")
if @count==3 if @count==3
points = [0,0]
@battlers[0].pbCancelMoves @battlers[0].pbCancelMoves
@battlers[1].pbCancelMoves @battlers[1].pbCancelMoves
ratings1 = [0,0,0] ratings1 = [0,0,0]
@@ -209,13 +209,13 @@ module PokeBattle_BattlePlayerModule
super super
end end
def pbSwitchInBetween(idxBattler,checkLaxOnly=false,canCancel=false) def pbSwitchInBetween(_idxBattler,_checkLaxOnly=false,_canCancel=false)
ret = @switches[@switchindex] ret = @switches[@switchindex]
@switchindex += 1 @switchindex += 1
return ret return ret
end end
def pbRandom(num) def pbRandom(_num)
ret = @randomnums[@randomindex] ret = @randomnums[@randomindex]
@randomindex += 1 @randomindex += 1
return ret return ret
@@ -24,7 +24,7 @@ class PokeBattle_DebugSceneNoLogging
def pbBeginAttackPhase; end def pbBeginAttackPhase; end
def pbShowOpponent(idxTrainer); end def pbShowOpponent(idxTrainer); end
def pbDamageAnimation(battler,effectiveness=0); end def pbDamageAnimation(battler,effectiveness=0); end
def pbCommonAnimation(animName,user=nil,target=nil,hitNum=0); end def pbCommonAnimation(animName,user=nil,target=nil); end
def pbAnimation(moveID,user,targets,hitNum=0); end def pbAnimation(moveID,user,targets,hitNum=0); end
def pbEndBattle(result); end def pbEndBattle(result); end
def pbWildBattleSuccess; end def pbWildBattleSuccess; end
@@ -74,7 +74,7 @@ class PokeBattle_DebugSceneNoLogging
def pbPartyScreen(idxBattler,canCancel=false) def pbPartyScreen(idxBattler,canCancel=false)
replacements = [] replacements = []
@battle.eachInTeamFromBattlerIndex(idxBattler) do |b,idxParty| @battle.eachInTeamFromBattlerIndex(idxBattler) do |_b,idxParty|
replacements.push(idxParty) if !@battle.pbFindBattler(idxParty,idxBattler) replacements.push(idxParty) if !@battle.pbFindBattler(idxParty,idxBattler)
end end
return if replacements.length==0 return if replacements.length==0
@@ -2129,7 +2129,7 @@ BattleHandlers::AbilityOnSwitchIn.add(:ANTICIPATION,
if NEWEST_BATTLE_MECHANICS && isConst?(m.id,PBMoves,:HIDDENPOWER) if NEWEST_BATTLE_MECHANICS && isConst?(m.id,PBMoves,:HIDDENPOWER)
moveType = pbHiddenPower(b.pokemon)[0] moveType = pbHiddenPower(b.pokemon)[0]
end end
eff = PBTypes.getCombinedEffectiveness(moveData[MOVE_TYPE],type1,type2,type3) eff = PBTypes.getCombinedEffectiveness(moveType,type1,type2,type3)
next if PBTypes.ineffective?(eff) next if PBTypes.ineffective?(eff)
next if !PBTypes.superEffective?(eff) && moveData[MOVE_FUNCTION_CODE]!="070" # OHKO next if !PBTypes.superEffective?(eff) && moveData[MOVE_FUNCTION_CODE]!="070" # OHKO
else else
+17 -22
View File
@@ -173,7 +173,7 @@ end
# Constant checks # Constant checks
#=============================================================================== #===============================================================================
# Pokérus check # Pokérus check
Events.onMapUpdate += proc { |sender,e| Events.onMapUpdate += proc { |_sender,_e|
next if !$Trainer next if !$Trainer
last = $PokemonGlobal.pokerusTime last = $PokemonGlobal.pokerusTime
now = pbGetTimeNow now = pbGetTimeNow
@@ -226,7 +226,7 @@ def pbBatteryLow?
return false return false
end end
Events.onMapUpdate += proc { |sender,e| Events.onMapUpdate += proc { |_sender,_e|
if !$PokemonTemp.batterywarning && pbBatteryLow? if !$PokemonTemp.batterywarning && pbBatteryLow?
if !$game_temp.in_menu && !$game_temp.in_battle && if !$game_temp.in_menu && !$game_temp.in_battle &&
!$game_player.move_route_forcing && !$game_temp.message_window_showing && !$game_player.move_route_forcing && !$game_temp.message_window_showing &&
@@ -266,7 +266,7 @@ Events.onStepTaken += proc{
} }
# Poison party Pokémon # Poison party Pokémon
Events.onStepTakenTransferPossible += proc { |sender,e| Events.onStepTakenTransferPossible += proc { |_sender,e|
handled = e[0] handled = e[0]
next if handled[0] next if handled[0]
if $PokemonGlobal.stepcount%4==0 && POISON_IN_FIELD if $PokemonGlobal.stepcount%4==0 && POISON_IN_FIELD
@@ -307,7 +307,7 @@ def pbCheckAllFainted
end end
# Gather soot from soot grass # 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 event = e[0] # Get the event affected by field movement
thistile = $MapFactory.getRealTilePos(event.map.map_id,event.x,event.y) thistile = $MapFactory.getRealTilePos(event.map.map_id,event.x,event.y)
map = $MapFactory.getMap(thistile[0]) map = $MapFactory.getMap(thistile[0])
@@ -331,7 +331,7 @@ Events.onStepTakenFieldMovement += proc { |sender,e|
} }
# Show grass rustle animation, and auto-move the player over waterfalls and ice # Show grass rustle animation, and auto-move the player over waterfalls and ice
Events.onStepTakenFieldMovement += proc { |sender,e| Events.onStepTakenFieldMovement += proc { |_sender,e|
event = e[0] # Get the event affected by field movement event = e[0] # Get the event affected by field movement
if $scene.is_a?(Scene_Map) if $scene.is_a?(Scene_Map)
currentTag = pbGetTerrainTag(event) currentTag = pbGetTerrainTag(event)
@@ -395,9 +395,8 @@ end
#=============================================================================== #===============================================================================
# Clears the weather of the old map, if the old and new maps have different # Clears the weather of the old map, if the old and new maps have different
# names or defined weather # names or defined weather
Events.onMapChanging += proc { |sender,e| Events.onMapChanging += proc { |_sender,e|
newMapID = e[0] newMapID = e[0]
newMap = e[1]
if newMapID>0 if newMapID>0
mapinfos = ($RPGVX) ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata") mapinfos = ($RPGVX) ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
oldWeather = pbGetMetadata($game_map.map_id,MetadataWeather) oldWeather = pbGetMetadata($game_map.map_id,MetadataWeather)
@@ -411,7 +410,7 @@ Events.onMapChanging += proc { |sender,e|
} }
# Set up various data related to the new map # Set up various data related to the new map
Events.onMapChange += proc { |sender,e| Events.onMapChange += proc { |_sender,e|
oldid = e[0] # previous map ID, 0 if no map ID oldid = e[0] # previous map ID, 0 if no map ID
healing = pbGetMetadata($game_map.map_id,MetadataHealingSpot) healing = pbGetMetadata($game_map.map_id,MetadataHealingSpot)
$PokemonGlobal.healingSpot = healing if healing $PokemonGlobal.healingSpot = healing if healing
@@ -430,18 +429,12 @@ Events.onMapChange += proc { |sender,e|
end end
} }
Events.onMapSceneChange += proc { |sender,e| Events.onMapSceneChange += proc { |_sender,e|
scene = e[0] scene = e[0]
mapChanged = e[1] mapChanged = e[1]
next if !scene || !scene.spriteset next if !scene || !scene.spriteset
# Update map trail # Update map trail
if $game_map if $game_map
lastmapdetails = $PokemonGlobal.mapTrail[0] ?
pbGetMetadata($PokemonGlobal.mapTrail[0],MetadataMapPosition) : [-1,0,0]
lastmapdetails = [-1,0,0] if !lastmapdetails
newmapdetails = $game_map.map_id ?
pbGetMetadata($game_map.map_id,MetadataMapPosition) : [-1,0,0]
newmapdetails = [-1,0,0] if !newmapdetails
$PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail $PokemonGlobal.mapTrail = [] if !$PokemonGlobal.mapTrail
if $PokemonGlobal.mapTrail[0]!=$game_map.map_id if $PokemonGlobal.mapTrail[0]!=$game_map.map_id
$PokemonGlobal.mapTrail[3] = $PokemonGlobal.mapTrail[2] if $PokemonGlobal.mapTrail[2] $PokemonGlobal.mapTrail[3] = $PokemonGlobal.mapTrail[2] if $PokemonGlobal.mapTrail[2]
@@ -556,7 +549,8 @@ def pbMoveRoute(event,commands,waitComplete=false)
route.skippable = true route.skippable = true
route.list.clear route.list.clear
route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn)) route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn))
i=0; while i<commands.length i=0
while i<commands.length
case commands[i] case commands[i]
when PBMoveRoute::Wait, PBMoveRoute::SwitchOn, PBMoveRoute::SwitchOff, when PBMoveRoute::Wait, PBMoveRoute::SwitchOn, PBMoveRoute::SwitchOff,
PBMoveRoute::ChangeSpeed, PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity, PBMoveRoute::ChangeSpeed, PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity,
@@ -600,7 +594,7 @@ end
#=============================================================================== #===============================================================================
# Player/event movement in the field # Player/event movement in the field
#=============================================================================== #===============================================================================
def pbLedge(xOffset,yOffset) def pbLedge(_xOffset,_yOffset)
if PBTerrain.isLedge?(pbFacingTerrainTag) if PBTerrain.isLedge?(pbFacingTerrainTag)
if pbJumpToward(2,true) if pbJumpToward(2,true)
$scene.spriteset.addUserAnimation(DUST_ANIMATION_ID,$game_player.x,$game_player.y,true,1) $scene.spriteset.addUserAnimation(DUST_ANIMATION_ID,$game_player.x,$game_player.y,true,1)
@@ -914,7 +908,7 @@ def pbEventFacesPlayer?(event,player,distance)
curx = event.x curx = event.x
cury = event.y cury = event.y
found = false found = false
for i in 0...distance distance.times do
curx += deltaX curx += deltaX
cury += deltaY cury += deltaY
if player.x==curx && player.y==cury if player.x==curx && player.y==cury
@@ -936,7 +930,7 @@ def pbEventCanReachPlayer?(event,player,distance)
cury = event.y cury = event.y
found = false found = false
realdist = 0 realdist = 0
for i in 0...distance distance.times do
curx += deltaX curx += deltaX
cury += deltaY cury += deltaY
if player.x==curx && player.y==cury if player.x==curx && player.y==cury
@@ -949,7 +943,7 @@ def pbEventCanReachPlayer?(event,player,distance)
# Check passibility # Check passibility
curx = event.x curx = event.x
cury = event.y cury = event.y
for i in 0...realdist realdist.times do
return false if !event.passable?(curx,cury,event.direction) return false if !event.passable?(curx,cury,event.direction)
curx += deltaX curx += deltaX
cury += deltaY cury += deltaY
@@ -1059,11 +1053,12 @@ module InterpreterFieldMixin
$PokemonMap.addMovedEvent(@event_id) if $PokemonMap $PokemonMap.addMovedEvent(@event_id) if $PokemonMap
if oldx!=event.x || oldy!=event.y if oldx!=event.x || oldy!=event.y
$game_player.lock $game_player.lock
begin loop do
Graphics.update Graphics.update
Input.update Input.update
pbUpdateSceneMap pbUpdateSceneMap
end until !event.moving? break if !event.moving?
end
$game_player.unlock $game_player.unlock
end end
end end
@@ -200,7 +200,7 @@ end
Events.onSpritesetCreate += proc { |sender,e| Events.onSpritesetCreate += proc { |_sender,e|
spriteset = e[0] # Spriteset being created spriteset = e[0] # Spriteset being created
viewport = e[1] # Viewport used for tilemap and characters viewport = e[1] # Viewport used for tilemap and characters
map = spriteset.map # Map associated with the spriteset (not necessarily the current map) map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
@@ -241,7 +241,6 @@ end
def pbBattleAnimation(bgm=nil,battletype=0,foe=nil) def pbBattleAnimation(bgm=nil,battletype=0,foe=nil)
$game_temp.in_battle = true $game_temp.in_battle = true
handled = false
viewport = Viewport.new(0,0,Graphics.width,Graphics.height) viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999 viewport.z = 99999
# Set up audio # Set up audio
@@ -134,7 +134,7 @@ module RPG
@blizzardBitmap2.fill_rect(0,4,10,2,snowColor) @blizzardBitmap2.fill_rect(0,4,10,2,snowColor)
@blizzardBitmap2.fill_rect(2,6,6,2,snowColor) @blizzardBitmap2.fill_rect(2,6,6,2,snowColor)
@blizzardBitmap2.fill_rect(4,8,2,2,snowColor) @blizzardBitmap2.fill_rect(4,8,2,2,snowColor)
for i in 0...540 540.times do
@blizzardBitmap3.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor) @blizzardBitmap3.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor)
@blizzardBitmap4.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor) @blizzardBitmap4.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,snowColor)
end end
@@ -163,7 +163,7 @@ module RPG
bmHeight = 200 bmHeight = 200
@sandstormBitmap1 = Bitmap.new(bmWidth,bmHeight) @sandstormBitmap1 = Bitmap.new(bmWidth,bmHeight)
@sandstormBitmap2 = Bitmap.new(bmWidth,bmHeight) @sandstormBitmap2 = Bitmap.new(bmWidth,bmHeight)
for i in 0...540 540.times do
@sandstormBitmap1.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2, @sandstormBitmap1.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,
sandstormColors[rand(sandstormColors.length)]) sandstormColors[rand(sandstormColors.length)])
@sandstormBitmap2.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2, @sandstormBitmap2.fill_rect(rand(bmWidth/2)*2,rand(bmHeight/2)*2,2,2,
@@ -43,7 +43,7 @@ class PokemonGlobalMetadata
# Events # Events
attr_accessor :eventvars attr_accessor :eventvars
# Affecting the map # Affecting the map
attr_accessor :bridge attr_writer :bridge
attr_accessor :repel attr_accessor :repel
attr_accessor :flashUsed attr_accessor :flashUsed
# Map transfers # Map transfers
@@ -189,7 +189,7 @@ def pbGetEnvironment
return ret return ret
end end
Events.onStartBattle += proc { |sender| Events.onStartBattle += proc { |_sender|
# Record current levels of Pokémon in party, to see if they gain a level # Record current levels of Pokémon in party, to see if they gain a level
# during battle and may need to evolve afterwards # during battle and may need to evolve afterwards
$PokemonTemp.evolutionLevels = [] $PokemonTemp.evolutionLevels = []
@@ -555,7 +555,7 @@ def pbAfterBattle(decision,canLose)
Events.onEndBattle.trigger(nil,decision,canLose) Events.onEndBattle.trigger(nil,decision,canLose)
end end
Events.onEndBattle += proc { |sender,e| Events.onEndBattle += proc { |_sender,e|
decision = e[0] decision = e[0]
canLose = e[1] canLose = e[1]
if NEWEST_BATTLE_MECHANICS || (decision!=2 && decision!=5) # not a loss or a draw if NEWEST_BATTLE_MECHANICS || (decision!=2 && decision!=5) # not a loss or a draw
@@ -420,7 +420,7 @@ def pbGenerateWildPokemon(species,level,isRoamer=false)
end end
# Shiny Charm makes shiny Pokémon more likely to generate # Shiny Charm makes shiny Pokémon more likely to generate
if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM) if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
for i in 0...2 # 3 times as likely 2.times do # 3 times as likely
break if genwildpoke.shiny? break if genwildpoke.shiny?
genwildpoke.personalID = rand(65536)|(rand(65536)<<16) genwildpoke.personalID = rand(65536)|(rand(65536)<<16)
end end
@@ -454,7 +454,6 @@ def pbEncounter(enctype)
encounter1 = $PokemonEncounters.pbEncounteredPokemon(enctype) encounter1 = $PokemonEncounters.pbEncounteredPokemon(enctype)
encounter1 = EncounterModifier.trigger(encounter1) encounter1 = EncounterModifier.trigger(encounter1)
return false if !encounter1 return false if !encounter1
encounter2 = nil
if $PokemonGlobal.partner if $PokemonGlobal.partner
encounter2 = $PokemonEncounters.pbEncounteredPokemon(enctype) encounter2 = $PokemonEncounters.pbEncounteredPokemon(enctype)
encounter2 = EncounterModifier.trigger(encounter2) encounter2 = EncounterModifier.trigger(encounter2)
@@ -6,7 +6,7 @@
################################################################################ ################################################################################
# Make all wild Pokémon shiny while a certain Switch is ON (see Settings). # Make all wild Pokémon shiny while a certain Switch is ON (see Settings).
Events.onWildPokemonCreate += proc { |sender,e| Events.onWildPokemonCreate += proc { |_sender, e|
pokemon = e[0] pokemon = e[0]
if $game_switches[SHINY_WILD_POKEMON_SWITCH] if $game_switches[SHINY_WILD_POKEMON_SWITCH]
pokemon.makeShiny pokemon.makeShiny
@@ -17,14 +17,14 @@ Events.onWildPokemonCreate += proc { |sender,e|
# map depend on the levels of Pokémon in the player's party. # map depend on the levels of Pokémon in the player's party.
# This is a simple method, and can/should be modified to account for evolutions # This is a simple method, and can/should be modified to account for evolutions
# and other such details. Of course, you don't HAVE to use this code. # and other such details. Of course, you don't HAVE to use this code.
Events.onWildPokemonCreate += proc { |sender,e| Events.onWildPokemonCreate += proc { |_sender, e|
pokemon = e[0] pokemon = e[0]
if $game_map.map_id==51 if $game_map.map_id == 51
mLevel = PBExperience.maxLevel max_level = PBExperience.maxLevel
newlevel = pbBalancedLevel($Trainer.party) - 4 + rand(5) # For variety new_level = pbBalancedLevel($Trainer.party) - 4 + rand(5) # For variety
newlevel = 1 if newlevel<1 new_level = 1 if new_level < 1
newlevel = mLevel if newlevel>mLevel new_level = max_level if new_level > max_level
pokemon.level = newlevel pokemon.level = new_level
pokemon.calcStats pokemon.calcStats
pokemon.resetMoves pokemon.resetMoves
end end
@@ -35,7 +35,7 @@ Events.onWildPokemonCreate += proc { |sender,e|
# Note that you can only modify a partner trainer's Pokémon, and not the trainer # Note that you can only modify a partner trainer's Pokémon, and not the trainer
# themselves nor their items this way, as those are generated from scratch # themselves nor their items this way, as those are generated from scratch
# before each battle. # before each battle.
#Events.onTrainerPartyLoad += proc { |sender,e| #Events.onTrainerPartyLoad += proc { |_sender, e|
# if e[0] # Trainer data should exist to be loaded, but may not exist somehow # if e[0] # Trainer data should exist to be loaded, but may not exist somehow
# trainer = e[0][0] # A PokeBattle_Trainer object of the loaded trainer # trainer = e[0][0] # A PokeBattle_Trainer object of the loaded trainer
# items = e[0][1] # An array of the trainer's items they can use # items = e[0][1] # An array of the trainer's items they can use
@@ -3,11 +3,10 @@ class PokemonGlobalMetadata
attr_accessor :roamedAlready # Whether a roamer has been encountered on current map attr_accessor :roamedAlready # Whether a roamer has been encountered on current map
attr_accessor :roamEncounter attr_accessor :roamEncounter
attr_accessor :roamPokemon attr_accessor :roamPokemon
attr_accessor :roamPokemonCaught attr_writer :roamPokemonCaught
def roamPokemonCaught def roamPokemonCaught
@roamPokemonCaught = [] if !@roamPokemonCaught return @roamPokemonCaught || []
return @roamPokemonCaught
end end
end end
@@ -97,7 +96,7 @@ end
# When the player moves to a new map (with a different name), make all roaming # When the player moves to a new map (with a different name), make all roaming
# Pokémon roam. # Pokémon roam.
Events.onMapChange += proc { |sender,e| Events.onMapChange += proc { |_sender,e|
oldMapID = e[0] oldMapID = e[0]
# Get and compare map names # Get and compare map names
mapInfos = $RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata") mapInfos = $RPGVX ? load_data("Data/MapInfos.rvdata") : load_data("Data/MapInfos.rxdata")
@@ -206,7 +205,7 @@ EncounterModifier.register(proc { |encounter|
next [chosenRoamer[1],chosenRoamer[2]] # Species, level next [chosenRoamer[1],chosenRoamer[2]] # Species, level
}) })
Events.onWildBattleOverride += proc { |sender,e| Events.onWildBattleOverride += proc { |_sender,e|
species = e[0] species = e[0]
level = e[1] level = e[1]
handled = e[2] handled = e[2]
@@ -19,20 +19,17 @@ class AntiRandom
# Get old value # Get old value
value=rand(@old.length) value=rand(@old.length)
return @old[value] return @old[value]
else
if @new.length>0
# Get new value
value=rand(@new.length)
ret=@new.delete_at(value)
@old.push(ret)
return ret
else
# Get old value
value=rand(@old.length)
return @old[value]
end
end end
return 0 if @new.length>0
# Get new value
value=rand(@new.length)
ret=@new.delete_at(value)
@old.push(ret)
return ret
end
# Get old value
value=rand(@old.length)
return @old[value]
end end
end end
@@ -310,7 +307,7 @@ class Maze
def buildMazeWall(x,y,dir,len) def buildMazeWall(x,y,dir,len)
wx=x;wy=y wx=x;wy=y
return if isBlockedNode?(x,y) return if isBlockedNode?(x,y)
for c in 0...len len.times do
ox=wx;oy=wy ox=wx;oy=wy
wy-=1 if dir==EdgeMasks::North wy-=1 if dir==EdgeMasks::North
wx-=1 if dir==EdgeMasks::West wx-=1 if dir==EdgeMasks::West
@@ -341,7 +338,6 @@ class Maze
def recurseDepthFirst(x,y,depth) def recurseDepthFirst(x,y,depth)
setVisited(x,y) setVisited(x,y)
dirs=@@dirs.shuffle! dirs=@@dirs.shuffle!
success=0
for c in 0...4 for c in 0...4
d=dirs[c] d=dirs[c]
cx=0;cy=0 cx=0;cy=0
@@ -543,7 +539,7 @@ end
def pbRandomRoomTile(dungeon,tiles) def pbRandomRoomTile(dungeon,tiles)
ar1=AntiRandom.new(dungeon.width) ar1=AntiRandom.new(dungeon.width)
ar2=AntiRandom.new(dungeon.height) ar2=AntiRandom.new(dungeon.height)
for i in 0...(tiles.length+1)*1000 ((tiles.length+1)*1000).times do
x=ar1.get() x=ar1.get()
y=ar2.get() y=ar2.get()
if dungeon.isRoom?(x,y) && if dungeon.isRoom?(x,y) &&
@@ -556,10 +552,9 @@ def pbRandomRoomTile(dungeon,tiles)
return nil return nil
end end
Events.onMapCreate += proc { |sender, e| Events.onMapCreate += proc { |_sender, e|
mapID=e[0] mapID=e[0]
map=e[1] map=e[1]
tileset=e[2]
if pbGetMetadata(mapID,MetadataDungeon) if pbGetMetadata(mapID,MetadataDungeon)
# this map is a randomly generated dungeon # this map is a randomly generated dungeon
dungeon=Dungeon.new(map.width,map.height) dungeon=Dungeon.new(map.width,map.height)
@@ -104,7 +104,7 @@ def pbHiddenMoveAnimation(pokemon)
phase=1 phase=1
frames=0 frames=0
strobeSpeed = 64*20/Graphics.frame_rate strobeSpeed = 64*20/Graphics.frame_rate
begin loop do
Graphics.update Graphics.update
Input.update Input.update
sprite.update sprite.update
@@ -176,7 +176,8 @@ def pbHiddenMoveAnimation(pokemon)
end end
end end
pbUpdateSceneMap pbUpdateSceneMap
end while phase!=6 break if phase==6
end
sprite.dispose sprite.dispose
for strobe in strobes for strobe in strobes
strobe.dispose strobe.dispose
@@ -380,7 +381,7 @@ def pbTransferUnderwater(mapid,x,y,direction=$game_player.direction)
} }
end end
Events.onAction += proc { |sender,e| Events.onAction += proc { |_sender,_e|
if $PokemonGlobal.diving if $PokemonGlobal.diving
if DIVING_SURFACE_ANYWHERE if DIVING_SURFACE_ANYWHERE
pbSurfacing pbSurfacing
@@ -673,7 +674,7 @@ def pbStrength
return false return false
end end
Events.onAction += proc { |sender,e| Events.onAction += proc { |_sender,_e|
facingEvent = $game_player.pbFacingEvent facingEvent = $game_player.pbFacingEvent
pbStrength if facingEvent && facingEvent.name.downcase=="boulder" pbStrength if facingEvent && facingEvent.name.downcase=="boulder"
} }
@@ -733,7 +734,7 @@ def pbStartSurfing
$game_player.check_event_trigger_here([1,2]) $game_player.check_event_trigger_here([1,2])
end end
def pbEndSurf(xOffset,yOffset) def pbEndSurf(_xOffset,_yOffset)
return false if !$PokemonGlobal.surfing return false if !$PokemonGlobal.surfing
x = $game_player.x x = $game_player.x
y = $game_player.y y = $game_player.y
@@ -765,7 +766,7 @@ def pbTransferSurfing(mapid,xcoord,ycoord,direction=$game_player.direction)
} }
end end
Events.onAction += proc { |sender,e| Events.onAction += proc { |_sender,_e|
next if $PokemonGlobal.surfing next if $PokemonGlobal.surfing
next if pbGetMetadata($game_map.map_id,MetadataBicycleAlways) next if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
next if !PBTerrain.isSurfable?(pbFacingTerrainTag) next if !PBTerrain.isSurfable?(pbFacingTerrainTag)
@@ -825,7 +826,7 @@ def pbSweetScent
viewport.color.blue = 0 viewport.color.blue = 0
viewport.color.alpha -= 10 viewport.color.alpha -= 10
alphaDiff = 12 * 20 / Graphics.frame_rate alphaDiff = 12 * 20 / Graphics.frame_rate
begin loop do
if count==0 && viewport.color.alpha<128 if count==0 && viewport.color.alpha<128
viewport.color.alpha += alphaDiff viewport.color.alpha += alphaDiff
elsif count>Graphics.frame_rate/4 elsif count>Graphics.frame_rate/4
@@ -836,9 +837,9 @@ def pbSweetScent
Graphics.update Graphics.update
Input.update Input.update
pbUpdateSceneMap pbUpdateSceneMap
end until viewport.color.alpha<=0 break if viewport.color.alpha<=0
end
viewport.dispose viewport.dispose
encounter = nil
enctype = $PokemonEncounters.pbEncounterType enctype = $PokemonEncounters.pbEncounterType
if enctype<0 || !$PokemonEncounters.isEncounterPossibleHere? || if enctype<0 || !$PokemonEncounters.isEncounterPossibleHere? ||
!pbEncounter(enctype) !pbEncounter(enctype)
@@ -969,7 +970,7 @@ def pbWaterfall
return false return false
end end
Events.onAction += proc { |sender,e| Events.onAction += proc { |_sender,_e|
terrain = pbFacingTerrainTag terrain = pbFacingTerrainTag
if terrain==PBTerrain::Waterfall if terrain==PBTerrain::Waterfall
pbWaterfall pbWaterfall
@@ -28,7 +28,7 @@ def pbClearData
__berryPlant__pbClearData __berryPlant__pbClearData
end end
Events.onSpritesetCreate += proc { |sender,e| Events.onSpritesetCreate += proc { |_sender,e|
spriteset = e[0] spriteset = e[0]
viewport = e[1] viewport = e[1]
map = spriteset.map map = spriteset.map
@@ -105,7 +105,7 @@ end
class BerryPlantSprite class BerryPlantSprite
REPLANTS = 9 REPLANTS = 9
def initialize(event,map,viewport) def initialize(event,map,_viewport)
@event=event @event=event
@map=map @map=map
@oldstage=0 @oldstage=0
@@ -321,7 +321,7 @@ def pbDayCareGenerateEgg
ivinherit[i] = PBStats::SPEED if isConst?(parent.item,PBItems,:POWERANKLET) ivinherit[i] = PBStats::SPEED if isConst?(parent.item,PBItems,:POWERANKLET)
end end
num = 0; r = rand(2) num = 0; r = rand(2)
for i in 0...2 2.times do
if ivinherit[r]!=nil if ivinherit[r]!=nil
parent = [mother,father][r] parent = [mother,father][r]
ivs[ivinherit[r]] = parent.iv[ivinherit[r]] ivs[ivinherit[r]] = parent.iv[ivinherit[r]]
@@ -355,7 +355,7 @@ def pbDayCareGenerateEgg
shinyretries += 5 if father.language!=mother.language shinyretries += 5 if father.language!=mother.language
shinyretries += 2 if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM) shinyretries += 2 if hasConst?(PBItems,:SHINYCHARM) && $PokemonBag.pbHasItem?(:SHINYCHARM)
if shinyretries>0 if shinyretries>0
for i in 0...shinyretries shinyretries.times do
break if egg.shiny? break if egg.shiny?
egg.personalID = rand(65536)|(rand(65536)<<16) egg.personalID = rand(65536)|(rand(65536)<<16)
end end
@@ -410,7 +410,7 @@ end
#=============================================================================== #===============================================================================
# Code that happens every step the player takes. # Code that happens every step the player takes.
#=============================================================================== #===============================================================================
Events.onStepTaken += proc { |sender,e| Events.onStepTaken += proc { |_sender,_e|
# Make an egg available at the Day Care # Make an egg available at the Day Care
deposited = pbDayCareDeposited deposited = pbDayCareDeposited
if deposited==2 && $PokemonGlobal.daycareEgg==0 if deposited==2 && $PokemonGlobal.daycareEgg==0
@@ -1,5 +1,5 @@
class PokemonTemp class PokemonTemp
attr_accessor :dependentEvents attr_writer :dependentEvents
def dependentEvents def dependentEvents
@dependentEvents=DependentEvents.new if !@dependentEvents @dependentEvents=DependentEvents.new if !@dependentEvents
@@ -38,11 +38,10 @@ end
class PokemonGlobalMetadata class PokemonGlobalMetadata
attr_accessor :dependentEvents attr_writer :dependentEvents
def dependentEvents def dependentEvents
@dependentEvents=[] if !@dependentEvents return @dependentEvents || []
return @dependentEvents
end end
end end
@@ -56,7 +55,7 @@ end
def pbTestPass(follower,x,y,direction=nil) def pbTestPass(follower,x,y,_direction=nil)
return $MapFactory.isPassableStrict?(follower.map.map_id,x,y,follower) return $MapFactory.isPassableStrict?(follower.map.map_id,x,y,follower)
end end
@@ -176,7 +175,6 @@ class DependentEvents
def pbEnsureEvent(event, newMapID) def pbEnsureEvent(event, newMapID)
events=$PokemonGlobal.dependentEvents events=$PokemonGlobal.dependentEvents
found=-1
for i in 0...events.length for i in 0...events.length
# Check original map ID and original event ID # Check original map ID and original event ID
if events[i][0]==event.map_id && events[i][1]==event.id if events[i][0]==event.map_id && events[i][1]==event.id
@@ -552,15 +550,14 @@ end
Events.onSpritesetCreate += proc { |sender,e| Events.onSpritesetCreate += proc { |_sender,e|
spriteset = e[0] # Spriteset being created spriteset = e[0] # Spriteset being created
viewport = e[1] # Viewport used for tilemap and characters viewport = e[1] # Viewport used for tilemap and characters
map = spriteset.map # Map associated with the spriteset (not necessarily the current map) map = spriteset.map # Map associated with the spriteset (not necessarily the current map)
spriteset.addUserSprite(DependentEventSprites.new(viewport,map)) spriteset.addUserSprite(DependentEventSprites.new(viewport,map))
} }
Events.onMapSceneChange += proc { |sender,e| Events.onMapSceneChange += proc { |_sender,e|
scene = e[0]
mapChanged = e[1] mapChanged = e[1]
if mapChanged if mapChanged
$PokemonTemp.dependentEvents.pbMapChangeMoveDependentEvents $PokemonTemp.dependentEvents.pbMapChangeMoveDependentEvents
@@ -72,7 +72,7 @@ module PBDayNight
def self.getShade def self.getShade
time = pbGetDayNightMinutes time = pbGetDayNightMinutes
time = (24*60)-time if time>(12*60) time = (24*60)-time if time>(12*60)
shade=255*time/(12*60) return 255*time/(12*60)
end end
# Gets a Tone object representing a suggested shading # Gets a Tone object representing a suggested shading
@@ -97,7 +97,7 @@ module PBDayNight
# Internal function # Internal function
def self.getToneInternal def getToneInternal
# Calculates the tone for the current frame, used for day/night effects # Calculates the tone for the current frame, used for day/night effects
realMinutes = pbGetDayNightMinutes realMinutes = pbGetDayNightMinutes
hour = realMinutes/60 hour = realMinutes/60
@@ -1,20 +1,20 @@
class PokeBattle_Trainer class PokeBattle_Trainer
attr_accessor(:name) attr_accessor :name
attr_accessor(:id) attr_accessor :id
attr_accessor(:metaID) attr_writer :metaID
attr_accessor(:trainertype) attr_accessor :trainertype
attr_accessor(:outfit) attr_writer :outfit
attr_accessor(:badges) attr_accessor :badges
attr_accessor(:money) attr_reader :money
attr_accessor(:seen) attr_accessor :seen
attr_accessor(:owned) attr_accessor :owned
attr_accessor(:formseen) attr_accessor :formseen
attr_accessor(:formlastseen) attr_accessor :formlastseen
attr_accessor(:shadowcaught) attr_accessor :shadowcaught
attr_accessor(:party) attr_accessor :party
attr_accessor(:pokedex) # Whether the Pokédex was obtained attr_accessor :pokedex # Whether the Pokédex was obtained
attr_accessor(:pokegear) # Whether the Pokégear was obtained attr_accessor :pokegear # Whether the Pokégear was obtained
attr_accessor(:language) attr_writer :language
def trainerTypeName # Name of this trainer type (localized) def trainerTypeName # Name of this trainer type (localized)
return PBTrainers.getName(@trainertype) rescue _INTL("PkMn Trainer") return PBTrainers.getName(@trainertype) rescue _INTL("PkMn Trainer")
@@ -55,13 +55,11 @@ class PokeBattle_Trainer
end end
def outfit def outfit
@outfit=0 if !@outfit return @outfit || 0
return @outfit
end end
def language def language
@language=pbGetLanguage() if !@language return @language || pbGetLanguage
return @language
end end
def money=(value) def money=(value)
@@ -126,7 +126,6 @@ def pbNewTrainer(trainerid,trainername,trainerparty,savechanges=true)
params.setDefaultValue(10) params.setDefaultValue(10)
level = pbMessageChooseNumber(_INTL("Set the level for {1} (max. #{PBExperience.maxLevel}).", level = pbMessageChooseNumber(_INTL("Set the level for {1} (max. #{PBExperience.maxLevel}).",
PBSpecies.getName(species)),params) PBSpecies.getName(species)),params)
tempPoke = pbNewPkmn(species,level)
pokemon.push([species,level]) pokemon.push([species,level])
break break
end end
@@ -136,7 +135,7 @@ def pbNewTrainer(trainerid,trainername,trainerparty,savechanges=true)
if savechanges if savechanges
data = pbLoadTrainersData data = pbLoadTrainersData
data.push(trainer) data.push(trainer)
data = save_data(data,"Data/trainers.dat") save_data(data,"Data/trainers.dat")
$PokemonTemp.trainersData = nil $PokemonTemp.trainersData = nil
pbConvertTrainerData pbConvertTrainerData
pbMessage(_INTL("The Trainer's data was added to the list of battles and in PBS/trainers.txt.")) pbMessage(_INTL("The Trainer's data was added to the list of battles and in PBS/trainers.txt."))
@@ -168,7 +167,6 @@ def pbGetFreeTrainerParty(trainerid,trainername)
end end
trainerid = getID(PBTrainers,trainerid) trainerid = getID(PBTrainers,trainerid)
end end
ret = -1
trainers = pbLoadTrainersData trainers = pbLoadTrainersData
usedparties = [] usedparties = []
for trainer in trainers for trainer in trainers
@@ -213,8 +211,7 @@ def pbMissingTrainer(trainerid, trainername, trainerparty)
end end
trainerid = getID(PBTrainers,trainerid) trainerid = getID(PBTrainers,trainerid)
end end
traineridstring = "#{trainerid}" traineridstring = getConstantName(PBTrainers,trainerid) rescue "#{trainerid}"
traineridstring = getConstantName(PBTrainers,trainerid) rescue "-"
if !$DEBUG if !$DEBUG
raise _INTL("Can't find trainer ({1}, {2}, ID {3})",traineridstring,trainername,trainerparty) raise _INTL("Can't find trainer ({1}, {2}, ID {3})",traineridstring,trainername,trainerparty)
end end
+2 -5
View File
@@ -209,7 +209,6 @@ def pbIsUnlosableItem?(item,species,ability)
:KYOGRE => [:BLUEORB], :KYOGRE => [:BLUEORB],
:GROUDON => [:REDORB] :GROUDON => [:REDORB]
} }
ret = false
combos.each do |comboSpecies, items| combos.each do |comboSpecies, items|
next if !isConst?(species,PBSpecies,comboSpecies) next if !isConst?(species,PBSpecies,comboSpecies)
items.each { |i| return true if isConst?(item,PBItems,i) } items.each { |i| return true if isConst?(item,PBItems,i) }
@@ -363,7 +362,6 @@ def pbChangeLevel(pkmn,newlevel,scene)
spatkdiff = pkmn.spatk spatkdiff = pkmn.spatk
spdefdiff = pkmn.spdef spdefdiff = pkmn.spdef
totalhpdiff = pkmn.totalhp totalhpdiff = pkmn.totalhp
oldlevel = pkmn.level
pkmn.level = newlevel pkmn.level = newlevel
pkmn.changeHappiness("vitamin") pkmn.changeHappiness("vitamin")
pkmn.calcStats pkmn.calcStats
@@ -677,7 +675,6 @@ end
# Use an item from the Bag and/or on a Pokémon # Use an item from the Bag and/or on a Pokémon
#=============================================================================== #===============================================================================
def pbUseItem(bag,item,bagscene=nil) def pbUseItem(bag,item,bagscene=nil)
found = false
useType = pbGetItemData(item,ITEM_FIELD_USE) useType = pbGetItemData(item,ITEM_FIELD_USE)
if pbIsMachine?(item) # TM or HM if pbIsMachine?(item) # TM or HM
if $Trainer.pokemonCount==0 if $Trainer.pokemonCount==0
@@ -808,7 +805,7 @@ def pbUseItemMessage(item)
end end
end end
def pbCheckUseOnPokemon(item,pkmn,screen) def pbCheckUseOnPokemon(_item,pkmn,_screen)
return pkmn && !pkmn.egg? return pkmn && !pkmn.egg?
end end
@@ -905,7 +902,7 @@ end
#=============================================================================== #===============================================================================
# Choose an item from the Bag # Choose an item from the Bag
#=============================================================================== #===============================================================================
def pbChooseItem(var=0,*args) def pbChooseItem(var=0,_args)
ret = 0 ret = 0
pbFadeOutIn { pbFadeOutIn {
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
+2 -3
View File
@@ -90,7 +90,7 @@ def pbFindPhoneTrainer(trtype,trname) # Ignores whether visible or not
end end
def pbHasPhoneTrainer?(trtype,trname) def pbHasPhoneTrainer?(trtype,trname)
return pbFindPhoneTrainer!=nil return pbFindPhoneTrainer(trtype,trname)!=nil
end end
def pbPhoneBattleCount(trtype,trname) def pbPhoneBattleCount(trtype,trname)
@@ -133,7 +133,7 @@ end
#=============================================================================== #===============================================================================
# Phone-related counters # Phone-related counters
#=============================================================================== #===============================================================================
Events.onMapUpdate += proc { |sender,e| Events.onMapUpdate += proc { |_sender,_e|
next if !$Trainer || !$Trainer.pokegear next if !$Trainer || !$Trainer.pokegear
# Reset time to next phone call if necessary # Reset time to next phone call if necessary
if !$PokemonGlobal.phoneTime || $PokemonGlobal.phoneTime<=0 if !$PokemonGlobal.phoneTime || $PokemonGlobal.phoneTime<=0
@@ -207,7 +207,6 @@ end
# Generate phone message # Generate phone message
#=============================================================================== #===============================================================================
def pbPhoneGenerateCall(phonenum) def pbPhoneGenerateCall(phonenum)
call = ""
phoneData = pbLoadPhoneData phoneData = pbLoadPhoneData
# Choose random greeting depending on time of day # Choose random greeting depending on time of day
call = pbRandomPhoneItem(phoneData.greetings) call = pbRandomPhoneItem(phoneData.greetings)
@@ -190,7 +190,7 @@ EncounterModifier.register(proc { |encounter|
next encounter next encounter
}) })
Events.onWildPokemonCreate += proc { |sender,e| Events.onWildPokemonCreate += proc { |_sender,e|
pokemon = e[0] pokemon = e[0]
next if !$PokemonTemp.pokeradar next if !$PokemonTemp.pokeradar
grasses = $PokemonTemp.pokeradar[3] grasses = $PokemonTemp.pokeradar[3]
@@ -202,7 +202,7 @@ Events.onWildPokemonCreate += proc { |sender,e|
end end
} }
Events.onWildBattleEnd += proc { |sender,e| Events.onWildBattleEnd += proc { |_sender,e|
species = e[0] species = e[0]
level = e[1] level = e[1]
decision = e[2] decision = e[2]
@@ -221,7 +221,7 @@ Events.onWildBattleEnd += proc { |sender,e|
end end
} }
Events.onStepTaken += proc { |sender,e| Events.onStepTaken += proc { |_sender,_e|
if $PokemonGlobal.pokeradarBattery && $PokemonGlobal.pokeradarBattery>0 && if $PokemonGlobal.pokeradarBattery && $PokemonGlobal.pokeradarBattery>0 &&
!$PokemonTemp.pokeradar !$PokemonTemp.pokeradar
$PokemonGlobal.pokeradarBattery -= 1 $PokemonGlobal.pokeradarBattery -= 1
@@ -232,11 +232,11 @@ Events.onStepTaken += proc { |sender,e|
end end
} }
Events.onMapUpdate += proc { |sender,e| Events.onMapUpdate += proc { |_sender,_e|
pbPokeRadarCancel if $PokemonGlobal.bicycle pbPokeRadarCancel if $PokemonGlobal.bicycle
} }
Events.onMapChange += proc { |sender,e| Events.onMapChange += proc { |_sender,_e|
pbPokeRadarCancel pbPokeRadarCancel
} }
+3 -4
View File
@@ -28,7 +28,7 @@ def pbStoreMail(pkmn,item,message,poke1=nil,poke2=nil,poke3=nil)
pkmn.mail = PokemonMail.new(item,message,$Trainer.name,poke1,poke2,poke3) pkmn.mail = PokemonMail.new(item,message,$Trainer.name,poke1,poke2,poke3)
end end
def pbDisplayMail(mail,bearer=nil) def pbDisplayMail(mail,_bearer=nil)
sprites = {} sprites = {}
viewport = Viewport.new(0,0,Graphics.width,Graphics.height) viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999 viewport.z = 99999
@@ -95,7 +95,7 @@ def pbWriteMail(item,pkmn,pkmnid,scene)
"",false,256,Graphics.width) { scene.pbUpdate } "",false,256,Graphics.width) { scene.pbUpdate }
if message!="" if message!=""
# Store mail if a message was written # Store mail if a message was written
poke1 = poke2 = poke3 = nil poke1 = poke2 = nil
if $Trainer.party[pkmnid+2] if $Trainer.party[pkmnid+2]
p = $Trainer.party[pkmnid+2] p = $Trainer.party[pkmnid+2]
poke1 = [p.species,p.gender,p.shiny?,(p.form rescue 0),p.shadowPokemon?] poke1 = [p.species,p.gender,p.shiny?,(p.form rescue 0),p.shadowPokemon?]
@@ -110,8 +110,7 @@ def pbWriteMail(item,pkmn,pkmnid,scene)
poke3.push(true) if pkmn.egg? poke3.push(true) if pkmn.egg?
pbStoreMail(pkmn,item,message,poke1,poke2,poke3) pbStoreMail(pkmn,item,message,poke1,poke2,poke3)
return true return true
else
return false if scene.pbConfirm(_INTL("Stop giving the Pokémon Mail?"))
end end
return false if scene.pbConfirm(_INTL("Stop giving the Pokémon Mail?"))
end end
end end
-10
View File
@@ -3,7 +3,6 @@
#=============================================================================== #===============================================================================
class PokemonBag class PokemonBag
attr_accessor :lastpocket attr_accessor :lastpocket
attr_reader :pockets
def self.pocketNames def self.pocketNames
return pbPocketNames return pbPocketNames
@@ -92,7 +91,6 @@ class PokemonBag
item = getID(PBItems,item) item = getID(PBItems,item)
if !item || item<1 if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
return 0
end end
pocket = pbGetPocket(item) pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
@@ -108,7 +106,6 @@ class PokemonBag
item = getID(PBItems,item) item = getID(PBItems,item)
if !item || item<1 if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
return false
end end
pocket = pbGetPocket(item) pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
@@ -121,7 +118,6 @@ class PokemonBag
item = getID(PBItems,item) item = getID(PBItems,item)
if !item || item<1 if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
return false
end end
pocket = pbGetPocket(item) pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
@@ -134,7 +130,6 @@ class PokemonBag
item = getID(PBItems,item) item = getID(PBItems,item)
if !item || item<1 if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
return false
end end
pocket = pbGetPocket(item) pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
@@ -148,10 +143,8 @@ class PokemonBag
newitem = getID(PBItems,newitem) newitem = getID(PBItems,newitem)
if !olditem || olditem<1 if !olditem || olditem<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",olditem)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",olditem))
return false
elsif !newitem || newitem<1 elsif !newitem || newitem<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",newitem)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",newitem))
return false
end end
pocket = pbGetPocket(olditem) pocket = pbGetPocket(olditem)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
@@ -179,7 +172,6 @@ class PokemonBag
item = getID(PBItems,item) item = getID(PBItems,item)
if !item || item<1 if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
return false
end end
pocket = pbGetPocket(item) pocket = pbGetPocket(item)
maxsize = maxPocketSize(pocket) maxsize = maxPocketSize(pocket)
@@ -209,7 +201,6 @@ class PokemonBag
item = getID(PBItems,item) item = getID(PBItems,item)
if !item || item<1 if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
return
end end
registeredlist = self.registeredItems registeredlist = self.registeredItems
registeredlist.push(item) if !registeredlist.include?(item) registeredlist.push(item) if !registeredlist.include?(item)
@@ -220,7 +211,6 @@ class PokemonBag
item = getID(PBItems,item) item = getID(PBItems,item)
if !item || item<1 if !item || item<1
raise ArgumentError.new(_INTL("Item number {1} is invalid.",item)) raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
return
end end
registeredlist = self.registeredItems registeredlist = self.registeredItems
if registeredlist.include?(item) if registeredlist.include?(item)
@@ -21,16 +21,16 @@ class PokeBattle_Pokemon
attr_accessor :moves # Moves (PBMove) attr_accessor :moves # Moves (PBMove)
attr_accessor :firstmoves # The moves known when this Pokémon was obtained attr_accessor :firstmoves # The moves known when this Pokémon was obtained
attr_accessor :item # Held item attr_accessor :item # Held item
attr_accessor :mail # Mail attr_writer :mail # Mail
attr_accessor :fused # The Pokémon fused into this one attr_accessor :fused # The Pokémon fused into this one
attr_accessor :iv # Array of 6 Individual Values for HP, Atk, Def, attr_accessor :iv # Array of 6 Individual Values for HP, Atk, Def,
# Speed, Sp Atk, and Sp Def # Speed, Sp Atk, and Sp Def
attr_accessor :ivMaxed # Array of booleans that max each IV value attr_writer :ivMaxed # Array of booleans that max each IV value
attr_accessor :ev # Effort Values attr_accessor :ev # Effort Values
attr_accessor :happiness # Current happiness attr_accessor :happiness # Current happiness
attr_accessor :ballused # Ball used attr_accessor :ballused # Ball used
attr_accessor :eggsteps # Steps to hatch egg, 0 if Pokémon is not an egg attr_accessor :eggsteps # Steps to hatch egg, 0 if Pokémon is not an egg
attr_accessor :markings # Markings attr_writer :markings # Markings
attr_accessor :ribbons # Array of ribbons attr_accessor :ribbons # Array of ribbons
attr_accessor :pokerus # Pokérus strain and infection time attr_accessor :pokerus # Pokérus strain and infection time
attr_accessor :personalID # Personal ID attr_accessor :personalID # Personal ID
@@ -41,15 +41,15 @@ class PokeBattle_Pokemon
# 4 - fateful encounter # 4 - fateful encounter
attr_accessor :obtainMap # Map where obtained attr_accessor :obtainMap # Map where obtained
attr_accessor :obtainText # Replaces the obtain map's name if not nil attr_accessor :obtainText # Replaces the obtain map's name if not nil
attr_accessor :obtainLevel # Level obtained attr_writer :obtainLevel # Level obtained
attr_accessor :hatchedMap # Map where an egg was hatched attr_accessor :hatchedMap # Map where an egg was hatched
attr_accessor :language # Language attr_writer :language # Language
attr_accessor :ot # Original Trainer's name attr_accessor :ot # Original Trainer's name
attr_accessor :otgender # Original Trainer's gender: attr_writer :otgender # Original Trainer's gender:
# 0 - male, 1 - female, 2 - mixed, 3 - unknown # 0 - male, 1 - female, 2 - mixed, 3 - unknown
# For information only, not used to verify # For information only, not used to verify
# ownership of the Pokémon # ownership of the Pokémon
attr_accessor :cool,:beauty,:cute,:smart,:tough,:sheen # Contest stats attr_writer :cool,:beauty,:cute,:smart,:tough,:sheen # Contest stats
IV_STAT_LIMIT = 31 # Max total IVs IV_STAT_LIMIT = 31 # Max total IVs
EV_LIMIT = 510 # Max total EVs EV_LIMIT = 510 # Max total EVs
@@ -348,7 +348,7 @@ class PokeBattle_Pokemon
strain = 1+rand(15) if strain<=0 || strain>=16 strain = 1+rand(15) if strain<=0 || strain>=16
time = 1+(strain%4) time = 1+(strain%4)
@pokerus = time @pokerus = time
@pokerus |= strain<<4 @pokerus |= strain << 4
end end
# Resets the infection time for this Pokémon's Pokérus (even if cured). # Resets the infection time for this Pokémon's Pokérus (even if cured).
@@ -357,7 +357,7 @@ class PokeBattle_Pokemon
strain = @pokerus%16 strain = @pokerus%16
time = 1+(strain%4) time = 1+(strain%4)
@pokerus = time @pokerus = time
@pokerus |= strain<<4 @pokerus |= strain << 4
end end
# Reduces the time remaining for this Pokémon's Pokérus (if infected). # Reduces the time remaining for this Pokémon's Pokérus (if infected).
@@ -447,7 +447,8 @@ class PokeBattle_Pokemon
return if move<=0 return if move<=0
for i in 0...4 # Already knows move, relocate it to the end of the list for i in 0...4 # Already knows move, relocate it to the end of the list
next if @moves[i].id!=move next if @moves[i].id!=move
j = i+1; while j<4 j = i+1
while j<4
break if @moves[j].id==0 break if @moves[j].id==0
tmp = @moves[j] tmp = @moves[j]
@moves[j] = @moves[j-1] @moves[j] = @moves[j-1]
@@ -524,12 +525,12 @@ class PokeBattle_Pokemon
#============================================================================= #=============================================================================
# Contest attributes, ribbons # Contest attributes, ribbons
#============================================================================= #=============================================================================
def cool; return @cool ? @cool : 0; end def cool; return @cool || 0; end
def beauty; return @beauty ? @beauty : 0; end def beauty; return @beauty || 0; end
def cute; return @cute ? @cute : 0; end def cute; return @cute || 0; end
def smart; return @smart ? @smart : 0; end def smart; return @smart || 0; end
def tough; return @tough ? @tough : 0; end def tough; return @tough || 0; end
def sheen; return @sheen ? @sheen : 0; end def sheen; return @sheen || 0; end
# Returns the number of ribbons this Pokémon has. # Returns the number of ribbons this Pokémon has.
def ribbonCount def ribbonCount
@@ -672,8 +673,7 @@ class PokeBattle_Pokemon
# Returns an array of booleans indicating whether a stat is made to have # Returns an array of booleans indicating whether a stat is made to have
# maximum IVs (for Hyper Training). Set like @ivMaxed[PBStats::ATTACK] = true # maximum IVs (for Hyper Training). Set like @ivMaxed[PBStats::ATTACK] = true
def ivMaxed def ivMaxed
@ivMaxed = [] if !@ivMaxed return @ivMaxed || []
return @ivMaxed
end end
# Returns this Pokémon's effective IVs, taking into account Hyper Training. # Returns this Pokémon's effective IVs, taking into account Hyper Training.
@@ -870,7 +870,6 @@ class PokeBattle_Pokemon
realSpecies = pbGetSpeciesFromFSpecies(species)[0] if species && species>0 realSpecies = pbGetSpeciesFromFSpecies(species)[0] if species && species>0
if !species || species<=0 || realSpecies>PBSpecies.maxValue || !cname if !species || species<=0 || realSpecies>PBSpecies.maxValue || !cname
raise ArgumentError.new(_INTL("The species given ({1}) is invalid.",ospecies)) raise ArgumentError.new(_INTL("The species given ({1}) is invalid.",ospecies))
return nil
end end
@species = realSpecies @species = realSpecies
@name = PBSpecies.getName(@species) @name = PBSpecies.getName(@species)
@@ -63,7 +63,7 @@ end
class PokeBattle_RealBattlePeer class PokeBattle_RealBattlePeer
def pbOnEnteringBattle(battle,pkmn,wild=false) def pbOnEnteringBattle(_battle,pkmn,wild=false)
f = MultipleForms.call("getFormOnEnteringBattle",pkmn,wild) f = MultipleForms.call("getFormOnEnteringBattle",pkmn,wild)
pkmn.form = f if f pkmn.form = f if f
end end
@@ -248,7 +248,6 @@ MultipleForms.register(:BURMY,{
}, },
"getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle| "getFormOnLeavingBattle" => proc { |pkmn,battle,usedInBattle,endBattle|
next if !endBattle || !usedInBattle next if !endBattle || !usedInBattle
env = battle.environment
case battle.environment case battle.environment
when PBEnvironment::Rock, PBEnvironment::Sand, PBEnvironment::Cave when PBEnvironment::Rock, PBEnvironment::Sand, PBEnvironment::Cave
next 1 # Sandy Cloak next 1 # Sandy Cloak
@@ -231,9 +231,9 @@ end
# Pokémon class. # Pokémon class.
#=============================================================================== #===============================================================================
class PokeBattle_Pokemon class PokeBattle_Pokemon
attr_accessor :heartgauge attr_writer :heartgauge
attr_accessor :shadow attr_accessor :shadow
attr_accessor :hypermode attr_writer :hypermode
attr_accessor :savedev attr_accessor :savedev
attr_accessor :savedexp attr_accessor :savedexp
attr_accessor :shadowmoves attr_accessor :shadowmoves
@@ -260,8 +260,7 @@ class PokeBattle_Pokemon
end end
def heartgauge def heartgauge
@heartgauge = 0 if !@heartgauge return @heartgauge || 0
return @heartgauge
end end
def heartStage def heartStage
@@ -668,7 +667,7 @@ end
Events.onStartBattle += proc { |sender| Events.onStartBattle += proc { |_sender|
# Record current heart gauges of Pokémon in party, to see if they drop to zero # Record current heart gauges of Pokémon in party, to see if they drop to zero
# during battle and need to say they're ready to be purified afterwards # during battle and need to say they're ready to be purified afterwards
$PokemonTemp.heartgauges = [] $PokemonTemp.heartgauges = []
@@ -677,9 +676,7 @@ Events.onStartBattle += proc { |sender|
end end
} }
Events.onEndBattle += proc { |sender,e| Events.onEndBattle += proc { |_sender,_e|
decision = e[0]
canLose = e[1]
for i in 0...$PokemonTemp.heartgauges.length for i in 0...$PokemonTemp.heartgauges.length
pokemon = $Trainer.party[i] pokemon = $Trainer.party[i]
if pokemon && $PokemonTemp.heartgauges[i] && if pokemon && $PokemonTemp.heartgauges[i] &&
@@ -39,7 +39,7 @@ HiddenMoveHandlers::UseMove.add(:CHATTER,proc { |move,pokemon|
class PokeBattle_Scene class PokeBattle_Scene
def pbChatter(user,target) def pbChatter(user,_target)
pbPlayCry(user.pokemon,90,100) if user.pokemon pbPlayCry(user.pokemon,90,100) if user.pokemon
Graphics.frame_rate.times do Graphics.frame_rate.times do
Graphics.update Graphics.update
@@ -111,7 +111,7 @@ class PokemonStorage
$Trainer.party $Trainer.party
end end
def party=(value) def party=(_value)
raise ArgumentError.new("Not supported") raise ArgumentError.new("Not supported")
end end
@@ -29,7 +29,7 @@ class Window_Pokedex < Window_DrawableCommand
return @commands.length return @commands.length
end end
def drawItem(index,count,rect) def drawItem(index,_count,rect)
return if index>=self.top_row+self.page_item_max return if index>=self.top_row+self.page_item_max
rect = Rect.new(rect.x+16,rect.y,rect.width-16,rect.height) rect = Rect.new(rect.x+16,rect.y,rect.width-16,rect.height)
species = @commands[index][0] species = @commands[index][0]
@@ -431,7 +431,8 @@ class PokemonPokedex_Scene
y = 78 y = 78
y += ((sliderheight-boxheight)*itemlist.top_row/(itemlist.row_max-itemlist.page_row_max)).floor y += ((sliderheight-boxheight)*itemlist.top_row/(itemlist.row_max-itemlist.page_row_max)).floor
overlay.blt(468,y,@sliderbitmap.bitmap,Rect.new(40,0,40,8)) overlay.blt(468,y,@sliderbitmap.bitmap,Rect.new(40,0,40,8))
i = 0; while i*16<boxheight-8-16 i = 0
while i*16<boxheight-8-16
height = [boxheight-8-16-i*16,16].min height = [boxheight-8-16-i*16,16].min
overlay.blt(468,y+8+i*16,@sliderbitmap.bitmap,Rect.new(40,8,40,height)) overlay.blt(468,y+8+i*16,@sliderbitmap.bitmap,Rect.new(40,8,40,height))
i += 1 i += 1
@@ -440,7 +441,7 @@ class PokemonPokedex_Scene
end end
end end
def pbRefreshDexSearch(params,index) def pbRefreshDexSearch(params,_index)
overlay = @sprites["overlay"].bitmap overlay = @sprites["overlay"].bitmap
overlay.clear overlay.clear
base = Color.new(248,248,248) base = Color.new(248,248,248)
@@ -509,7 +510,7 @@ class PokemonPokedex_Scene
pbDrawTextPositions(overlay,textpos) pbDrawTextPositions(overlay,textpos)
end end
def pbRefreshDexSearchParam(mode,cmds,sel,index) def pbRefreshDexSearchParam(mode,cmds,sel,_index)
overlay = @sprites["overlay"].bitmap overlay = @sprites["overlay"].bitmap
overlay.clear overlay.clear
base = Color.new(248,248,248) base = Color.new(248,248,248)
@@ -795,7 +796,6 @@ class PokemonPokedex_Scene
region = dexnames[pbGetSavePositionIndex][1] region = dexnames[pbGetSavePositionIndex][1]
end end
end end
ret = -1
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)
ret = screen.pbStartScreen(@dexlist,index,region) ret = screen.pbStartScreen(@dexlist,index,region)
@@ -985,7 +985,6 @@ class PokemonPokedex_Scene
def pbDexSearch def pbDexSearch
oldsprites = pbFadeOutAndHide(@sprites) oldsprites = pbFadeOutAndHide(@sprites)
oldparams = @searchParams
params = @searchParams.clone params = @searchParams.clone
@orderCommands = [] @orderCommands = []
@orderCommands[MODENUMERICAL] = _INTL("Numerical") @orderCommands[MODENUMERICAL] = _INTL("Numerical")
+4 -4
View File
@@ -113,7 +113,7 @@ class Window_CommandPokemonColor < Window_CommandPokemon
super(commands,width) super(commands,width)
end end
def drawItem(index,count,rect) def drawItem(index,_count,rect)
pbSetSystemFont(self.contents) if @starting pbSetSystemFont(self.contents) if @starting
rect = drawCursor(index,rect) rect = drawCursor(index,rect)
base = self.baseColor base = self.baseColor
@@ -134,7 +134,7 @@ end
class PokemonPartyBlankPanel < SpriteWrapper class PokemonPartyBlankPanel < SpriteWrapper
attr_accessor :text attr_accessor :text
def initialize(pokemon,index,viewport=nil) def initialize(_pokemon,index,viewport=nil)
super(viewport) super(viewport)
self.x = [0,256,0,256,0,256][index] self.x = [0,256,0,256,0,256][index]
self.y = [0,16,96,112,192,208][index] self.y = [0,16,96,112,192,208][index]
@@ -165,7 +165,7 @@ class PokemonPartyPanel < SpriteWrapper
attr_reader :selected attr_reader :selected
attr_reader :preselected attr_reader :preselected
attr_reader :switching attr_reader :switching
attr_accessor :text attr_reader :text
def initialize(pokemon,index,viewport=nil) def initialize(pokemon,index,viewport=nil)
super(viewport) super(viewport)
@@ -832,7 +832,7 @@ class PokemonPartyScreen
@party = party @party = party
end end
def pbStartScene(helptext,numBattlersOut,annotations=nil) def pbStartScene(helptext,_numBattlersOut,annotations=nil)
@scene.pbStartScene(@party,helptext,annotations) @scene.pbStartScene(@party,helptext,annotations)
end end

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