Merge remote-tracking branch 'upstream/master' into handlerhash-block

This commit is contained in:
jonisavo
2020-09-06 07:02:03 +03:00
234 changed files with 1516 additions and 1536 deletions

Binary file not shown.

View File

@@ -87,8 +87,8 @@ NO_SIGNPOSTS = []
# * The maximum length, in characters, that the player's name can be. # * The maximum length, in characters, that the player's name can be.
#=============================================================================== #===============================================================================
INITIAL_MONEY = 3000 INITIAL_MONEY = 3000
MAX_MONEY = 999999 MAX_MONEY = 999_999
MAX_COINS = 99999 MAX_COINS = 99_999
MAX_PLAYER_NAME_SIZE = 10 MAX_PLAYER_NAME_SIZE = 10
#=============================================================================== #===============================================================================
@@ -97,9 +97,9 @@ MAX_PLAYER_NAME_SIZE = 10
# associated trainer type will be named as whatever is in that variable. # associated trainer type will be named as whatever is in that variable.
#=============================================================================== #===============================================================================
RIVAL_NAMES = [ RIVAL_NAMES = [
[:RIVAL1,12], [:RIVAL1, 12],
[:RIVAL2,12], [:RIVAL2, 12],
[:CHAMPION,12] [:CHAMPION, 12]
] ]
#=============================================================================== #===============================================================================
@@ -155,7 +155,7 @@ SCALED_EXP_FORMULA = true
SPLIT_EXP_BETWEEN_GAINERS = false SPLIT_EXP_BETWEEN_GAINERS = false
ENABLE_CRITICAL_CAPTURES = false ENABLE_CRITICAL_CAPTURES = false
GAIN_EXP_FOR_CAPTURE = true GAIN_EXP_FOR_CAPTURE = true
MEGA_RINGS = [:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM] MEGA_RINGS = [:MEGARING, :MEGABRACELET, :MEGACUFF, :MEGACHARM]
#=============================================================================== #===============================================================================
# * The names of each pocket of the Bag. Leave the first entry blank. # * The names of each pocket of the Bag. Leave the first entry blank.
@@ -166,18 +166,18 @@ MEGA_RINGS = [:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM]
# first entry (the 0). # first entry (the 0).
#=============================================================================== #===============================================================================
def pbPocketNames; return ["", def pbPocketNames; return ["",
_INTL("Items"), _INTL("Items"),
_INTL("Medicine"), _INTL("Medicine"),
_INTL("Poké Balls"), _INTL("Poké Balls"),
_INTL("TMs & HMs"), _INTL("TMs & HMs"),
_INTL("Berries"), _INTL("Berries"),
_INTL("Mail"), _INTL("Mail"),
_INTL("Battle Items"), _INTL("Battle Items"),
_INTL("Key Items") _INTL("Key Items")
]; end ]; end
BAG_MAX_POCKET_SIZE = [0,-1,-1,-1,-1,-1,-1,-1,-1] BAG_MAX_POCKET_SIZE = [0, -1, -1, -1, -1, -1, -1, -1, -1]
BAG_MAX_PER_SLOT = 999 BAG_MAX_PER_SLOT = 999
BAG_POCKET_AUTO_SORT = [0,false,false,false,true,true,false,false,false] BAG_POCKET_AUTO_SORT = [0, false, false, false, true, true, false, false, false]
#=============================================================================== #===============================================================================
# * A set of arrays each containing details of a graphic to be shown on the # * A set of arrays each containing details of a graphic to be shown on the
@@ -190,8 +190,8 @@ BAG_POCKET_AUTO_SORT = [0,false,false,false,true,true,false,false,false]
# - The graphic will always (true) or never (false) be shown on a wall map. # - The graphic will always (true) or never (false) be shown on a wall map.
#=============================================================================== #===============================================================================
REGION_MAP_EXTRAS = [ REGION_MAP_EXTRAS = [
[0,51,16,15,"mapHiddenBerth",false], [0, 51, 16, 15, "mapHiddenBerth", false],
[0,52,20,14,"mapHiddenFaraday",false] [0, 52, 20, 14, "mapHiddenFaraday", false]
] ]
#=============================================================================== #===============================================================================
@@ -229,9 +229,9 @@ NUM_STORAGE_BOXES = 30
#=============================================================================== #===============================================================================
USE_CURRENT_REGION_DEX = false USE_CURRENT_REGION_DEX = false
def pbDexNames; return [ def pbDexNames; return [
[_INTL("Kanto Pokédex"),0], [_INTL("Kanto Pokédex"), 0],
[_INTL("Johto Pokédex"),1], [_INTL("Johto Pokédex"), 1],
_INTL("National Pokédex") _INTL("National Pokédex")
]; end ]; end
DEX_SHOWS_ALL_FORMS = false DEX_SHOWS_ALL_FORMS = false
DEXES_WITH_OFFSETS = [] DEXES_WITH_OFFSETS = []
@@ -250,27 +250,27 @@ DEXES_WITH_OFFSETS = []
# - Roaming areas specifically for this Pokémon (optional). # - Roaming areas specifically for this Pokémon (optional).
#=============================================================================== #===============================================================================
RoamingAreas = { RoamingAreas = {
5 => [21,28,31,39,41,44,47,66,69], 5 => [ 21, 28, 31, 39, 41, 44, 47, 66, 69],
21 => [5,28,31,39,41,44,47,66,69], 21 => [5, 28, 31, 39, 41, 44, 47, 66, 69],
28 => [5,21,31,39,41,44,47,66,69], 28 => [5, 21, 31, 39, 41, 44, 47, 66, 69],
31 => [5,21,28,39,41,44,47,66,69], 31 => [5, 21, 28, 39, 41, 44, 47, 66, 69],
39 => [5,21,28,31,41,44,47,66,69], 39 => [5, 21, 28, 31, 41, 44, 47, 66, 69],
41 => [5,21,28,31,39,44,47,66,69], 41 => [5, 21, 28, 31, 39, 44, 47, 66, 69],
44 => [5,21,28,31,39,41,47,66,69], 44 => [5, 21, 28, 31, 39, 41, 47, 66, 69],
47 => [5,21,28,31,39,41,44,66,69], 47 => [5, 21, 28, 31, 39, 41, 44, 66, 69],
66 => [5,21,28,31,39,41,44,47,69], 66 => [5, 21, 28, 31, 39, 41, 44, 47, 69],
69 => [5,21,28,31,39,41,44,47,66] 69 => [5, 21, 28, 31, 39, 41, 44, 47, 66 ]
} }
RoamingSpecies = [ RoamingSpecies = [
[:LATIAS, 30, 53, 0, "Battle roaming"], [:LATIAS, 30, 53, 0, "Battle roaming"],
[:LATIOS, 30, 53, 0, "Battle roaming"], [:LATIOS, 30, 53, 0, "Battle roaming"],
[:KYOGRE, 40, 54, 2, nil, { [:KYOGRE, 40, 54, 2, nil, {
2 => [21,31], 2 => [ 21, 31 ],
21 => [2,31,69], 21 => [2, 31, 69],
31 => [2,21,69], 31 => [2, 21, 69],
69 => [21,31] 69 => [ 21, 31 ]
}], }],
[:ENTEI, 40, 55, 1, nil] [:ENTEI, 40, 55, 1, nil]
] ]
#=============================================================================== #===============================================================================
@@ -283,10 +283,10 @@ RoamingSpecies = [
# - Maximum possible level (optional). # - Maximum possible level (optional).
#=============================================================================== #===============================================================================
POKE_RADAR_ENCOUNTERS = [ POKE_RADAR_ENCOUNTERS = [
[5, 20, :STARLY, 12, 15], [5, 20, :STARLY, 12, 15],
[21, 10, :STANTLER, 14], [21, 10, :STANTLER, 14],
[28, 20, :BUTTERFREE, 15, 18], [28, 20, :BUTTERFREE, 15, 18],
[28, 20, :BEEDRILL, 15, 18] [28, 20, :BEEDRILL, 15, 18]
] ]
#=============================================================================== #===============================================================================
@@ -348,6 +348,6 @@ PLANT_SPARKLE_ANIMATION_ID = 7
# languages to choose from. # languages to choose from.
#=============================================================================== #===============================================================================
LANGUAGES = [ LANGUAGES = [
# ["English","english.dat"], # ["English", "english.dat"],
# ["Deutsch","deutsch.dat"] # ["Deutsch", "deutsch.dat"]
] ]

View File

@@ -7,24 +7,20 @@ class Class
end end
end end
#=============================================================================== #===============================================================================
# module Comparable # module Comparable
#=============================================================================== #===============================================================================
unless Comparable.method_defined? :clamp unless Comparable.method_defined? :clamp
module Comparable module Comparable
def clamp(min, max) def clamp(min, max)
if max-min<0 if max - min < 0
raise ArgumentError("min argument must be smaller than max argument") raise ArgumentError("min argument must be smaller than max argument")
end end
return (self>max) ? max : (self<min) ? min : self return (self > max) ? max : (self < min) ? min : self
end end
end end
end end
#=============================================================================== #===============================================================================
# class Boolean # class Boolean
#=============================================================================== #===============================================================================
@@ -34,32 +30,30 @@ class Boolean
end end
end end
#=============================================================================== #===============================================================================
# class String # class String
#=============================================================================== #===============================================================================
class String class String
def starts_with?(str) def starts_with?(str)
proc = (self[0...str.length] == str) if self.length >= str.length proc = (self[0...str.length] == str) if self.length >= str.length
return proc ? proc : false return proc || false
end end
def ends_with?(str) def ends_with?(str)
e = self.length - 1 e = self.length - 1
proc = (self[(e-str.length)...e] == str) if self.length >= str.length proc = (self[(e-str.length)...e] == str) if self.length >= str.length
return proc ? proc : false return proc || false
end end
def starts_with_vowel? def starts_with_vowel?
return ['a','e','i','o','u'].include?(self[0,1].downcase) return ['a', 'e', 'i', 'o', 'u'].include?(self[0, 1].downcase)
end end
def first(n=1) def first(n = 1)
return self[0...n] return self[0...n]
end end
def last(n=1) def last(n = 1)
return self[-n..-1] || self return self[-n..-1] || self
end end
@@ -90,14 +84,14 @@ class String
return blank return blank
end end
def cut(bitmap,width) def cut(bitmap, width)
string = self string = self
width -= bitmap.text_size("...").width width -= bitmap.text_size("...").width
string_width = 0 string_width = 0
text = [] text = []
for char in string.scan(/./) for char in string.scan(/./)
wdh = bitmap.text_size(char).width wdh = bitmap.text_size(char).width
next if (wdh+string_width) > width next if (wdh + string_width) > width
string_width += wdh string_width += wdh
text.push(char) text.push(char)
end end
@@ -110,8 +104,6 @@ class String
end end
end end
#=============================================================================== #===============================================================================
# class Numeric # class Numeric
#=============================================================================== #===============================================================================
@@ -122,21 +114,17 @@ class Numeric
end end
end end
#=============================================================================== #===============================================================================
# class Integer # class Integer
#=============================================================================== #===============================================================================
class Integer class Integer
# Returns an array containing each digit of the number in turn. # Returns an array containing each digit of the number in turn.
def digits(base=10) def digits(base = 10)
quotient, remainder = divmod(base) quotient, remainder = divmod(base)
(quotient==0) ? [remainder] : quotient.digits(base).push(remainder) return (quotient == 0) ? [remainder] : quotient.digits(base).push(remainder)
end end
end end
#=============================================================================== #===============================================================================
# class Array # class Array
#=============================================================================== #===============================================================================
@@ -150,7 +138,7 @@ class Array
end end
def ^(other) # xor of two arrays def ^(other) # xor of two arrays
return (self|other)-(self&other) return (self|other) - (self&other)
end end
def shuffle def shuffle
@@ -158,15 +146,14 @@ class Array
end unless method_defined? :shuffle end unless method_defined? :shuffle
def shuffle! def shuffle!
(size-1).times do |i| (size - 1).times do |i|
r = i+rand(size-i) r = i + rand(size - i)
self[i], self[r] = self[r], self[i] self[i], self[r] = self[r], self[i]
end end
self self
end unless method_defined? :shuffle! end unless method_defined? :shuffle!
end end
#=============================================================================== #===============================================================================
# module Enumerable # module Enumerable
#=============================================================================== #===============================================================================
@@ -178,8 +165,6 @@ module Enumerable
end end
end end
#=============================================================================== #===============================================================================
# Kernel methods # Kernel methods
#=============================================================================== #===============================================================================

View File

@@ -62,10 +62,12 @@ end
##################################### #####################################
# Works around a problem with FileTest.exist # Works around a problem with FileTest.exist
# if directory contains accent marks # if directory contains accent marks
def safeExists?(f) if !defined?(safeExists?)
ret=false def safeExists?(f)
File.open(f,"rb") { ret=true } rescue nil ret=false
return ret File.open(f,"rb") { ret=true } rescue nil
return ret
end
end end

View File

@@ -1,3 +1,42 @@
class PictureOrigin
TopLeft = 0
Center = 1
TopRight = 2
BottomLeft = 3
LowerLeft = 3
BottomRight = 4
LowerRight = 4
Top = 5
Bottom = 6
Left = 7
Right = 8
end
class Processes
XY = 0
DeltaXY = 1
Z = 2
Curve = 3
Zoom = 4
Angle = 5
Tone = 6
Color = 7
Hue = 8
Opacity = 9
Visible = 10
BlendType = 11
SE = 12
Name = 13
Origin = 14
Src = 15
SrcSize = 16
CropBottom = 17
end
def getCubicPoint2(src,t) def getCubicPoint2(src,t)
x0 = src[0]; y0 = src[1] x0 = src[0]; y0 = src[1]
cx0 = src[2]; cy0 = src[3] cx0 = src[2]; cy0 = src[3]
@@ -31,29 +70,9 @@ end
class Processes #===============================================================================
XY = 0 # PictureEx
DeltaXY = 1 #===============================================================================
Z = 2
Curve = 3
Zoom = 4
Angle = 5
Tone = 6
Color = 7
Hue = 8
Opacity = 9
Visible = 10
BlendType = 11
SE = 12
Name = 13
Origin = 14
Src = 15
SrcSize = 16
CropBottom = 17
end
class PictureEx class PictureEx
attr_accessor :x # x-coordinate attr_accessor :x # x-coordinate
attr_accessor :y # y-coordinate attr_accessor :y # y-coordinate
@@ -429,6 +448,9 @@ end
#===============================================================================
#
#===============================================================================
def setPictureSprite(sprite, picture, iconSprite=false) def setPictureSprite(sprite, picture, iconSprite=false)
return if picture.frameUpdates.length==0 return if picture.frameUpdates.length==0
for i in 0...picture.frameUpdates.length for i in 0...picture.frameUpdates.length
@@ -495,215 +517,3 @@ end
def setPictureIconSprite(sprite, picture) def setPictureIconSprite(sprite, picture)
setPictureSprite(sprite,picture,true) setPictureSprite(sprite,picture,true)
end end
class PictureOrigin
TopLeft = 0
Center = 1
TopRight = 2
BottomLeft = 3
LowerLeft = 3
BottomRight = 4
LowerRight = 4
Top = 5
Bottom = 6
Left = 7
Right = 8
end
def pbTextBitmap(text, maxwidth=Graphics.width)
dims = []
tmp = Bitmap.new(maxwidth,Graphics.height)
pbSetSystemFont(tmp)
drawFormattedTextEx(tmp,0,0,maxwidth,text,Color.new(248,248,248),Color.new(168,184,184))
return tmp
end
class PictureSprite < SpriteWrapper
def initialize(viewport, picture)
super(viewport)
@picture = picture
@pictureBitmap = nil
@customBitmap = nil
@customBitmapIsBitmap = true
@hue = 0
update
end
def dispose
@pictureBitmap.dispose if @pictureBitmap
super
end
# Doesn't free the bitmap
def setCustomBitmap(bitmap)
@customBitmap = bitmap
@customBitmapIsBitmap = @customBitmap.is_a?(Bitmap)
end
def update
super
@pictureBitmap.update if @pictureBitmap
# If picture file name is different from current one
if @customBitmap && @picture.name==""
self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap
elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i
# Remember file name to instance variables
@picture_name = @picture.name
@hue = @picture.hue.to_i
# If file name is not empty
if @picture_name == ""
@pictureBitmap.dispose if @pictureBitmap
@pictureBitmap = nil
self.visible = false
return
end
# Get picture graphic
@pictureBitmap.dispose if @pictureBitmap
@pictureBitmap = AnimatedBitmap.new(@picture_name, @hue)
self.bitmap = (@pictureBitmap) ? @pictureBitmap.bitmap : nil
elsif @picture_name == ""
# Set sprite to invisible
self.visible = false
return
end
setPictureSprite(self,@picture)
end
end
class EventScene
attr_accessor :onCTrigger,:onBTrigger,:onUpdate
def initialize(viewport=nil)
@viewport = viewport
@onCTrigger = Event.new
@onBTrigger = Event.new
@onUpdate = Event.new
@pictures = []
@picturesprites = []
@usersprites = []
@disposed = false
end
def dispose
return if disposed?
for sprite in @picturesprites
sprite.dispose
end
for sprite in @usersprites
sprite.dispose
end
@onCTrigger.clear
@onBTrigger.clear
@onUpdate.clear
@pictures.clear
@picturesprites.clear
@usersprites.clear
@disposed = true
end
def disposed?
return @disposed
end
def addBitmap(x, y, bitmap)
# _bitmap_ can be a Bitmap or an AnimatedBitmap
# (update method isn't called if it's animated)
# EventScene doesn't take ownership of the passed-in bitmap
num = @pictures.length
picture = PictureEx.new(num)
picture.setXY(0,x,y)
picture.setVisible(0,true)
@pictures[num] = picture
@picturesprites[num] = PictureSprite.new(@viewport,picture)
@picturesprites[num].setCustomBitmap(bitmap)
return picture
end
def addLabel(x, y, width, text)
addBitmap(x,y,pbTextBitmap(text,width))
end
def addImage(x, y, name)
num = @pictures.length
picture = PictureEx.new(num)
picture.name = name
picture.setXY(0,x,y)
picture.setVisible(0,true)
@pictures[num] = picture
@picturesprites[num] = PictureSprite.new(@viewport,picture)
return picture
end
def addUserSprite(sprite)
@usersprites.push(sprite)
end
def getPicture(num)
return @pictures[num]
end
def wait(frames)
frames.times { update }
end
def pictureWait(extraframes=0)
loop do
hasRunning = false
for pic in @pictures
hasRunning = true if pic.running?
end
break if !hasRunning
update
end
extraframes.times { update }
end
def update
return if disposed?
Graphics.update
Input.update
for picture in @pictures
picture.update
end
for sprite in @picturesprites
sprite.update
end
for sprite in @usersprites
next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite)
sprite.update
end
@onUpdate.trigger(self)
if Input.trigger?(Input::B)
@onBTrigger.trigger(self)
elsif Input.trigger?(Input::C)
@onCTrigger.trigger(self)
end
end
def main
while !disposed?
update
end
end
end
def pbEventScreen(cls)
pbFadeOutIn {
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
PBDebug.logonerr {
cls.new(viewport).main
}
viewport.dispose
}
end

View File

@@ -0,0 +1,199 @@
class PictureSprite < SpriteWrapper
def initialize(viewport, picture)
super(viewport)
@picture = picture
@pictureBitmap = nil
@customBitmap = nil
@customBitmapIsBitmap = true
@hue = 0
update
end
def dispose
@pictureBitmap.dispose if @pictureBitmap
super
end
# Doesn't free the bitmap
def setCustomBitmap(bitmap)
@customBitmap = bitmap
@customBitmapIsBitmap = @customBitmap.is_a?(Bitmap)
end
def update
super
@pictureBitmap.update if @pictureBitmap
# If picture file name is different from current one
if @customBitmap && @picture.name==""
self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap
elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i
# Remember file name to instance variables
@picture_name = @picture.name
@hue = @picture.hue.to_i
# If file name is not empty
if @picture_name == ""
@pictureBitmap.dispose if @pictureBitmap
@pictureBitmap = nil
self.visible = false
return
end
# Get picture graphic
@pictureBitmap.dispose if @pictureBitmap
@pictureBitmap = AnimatedBitmap.new(@picture_name, @hue)
self.bitmap = (@pictureBitmap) ? @pictureBitmap.bitmap : nil
elsif @picture_name == ""
# Set sprite to invisible
self.visible = false
return
end
setPictureSprite(self,@picture)
end
end
def pbTextBitmap(text, maxwidth=Graphics.width)
dims = []
tmp = Bitmap.new(maxwidth,Graphics.height)
pbSetSystemFont(tmp)
drawFormattedTextEx(tmp,0,0,maxwidth,text,Color.new(248,248,248),Color.new(168,184,184))
return tmp
end
#===============================================================================
# EventScene
#===============================================================================
class EventScene
attr_accessor :onCTrigger,:onBTrigger,:onUpdate
def initialize(viewport=nil)
@viewport = viewport
@onCTrigger = Event.new
@onBTrigger = Event.new
@onUpdate = Event.new
@pictures = []
@picturesprites = []
@usersprites = []
@disposed = false
end
def dispose
return if disposed?
for sprite in @picturesprites
sprite.dispose
end
for sprite in @usersprites
sprite.dispose
end
@onCTrigger.clear
@onBTrigger.clear
@onUpdate.clear
@pictures.clear
@picturesprites.clear
@usersprites.clear
@disposed = true
end
def disposed?
return @disposed
end
def addBitmap(x, y, bitmap)
# _bitmap_ can be a Bitmap or an AnimatedBitmap
# (update method isn't called if it's animated)
# EventScene doesn't take ownership of the passed-in bitmap
num = @pictures.length
picture = PictureEx.new(num)
picture.setXY(0,x,y)
picture.setVisible(0,true)
@pictures[num] = picture
@picturesprites[num] = PictureSprite.new(@viewport,picture)
@picturesprites[num].setCustomBitmap(bitmap)
return picture
end
def addLabel(x, y, width, text)
addBitmap(x,y,pbTextBitmap(text,width))
end
def addImage(x, y, name)
num = @pictures.length
picture = PictureEx.new(num)
picture.name = name
picture.setXY(0,x,y)
picture.setVisible(0,true)
@pictures[num] = picture
@picturesprites[num] = PictureSprite.new(@viewport,picture)
return picture
end
def addUserSprite(sprite)
@usersprites.push(sprite)
end
def getPicture(num)
return @pictures[num]
end
def wait(frames)
frames.times { update }
end
def pictureWait(extraframes=0)
loop do
hasRunning = false
for pic in @pictures
hasRunning = true if pic.running?
end
break if !hasRunning
update
end
extraframes.times { update }
end
def update
return if disposed?
Graphics.update
Input.update
for picture in @pictures
picture.update
end
for sprite in @picturesprites
sprite.update
end
for sprite in @usersprites
next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite)
sprite.update
end
@onUpdate.trigger(self)
if Input.trigger?(Input::B)
@onBTrigger.trigger(self)
elsif Input.trigger?(Input::C)
@onCTrigger.trigger(self)
end
end
def main
while !disposed?
update
end
end
end
#===============================================================================
#
#===============================================================================
def pbEventScreen(cls)
pbFadeOutIn {
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 99999
PBDebug.logonerr {
cls.new(viewport).main
}
viewport.dispose
}
end

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