Merge branch 'dev' into ai

This commit is contained in:
Maruno17
2023-02-05 19:10:25 +00:00
208 changed files with 3123 additions and 3331 deletions

View File

@@ -21,6 +21,10 @@ Layout/HashAlignment:
EnforcedHashRocketStyle: table EnforcedHashRocketStyle: table
EnforcedColonStyle: table EnforcedColonStyle: table
# This interferes with the presentation of some code, notably registered procs.
Layout/MultilineMethodCallBraceLayout:
Enabled: false
# This means hashes and arrays are written the same way, rather than hashes # This means hashes and arrays are written the same way, rather than hashes
# needing to be written like { foo => bar } while arrays are like [foo, bar]. # needing to be written like { foo => bar } while arrays are like [foo, bar].
Layout/SpaceInsideHashLiteralBraces: Layout/SpaceInsideHashLiteralBraces:
@@ -59,6 +63,24 @@ Naming/ClassAndModuleCamelCase:
Naming/FileName: Naming/FileName:
Enabled: false Enabled: false
# Disabled for sanity's sake. While this is a cop we want to obey, fixing all
# this is a gargantuan task that may never be completed, and we don't need
# rubocop telling us about the 4000+ instances of camelCase method names.
Naming/MethodName:
Enabled: false
# Disabled for sanity's sake. While this is a cop we want to obey, fixing all
# this is a gargantuan task that may never be completed, and we don't need
# rubocop telling us about the 1500+ instances of camelCase parameter names.
Naming/MethodParameterName:
Enabled: false
# Disabled for sanity's sake. While this is a cop we want to obey, fixing all
# this is a gargantuan task that may never be completed, and we don't need
# rubocop telling us about the 10000+ instances of camelCase variable names.
Naming/VariableName:
Enabled: false
#=============================================================================== #===============================================================================
# Security # Security
#=============================================================================== #===============================================================================
@@ -81,13 +103,21 @@ Style/AccessorGrouping:
# The assign_to_condition style looks awful, indenting loads of lines and # The assign_to_condition style looks awful, indenting loads of lines and
# increasing the separation between variable and value being assigned to it. # increasing the separation between variable and value being assigned to it.
# Having said that, using "assign_inside_condition" flags every instance of
# conditional assignment using a one-line ternary operator, so this cop has been
# disabled because such assignment is fine.
Style/ConditionalAssignment: Style/ConditionalAssignment:
Enabled: false
EnforcedStyle: assign_inside_condition EnforcedStyle: assign_inside_condition
# Check with yard instead. # Check with yard instead.
Style/Documentation: Style/Documentation:
Enabled: false Enabled: false
# This is just shorthand that looks bad due to the lack of an "end" to a "def".
Style/EndlessMethod:
EnforcedStyle: disallow
# It's a choice between format and sprintf. We already make use of sprintf and # It's a choice between format and sprintf. We already make use of sprintf and
# the translatable _ISPRINTF, so... # the translatable _ISPRINTF, so...
Style/FormatString: Style/FormatString:
@@ -106,6 +136,16 @@ Style/GlobalVars:
Style/HashSyntax: Style/HashSyntax:
EnforcedStyle: no_mixed_keys EnforcedStyle: no_mixed_keys
# Sometimes you want to clearly separate sets of code, one per "paradigm".
Style/IfInsideElse:
Enabled: false
AllowIfModifier: true
# The alernative is ->(x) { x } which is less English than "lambda". This style
# makes lambda definitions require the word "lambda".
Style/Lambda:
EnforcedStyle: lambda
# unless just adds mental gymnastics trying to figure out what it actually # unless just adds mental gymnastics trying to figure out what it actually
# means. I much prefer if !something. # means. I much prefer if !something.
Style/NegatedIf: Style/NegatedIf:
@@ -139,6 +179,11 @@ Style/SingleLineBlockParams:
Style/SingleLineMethods: Style/SingleLineMethods:
Enabled: false Enabled: false
# This requires writing array[n..] instead of array[n..-1], and I think endless
# ranges look bad.
Style/SlicingWithRange:
Enabled: false
# Single quotes being faster is hardly measurable and only affects parse time. # Single quotes being faster is hardly measurable and only affects parse time.
# Enforcing double quotes reduces the times where you need to change them # Enforcing double quotes reduces the times where you need to change them
# when introducing an interpolation or an apostrophe. Use single quotes only if # when introducing an interpolation or an apostrophe. Use single quotes only if
@@ -154,6 +199,10 @@ Style/SymbolArray:
Style/WordArray: Style/WordArray:
EnforcedStyle: brackets EnforcedStyle: brackets
# Allows procs to be written like { |obj| obj.something } which is clearer.
Style/SymbolProc:
AllowMethodsWithArguments: true
# Parentheses around the condition in a ternary operator helps to differentiate # Parentheses around the condition in a ternary operator helps to differentiate
# it from the true/false results. # it from the true/false results.
Style/TernaryParentheses: Style/TernaryParentheses:

View File

@@ -2,9 +2,7 @@
# Reads files of certain format from a directory # Reads files of certain format from a directory
#=============================================================================== #===============================================================================
class Dir class Dir
#----------------------------------------------------------------------------- # Reads all files in a directory
# Reads all files in a directory
#-----------------------------------------------------------------------------
def self.get(dir, filters = "*", full = true) def self.get(dir, filters = "*", full = true)
files = [] files = []
filters = [filters] if !filters.is_a?(Array) filters = [filters] if !filters.is_a?(Array)
@@ -15,9 +13,8 @@ class Dir
end end
return files.sort return files.sort
end end
#-----------------------------------------------------------------------------
# Generates entire file/folder tree from a certain directory # Generates entire file/folder tree from a certain directory
#-----------------------------------------------------------------------------
def self.all(dir, filters = "*", full = true) def self.all(dir, filters = "*", full = true)
# sets variables for starting # sets variables for starting
files = [] files = []
@@ -33,81 +30,67 @@ class Dir
# returns all found files # returns all found files
return files + subfolders return files + subfolders
end end
#-----------------------------------------------------------------------------
# Checks for existing directory, gets around accents # Checks for existing directory, gets around accents
#-----------------------------------------------------------------------------
def self.safe?(dir) def self.safe?(dir)
return false if !FileTest.directory?(dir) return false if !FileTest.directory?(dir)
ret = false ret = false
self.chdir(dir) { ret = true } rescue nil self.chdir(dir) { ret = true } rescue nil
return ret return ret
end end
#-----------------------------------------------------------------------------
# Creates all the required directories for filename path # Creates all the required directories for filename path
#-----------------------------------------------------------------------------
def self.create(path) def self.create(path)
path.gsub!("\\", "/") # Windows compatibility path.gsub!("\\", "/") # Windows compatibility
# get path tree # get path tree
dirs = path.split("/") dirs = path.split("/")
full = "" full = ""
for dir in dirs dirs.each do |dir|
full += dir + "/" full += dir + "/"
# creates directories # creates directories
self.mkdir(full) if !self.safe?(full) self.mkdir(full) if !self.safe?(full)
end end
end end
#-----------------------------------------------------------------------------
# Generates entire folder tree from a certain directory # Generates entire folder tree from a certain directory
#-----------------------------------------------------------------------------
def self.all_dirs(dir) def self.all_dirs(dir)
# sets variables for starting # sets variables for starting
dirs = [] dirs = []
for file in self.get(dir, "*", true) self.get(dir, "*", true).each do |file|
# engages in recursion to read the entire folder tree # engages in recursion to read the entire folder tree
dirs += self.all_dirs(file) if self.safe?(file) dirs += self.all_dirs(file) if self.safe?(file)
end end
# returns all found directories # returns all found directories
return dirs.length > 0 ? (dirs + [dir]) : [dir] return dirs.length > 0 ? (dirs + [dir]) : [dir]
end end
#-----------------------------------------------------------------------------
# Deletes all the files in a directory and all the sub directories (allows for non-empty dirs) # Deletes all the files in a directory and all the sub directories (allows for non-empty dirs)
#-----------------------------------------------------------------------------
def self.delete_all(dir) def self.delete_all(dir)
# delete all files in dir # delete all files in dir
self.all(dir).each { |f| File.delete(f) } self.all(dir).each { |f| File.delete(f) }
# delete all dirs in dir # delete all dirs in dir
self.all_dirs(dir).each { |f| Dir.delete(f) } self.all_dirs(dir).each { |f| Dir.delete(f) }
end end
#-----------------------------------------------------------------------------
end end
#=============================================================================== #===============================================================================
# extensions for file class # Extensions for file class
#=============================================================================== #===============================================================================
class File class File
#----------------------------------------------------------------------------- # Checks for existing file, gets around accents
# Checks for existing file, gets around accents
#-----------------------------------------------------------------------------
def self.safe?(file) def self.safe?(file)
ret = false ret = false
self.open(file, "rb") { ret = true } rescue nil self.open(file, "rb") { ret = true } rescue nil
return ret return ret
end end
#-----------------------------------------------------------------------------
# Checks for existing .rxdata file # Checks for existing .rxdata file
#-----------------------------------------------------------------------------
def self.safeData?(file) def self.safeData?(file)
ret = false
ret = (load_data(file) ? true : false) rescue false ret = (load_data(file) ? true : false) rescue false
return ret return ret
end end
#-----------------------------------------------------------------------------
end end
#=============================================================================== #===============================================================================
# Checking for files and directories # Checking for files and directories
#=============================================================================== #===============================================================================
@@ -137,10 +120,10 @@ def safeGlob(dir, wildcard)
ret = [] ret = []
afterChdir = false afterChdir = false
begin begin
Dir.chdir(dir) { Dir.chdir(dir) do
afterChdir = true afterChdir = true
Dir.glob(wildcard) { |f| ret.push(dir + "/" + f) } Dir.glob(wildcard) { |f| ret.push(dir + "/" + f) }
} end
rescue Errno::ENOENT rescue Errno::ENOENT
raise if afterChdir raise if afterChdir
end end
@@ -168,13 +151,13 @@ def pbResolveBitmap(x)
# filename = pbTryString(path) if !filename # filename = pbTryString(path) if !filename
# filename = pbTryString(path + ".gif") if !filename # filename = pbTryString(path + ".gif") if !filename
# } # }
RTP.eachPathFor(noext) { |path| RTP.eachPathFor(noext) do |path|
filename = pbTryString(path + ".png") if !filename filename = pbTryString(path + ".png") if !filename
filename = pbTryString(path + ".gif") if !filename filename = pbTryString(path + ".gif") if !filename
# filename = pbTryString(path + ".jpg") if !filename # filename = pbTryString(path + ".jpg") if !filename
# filename = pbTryString(path + ".jpeg") if !filename # filename = pbTryString(path + ".jpeg") if !filename
# filename = pbTryString(path + ".bmp") if !filename # filename = pbTryString(path + ".bmp") if !filename
} end
return filename return filename
end end
@@ -219,19 +202,20 @@ def canonicalize(c)
return retstr return retstr
end end
#===============================================================================
#
#===============================================================================
module RTP module RTP
@rtpPaths = nil @rtpPaths = nil
def self.exists?(filename, extensions = []) def self.exists?(filename, extensions = [])
return false if nil_or_empty?(filename) return false if nil_or_empty?(filename)
eachPathFor(filename) { |path| eachPathFor(filename) do |path|
return true if safeExists?(path) return true if safeExists?(path)
extensions.each do |ext| extensions.each do |ext|
return true if safeExists?(path + ext) return true if safeExists?(path + ext)
end end
} end
return false return false
end end
@@ -245,17 +229,17 @@ module RTP
def self.getPath(filename, extensions = []) def self.getPath(filename, extensions = [])
return filename if nil_or_empty?(filename) return filename if nil_or_empty?(filename)
eachPathFor(filename) { |path| eachPathFor(filename) do |path|
return path if safeExists?(path) return path if safeExists?(path)
extensions.each do |ext| extensions.each do |ext|
file = path + ext file = path + ext
return file if safeExists?(file) return file if safeExists?(file)
end end
} end
return filename return filename
end end
# Gets the absolute RGSS paths for the given file name # Gets the absolute RGSS paths for the given file name
def self.eachPathFor(filename) def self.eachPathFor(filename)
return if !filename return if !filename
if filename[/^[A-Za-z]\:[\/\\]/] || filename[/^[\/\\]/] if filename[/^[A-Za-z]\:[\/\\]/] || filename[/^[\/\\]/]
@@ -263,13 +247,13 @@ module RTP
yield filename yield filename
else else
# relative path # relative path
RTP.eachPath { |path| RTP.eachPath do |path|
if path == "./" if path == "./"
yield filename yield filename
else else
yield path + filename yield path + filename
end end
} end
end end
end end
@@ -299,8 +283,9 @@ module RTP
end end
end end
#===============================================================================
#
#===============================================================================
module FileTest module FileTest
IMAGE_EXTENSIONS = [".png", ".gif"] # ".jpg", ".jpeg", ".bmp", IMAGE_EXTENSIONS = [".png", ".gif"] # ".jpg", ".jpeg", ".bmp",
AUDIO_EXTENSIONS = [".mid", ".midi", ".ogg", ".wav", ".wma"] # ".mp3" AUDIO_EXTENSIONS = [".mid", ".midi", ".ogg", ".wav", ".wma"] # ".mp3"
@@ -314,27 +299,23 @@ module FileTest
end end
end end
#===============================================================================
#
#===============================================================================
# Used to determine whether a data file exists (rather than a graphics or # Used to determine whether a data file exists (rather than a graphics or
# audio file). Doesn't check RTP, but does check encrypted archives. # audio file). Doesn't check RTP, but does check encrypted archives.
# NOTE: pbGetFileChar checks anything added in MKXP's RTP setting, and matching
# NOTE: pbGetFileChar checks anything added in MKXP's RTP setting, # mount points added through System.mount.
# and matching mount points added through System.mount
def pbRgssExists?(filename) def pbRgssExists?(filename)
if safeExists?("./Game.rgssad") return !pbGetFileChar(filename).nil? if safeExists?("./Game.rgssad")
return pbGetFileChar(filename) != nil filename = canonicalize(filename)
else return safeExists?(filename)
filename = canonicalize(filename)
return safeExists?(filename)
end
end end
# Opens an IO, even if the file is in an encrypted archive. # Opens an IO, even if the file is in an encrypted archive.
# Doesn't check RTP for the file. # Doesn't check RTP for the file.
# NOTE: load_data checks anything added in MKXP's RTP setting, and matching
# NOTE: load_data checks anything added in MKXP's RTP setting, # mount points added through System.mount.
# and matching mount points added through System.mount
def pbRgssOpen(file, mode = nil) def pbRgssOpen(file, mode = nil)
# File.open("debug.txt","ab") { |fw| fw.write([file,mode,Time.now.to_f].inspect+"\r\n") } # File.open("debug.txt","ab") { |fw| fw.write([file,mode,Time.now.to_f].inspect+"\r\n") }
if !safeExists?("./Game.rgssad") if !safeExists?("./Game.rgssad")
@@ -385,9 +366,8 @@ end
# Gets the contents of a file. Doesn't check RTP, but does check # Gets the contents of a file. Doesn't check RTP, but does check
# encrypted archives. # encrypted archives.
# NOTE: load_data will check anything added in MKXP's RTP setting, and matching
# NOTE: load_data will check anything added in MKXP's RTP setting, # mount points added through System.mount.
# and matching mount points added through System.mount
def pbGetFileString(file) def pbGetFileString(file)
file = canonicalize(file) file = canonicalize(file)
if !safeExists?("./Game.rgssad") if !safeExists?("./Game.rgssad")
@@ -407,14 +387,14 @@ def pbGetFileString(file)
return str return str
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class StringInput class StringInput
include Enumerable include Enumerable
attr_reader :lineno, :string
class << self class << self
def new(str) def new(str)
if block_given? if block_given?
@@ -438,8 +418,6 @@ class StringInput
@lineno = 0 @lineno = 0
end end
attr_reader :lineno, :string
def inspect def inspect
return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0, 30].inspect}>" return "#<#{self.class}:#{@closed ? 'closed' : 'open'},src=#{@string[0, 30].inspect}>"
end end

View File

@@ -109,22 +109,21 @@ module FileOutputMixin
end end
class File < IO class File < IO
=begin # unless defined?(debugopen)
unless defined?(debugopen) # class << self
class << self # alias debugopen open
alias debugopen open # end
end # end
end
# def open(f, m = "r")
# debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") }
# if block_given?
# debugopen(f, m) { |file| yield file }
# else
# return debugopen(f, m)
# end
# end
def open(f, m = "r")
debugopen("debug.txt", "ab") { |file| file.write([f, m, Time.now.to_f].inspect + "\r\n") }
if block_given?
debugopen(f, m) { |file| yield file }
else
return debugopen(f, m)
end
end
=end
include FileInputMixin include FileInputMixin
include FileOutputMixin include FileOutputMixin
end end

View File

@@ -9,13 +9,13 @@ def pbPostData(url, postdata, filename = nil, depth = 0)
# path = $2 # path = $2
# path = "/" if path.length == 0 # path = "/" if path.length == 0
userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14" userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14"
body = postdata.map { |key, value| body = postdata.map do |key, value|
keyString = key.to_s keyString = key.to_s
valueString = value.to_s valueString = value.to_s
keyString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) } keyString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) }
valueString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) } valueString.gsub!(/[^a-zA-Z0-9_\.\-]/n) { |s| sprintf("%%%02x", s[0]) }
next "#{keyString}=#{valueString}" next "#{keyString}=#{valueString}"
}.join("&") end.join("&")
ret = HTTPLite.post_body( ret = HTTPLite.post_body(
url, url,
body, body,

View File

@@ -168,24 +168,26 @@ class Color
# New constructor, accepts RGB values as well as a hex number or string value. # New constructor, accepts RGB values as well as a hex number or string value.
def initialize(*args) def initialize(*args)
pbPrintException("Wrong number of arguments! At least 1 is needed!") if args.length < 1 pbPrintException("Wrong number of arguments! At least 1 is needed!") if args.length < 1
if args.length == 1 case args.length
if args.first.is_a?(Fixnum) when 1
case args.first
when Integer
hex = args.first.to_s(16) hex = args.first.to_s(16)
elsif args.first.is_a?(String) when String
try_rgb_format = args.first.split(",") try_rgb_format = args.first.split(",")
return init_original(*try_rgb_format.map(&:to_i)) if try_rgb_format.length.between?(3, 4) init_original(*try_rgb_format.map(&:to_i)) if try_rgb_format.length.between?(3, 4)
hex = args.first.delete("#") hex = args.first.delete("#")
end end
pbPrintException("Wrong type of argument given!") if !hex pbPrintException("Wrong type of argument given!") if !hex
r = hex[0...2].to_i(16) r = hex[0...2].to_i(16)
g = hex[2...4].to_i(16) g = hex[2...4].to_i(16)
b = hex[4...6].to_i(16) b = hex[4...6].to_i(16)
elsif args.length == 3 when 3
r, g, b = *args r, g, b = *args
end end
return init_original(r, g, b) if r && g && b init_original(r, g, b) if r && g && b
return init_original(*args) init_original(*args)
end end
def self.new_from_rgb(param) def self.new_from_rgb(param)
@@ -242,7 +244,9 @@ class Color
# @return [String] this color in the format "RRGGBBAA" (or "RRGGBB" if this color's alpha is 255) # @return [String] this color in the format "RRGGBBAA" (or "RRGGBB" if this color's alpha is 255)
def to_rgb32(always_include_alpha = false) def to_rgb32(always_include_alpha = false)
return sprintf("%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i) if self.alpha.to_i == 255 && !always_include_alpha if self.alpha.to_i == 255 && !always_include_alpha
return sprintf("%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i)
end
return sprintf("%02X%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i, self.alpha.to_i) return sprintf("%02X%02X%02X%02X", self.red.to_i, self.green.to_i, self.blue.to_i, self.alpha.to_i)
end end
@@ -253,7 +257,7 @@ class Color
# @return [Integer] this color in RGB format converted to an integer # @return [Integer] this color in RGB format converted to an integer
def to_i def to_i
return self.to_rgb24.to_i(16) return self.to_rgb24.to_i(16)
end end
# @return [Color] the contrasting color to this one # @return [Color] the contrasting color to this one
@@ -282,11 +286,11 @@ class Color
# Converts the provided hex string/24-bit integer to RGB values. # Converts the provided hex string/24-bit integer to RGB values.
def self.hex_to_rgb(hex) def self.hex_to_rgb(hex)
hex = hex.delete("#") if hex.is_a?(String) hex = hex.delete("#") if hex.is_a?(String)
hex = hex.to_s(16) if hex.is_a?(Numeric) hex = hex.to_s(16) if hex.is_a?(Numeric)
r = hex[0...2].to_i(16) r = hex[0...2].to_i(16)
g = hex[2...4].to_i(16) g = hex[2...4].to_i(16)
b = hex[4...6].to_i(16) b = hex[4...6].to_i(16)
return r, g, b return r, g, b
end end
# Parses the input as a Color and returns a Color object made from it. # Parses the input as a Color and returns a Color object made from it.

View File

@@ -45,7 +45,7 @@ module Translator
end end
end end
end end
MessageTypes.addMessagesAsHash(MessageTypes::ScriptTexts, texts) MessageTypes.addMessagesAsHash(MessageTypes::SCRIPT_TEXTS, texts)
# Find all text in common events and add them to messages # Find all text in common events and add them to messages
commonevents = load_data("Data/CommonEvents.rxdata") commonevents = load_data("Data/CommonEvents.rxdata")
items = [] items = []
@@ -87,7 +87,7 @@ module Translator
elsif list.code == 209 # Set Move Route elsif list.code == 209 # Set Move Route
route = list.parameters[1] route = list.parameters[1]
route.list.size.times do |k| route.list.size.times do |k|
if route.list[k].code == PBMoveRoute::Script if route.list[k].code == PBMoveRoute::SCRIPT
find_translatable_text_from_event_script(items, route.list[k].parameters[0]) find_translatable_text_from_event_script(items, route.list[k].parameters[0])
end end
end end
@@ -157,7 +157,7 @@ module Translator
elsif list.code == 209 # Set Move Route elsif list.code == 209 # Set Move Route
route = list.parameters[1] route = list.parameters[1]
route.list.size.times do |k| route.list.size.times do |k|
if route.list[k].code == PBMoveRoute::Script if route.list[k].code == PBMoveRoute::SCRIPT
find_translatable_text_from_event_script(items, route.list[k].parameters[0]) find_translatable_text_from_event_script(items, route.list[k].parameters[0])
end end
end end
@@ -190,7 +190,7 @@ module Translator
def find_translatable_text_from_RGSS_script(items, script) def find_translatable_text_from_RGSS_script(items, script)
script.force_encoding(Encoding::UTF_8) script.force_encoding(Encoding::UTF_8)
script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s| script.scan(/(?:_INTL|_ISPRINTF)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) do |s|
string = s[0] string = s[0]
string.gsub!(/\\r/, "\r") string.gsub!(/\\r/, "\r")
string.gsub!(/\\n/, "\n") string.gsub!(/\\n/, "\n")
@@ -198,17 +198,17 @@ module Translator
string.gsub!(/\\\"/, "\"") string.gsub!(/\\\"/, "\"")
string.gsub!(/\\\\/, "\\") string.gsub!(/\\\\/, "\\")
items.push(string) items.push(string)
} end
end end
def find_translatable_text_from_event_script(items, script) def find_translatable_text_from_event_script(items, script)
script.force_encoding(Encoding::UTF_8) script.force_encoding(Encoding::UTF_8)
script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) { |s| script.scan(/(?:_I)\s*\(\s*\"((?:[^\\\"]*\\\"?)*[^\"]*)\"/) do |s|
string = s[0] string = s[0]
string.gsub!(/\\\"/, "\"") string.gsub!(/\\\"/, "\"")
string.gsub!(/\\\\/, "\\") string.gsub!(/\\\\/, "\\")
items.push(string) items.push(string)
} end
end end
def normalize_value(value) def normalize_value(value)
@@ -239,7 +239,7 @@ module Translator
return value return value
end end
#============================================================================= #-----------------------------------------------------------------------------
def extract_text(language_name = "default", core_text = false, separate_map_files = false) def extract_text(language_name = "default", core_text = false, separate_map_files = false)
dir_name = sprintf("Text_%s_%s", language_name, (core_text) ? "core" : "game") dir_name = sprintf("Text_%s_%s", language_name, (core_text) ? "core" : "game")
@@ -267,7 +267,10 @@ module Translator
# existing destination folder # existing destination folder
if Dir.safe?(dir_name) if Dir.safe?(dir_name)
has_files = false has_files = false
Dir.all(dir_name).each { |f| has_files = true; break } Dir.all(dir_name).each do |f|
has_files = true
break
end
if has_files && !pbConfirmMessageSerious(_INTL("Replace all text files in folder '{1}'?", dir_name)) if has_files && !pbConfirmMessageSerious(_INTL("Replace all text files in folder '{1}'?", dir_name))
pbDisposeMessageWindow(msg_window) pbDisposeMessageWindow(msg_window)
return return
@@ -293,18 +296,18 @@ module Translator
max_section_id.times do |i| max_section_id.times do |i|
section_name = getConstantName(MessageTypes, i, false) section_name = getConstantName(MessageTypes, i, false)
next if !section_name next if !section_name
if i == MessageTypes::EventTexts if i == MessageTypes::EVENT_TEXTS
if separate_map_files if separate_map_files
map_infos = pbLoadMapInfos map_infos = pbLoadMapInfos
default_messages[i].each_with_index do |map_msgs, map_id| default_messages[i].each_with_index do |map_msgs, map_id|
next if !map_msgs || map_msgs.length == 0 next if !map_msgs || map_msgs.length == 0
filename = sprintf("Map%03d", map_id) filename = sprintf("Map%03d", map_id)
filename += " " + map_infos[map_id].name if map_infos[map_id] filename += " " + map_infos[map_id].name if map_infos[map_id]
File.open(dir_name + "/" + filename + ".txt", "wb") { |f| File.open(dir_name + "/" + filename + ".txt", "wb") do |f|
write_header.call(f, true) write_header.call(f, true)
translated_msgs = language_messages[i][map_id] if language_messages && language_messages[i] translated_msgs = language_messages[i][map_id] if language_messages && language_messages[i]
write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs) write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs)
} end
end end
else else
next if !default_messages[i] || default_messages[i].length == 0 next if !default_messages[i] || default_messages[i].length == 0
@@ -314,7 +317,7 @@ module Translator
break if !map_msgs break if !map_msgs
end end
next if no_difference next if no_difference
File.open(dir_name + "/" + section_name + ".txt", "wb") { |f| File.open(dir_name + "/" + section_name + ".txt", "wb") do |f|
write_header.call(f, false) write_header.call(f, false)
default_messages[i].each_with_index do |map_msgs, map_id| default_messages[i].each_with_index do |map_msgs, map_id|
next if !map_msgs || map_msgs.length == 0 next if !map_msgs || map_msgs.length == 0
@@ -322,15 +325,15 @@ module Translator
translated_msgs = (language_messages && language_messages[i]) ? language_messages[i][map_id] : nil translated_msgs = (language_messages && language_messages[i]) ? language_messages[i][map_id] : nil
write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs) write_section_texts_to_file(f, sprintf("Map%03d", map_id), translated_msgs, map_msgs)
end end
} end
end end
else # MessageTypes sections else # MessageTypes sections
next if !default_messages[i] || default_messages[i].length == 0 next if !default_messages[i] || default_messages[i].length == 0
File.open(dir_name + "/" + section_name + ".txt", "wb") { |f| File.open(dir_name + "/" + section_name + ".txt", "wb") do |f|
write_header.call(f, true) write_header.call(f, true)
translated_msgs = (language_messages) ? language_messages[i] : nil translated_msgs = (language_messages) ? language_messages[i] : nil
write_section_texts_to_file(f, section_name, translated_msgs, default_messages[i]) write_section_texts_to_file(f, section_name, translated_msgs, default_messages[i])
} end
end end
end end
msg_window.textspeed = MessageConfig.pbSettingToTextSpeed($PokemonSystem.textspeed) msg_window.textspeed = MessageConfig.pbSettingToTextSpeed($PokemonSystem.textspeed)
@@ -368,7 +371,7 @@ module Translator
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
def compile_text(dir_name, dat_filename) def compile_text(dir_name, dat_filename)
msg_window = pbCreateMessageWindow msg_window = pbCreateMessageWindow
@@ -449,16 +452,16 @@ module Translator
break if i >= contents.length break if i >= contents.length
end end
# Add ordered list/hash (text_hash) to array of all text (all_text) # Add ordered list/hash (text_hash) to array of all text (all_text)
all_text[MessageTypes::EventTexts] = [] if is_map && !all_text[MessageTypes::EventTexts] all_text[MessageTypes::EVENT_TEXTS] = [] if is_map && !all_text[MessageTypes::EVENT_TEXTS]
target_section = (is_map) ? all_text[MessageTypes::EventTexts][section_id] : all_text[section_id] target_section = (is_map) ? all_text[MessageTypes::EVENT_TEXTS][section_id] : all_text[section_id]
if target_section if target_section
if text_hash.is_a?(Hash) if text_hash.is_a?(Hash)
text_hash.keys.each { |key| target_section[key] = text_hash[key] if text_hash[key] } text_hash.each_key { |key| target_section[key] = text_hash[key] if text_hash[key] }
else # text_hash is an array else # text_hash is an array
text_hash.each_with_index { |line, i| target_section[i] = line if line } text_hash.each_with_index { |line, j| target_section[j] = line if line }
end end
elsif is_map elsif is_map
all_text[MessageTypes::EventTexts][section_id] = text_hash all_text[MessageTypes::EVENT_TEXTS][section_id] = text_hash
else else
all_text[section_id] = text_hash all_text[section_id] = text_hash
end end
@@ -567,15 +570,16 @@ class Translation
def setMapMessagesAsHash(map_id, array) def setMapMessagesAsHash(map_id, array)
load_default_messages load_default_messages
@default_game_messages[MessageTypes::EventTexts] ||= [] @default_game_messages[MessageTypes::EVENT_TEXTS] ||= []
@default_game_messages[MessageTypes::EventTexts][map_id] = priv_add_to_hash(MessageTypes::EventTexts, array, nil, map_id) @default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS,
array, nil, map_id)
end end
def addMapMessagesAsHash(map_id, array) def addMapMessagesAsHash(map_id, array)
load_default_messages load_default_messages
@default_game_messages[MessageTypes::EventTexts] ||= [] @default_game_messages[MessageTypes::EVENT_TEXTS] ||= []
@default_game_messages[MessageTypes::EventTexts][map_id] = priv_add_to_hash( @default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS,
MessageTypes::EventTexts, array, @default_game_messages[MessageTypes::EventTexts][map_id], map_id) array, @default_game_messages[MessageTypes::EVENT_TEXTS][map_id], map_id)
end end
def get(type, id) def get(type, id)
@@ -606,23 +610,25 @@ class Translation
delayed_load_message_files delayed_load_message_files
key = Translation.stringToKey(text) key = Translation.stringToKey(text)
return text if nil_or_empty?(key) return text if nil_or_empty?(key)
if @game_messages && @game_messages[MessageTypes::EventTexts] if @game_messages && @game_messages[MessageTypes::EVENT_TEXTS]
if @game_messages[MessageTypes::EventTexts][map_id] && @game_messages[MessageTypes::EventTexts][map_id][key] if @game_messages[MessageTypes::EVENT_TEXTS][map_id] && @game_messages[MessageTypes::EVENT_TEXTS][map_id][key]
return @game_messages[MessageTypes::EventTexts][map_id][key] return @game_messages[MessageTypes::EVENT_TEXTS][map_id][key]
elsif @game_messages[MessageTypes::EventTexts][0] && @game_messages[MessageTypes::EventTexts][0][key] elsif @game_messages[MessageTypes::EVENT_TEXTS][0] && @game_messages[MessageTypes::EVENT_TEXTS][0][key]
return @game_messages[MessageTypes::EventTexts][0][key] return @game_messages[MessageTypes::EVENT_TEXTS][0][key]
end end
end end
if @core_messages && @core_messages[MessageTypes::EventTexts] if @core_messages && @core_messages[MessageTypes::EVENT_TEXTS]
if @core_messages[MessageTypes::EventTexts][map_id] && @core_messages[MessageTypes::EventTexts][map_id][key] if @core_messages[MessageTypes::EVENT_TEXTS][map_id] && @core_messages[MessageTypes::EVENT_TEXTS][map_id][key]
return @core_messages[MessageTypes::EventTexts][map_id][key] return @core_messages[MessageTypes::EVENT_TEXTS][map_id][key]
elsif @core_messages[MessageTypes::EventTexts][0] && @core_messages[MessageTypes::EventTexts][0][key] elsif @core_messages[MessageTypes::EVENT_TEXTS][0] && @core_messages[MessageTypes::EVENT_TEXTS][0][key]
return @core_messages[MessageTypes::EventTexts][0][key] return @core_messages[MessageTypes::EVENT_TEXTS][0][key]
end end
end end
return text return text
end end
#-----------------------------------------------------------------------------
private private
def delayed_load_message_files def delayed_load_message_files
@@ -641,7 +647,7 @@ class Translation
end end
def priv_add_to_hash(type, array, ret, map_id = 0) def priv_add_to_hash(type, array, ret, map_id = 0)
if type == MessageTypes::EventTexts if type == MessageTypes::EVENT_TEXTS
@default_core_messages[type] ||= [] @default_core_messages[type] ||= []
@default_core_messages[type][map_id] ||= {} @default_core_messages[type][map_id] ||= {}
default_keys = @default_core_messages[type][map_id].keys default_keys = @default_core_messages[type][map_id].keys
@@ -666,36 +672,36 @@ module MessageTypes
# NOTE: These constants aren't numbered in any particular order, but these # NOTE: These constants aren't numbered in any particular order, but these
# numbers are retained for backwards compatibility with older extracted # numbers are retained for backwards compatibility with older extracted
# text files. # text files.
EventTexts = 0 # Used for text in both common events and map events EVENT_TEXTS = 0 # Used for text in both common events and map events
Species = 1 SPECIES_NAMES = 1
SpeciesCategories = 2 SPECIES_CATEGORIES = 2
PokedexEntries = 3 POKEDEX_ENTRIES = 3
SpeciesForms = 4 SPECIES_FORM_NAMES = 4
Moves = 5 MOVE_NAMES = 5
MoveDescriptions = 6 MOVE_DESCRIPTIONS = 6
Items = 7 ITEM_NAMES = 7
ItemPlurals = 8 ITEM_NAME_PLURALS = 8
ItemDescriptions = 9 ITEM_DESCRIPTIONS = 9
Abilities = 10 ABILITY_NAMES = 10
AbilityDescriptions = 11 ABILITY_DESCRIPTIONS = 11
Types = 12 TYPE_NAMES = 12
TrainerTypes = 13 TRAINER_TYPE_NAMES = 13
TrainerNames = 14 TRAINER_NAMES = 14
FrontierIntroSpeeches = 15 FRONTIER_INTRO_SPEECHES = 15
FrontierEndSpeechesWin = 16 FRONTIER_END_SPEECHES_WIN = 16
FrontierEndSpeechesLose = 17 FRONTIER_END_SPEECHES_LOSE = 17
Regions = 18 REGION_NAMES = 18
RegionLocations = 19 REGION_LOCATION_NAMES = 19
RegionDescriptions = 20 REGION_LOCATION_DESCRIPTIONS = 20
MapNames = 21 MAP_NAMES = 21
PhoneMessages = 22 PHONE_MESSAGES = 22
TrainerLoseTexts = 23 TRAINER_SPEECHES_LOSE = 23
ScriptTexts = 24 SCRIPT_TEXTS = 24
RibbonNames = 25 RIBBON_NAMES = 25
RibbonDescriptions = 26 RIBBON_DESCRIPTIONS = 26
StorageCreator = 27 STORAGE_CREATOR_NAME = 27
ItemPortions = 28 ITEM_PORTION_NAMES = 28
ItemPortionPlurals = 29 ITEM_PORTION_NAME_PLURALS = 29
@@messages = Translation.new @@messages = Translation.new
def self.load_default_messages def self.load_default_messages
@@ -762,7 +768,7 @@ end
# parameters by replacing {1}, {2}, etc. with those placeholders. # parameters by replacing {1}, {2}, etc. with those placeholders.
def _INTL(*arg) def _INTL(*arg)
begin begin
string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0]) string = MessageTypes.getFromHash(MessageTypes::SCRIPT_TEXTS, arg[0])
rescue rescue
string = arg[0] string = arg[0]
end end
@@ -778,15 +784,13 @@ end
# This version acts more like sprintf, supports e.g. {1:d} or {2:s} # This version acts more like sprintf, supports e.g. {1:d} or {2:s}
def _ISPRINTF(*arg) def _ISPRINTF(*arg)
begin begin
string = MessageTypes.getFromHash(MessageTypes::ScriptTexts, arg[0]) string = MessageTypes.getFromHash(MessageTypes::SCRIPT_TEXTS, arg[0])
rescue rescue
string = arg[0] string = arg[0]
end end
string = string.clone string = string.clone
(1...arg.length).each do |i| (1...arg.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, arg[i]) }
next sprintf("%" + $1, arg[i])
}
end end
return string return string
end end
@@ -808,9 +812,7 @@ def _MAPISPRINTF(mapid, *arg)
string = MessageTypes.getFromMapHash(mapid, arg[0]) string = MessageTypes.getFromMapHash(mapid, arg[0])
string = string.clone string = string.clone
(1...arg.length).each do |i| (1...arg.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, arg[i]) }
next sprintf("%" + $1, arg[i])
}
end end
return string return string
end end

View File

@@ -16,9 +16,7 @@ module Input
def self.update def self.update
update_KGC_ScreenCapture update_KGC_ScreenCapture
if trigger?(Input::F8) pbScreenCapture if trigger?(Input::F8)
pbScreenCapture
end
end end
end end

View File

@@ -106,9 +106,8 @@
module PluginManager module PluginManager
# Holds all registered plugin data. # Holds all registered plugin data.
@@Plugins = {} @@Plugins = {}
#-----------------------------------------------------------------------------
# Registers a plugin and tests its dependencies and incompatibilities. # Registers a plugin and tests its dependencies and incompatibilities.
#-----------------------------------------------------------------------------
def self.register(options) def self.register(options)
name = nil name = nil
version = nil version = nil
@@ -137,9 +136,7 @@ module PluginManager
end end
name = value name = value
when :version # Plugin version when :version # Plugin version
if nil_or_empty?(value) self.error("Plugin version must be a string.") if nil_or_empty?(value)
self.error("Plugin version must be a string.")
end
version = value version = value
when :essentials when :essentials
essentials = value essentials = value
@@ -289,9 +286,8 @@ module PluginManager
:credits => credits :credits => credits
} }
end end
#-----------------------------------------------------------------------------
# Throws a pure error message without stack trace or any other useless info. # Throws a pure error message without stack trace or any other useless info.
#-----------------------------------------------------------------------------
def self.error(msg) def self.error(msg)
Graphics.update Graphics.update
t = Thread.new do t = Thread.new do
@@ -304,11 +300,10 @@ module PluginManager
end end
Kernel.exit! true Kernel.exit! true
end end
#-----------------------------------------------------------------------------
# Returns true if the specified plugin is installed. # Returns true if the specified plugin is installed.
# If the version is specified, this version is taken into account. # If the version is specified, this version is taken into account.
# If mustequal is true, the version must be a match with the specified version. # If mustequal is true, the version must be a match with the specified version.
#-----------------------------------------------------------------------------
def self.installed?(plugin_name, plugin_version = nil, mustequal = false) def self.installed?(plugin_name, plugin_version = nil, mustequal = false)
plugin = @@Plugins[plugin_name] plugin = @@Plugins[plugin_name]
return false if plugin.nil? return false if plugin.nil?
@@ -317,41 +312,36 @@ module PluginManager
return true if !mustequal && comparison >= 0 return true if !mustequal && comparison >= 0
return true if mustequal && comparison == 0 return true if mustequal && comparison == 0
end end
#-----------------------------------------------------------------------------
# Returns the string names of all installed plugins. # Returns the string names of all installed plugins.
#-----------------------------------------------------------------------------
def self.plugins def self.plugins
return @@Plugins.keys return @@Plugins.keys
end end
#-----------------------------------------------------------------------------
# Returns the installed version of the specified plugin. # Returns the installed version of the specified plugin.
#-----------------------------------------------------------------------------
def self.version(plugin_name) def self.version(plugin_name)
return if !installed?(plugin_name) return if !installed?(plugin_name)
return @@Plugins[plugin_name][:version] return @@Plugins[plugin_name][:version]
end end
#-----------------------------------------------------------------------------
# Returns the link of the specified plugin. # Returns the link of the specified plugin.
#-----------------------------------------------------------------------------
def self.link(plugin_name) def self.link(plugin_name)
return if !installed?(plugin_name) return if !installed?(plugin_name)
return @@Plugins[plugin_name][:link] return @@Plugins[plugin_name][:link]
end end
#-----------------------------------------------------------------------------
# Returns the credits of the specified plugin. # Returns the credits of the specified plugin.
#-----------------------------------------------------------------------------
def self.credits(plugin_name) def self.credits(plugin_name)
return if !installed?(plugin_name) return if !installed?(plugin_name)
return @@Plugins[plugin_name][:credits] return @@Plugins[plugin_name][:credits]
end end
#-----------------------------------------------------------------------------
# Compares two versions given in string form. v1 should be the plugin version # Compares two versions given in string form. v1 should be the plugin version
# you actually have, and v2 should be the minimum/desired plugin version. # you actually have, and v2 should be the minimum/desired plugin version.
# Return values: # Return values:
# 1 if v1 is higher than v2 # 1 if v1 is higher than v2
# 0 if v1 is equal to v2 # 0 if v1 is equal to v2
# -1 if v1 is lower than v2 # -1 if v1 is lower than v2
#-----------------------------------------------------------------------------
def self.compare_versions(v1, v2) def self.compare_versions(v1, v2)
d1 = v1.chars d1 = v1.chars
d1.insert(0, "0") if d1[0] == "." # Turn ".123" into "0.123" d1.insert(0, "0") if d1[0] == "." # Turn ".123" into "0.123"
@@ -376,9 +366,8 @@ module PluginManager
end end
return 0 return 0
end end
#-----------------------------------------------------------------------------
# formats the error message # Formats the error message
#-----------------------------------------------------------------------------
def self.pluginErrorMsg(name, script) def self.pluginErrorMsg(name, script)
e = $! e = $!
# begin message formatting # begin message formatting
@@ -415,14 +404,13 @@ module PluginManager
end end
end end
end end
#-----------------------------------------------------------------------------
# Used to read the metadata file # Used to read the metadata file
#-----------------------------------------------------------------------------
def self.readMeta(dir, file) def self.readMeta(dir, file)
filename = "#{dir}/#{file}" filename = "#{dir}/#{file}"
meta = {} meta = {}
# read file # read file
Compiler.pbCompilerEachPreppedLine(filename) { |line, line_no| Compiler.pbCompilerEachPreppedLine(filename) do |line, line_no|
# split line up into property name and values # split line up into property name and values
if !line[/^\s*(\w+)\s*=\s*(.*)$/] if !line[/^\s*(\w+)\s*=\s*(.*)$/]
raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}", FileLineData.linereport) raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}", FileLineData.linereport)
@@ -466,7 +454,7 @@ module PluginManager
else else
meta[property.downcase.to_sym] = data[0] meta[property.downcase.to_sym] = data[0]
end end
} end
# generate a list of all script files to be loaded, in the order they are to # generate a list of all script files to be loaded, in the order they are to
# be loaded (files listed in the meta file are loaded first) # be loaded (files listed in the meta file are loaded first)
meta[:scripts] = [] if !meta[:scripts] meta[:scripts] = [] if !meta[:scripts]
@@ -480,9 +468,8 @@ module PluginManager
# return meta hash # return meta hash
return meta return meta
end end
#-----------------------------------------------------------------------------
# Get a list of all the plugin directories to inspect # Get a list of all the plugin directories to inspect
#-----------------------------------------------------------------------------
def self.listAll def self.listAll
return [] if !$DEBUG || safeExists?("Game.rgssad") || !Dir.safe?("Plugins") return [] if !$DEBUG || safeExists?("Game.rgssad") || !Dir.safe?("Plugins")
# get a list of all directories in the `Plugins/` folder # get a list of all directories in the `Plugins/` folder
@@ -491,9 +478,8 @@ module PluginManager
# return all plugins # return all plugins
return dirs return dirs
end end
#-----------------------------------------------------------------------------
# Catch any potential loop with dependencies and raise an error # Catch any potential loop with dependencies and raise an error
#-----------------------------------------------------------------------------
def self.validateDependencies(name, meta, og = nil) def self.validateDependencies(name, meta, og = nil)
# exit if no registered dependency # exit if no registered dependency
return nil if !meta[name] || !meta[name][:dependencies] return nil if !meta[name] || !meta[name][:dependencies]
@@ -511,9 +497,8 @@ module PluginManager
end end
return name return name
end end
#-----------------------------------------------------------------------------
# Sort load order based on dependencies (this ends up in reverse order) # Sort load order based on dependencies (this ends up in reverse order)
#-----------------------------------------------------------------------------
def self.sortLoadOrder(order, plugins) def self.sortLoadOrder(order, plugins)
# go through the load order # go through the load order
order.each do |o| order.each do |o|
@@ -540,9 +525,8 @@ module PluginManager
end end
return order return order
end end
#-----------------------------------------------------------------------------
# Get the order in which to load plugins # Get the order in which to load plugins
#-----------------------------------------------------------------------------
def self.getPluginOrder def self.getPluginOrder
plugins = {} plugins = {}
order = [] order = []
@@ -568,9 +552,8 @@ module PluginManager
# sort the load order # sort the load order
return self.sortLoadOrder(order, plugins).reverse, plugins return self.sortLoadOrder(order, plugins).reverse, plugins
end end
#-----------------------------------------------------------------------------
# Check if plugins need compiling # Check if plugins need compiling
#-----------------------------------------------------------------------------
def self.needCompiling?(order, plugins) def self.needCompiling?(order, plugins)
# fixed actions # fixed actions
return false if !$DEBUG || safeExists?("Game.rgssad") return false if !$DEBUG || safeExists?("Game.rgssad")
@@ -590,9 +573,8 @@ module PluginManager
end end
return false return false
end end
#-----------------------------------------------------------------------------
# Check if plugins need compiling # Check if plugins need compiling
#-----------------------------------------------------------------------------
def self.compilePlugins(order, plugins) def self.compilePlugins(order, plugins)
Console.echo_li("Compiling plugin scripts...") Console.echo_li("Compiling plugin scripts...")
scripts = [] scripts = []
@@ -618,9 +600,8 @@ module PluginManager
GC.start GC.start
Console.echo_done(true) Console.echo_done(true)
end end
#-----------------------------------------------------------------------------
# Check if plugins need compiling # Check if plugins need compiling
#-----------------------------------------------------------------------------
def self.runPlugins def self.runPlugins
Console.echo_h1("Checking plugins") Console.echo_h1("Checking plugins")
# get the order of plugins to interpret # get the order of plugins to interpret
@@ -668,9 +649,8 @@ module PluginManager
Console.echoln_li_done("No plugins found") Console.echoln_li_done("No plugins found")
end end
end end
#-----------------------------------------------------------------------------
# Get plugin dir from name based on meta entries # Get plugin dir from name based on meta entries
#-----------------------------------------------------------------------------
def self.findDirectory(name) def self.findDirectory(name)
# go through the plugins folder # go through the plugins folder
Dir.get("Plugins").each do |dir| Dir.get("Plugins").each do |dir|
@@ -683,5 +663,4 @@ module PluginManager
# return nil if no plugin dir found # return nil if no plugin dir found
return nil return nil
end end
#-----------------------------------------------------------------------------
end end

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class SpriteAnimation class SpriteAnimation
@@_animations = [] @@_animations = []
@@_reference_count = {} @@_reference_count = {}
@@ -53,9 +56,7 @@ class SpriteAnimation
sprite.visible = false sprite.visible = false
@_animation_sprites.push(sprite) @_animation_sprites.push(sprite)
end end
unless @@_animations.include?(animation) @@_animations.push(animation) unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end end
update_animation update_animation
end end
@@ -94,13 +95,9 @@ class SpriteAnimation
sprite = @_animation_sprites[0] sprite = @_animation_sprites[0]
if sprite if sprite
@@_reference_count[sprite.bitmap] -= 1 @@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0 sprite.bitmap.dispose if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
@_animation_sprites.each do |sprite|
sprite.dispose
end end
@_animation_sprites.each { |s| s.dispose }
@_animation_sprites = nil @_animation_sprites = nil
@_animation = nil @_animation = nil
end end
@@ -110,13 +107,9 @@ class SpriteAnimation
sprite = @_loop_animation_sprites[0] sprite = @_loop_animation_sprites[0]
if sprite if sprite
@@_reference_count[sprite.bitmap] -= 1 @@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0 sprite.bitmap.dispose if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
@_loop_animation_sprites.each do |sprite|
sprite.dispose
end end
@_loop_animation_sprites.each { |s| s.dispose }
@_loop_animation_sprites = nil @_loop_animation_sprites = nil
@_loop_animation = nil @_loop_animation = nil
end end
@@ -262,8 +255,9 @@ class SpriteAnimation
end end
end end
#===============================================================================
#
#===============================================================================
module RPG module RPG
class Sprite < ::Sprite class Sprite < ::Sprite
def initialize(viewport = nil) def initialize(viewport = nil)
@@ -465,9 +459,7 @@ module RPG
@_damage_sprite.y += 4 @_damage_sprite.y += 4
end end
@_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32) @_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32)
if @_damage_duration == 0 dispose_damage if @_damage_duration == 0
dispose_damage
end
end end
@animations.each do |a| @animations.each do |a|
a.update a.update

View File

@@ -99,6 +99,8 @@ module SaveData
return @old_format_get_proc.call(old_format) return @old_format_get_proc.call(old_format)
end end
#---------------------------------------------------------------------------
private private
# Raises an {InvalidValueError} if the given value is invalid. # Raises an {InvalidValueError} if the given value is invalid.

View File

@@ -71,6 +71,8 @@ module SaveData
@value_procs[key].call(object) if @value_procs[key].is_a?(Proc) @value_procs[key].call(object) if @value_procs[key].is_a?(Proc)
end end
#---------------------------------------------------------------------------
private private
# @!group Configuration # @!group Configuration

View File

@@ -4,11 +4,7 @@ SaveData.register(:player) do
ensure_class :Player ensure_class :Player
save_value { $player } save_value { $player }
load_value { |value| $player = $Trainer = value } load_value { |value| $player = $Trainer = value }
new_game_value { new_game_value { Player.new("Unnamed", GameData::TrainerType.keys.first) }
# Get the first defined trainer type as a placeholder
trainer_type = GameData::TrainerType.keys.first
Player.new("Unnamed", trainer_type)
}
from_old_format { |old_format| old_format[0] } from_old_format { |old_format| old_format[0] }
end end

View File

@@ -75,9 +75,7 @@ module Game
$game_map = $map_factory.map $game_map = $map_factory.map
magic_number_matches = ($game_system.magic_number == $data_system.magic_number) magic_number_matches = ($game_system.magic_number == $data_system.magic_number)
if !magic_number_matches || $PokemonGlobal.safesave if !magic_number_matches || $PokemonGlobal.safesave
if pbMapInterpreterRunning? pbMapInterpreter.setup(nil, 0) if pbMapInterpreterRunning?
pbMapInterpreter.setup(nil, 0)
end
begin begin
$map_factory.setup($game_map.map_id) $map_factory.setup($game_map.map_id)
rescue Errno::ENOENT rescue Errno::ENOENT

View File

@@ -197,9 +197,7 @@ class Scene_Map
$game_temp.menu_beep = true $game_temp.menu_beep = true
end end
elsif Input.trigger?(Input::SPECIAL) elsif Input.trigger?(Input::SPECIAL)
unless $game_player.moving? $game_temp.ready_menu_calling = true if !$game_player.moving?
$game_temp.ready_menu_calling = true
end
elsif Input.press?(Input::F9) elsif Input.press?(Input::F9)
$game_temp.debug_calling = true if $DEBUG $game_temp.debug_calling = true if $DEBUG
end end

View File

@@ -5,11 +5,9 @@
# Game_System class and the Game_Event class. # Game_System class and the Game_Event class.
#=============================================================================== #===============================================================================
class Interpreter class Interpreter
#----------------------------------------------------------------------------- # Object Initialization
# * Object Initialization
# depth : nest depth # depth : nest depth
# main : main flag # main : main flag
#-----------------------------------------------------------------------------
def initialize(depth = 0, main = false) def initialize(depth = 0, main = false)
@depth = depth @depth = depth
@main = main @main = main
@@ -39,11 +37,10 @@ class Interpreter
@renamed_choices = [] @renamed_choices = []
end_follower_overrides end_follower_overrides
end end
#-----------------------------------------------------------------------------
# * Event Setup # Event Setup
# list : list of event commands # list : list of event commands
# event_id : event ID # event_id : event ID
#-----------------------------------------------------------------------------
def setup(list, event_id, map_id = nil) def setup(list, event_id, map_id = nil)
clear clear
@map_id = map_id || $game_map.map_id @map_id = map_id || $game_map.map_id
@@ -82,9 +79,7 @@ class Interpreter
def running? def running?
return !@list.nil? return !@list.nil?
end end
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update def update
@loop_count = 0 @loop_count = 0
loop do loop do
@@ -135,9 +130,7 @@ class Interpreter
@index += 1 @index += 1
end end
end end
#-----------------------------------------------------------------------------
# * Execute script
#-----------------------------------------------------------------------------
def execute_script(script) def execute_script(script)
begin begin
result = eval(script) result = eval(script)
@@ -150,13 +143,13 @@ class Interpreter
message = pbGetExceptionMessage(e) message = pbGetExceptionMessage(e)
backtrace_text = "" backtrace_text = ""
if e.is_a?(SyntaxError) if e.is_a?(SyntaxError)
script.each_line { |line| script.each_line do |line|
line.gsub!(/\s+$/, "") line.gsub!(/\s+$/, "")
if line[/^\s*\(/] if line[/^\s*\(/]
message += "\r\n***Line '#{line}' shouldn't begin with '('. Try putting the '('\r\n" message += "\r\n***Line '#{line}' shouldn't begin with '('. Try putting the '('\r\n"
message += "at the end of the previous line instead, or using 'extendtext.exe'." message += "at the end of the previous line instead, or using 'extendtext.exe'."
end end
} end
else else
backtrace_text += "\r\n" backtrace_text += "\r\n"
backtrace_text += "Backtrace:" backtrace_text += "Backtrace:"
@@ -182,10 +175,7 @@ class Interpreter
raise EventScriptError.new(err) raise EventScriptError.new(err)
end end
end end
#-----------------------------------------------------------------------------
# * Get Character
# parameter : parameter
#-----------------------------------------------------------------------------
def get_character(parameter = 0) def get_character(parameter = 0)
case parameter case parameter
when -1 # player when -1 # player
@@ -210,21 +200,18 @@ class Interpreter
def get_event(parameter) def get_event(parameter)
return get_character(parameter) return get_character(parameter)
end end
#-----------------------------------------------------------------------------
# * Freezes all events on the map (for use at the beginning of common events) # Freezes all events on the map (for use at the beginning of common events)
#-----------------------------------------------------------------------------
def pbGlobalLock def pbGlobalLock
$game_map.events.each_value { |event| event.minilock } $game_map.events.each_value { |event| event.minilock }
end end
#-----------------------------------------------------------------------------
# * Unfreezes all events on the map (for use at the end of common events) # Unfreezes all events on the map (for use at the end of common events)
#-----------------------------------------------------------------------------
def pbGlobalUnlock def pbGlobalUnlock
$game_map.events.each_value { |event| event.unlock } $game_map.events.each_value { |event| event.unlock }
end end
#-----------------------------------------------------------------------------
# * Gets the next index in the interpreter, ignoring certain commands between messages # Gets the next index in the interpreter, ignoring certain commands between messages
#-----------------------------------------------------------------------------
def pbNextIndex(index) def pbNextIndex(index)
return -1 if !@list || @list.length == 0 return -1 if !@list || @list.length == 0
i = index + 1 i = index + 1
@@ -292,9 +279,6 @@ class Interpreter
@follower_animation_id = nil @follower_animation_id = nil
end end
#-----------------------------------------------------------------------------
# * Various methods to be used in a script event command.
#-----------------------------------------------------------------------------
# Helper function that shows a picture in a script. # Helper function that shows a picture in a script.
def pbShowPicture(number, name, origin, x, y, zoomX = 100, zoomY = 100, opacity = 255, blendType = 0) def pbShowPicture(number, name, origin, x, y, zoomX = 100, zoomY = 100, opacity = 255, blendType = 0)
number += ($game_temp.in_battle ? 50 : 0) number += ($game_temp.in_battle ? 50 : 0)

View File

@@ -121,6 +121,7 @@ class Interpreter
def command_dummy def command_dummy
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * End Event # * End Event
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -132,6 +133,7 @@ class Interpreter
$game_map.events[@event_id].unlock $game_map.events[@event_id].unlock
end end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Command Skip # * Command Skip
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -142,6 +144,7 @@ class Interpreter
@index += 1 @index += 1
end end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Command If # * Command If
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -152,6 +155,7 @@ class Interpreter
end end
return command_skip return command_skip
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Show Text # * Show Text
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -203,6 +207,7 @@ class Interpreter
@message_waiting = false @message_waiting = false
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Show Choices # * Show Choices
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -289,6 +294,7 @@ class Interpreter
return if !condition || nil_or_empty?(new_name) return if !condition || nil_or_empty?(new_name)
@renamed_choices[number - 1] = new_name @renamed_choices[number - 1] = new_name
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * When [**] # * When [**]
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -300,6 +306,7 @@ class Interpreter
end end
return command_skip return command_skip
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * When Cancel # * When Cancel
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -311,6 +318,7 @@ class Interpreter
end end
return command_skip return command_skip
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Input Number # * Input Number
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -325,6 +333,7 @@ class Interpreter
@message_waiting = false @message_waiting = false
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Text Options # * Change Text Options
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -334,6 +343,7 @@ class Interpreter
$game_system.message_frame = @parameters[1] $game_system.message_frame = @parameters[1]
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Button Input Processing # * Button Input Processing
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -371,6 +381,7 @@ class Interpreter
@index += 1 @index += 1
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Wait # * Wait
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -378,6 +389,7 @@ class Interpreter
@wait_count = @parameters[0] * Graphics.frame_rate / 20 @wait_count = @parameters[0] * Graphics.frame_rate / 20
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Conditional Branch # * Conditional Branch
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -433,6 +445,7 @@ class Interpreter
end end
return command_skip return command_skip
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Else # * Else
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -443,12 +456,14 @@ class Interpreter
end end
return command_skip return command_skip
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Loop # * Loop
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def command_112 def command_112
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Repeat Above # * Repeat Above
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -459,6 +474,7 @@ class Interpreter
return true if @list[@index].indent == indent return true if @list[@index].indent == indent
end end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Break Loop # * Break Loop
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -475,6 +491,7 @@ class Interpreter
end end
end end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Exit Event Processing # * Exit Event Processing
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -482,6 +499,7 @@ class Interpreter
command_end command_end
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Erase Event # * Erase Event
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -493,6 +511,7 @@ class Interpreter
@index += 1 @index += 1
return false return false
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Call Common Event # * Call Common Event
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -504,12 +523,14 @@ class Interpreter
end end
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Label # * Label
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def command_118 def command_118
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Jump to Label # * Jump to Label
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -528,6 +549,7 @@ class Interpreter
temp_index += 1 temp_index += 1
end end
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Control Switches # * Control Switches
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -542,6 +564,7 @@ class Interpreter
$game_map.need_refresh = true if should_refresh $game_map.need_refresh = true if should_refresh
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Control Variables # * Control Variables
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -606,6 +629,7 @@ class Interpreter
end end
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Control Self Switch # * Control Self Switch
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -620,6 +644,7 @@ class Interpreter
end end
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Control Timer # * Control Timer
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -628,6 +653,7 @@ class Interpreter
$game_system.timer = @parameters[1] * Graphics.frame_rate if @parameters[0] == 0 $game_system.timer = @parameters[1] * Graphics.frame_rate if @parameters[0] == 0
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Gold # * Change Gold
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -642,6 +668,7 @@ class Interpreter
def command_127; command_dummy; end # Change Weapons def command_127; command_dummy; end # Change Weapons
def command_128; command_dummy; end # Change Armor def command_128; command_dummy; end # Change Armor
def command_129; command_dummy; end # Change Party Member def command_129; command_dummy; end # Change Party Member
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Windowskin # * Change Windowskin
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -654,6 +681,7 @@ class Interpreter
end end
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Battle BGM # * Change Battle BGM
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -661,10 +689,12 @@ class Interpreter
($PokemonGlobal.nextBattleBGM = @parameters[0]) ? @parameters[0].clone : nil ($PokemonGlobal.nextBattleBGM = @parameters[0]) ? @parameters[0].clone : nil
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Battle End ME # * Change Battle End ME
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def command_133; command_dummy; end def command_133; command_dummy; end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Save Access # * Change Save Access
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -672,6 +702,7 @@ class Interpreter
$game_system.save_disabled = (@parameters[0] == 0) $game_system.save_disabled = (@parameters[0] == 0)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Menu Access # * Change Menu Access
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -679,6 +710,7 @@ class Interpreter
$game_system.menu_disabled = (@parameters[0] == 0) $game_system.menu_disabled = (@parameters[0] == 0)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Encounter # * Change Encounter
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -687,6 +719,7 @@ class Interpreter
$game_player.make_encounter_count $game_player.make_encounter_count
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Transfer Player # * Transfer Player
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -716,6 +749,7 @@ class Interpreter
end end
return false return false
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Set Event Location # * Set Event Location
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -747,6 +781,7 @@ class Interpreter
end end
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Scroll Map # * Scroll Map
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -756,6 +791,7 @@ class Interpreter
$game_map.start_scroll(@parameters[0], @parameters[1], @parameters[2]) $game_map.start_scroll(@parameters[0], @parameters[1], @parameters[2])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Map Settings # * Change Map Settings
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -778,6 +814,7 @@ class Interpreter
end end
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Fog Color Tone # * Change Fog Color Tone
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -785,6 +822,7 @@ class Interpreter
$game_map.start_fog_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) $game_map.start_fog_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Fog Opacity # * Change Fog Opacity
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -792,6 +830,7 @@ class Interpreter
$game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) $game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Show Animation # * Show Animation
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -806,6 +845,7 @@ class Interpreter
character.animation_id = @parameters[1] character.animation_id = @parameters[1]
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Transparent Flag # * Change Transparent Flag
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -813,6 +853,7 @@ class Interpreter
$game_player.transparent = (@parameters[0] == 0) $game_player.transparent = (@parameters[0] == 0)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Set Move Route # * Set Move Route
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -827,6 +868,7 @@ class Interpreter
character.force_move_route(@parameters[1]) character.force_move_route(@parameters[1])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Wait for Move's Completion # * Wait for Move's Completion
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -834,6 +876,7 @@ class Interpreter
@move_route_waiting = true if !$game_temp.in_battle @move_route_waiting = true if !$game_temp.in_battle
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Prepare for Transition # * Prepare for Transition
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -842,6 +885,7 @@ class Interpreter
Graphics.freeze Graphics.freeze
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Execute Transition # * Execute Transition
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -852,6 +896,7 @@ class Interpreter
@index += 1 @index += 1
return false return false
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Screen Color Tone # * Change Screen Color Tone
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -859,6 +904,7 @@ class Interpreter
$game_screen.start_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) $game_screen.start_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Screen Flash # * Screen Flash
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -866,6 +912,7 @@ class Interpreter
$game_screen.start_flash(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) $game_screen.start_flash(@parameters[0], @parameters[1] * Graphics.frame_rate / 20)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Screen Shake # * Screen Shake
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -873,6 +920,7 @@ class Interpreter
$game_screen.start_shake(@parameters[0], @parameters[1], @parameters[2] * Graphics.frame_rate / 20) $game_screen.start_shake(@parameters[0], @parameters[1], @parameters[2] * Graphics.frame_rate / 20)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Show Picture # * Show Picture
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -889,6 +937,7 @@ class Interpreter
x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9]) x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Move Picture # * Move Picture
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -905,6 +954,7 @@ class Interpreter
@parameters[2], x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9]) @parameters[2], x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Rotate Picture # * Rotate Picture
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -913,6 +963,7 @@ class Interpreter
$game_screen.pictures[number].rotate(@parameters[1]) $game_screen.pictures[number].rotate(@parameters[1])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Change Picture Color Tone # * Change Picture Color Tone
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -922,6 +973,7 @@ class Interpreter
@parameters[2] * Graphics.frame_rate / 20) @parameters[2] * Graphics.frame_rate / 20)
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Erase Picture # * Erase Picture
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -930,6 +982,7 @@ class Interpreter
$game_screen.pictures[number].erase $game_screen.pictures[number].erase
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Set Weather Effects # * Set Weather Effects
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -937,6 +990,7 @@ class Interpreter
$game_screen.weather(@parameters[0], @parameters[1], @parameters[2]) $game_screen.weather(@parameters[0], @parameters[1], @parameters[2])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Play BGM # * Play BGM
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -944,6 +998,7 @@ class Interpreter
pbBGMPlay(@parameters[0]) pbBGMPlay(@parameters[0])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Fade Out BGM # * Fade Out BGM
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -951,6 +1006,7 @@ class Interpreter
pbBGMFade(@parameters[0]) pbBGMFade(@parameters[0])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Play BGS # * Play BGS
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -958,6 +1014,7 @@ class Interpreter
pbBGSPlay(@parameters[0]) pbBGSPlay(@parameters[0])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Fade Out BGS # * Fade Out BGS
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -965,6 +1022,7 @@ class Interpreter
pbBGSFade(@parameters[0]) pbBGSFade(@parameters[0])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Memorize BGM/BGS # * Memorize BGM/BGS
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -973,6 +1031,7 @@ class Interpreter
$game_system.bgs_memorize $game_system.bgs_memorize
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Restore BGM/BGS # * Restore BGM/BGS
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -981,6 +1040,7 @@ class Interpreter
$game_system.bgs_restore $game_system.bgs_restore
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Play ME # * Play ME
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -988,6 +1048,7 @@ class Interpreter
pbMEPlay(@parameters[0]) pbMEPlay(@parameters[0])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Play SE # * Play SE
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -995,6 +1056,7 @@ class Interpreter
pbSEPlay(@parameters[0]) pbSEPlay(@parameters[0])
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Stop SE # * Stop SE
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -1008,6 +1070,7 @@ class Interpreter
def command_602; command_if(1); end # If Escape def command_602; command_if(1); end # If Escape
def command_603; command_if(2); end # If Lose def command_603; command_if(2); end # If Lose
def command_302; command_dummy; end # Shop Processing def command_302; command_dummy; end # Shop Processing
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Name Input Processing # * Name Input Processing
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -1018,14 +1081,14 @@ class Interpreter
end end
if $game_actors && $data_actors && $data_actors[@parameters[0]] if $game_actors && $data_actors && $data_actors[@parameters[0]]
$game_temp.battle_abort = true $game_temp.battle_abort = true
pbFadeOutIn { pbFadeOutIn do
sscene = PokemonEntryScene.new sscene = PokemonEntryScene.new
sscreen = PokemonEntry.new(sscene) sscreen = PokemonEntry.new(sscene)
$game_actors[@parameters[0]].name = sscreen.pbStartScreen( $game_actors[@parameters[0]].name = sscreen.pbStartScreen(
_INTL("Enter {1}'s name.", $game_actors[@parameters[0]].name), _INTL("Enter {1}'s name.", $game_actors[@parameters[0]].name),
1, @parameters[1], $game_actors[@parameters[0]].name 1, @parameters[1], $game_actors[@parameters[0]].name
) )
} end
end end
return true return true
end end
@@ -1033,6 +1096,7 @@ class Interpreter
def command_311; command_dummy; end # Change HP def command_311; command_dummy; end # Change HP
def command_312; command_dummy; end # Change SP def command_312; command_dummy; end # Change SP
def command_313; command_dummy; end # Change State def command_313; command_dummy; end # Change State
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Recover All # * Recover All
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -1065,6 +1129,7 @@ class Interpreter
def command_338; command_dummy; end # Deal Damage def command_338; command_dummy; end # Deal Damage
def command_339; command_dummy; end # Force Action def command_339; command_dummy; end # Force Action
def command_340; command_dummy; end # Abort Battle def command_340; command_dummy; end # Abort Battle
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Call Menu Screen # * Call Menu Screen
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -1073,6 +1138,7 @@ class Interpreter
@index += 1 @index += 1
return false return false
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Call Save Screen # * Call Save Screen
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -1082,6 +1148,7 @@ class Interpreter
screen.pbSaveScreen screen.pbSaveScreen
return true return true
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Game Over # * Game Over
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -1090,6 +1157,7 @@ class Interpreter
pbBGSFade(1.0) pbBGSFade(1.0)
pbFadeOutIn { pbStartOver(true) } pbFadeOutIn { pbStartOver(true) }
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Return to Title Screen # * Return to Title Screen
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
@@ -1097,6 +1165,7 @@ class Interpreter
$game_temp.title_screen_calling = true $game_temp.title_screen_calling = true
return false return false
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# * Script # * Script
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------

View File

@@ -5,9 +5,6 @@
# flashing, etc. Refer to "$game_screen" for the instance of this class. # flashing, etc. Refer to "$game_screen" for the instance of this class.
#=============================================================================== #===============================================================================
class Game_Screen class Game_Screen
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_reader :brightness # brightness attr_reader :brightness # brightness
attr_reader :tone # color tone attr_reader :tone # color tone
attr_reader :flash_color # flash color attr_reader :flash_color # flash color
@@ -17,9 +14,6 @@ class Game_Screen
attr_reader :weather_max # max number of weather sprites attr_reader :weather_max # max number of weather sprites
attr_accessor :weather_duration # ticks in which the weather should fade in attr_accessor :weather_duration # ticks in which the weather should fade in
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize def initialize
@brightness = 255 @brightness = 255
@fadeout_duration = 0 @fadeout_duration = 0
@@ -42,52 +36,30 @@ class Game_Screen
@weather_max = 0.0 @weather_max = 0.0
@weather_duration = 0 @weather_duration = 0
end end
#-----------------------------------------------------------------------------
# * Start Changing Color Tone
# tone : color tone
# duration : time
#-----------------------------------------------------------------------------
def start_tone_change(tone, duration) def start_tone_change(tone, duration)
@tone_target = tone.clone @tone_target = tone.clone
@tone_duration = duration @tone_duration = duration
if @tone_duration == 0 @tone = @tone_target.clone if @tone_duration == 0
@tone = @tone_target.clone
end
end end
#-----------------------------------------------------------------------------
# * Start Flashing
# color : color
# duration : time
#-----------------------------------------------------------------------------
def start_flash(color, duration) def start_flash(color, duration)
@flash_color = color.clone @flash_color = color.clone
@flash_duration = duration @flash_duration = duration
end end
#-----------------------------------------------------------------------------
# * Start Shaking
# power : strength
# speed : speed
# duration : time
#-----------------------------------------------------------------------------
def start_shake(power, speed, duration) def start_shake(power, speed, duration)
@shake_power = power @shake_power = power
@shake_speed = speed @shake_speed = speed
@shake_duration = duration @shake_duration = duration
end end
#-----------------------------------------------------------------------------
# * Set Weather
# type : type
# power : strength
# duration : time
#-----------------------------------------------------------------------------
def weather(type, power, duration) def weather(type, power, duration)
@weather_type = GameData::Weather.get(type).id @weather_type = GameData::Weather.get(type).id
@weather_max = (power + 1) * RPG::Weather::MAX_SPRITES / 10 @weather_max = (power + 1) * RPG::Weather::MAX_SPRITES / 10
@weather_duration = duration # In 1/20ths of a seconds @weather_duration = duration # In 1/20ths of a seconds
end end
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update def update
if @fadeout_duration && @fadeout_duration >= 1 if @fadeout_duration && @fadeout_duration >= 1
d = @fadeout_duration d = @fadeout_duration

View File

@@ -5,25 +5,20 @@
# Refer to "$game_switches" for the instance of this class. # Refer to "$game_switches" for the instance of this class.
#=============================================================================== #===============================================================================
class Game_Switches class Game_Switches
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize def initialize
@data = [] @data = []
end end
#-----------------------------------------------------------------------------
# * Get Switch # Get Switch
# switch_id : switch ID # switch_id : switch ID
#-----------------------------------------------------------------------------
def [](switch_id) def [](switch_id)
return @data[switch_id] if switch_id <= 5000 && @data[switch_id] return @data[switch_id] if switch_id <= 5000 && @data[switch_id]
return false return false
end end
#-----------------------------------------------------------------------------
# * Set Switch # Set Switch
# switch_id : switch ID # switch_id : switch ID
# value : ON (true) / OFF (false) # value : ON (true) / OFF (false)
#-----------------------------------------------------------------------------
def []=(switch_id, value) def []=(switch_id, value)
@data[switch_id] = value if switch_id <= 5000 @data[switch_id] = value if switch_id <= 5000
end end

View File

@@ -5,25 +5,20 @@
# Refer to "$game_variables" for the instance of this class. # Refer to "$game_variables" for the instance of this class.
#=============================================================================== #===============================================================================
class Game_Variables class Game_Variables
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize def initialize
@data = [] @data = []
end end
#-----------------------------------------------------------------------------
# * Get Variable # Get Variable
# variable_id : variable ID # variable_id : variable ID
#-----------------------------------------------------------------------------
def [](variable_id) def [](variable_id)
return @data[variable_id] if variable_id <= 5000 && !@data[variable_id].nil? return @data[variable_id] if variable_id <= 5000 && !@data[variable_id].nil?
return 0 return 0
end end
#-----------------------------------------------------------------------------
# * Set Variable # Set Variable
# variable_id : variable ID # variable_id : variable ID
# value : the variable's value # value : the variable's value
#-----------------------------------------------------------------------------
def []=(variable_id, value) def []=(variable_id, value)
@data[variable_id] = value if variable_id <= 5000 @data[variable_id] = value if variable_id <= 5000
end end

View File

@@ -5,24 +5,19 @@
# "Hash." Refer to "$game_self_switches" for the instance of this class. # "Hash." Refer to "$game_self_switches" for the instance of this class.
#=============================================================================== #===============================================================================
class Game_SelfSwitches class Game_SelfSwitches
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize def initialize
@data = {} @data = {}
end end
#-----------------------------------------------------------------------------
# * Get Self Switch # Get Self Switch
# key : key # key : key
#-----------------------------------------------------------------------------
def [](key) def [](key)
return @data[key] == true return @data[key] == true
end end
#-----------------------------------------------------------------------------
# * Set Self Switch # Set Self Switch
# key : key # key : key
# value : ON (true) / OFF (false) # value : ON (true) / OFF (false)
#-----------------------------------------------------------------------------
def []=(key, value) def []=(key, value)
@data[key] = value @data[key] = value
end end

View File

@@ -4,11 +4,7 @@
# This class handles the picture. It's used within the Game_Screen class # This class handles the picture. It's used within the Game_Screen class
# ($game_screen). # ($game_screen).
#=============================================================================== #===============================================================================
class Game_Picture class Game_Picture
#-----------------------------------------------------------------------------
# * Public Instance Variables
#-----------------------------------------------------------------------------
attr_reader :number # picture number attr_reader :number # picture number
attr_reader :name # file name attr_reader :name # file name
attr_reader :origin # starting point attr_reader :origin # starting point
@@ -21,10 +17,6 @@ class Game_Picture
attr_reader :tone # color tone attr_reader :tone # color tone
attr_reader :angle # rotation angle attr_reader :angle # rotation angle
#-----------------------------------------------------------------------------
# * Object Initialization
# number : picture number
#-----------------------------------------------------------------------------
def initialize(number) def initialize(number)
@number = number @number = number
@name = "" @name = ""
@@ -47,8 +39,8 @@ class Game_Picture
@angle = 0 @angle = 0
@rotate_speed = 0 @rotate_speed = 0
end end
#-----------------------------------------------------------------------------
# * Show Picture # Show Picture
# name : file name # name : file name
# origin : starting point # origin : starting point
# x : x-coordinate # x : x-coordinate
@@ -57,7 +49,6 @@ class Game_Picture
# zoom_y : y directional zoom rate # zoom_y : y directional zoom rate
# opacity : opacity level # opacity : opacity level
# blend_type : blend method # blend_type : blend method
#-----------------------------------------------------------------------------
def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type) def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
@name = name @name = name
@origin = origin @origin = origin
@@ -79,8 +70,8 @@ class Game_Picture
@angle = 0 @angle = 0
@rotate_speed = 0 @rotate_speed = 0
end end
#-----------------------------------------------------------------------------
# * Move Picture # Move Picture
# duration : time # duration : time
# origin : starting point # origin : starting point
# x : x-coordinate # x : x-coordinate
@@ -89,7 +80,6 @@ class Game_Picture
# zoom_y : y directional zoom rate # zoom_y : y directional zoom rate
# opacity : opacity level # opacity : opacity level
# blend_type : blend method # blend_type : blend method
#-----------------------------------------------------------------------------
def move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type) def move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
@duration = duration @duration = duration
@origin = origin @origin = origin
@@ -100,34 +90,28 @@ class Game_Picture
@target_opacity = opacity.to_f @target_opacity = opacity.to_f
@blend_type = blend_type || 0 @blend_type = blend_type || 0
end end
#-----------------------------------------------------------------------------
# * Change Rotation Speed # Change Rotation Speed
# speed : rotation speed # speed : rotation speed
#-----------------------------------------------------------------------------
def rotate(speed) def rotate(speed)
@rotate_speed = speed @rotate_speed = speed
end end
#-----------------------------------------------------------------------------
# * Start Change of Color Tone # Start Change of Color Tone
# tone : color tone # tone : color tone
# duration : time # duration : time
#-----------------------------------------------------------------------------
def start_tone_change(tone, duration) def start_tone_change(tone, duration)
@tone_target = tone.clone @tone_target = tone.clone
@tone_duration = duration @tone_duration = duration
if @tone_duration == 0 @tone = @tone_target.clone if @tone_duration == 0
@tone = @tone_target.clone
end
end end
#-----------------------------------------------------------------------------
# * Erase Picture # Erase Picture
#-----------------------------------------------------------------------------
def erase def erase
@name = "" @name = ""
end end
#-----------------------------------------------------------------------------
# * Frame Update # Frame Update
#-----------------------------------------------------------------------------
def update def update
if @duration >= 1 if @duration >= 1
d = @duration d = @duration

View File

@@ -106,28 +106,24 @@ class Game_Map
return GameData::MapMetadata.try_get(@map_id) return GameData::MapMetadata.try_get(@map_id)
end end
#-----------------------------------------------------------------------------
# Returns the name of this map's BGM. If it's night time, returns the night # Returns the name of this map's BGM. If it's night time, returns the night
# version of the BGM (if it exists). # version of the BGM (if it exists).
#-----------------------------------------------------------------------------
def bgm_name def bgm_name
if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n") if PBDayNight.isNight? && FileTest.audio_exist?("Audio/BGM/" + @map.bgm.name + "_n")
return @map.bgm.name + "_n" return @map.bgm.name + "_n"
end end
return @map.bgm.name return @map.bgm.name
end end
#-----------------------------------------------------------------------------
# * Autoplays background music # Autoplays background music
# Plays music called "[normal BGM]_n" if it's night time and it exists # Plays music called "[normal BGM]_n" if it's night time and it exists
#-----------------------------------------------------------------------------
def autoplayAsCue def autoplayAsCue
pbCueBGM(bgm_name, 1.0, @map.bgm.volume, @map.bgm.pitch) if @map.autoplay_bgm pbCueBGM(bgm_name, 1.0, @map.bgm.volume, @map.bgm.pitch) if @map.autoplay_bgm
pbBGSPlay(@map.bgs) if @map.autoplay_bgs pbBGSPlay(@map.bgs) if @map.autoplay_bgs
end end
#-----------------------------------------------------------------------------
# * Plays background music # Plays background music
# Plays music called "[normal BGM]_n" if it's night time and it exists # Plays music called "[normal BGM]_n" if it's night time and it exists
#-----------------------------------------------------------------------------
def autoplay def autoplay
pbBGMPlay(bgm_name, @map.bgm.volume, @map.bgm.pitch) if @map.autoplay_bgm pbBGMPlay(bgm_name, @map.bgm.volume, @map.bgm.pitch) if @map.autoplay_bgm
pbBGSPlay(@map.bgs) if @map.autoplay_bgs pbBGSPlay(@map.bgs) if @map.autoplay_bgs
@@ -249,7 +245,7 @@ class Game_Map
end end
# Returns whether the position x,y is fully passable (there is no blocking # Returns whether the position x,y is fully passable (there is no blocking
# event there, and the tile is fully passable in all directions) # event there, and the tile is fully passable in all directions).
def passableStrict?(x, y, d, self_event = nil) def passableStrict?(x, y, d, self_event = nil)
return false if !valid?(x, y) return false if !valid?(x, y)
events.each_value do |event| events.each_value do |event|
@@ -375,17 +371,13 @@ class Game_Map
def start_fog_tone_change(tone, duration) def start_fog_tone_change(tone, duration)
@fog_tone_target = tone.clone @fog_tone_target = tone.clone
@fog_tone_duration = duration @fog_tone_duration = duration
if @fog_tone_duration == 0 @fog_tone = @fog_tone_target.clone if @fog_tone_duration == 0
@fog_tone = @fog_tone_target.clone
end
end end
def start_fog_opacity_change(opacity, duration) def start_fog_opacity_change(opacity, duration)
@fog_opacity_target = opacity.to_f @fog_opacity_target = opacity.to_f
@fog_opacity_duration = duration @fog_opacity_duration = duration
if @fog_opacity_duration == 0 @fog_opacity = @fog_opacity_target if @fog_opacity_duration == 0
@fog_opacity = @fog_opacity_target
end
end end
def set_tile(x, y, layer, id = 0) def set_tile(x, y, layer, id = 0)

View File

@@ -5,78 +5,78 @@
# Version 1.02 # Version 1.02
# 2005-12-18 # 2005-12-18
#=============================================================================== #===============================================================================
=begin #
# This script supplements the built-in "Scroll Map" event command with the
This script supplements the built-in "Scroll Map" event command with the # aim of simplifying cutscenes (and map scrolling in general). Whereas the
aim of simplifying cutscenes (and map scrolling in general). Whereas the # normal event command requires a direction and number of tiles to scroll,
normal event command requires a direction and number of tiles to scroll, # Map Autoscroll scrolls the map to center on the tile whose x and y
Map Autoscroll scrolls the map to center on the tile whose x and y # coordinates are given.
coordinates are given. #
# FEATURES
FEATURES # - automatic map scrolling to given x,y coordinate (or player)
- automatic map scrolling to given x,y coordinate (or player) # - destination is fixed, so it's possible to scroll to same place even if
- destination is fixed, so it's possible to scroll to same place even if # origin is variable (e.g. moving NPC)
origin is variable (e.g. moving NPC) # - variable speed (just like "Scroll Map" event command)
- variable speed (just like "Scroll Map" event command) # - diagonal scrolling supported
- diagonal scrolling supported #
# SETUP
SETUP # Instead of a "Scroll Map" event command, use the "Call Script" command
Instead of a "Scroll Map" event command, use the "Call Script" command # and enter on the following on the first line:
and enter on the following on the first line: #
# autoscroll(x,y)
autoscroll(x,y) #
# (replacing "x" and "y" with the x and y coordinates of the tile to scroll to)
(replacing "x" and "y" with the x and y coordinates of the tile to scroll to) #
# To specify a scroll speed other than the default (4), use:
To specify a scroll speed other than the default (4), use: #
# autoscroll(x,y,speed)
autoscroll(x,y,speed) #
# (now also replacing "speed" with the scroll speed from 1-6)
(now also replacing "speed" with the scroll speed from 1-6) #
# Diagonal scrolling happens automatically when the destination is diagonal
Diagonal scrolling happens automatically when the destination is diagonal # relative to the starting point (i.e., not directly up, down, left or right).
relative to the starting point (i.e., not directly up, down, left or right). #
# To scroll to the player, instead use the following:
To scroll to the player, instead use the following: #
# autoscroll_player(speed)
autoscroll_player(speed) #
# Note: because of how the interpreter and the "Call Script" event command
Note: because of how the interpreter and the "Call Script" event command # are setup, the call to autoscroll(...) can only be on the first line of
are setup, the call to autoscroll(...) can only be on the first line of # the "Call Script" event command (and not flowing down to subsequent lines).
the "Call Script" event command (and not flowing down to subsequent lines). #
# For example, the following call may not work as expected:
For example, the following call may not work as expected: #
# autoscroll($game_variables[1],
autoscroll($game_variables[1], # $game_variables[2])
$game_variables[2]) #
# (since the long argument names require dropping down to a second line)
(since the long argument names require dropping down to a second line) # A work-around is to setup new variables with shorter names in a preceding
A work-around is to setup new variables with shorter names in a preceding # (separate) "Call Script" event command:
(separate) "Call Script" event command: #
# @x = $game_variables[1]
@x = $game_variables[1] # @y = $game_variables[2]
@y = $game_variables[2] #
# and then use those as arguments:
and then use those as arguments: #
# autoscroll(@x,@y)
autoscroll(@x,@y) #
# The renaming must be in a separate "Call Script" because otherwise
The renaming must be in a separate "Call Script" because otherwise # the call to autoscroll(...) isn't on the first line.
the call to autoscroll(...) isn't on the first line. #
# Originally requested by militantmilo80:
Originally requested by militantmilo80: # http://www.rmxp.net/forums/index.php?showtopic=29519
http://www.rmxp.net/forums/index.php?showtopic=29519 #
#===============================================================================
=end
#===============================================================================
#
#===============================================================================
class Interpreter class Interpreter
SCROLL_SPEED_DEFAULT = 4 SCROLL_SPEED_DEFAULT = 4
#----------------------------------------------------------------------------- # Map Autoscroll to Coordinates
# * Map Autoscroll to Coordinates
# x : x coordinate to scroll to and center on # x : x coordinate to scroll to and center on
# y : y coordinate to scroll to and center on # y : y coordinate to scroll to and center on
# speed : (optional) scroll speed (from 1-6, default being 4) # speed : (optional) scroll speed (from 1-6, default being 4)
#-----------------------------------------------------------------------------
def autoscroll(x, y, speed = SCROLL_SPEED_DEFAULT) def autoscroll(x, y, speed = SCROLL_SPEED_DEFAULT)
if $game_map.scrolling? if $game_map.scrolling?
return false return false
@@ -130,17 +130,16 @@ class Interpreter
return !@diag return !@diag
end end
#----------------------------------------------------------------------------- # Map Autoscroll (to Player)
# * Map Autoscroll (to Player)
# speed : (optional) scroll speed (from 1-6, default being 4) # speed : (optional) scroll speed (from 1-6, default being 4)
#-----------------------------------------------------------------------------
def autoscroll_player(speed = SCROLL_SPEED_DEFAULT) def autoscroll_player(speed = SCROLL_SPEED_DEFAULT)
autoscroll($game_player.x, $game_player.y, speed) autoscroll($game_player.x, $game_player.y, speed)
end end
end end
#===============================================================================
#
#===============================================================================
class Game_Map class Game_Map
def scroll_downright(distance) def scroll_downright(distance)
@display_x = [@display_x + distance, @display_x = [@display_x + distance,

View File

@@ -355,7 +355,7 @@ class PokemonMapFactory
def updateMaps(scene) def updateMaps(scene)
updateMapsInternal updateMapsInternal
$map_factory.setSceneStarted(scene) if @mapChanged setSceneStarted(scene) if @mapChanged
end end
def updateMapsInternal def updateMapsInternal
@@ -433,9 +433,9 @@ module MapFactoryHelper
end end
def self.mapsConnected?(id1, id2) def self.mapsConnected?(id1, id2)
MapFactoryHelper.eachConnectionForMap(id1) { |conn| MapFactoryHelper.eachConnectionForMap(id1) do |conn|
return true if conn[0] == id2 || conn[3] == id2 return true if conn[0] == id2 || conn[3] == id2
} end
return false return false
end end

View File

@@ -763,26 +763,33 @@ class Game_Character
@jump_speed_real = nil # Reset jump speed @jump_speed_real = nil # Reset jump speed
@jump_count = Game_Map::REAL_RES_X / jump_speed_real # Number of frames to jump one tile @jump_count = Game_Map::REAL_RES_X / jump_speed_real # Number of frames to jump one tile
end end
@stop_count = 0 increase_steps
triggerLeaveTile
end end
def jumpForward def jumpForward(distance = 1)
return false if distance == 0
old_x = @x
old_y = @y
case self.direction case self.direction
when 2 then jump(0, 1) # down when 2 then jump(0, distance) # down
when 4 then jump(-1, 0) # left when 4 then jump(-distance, 0) # left
when 6 then jump(1, 0) # right when 6 then jump(distance, 0) # right
when 8 then jump(0, -1) # up when 8 then jump(0, -distance) # up
end end
return @x != old_x || @y != old_y
end end
def jumpBackward def jumpBackward(distance = 1)
return false if distance == 0
old_x = @x
old_y = @y
case self.direction case self.direction
when 2 then jump(0, -1) # down when 2 then jump(0, -distance) # down
when 4 then jump(1, 0) # left when 4 then jump(distance, 0) # left
when 6 then jump(-1, 0) # right when 6 then jump(-distance, 0) # right
when 8 then jump(0, 1) # up when 8 then jump(0, distance) # up
end end
return @x != old_x || @y != old_y
end end
def turn_generic(dir) def turn_generic(dir)
@@ -926,12 +933,16 @@ class Game_Character
@real_y = dest_y if @real_y < dest_y + 0.1 @real_y = dest_y if @real_y < dest_y + 0.1
end end
# Refresh how far is left to travel in a jump # Refresh how far is left to travel in a jump
if jumping? was_jumping = jumping?
if was_jumping
@jump_count -= 1 if @jump_count > 0 # For stationary jumps only @jump_count -= 1 if @jump_count > 0 # For stationary jumps only
@jump_distance_left = [(dest_x - @real_x).abs, (dest_y - @real_y).abs].max @jump_distance_left = [(dest_x - @real_x).abs, (dest_y - @real_y).abs].max
end end
# End of a step, so perform events that happen at this time # End of a step, so perform events that happen at this time
if !jumping? && !moving? if !jumping? && !moving?
if was_jumping && !(self.is_a?(Game_Player) && $PokemonGlobal.surfing && !$game_temp.ending_surf)
$scene.spriteset.addUserAnimation(Settings::DUST_ANIMATION_ID, @x, @y, true, 1)
end
EventHandlers.trigger(:on_step_taken, self) EventHandlers.trigger(:on_step_taken, self)
calculate_bush_depth calculate_bush_depth
@stopped_this_frame = true @stopped_this_frame = true

View File

@@ -237,9 +237,7 @@ class Game_Event < Game_Character
@trigger = @page.trigger @trigger = @page.trigger
@list = @page.list @list = @page.list
@interpreter = nil @interpreter = nil
if @trigger == 4 # Parallel Process @interpreter = Interpreter.new if @trigger == 4 # Parallel Process
@interpreter = Interpreter.new
end
check_event_trigger_auto check_event_trigger_auto
end end
@@ -262,18 +260,14 @@ class Game_Event < Game_Character
@moveto_happened = false @moveto_happened = false
last_moving = moving? last_moving = moving?
super super
if !moving? && last_moving $game_player.pbCheckEventTriggerFromDistance([2]) if !moving? && last_moving
$game_player.pbCheckEventTriggerFromDistance([2])
end
if @need_refresh if @need_refresh
@need_refresh = false @need_refresh = false
refresh refresh
end end
check_event_trigger_auto check_event_trigger_auto
if @interpreter if @interpreter
unless @interpreter.running? @interpreter.setup(@list, @event.id, @map_id) if !@interpreter.running?
@interpreter.setup(@list, @event.id, @map_id)
end
@interpreter.update @interpreter.update
end end
end end

View File

@@ -116,26 +116,39 @@ class Game_Player < Game_Character
@bump_se = Graphics.frame_rate / 4 @bump_se = Graphics.frame_rate / 4
end end
def add_move_distance_to_stats(distance = 1)
if $PokemonGlobal&.diving || $PokemonGlobal&.surfing
$stats.distance_surfed += distance
elsif $PokemonGlobal&.bicycle
$stats.distance_cycled += distance
else
$stats.distance_walked += distance
end
$stats.distance_slid_on_ice += distance if $PokemonGlobal.ice_sliding
end
def move_generic(dir, turn_enabled = true) def move_generic(dir, turn_enabled = true)
turn_generic(dir, true) if turn_enabled turn_generic(dir, true) if turn_enabled
if !$game_temp.encounter_triggered if !$game_temp.encounter_triggered
if can_move_in_direction?(dir) if can_move_in_direction?(dir)
x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0 x_offset = (dir == 4) ? -1 : (dir == 6) ? 1 : 0
y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0 y_offset = (dir == 8) ? -1 : (dir == 2) ? 1 : 0
return if pbLedge(x_offset, y_offset) # Jump over ledges
if pbFacingTerrainTag.ledge
if jumpForward(2)
pbSEPlay("Player jump")
increase_steps
end
return
end
# Jumping out of surfing back onto land
return if pbEndSurf(x_offset, y_offset) return if pbEndSurf(x_offset, y_offset)
# General movement
turn_generic(dir, true) turn_generic(dir, true)
if !$game_temp.encounter_triggered if !$game_temp.encounter_triggered
@x += x_offset @x += x_offset
@y += y_offset @y += y_offset
if $PokemonGlobal&.diving || $PokemonGlobal&.surfing add_move_distance_to_stats(x_offset.abs + y_offset.abs)
$stats.distance_surfed += 1
elsif $PokemonGlobal&.bicycle
$stats.distance_cycled += 1
else
$stats.distance_walked += 1
end
$stats.distance_slid_on_ice += 1 if $PokemonGlobal.ice_sliding
increase_steps increase_steps
end end
elsif !check_event_trigger_touch(dir) elsif !check_event_trigger_touch(dir)
@@ -155,36 +168,10 @@ class Game_Player < Game_Character
end end
def jump(x_plus, y_plus) def jump(x_plus, y_plus)
if x_plus != 0 || y_plus != 0 old_x = @x
if x_plus.abs > y_plus.abs old_y = @y
(x_plus < 0) ? turn_left : turn_right super
else add_move_distance_to_stats(x_plus.abs + y_plus.abs) if @x != old_x || @y != old_y
(y_plus < 0) ? turn_up : turn_down
end
each_occupied_tile { |i, j| return if !passable?(i + x_plus, j + y_plus, 0) }
end
@x = @x + x_plus
@y = @y + y_plus
real_distance = Math.sqrt((x_plus * x_plus) + (y_plus * y_plus))
distance = [1, real_distance].max
@jump_peak = distance * Game_Map::TILE_HEIGHT * 3 / 8 # 3/4 of tile for ledge jumping
@jump_distance = [x_plus.abs * Game_Map::REAL_RES_X, y_plus.abs * Game_Map::REAL_RES_Y].max
@jump_distance_left = 1 # Just needs to be non-zero
if real_distance > 0 # Jumping to somewhere else
if $PokemonGlobal&.diving || $PokemonGlobal&.surfing
$stats.distance_surfed += x_plus.abs + y_plus.abs
elsif $PokemonGlobal&.bicycle
$stats.distance_cycled += x_plus.abs + y_plus.abs
else
$stats.distance_walked += x_plus.abs + y_plus.abs
end
@jump_count = 0
else # Jumping on the spot
@jump_speed_real = nil # Reset jump speed
@jump_count = Game_Map::REAL_RES_X / jump_speed_real # Number of frames to jump one tile
end
@stop_count = 0
triggerLeaveTile
end end
def pbTriggeredTrainerEvents(triggers, checkIfRunning = true, trainer_only = false) def pbTriggeredTrainerEvents(triggers, checkIfRunning = true, trainer_only = false)
@@ -267,13 +254,11 @@ class Game_Player < Game_Character
return $game_map.terrain_tag(facing[1], facing[2]) return $game_map.terrain_tag(facing[1], facing[2])
end end
#----------------------------------------------------------------------------- # Passable Determinants
# * Passable Determinants
# x : x-coordinate # x : x-coordinate
# y : y-coordinate # y : y-coordinate
# d : direction (0,2,4,6,8) # d : direction (0, 2, 4, 6, 8)
# * 0 = Determines if all directions are impassable (for jumping) # * 0 = Determines if all directions are impassable (for jumping)
#-----------------------------------------------------------------------------
def passable?(x, y, d, strict = false) def passable?(x, y, d, strict = false)
# Get new coordinates # Get new coordinates
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
@@ -289,28 +274,22 @@ class Game_Player < Game_Character
return super return super
end end
#----------------------------------------------------------------------------- # Set Map Display Position to Center of Screen
# * Set Map Display Position to Center of Screen
#-----------------------------------------------------------------------------
def center(x, y) def center(x, y)
self.map.display_x = (x * Game_Map::REAL_RES_X) - SCREEN_CENTER_X self.map.display_x = (x * Game_Map::REAL_RES_X) - SCREEN_CENTER_X
self.map.display_y = (y * Game_Map::REAL_RES_Y) - SCREEN_CENTER_Y self.map.display_y = (y * Game_Map::REAL_RES_Y) - SCREEN_CENTER_Y
end end
#----------------------------------------------------------------------------- # Move to Designated Position
# * Move to Designated Position
# x : x-coordinate # x : x-coordinate
# y : y-coordinate # y : y-coordinate
#-----------------------------------------------------------------------------
def moveto(x, y) def moveto(x, y)
super super
center(x, y) center(x, y)
make_encounter_count make_encounter_count
end end
#----------------------------------------------------------------------------- # Make Encounter Count
# * Make Encounter Count
#-----------------------------------------------------------------------------
def make_encounter_count def make_encounter_count
# Image of two dice rolling # Image of two dice rolling
if $game_map.map_id != 0 if $game_map.map_id != 0
@@ -319,18 +298,13 @@ class Game_Player < Game_Character
end end
end end
#-----------------------------------------------------------------------------
# * Refresh
#-----------------------------------------------------------------------------
def refresh def refresh
@opacity = 255 @opacity = 255
@blend_type = 0 @blend_type = 0
end end
#----------------------------------------------------------------------------- # Trigger event(s) at the same coordinates as self with the appropriate
# * Trigger event(s) at the same coordinates as self with the appropriate # trigger(s) that can be triggered
# trigger(s) that can be triggered
#-----------------------------------------------------------------------------
def check_event_trigger_here(triggers) def check_event_trigger_here(triggers)
result = false result = false
# If event is running # If event is running
@@ -348,9 +322,7 @@ class Game_Player < Game_Character
return result return result
end end
#----------------------------------------------------------------------------- # Front Event Starting Determinant
# * Front Event Starting Determinant
#-----------------------------------------------------------------------------
def check_event_trigger_there(triggers) def check_event_trigger_there(triggers)
result = false result = false
# If event is running # If event is running
@@ -389,9 +361,7 @@ class Game_Player < Game_Character
return result return result
end end
#----------------------------------------------------------------------------- # Touch Event Starting Determinant
# * Touch Event Starting Determinant
#-----------------------------------------------------------------------------
def check_event_trigger_touch(dir) def check_event_trigger_touch(dir)
result = false result = false
return result if $game_system.map_interpreter.running? return result if $game_system.map_interpreter.running?
@@ -417,9 +387,6 @@ class Game_Player < Game_Character
return result return result
end end
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update def update
last_real_x = @real_x last_real_x = @real_x
last_real_y = @real_y last_real_y = @real_y
@@ -434,12 +401,6 @@ class Game_Player < Game_Character
$game_temp.followers.update $game_temp.followers.update
# Count down the time between allowed bump sounds # Count down the time between allowed bump sounds
@bump_se -= 1 if @bump_se && @bump_se > 0 @bump_se -= 1 if @bump_se && @bump_se > 0
# Finish up dismounting from surfing
if $game_temp.ending_surf && !moving?
pbCancelVehicles
$game_temp.surf_base_coords = nil
$game_temp.ending_surf = false
end
update_event_triggering update_event_triggering
end end
@@ -531,21 +492,21 @@ class Game_Player < Game_Character
end end
end end
# Track the player on-screen as they move # Track the player on-screen as they move.
def update_screen_position(last_real_x, last_real_y) def update_screen_position(last_real_x, last_real_y)
return if self.map.scrolling? || !(@moved_last_frame || @moved_this_frame) return if self.map.scrolling? || !(@moved_last_frame || @moved_this_frame)
if (@real_x < last_real_x && @real_x - $game_map.display_x < SCREEN_CENTER_X) || if (@real_x < last_real_x && @real_x < $game_map.display_x + SCREEN_CENTER_X) ||
(@real_x > last_real_x && @real_x - $game_map.display_x > SCREEN_CENTER_X) (@real_x > last_real_x && @real_x > $game_map.display_x + SCREEN_CENTER_X)
self.map.display_x += @real_x - last_real_x self.map.display_x += @real_x - last_real_x
end end
if (@real_y < last_real_y && @real_y - $game_map.display_y < SCREEN_CENTER_Y) || if (@real_y < last_real_y && @real_y < $game_map.display_y + SCREEN_CENTER_Y) ||
(@real_y > last_real_y && @real_y - $game_map.display_y > SCREEN_CENTER_Y) (@real_y > last_real_y && @real_y > $game_map.display_y + SCREEN_CENTER_Y)
self.map.display_y += @real_y - last_real_y self.map.display_y += @real_y - last_real_y
end end
end end
def update_event_triggering def update_event_triggering
return if moving? || $PokemonGlobal.ice_sliding return if moving? || jumping? || $PokemonGlobal.ice_sliding
# Try triggering events upon walking into them/in front of them # Try triggering events upon walking into them/in front of them
if @moved_this_frame if @moved_this_frame
$game_temp.followers.turn_followers $game_temp.followers.turn_followers
@@ -564,8 +525,6 @@ class Game_Player < Game_Character
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================

View File

@@ -5,42 +5,28 @@
# event. This class is used within the Game_Map class ($game_map). # event. This class is used within the Game_Map class ($game_map).
#=============================================================================== #===============================================================================
class Game_CommonEvent class Game_CommonEvent
#-----------------------------------------------------------------------------
# * Object Initialization
# common_event_id : common event ID
#-----------------------------------------------------------------------------
def initialize(common_event_id) def initialize(common_event_id)
@common_event_id = common_event_id @common_event_id = common_event_id
@interpreter = nil @interpreter = nil
refresh refresh
end end
#-----------------------------------------------------------------------------
# * Get Name
#-----------------------------------------------------------------------------
def name def name
return $data_common_events[@common_event_id].name return $data_common_events[@common_event_id].name
end end
#-----------------------------------------------------------------------------
# * Get Trigger
#-----------------------------------------------------------------------------
def trigger def trigger
return $data_common_events[@common_event_id].trigger return $data_common_events[@common_event_id].trigger
end end
#-----------------------------------------------------------------------------
# * Get Condition Switch ID
#-----------------------------------------------------------------------------
def switch_id def switch_id
return $data_common_events[@common_event_id].switch_id return $data_common_events[@common_event_id].switch_id
end end
#-----------------------------------------------------------------------------
# * Get List of Event Commands
#-----------------------------------------------------------------------------
def list def list
return $data_common_events[@common_event_id].list return $data_common_events[@common_event_id].list
end end
#-----------------------------------------------------------------------------
# * Checks if switch is on
#-----------------------------------------------------------------------------
def switchIsOn?(id) def switchIsOn?(id)
switchName = $data_system.switches[id] switchName = $data_system.switches[id]
return false if !switchName return false if !switchName
@@ -50,22 +36,16 @@ class Game_CommonEvent
return $game_switches[id] return $game_switches[id]
end end
end end
#-----------------------------------------------------------------------------
# * Refresh
#-----------------------------------------------------------------------------
def refresh def refresh
# Create an interpreter for parallel process if necessary # Create an interpreter for parallel process if necessary
if self.trigger == 2 && switchIsOn?(self.switch_id) if self.trigger == 2 && switchIsOn?(self.switch_id)
if @interpreter.nil? @interpreter = Interpreter.new if @interpreter.nil?
@interpreter = Interpreter.new
end
else else
@interpreter = nil @interpreter = nil
end end
end end
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update def update
return if !@interpreter return if !@interpreter
# Set up event if interpreter is not running # Set up event if interpreter is not running

View File

@@ -27,7 +27,7 @@ class Game_Follower < Game_Event
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
def move_through(direction) def move_through(direction)
old_through = @through old_through = @through
@@ -105,7 +105,7 @@ class Game_Follower < Game_Event
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
def turn_towards_leader(leader) def turn_towards_leader(leader)
pbTurnTowardEvent(self, leader) pbTurnTowardEvent(self, leader)
@@ -146,7 +146,7 @@ class Game_Follower < Game_Event
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
def update_move def update_move
was_jumping = jumping? was_jumping = jumping?
@@ -157,7 +157,7 @@ class Game_Follower < Game_Event
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
private private

View File

@@ -77,14 +77,14 @@ class Game_FollowerFactory
attr_reader :last_update attr_reader :last_update
def initialize def initialize
@events = [] @events = []
$PokemonGlobal.followers.each do |follower| $PokemonGlobal.followers.each do |follower|
@events.push(create_follower_object(follower)) @events.push(create_follower_object(follower))
end end
@last_update = -1 @last_update = -1
end end
#============================================================================= #-----------------------------------------------------------------------------
def add_follower(event, name = nil, common_event_id = nil) def add_follower(event, name = nil, common_event_id = nil)
return if !event return if !event
@@ -150,7 +150,7 @@ class Game_FollowerFactory
$PokemonGlobal.followers.each_with_index { |follower, i| yield @events[i], follower } $PokemonGlobal.followers.each_with_index { |follower, i| yield @events[i], follower }
end end
#============================================================================= #-----------------------------------------------------------------------------
def turn_followers def turn_followers
leader = $game_player leader = $game_player
@@ -208,11 +208,11 @@ class Game_FollowerFactory
vector = $map_factory.getRelativePos(event.map.map_id, event.x, event.y, vector = $map_factory.getRelativePos(event.map.map_id, event.x, event.y,
leader[0], leader[1], leader[2]) leader[0], leader[1], leader[2])
if vector[0] != 0 if vector[0] != 0
move_route.prepend((vector[0] > 0) ? PBMoveRoute::Right : PBMoveRoute::Left) move_route.prepend((vector[0] > 0) ? PBMoveRoute::RIGHT : PBMoveRoute::LEFT)
elsif vector[1] != 0 elsif vector[1] != 0
move_route.prepend((vector[1] > 0) ? PBMoveRoute::Down : PBMoveRoute::Up) move_route.prepend((vector[1] > 0) ? PBMoveRoute::DOWN : PBMoveRoute::UP)
end end
pbMoveRoute(event, move_route + [PBMoveRoute::Opacity, 0]) pbMoveRoute(event, move_route + [PBMoveRoute::OPACITY, 0])
end end
end end
@@ -237,7 +237,7 @@ class Game_FollowerFactory
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
def update def update
followers = $PokemonGlobal.followers followers = $PokemonGlobal.followers
@@ -286,7 +286,7 @@ class Game_FollowerFactory
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
private private
@@ -388,7 +388,6 @@ module Followers
end end
end end
#=============================================================================== #===============================================================================
# Deprecated methods # Deprecated methods
#=============================================================================== #===============================================================================

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class BushBitmap class BushBitmap
def initialize(bitmap, isTile, depth) def initialize(bitmap, isTile, depth)
@bitmaps = [] @bitmaps = []
@@ -53,8 +56,9 @@ class BushBitmap
end end
end end
#===============================================================================
#
#===============================================================================
class Sprite_Character < RPG::Sprite class Sprite_Character < RPG::Sprite
attr_accessor :character attr_accessor :character

View File

@@ -48,15 +48,15 @@ class Sprite_Reflection
# Just-in-time creation of sprite # Just-in-time creation of sprite
@sprite = Sprite.new(@viewport) if !@sprite @sprite = Sprite.new(@viewport) if !@sprite
if @sprite if @sprite
x = @rsprite.x - @rsprite.ox * TilemapRenderer::ZOOM_X x = @rsprite.x - (@rsprite.ox * TilemapRenderer::ZOOM_X)
y = @rsprite.y - @rsprite.oy * TilemapRenderer::ZOOM_Y y = @rsprite.y - (@rsprite.oy * TilemapRenderer::ZOOM_Y)
y -= Game_Map::TILE_HEIGHT * TilemapRenderer::ZOOM_Y if @rsprite.character.character_name[/offset/i] y -= Game_Map::TILE_HEIGHT * TilemapRenderer::ZOOM_Y if @rsprite.character.character_name[/offset/i]
@height = $PokemonGlobal.bridge if !@fixedheight @height = $PokemonGlobal.bridge if !@fixedheight
y += @height * TilemapRenderer::ZOOM_Y * Game_Map::TILE_HEIGHT / 2 y += @height * TilemapRenderer::ZOOM_Y * Game_Map::TILE_HEIGHT / 2
width = @rsprite.src_rect.width width = @rsprite.src_rect.width
height = @rsprite.src_rect.height height = @rsprite.src_rect.height
@sprite.x = x + (width / 2) * TilemapRenderer::ZOOM_X @sprite.x = x + ((width / 2) * TilemapRenderer::ZOOM_X)
@sprite.y = y + (height + (height / 2)) * TilemapRenderer::ZOOM_Y @sprite.y = y + ((height + (height / 2)) * TilemapRenderer::ZOOM_Y)
@sprite.ox = width / 2 @sprite.ox = width / 2
@sprite.oy = (height / 2) - 2 # Hard-coded 2 pixel shift up @sprite.oy = (height / 2) - 2 # Hard-coded 2 pixel shift up
@sprite.oy -= @rsprite.character.bob_height * 2 @sprite.oy -= @rsprite.character.bob_height * 2

View File

@@ -22,7 +22,7 @@ class Sprite_SurfBase
def dispose def dispose
return if @disposed return if @disposed
@sprite&.dispose @sprite&.dispose
@sprite = nil @sprite = nil
@surfbitmap.dispose @surfbitmap.dispose
@divebitmap.dispose @divebitmap.dispose
@disposed = true @disposed = true

View File

@@ -1,4 +1,6 @@
# Unused #===============================================================================
# Unused.
#===============================================================================
class ClippableSprite < Sprite_Character class ClippableSprite < Sprite_Character
def initialize(viewport, event, tilemap) def initialize(viewport, event, tilemap)
@tilemap = tilemap @tilemap = tilemap
@@ -29,8 +31,9 @@ class ClippableSprite < Sprite_Character
end end
end end
#===============================================================================
#
#===============================================================================
class Spriteset_Map class Spriteset_Map
attr_reader :map attr_reader :map

View File

@@ -1,9 +1,8 @@
=begin #===============================================================================
A sprite whose sole purpose is to display an animation. This sprite # A sprite whose sole purpose is to display an animation. This sprite can be
can be displayed anywhere on the map and is disposed # displayed anywhere on the map and is disposed automatically when its animation
automatically when its animation is finished. # is finished. Used for grass rustling and so forth.
Used for grass rustling and so forth. #===============================================================================
=end
class AnimationSprite < RPG::Sprite class AnimationSprite < RPG::Sprite
def initialize(animID, map, tileX, tileY, viewport = nil, tinting = false, height = 3) def initialize(animID, map, tileX, tileY, viewport = nil, tinting = false, height = 3)
super(viewport) super(viewport)
@@ -38,8 +37,9 @@ class AnimationSprite < RPG::Sprite
end end
end end
#===============================================================================
#
#===============================================================================
class Spriteset_Map class Spriteset_Map
alias _animationSprite_initialize initialize unless private_method_defined?(:_animationSprite_initialize) alias _animationSprite_initialize initialize unless private_method_defined?(:_animationSprite_initialize)
alias _animationSprite_update update unless method_defined?(:_animationSprite_update) alias _animationSprite_update update unless method_defined?(:_animationSprite_update)

View File

@@ -117,11 +117,9 @@ class Sprite_Shadow < RPG::Sprite
end end
end end
#===============================================================================
#===================================================
# ? CLASS Sprite_Character edit # ? CLASS Sprite_Character edit
#=================================================== #===============================================================================
class Sprite_Character < RPG::Sprite class Sprite_Character < RPG::Sprite
alias shadow_initialize initialize unless private_method_defined?(:shadow_initialize) alias shadow_initialize initialize unless private_method_defined?(:shadow_initialize)
@@ -161,20 +159,16 @@ class Sprite_Character < RPG::Sprite
end end
end end
#===============================================================================
#===================================================
# ? CLASS Game_Event edit # ? CLASS Game_Event edit
#=================================================== #===============================================================================
class Game_Event class Game_Event
attr_accessor :id attr_accessor :id
end end
#===============================================================================
#===================================================
# ? CLASS Spriteset_Map edit # ? CLASS Spriteset_Map edit
#=================================================== #===============================================================================
class Spriteset_Map class Spriteset_Map
attr_accessor :shadows attr_accessor :shadows
@@ -202,9 +196,7 @@ class Spriteset_Map
end end
end end
#===============================================================================
#===================================================
# ? XPML Definition, by Rataime, using ideas from Near Fantastica # ? XPML Definition, by Rataime, using ideas from Near Fantastica
# #
# Returns nil if the markup wasn't present at all, # Returns nil if the markup wasn't present at all,
@@ -222,7 +214,7 @@ end
# p XPML_read("second", event_id) -> [1, "two"] # p XPML_read("second", event_id) -> [1, "two"]
# p XPML_read("third", event_id) -> [3] # p XPML_read("third", event_id) -> [3]
# p XPML_read("forth", event_id) -> nil # p XPML_read("forth", event_id) -> nil
#=================================================== #===============================================================================
def XPML_read(map, markup, event, max_param_number = 0) def XPML_read(map, markup, event, max_param_number = 0)
parameter_list = nil parameter_list = nil
return nil if !event || event.list.nil? return nil if !event || event.list.nil?

View File

@@ -1,6 +1,8 @@
#===============================================================================
# Particle Engine, Peter O., 2007-11-03 # Particle Engine, Peter O., 2007-11-03
# Based on version 2 by Near Fantastica, 04.01.06 # Based on version 2 by Near Fantastica, 04.01.06
# In turn based on the Particle Engine designed by PinkMan # In turn based on the Particle Engine designed by PinkMan
#===============================================================================
class Particle_Engine class Particle_Engine
def initialize(viewport = nil, map = nil) def initialize(viewport = nil, map = nil)
@map = (map) ? map : $game_map @map = (map) ? map : $game_map
@@ -98,8 +100,9 @@ class Particle_Engine
end end
end end
#===============================================================================
#
#===============================================================================
class ParticleEffect class ParticleEffect
attr_accessor :x, :y, :z attr_accessor :x, :y, :z
@@ -113,8 +116,9 @@ class ParticleEffect
def dispose; end def dispose; end
end end
#===============================================================================
#
#===============================================================================
class ParticleSprite class ParticleSprite
attr_accessor :x, :y, :z, :ox, :oy, :opacity, :blend_type attr_accessor :x, :y, :z, :ox, :oy, :opacity, :blend_type
attr_reader :bitmap attr_reader :bitmap
@@ -171,8 +175,9 @@ class ParticleSprite
end end
end end
#===============================================================================
#
#===============================================================================
class ParticleEffect_Event < ParticleEffect class ParticleEffect_Event < ParticleEffect
attr_accessor :event attr_accessor :event
@@ -357,8 +362,9 @@ class ParticleEffect_Event < ParticleEffect
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Fire < ParticleEffect_Event class Particle_Engine::Fire < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -368,8 +374,9 @@ class Particle_Engine::Fire < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Smoke < ParticleEffect_Event class Particle_Engine::Smoke < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -379,8 +386,9 @@ class Particle_Engine::Smoke < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Teleport < ParticleEffect_Event class Particle_Engine::Teleport < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -394,8 +402,9 @@ class Particle_Engine::Teleport < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Spirit < ParticleEffect_Event class Particle_Engine::Spirit < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -405,8 +414,9 @@ class Particle_Engine::Spirit < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Explosion < ParticleEffect_Event class Particle_Engine::Explosion < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -416,8 +426,9 @@ class Particle_Engine::Explosion < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Aura < ParticleEffect_Event class Particle_Engine::Aura < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -427,8 +438,9 @@ class Particle_Engine::Aura < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Soot < ParticleEffect_Event class Particle_Engine::Soot < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -438,8 +450,9 @@ class Particle_Engine::Soot < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::SootSmoke < ParticleEffect_Event class Particle_Engine::SootSmoke < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -452,8 +465,9 @@ class Particle_Engine::SootSmoke < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Rocket < ParticleEffect_Event class Particle_Engine::Rocket < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -463,8 +477,9 @@ class Particle_Engine::Rocket < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::FixedTeleport < ParticleEffect_Event class Particle_Engine::FixedTeleport < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -478,9 +493,9 @@ class Particle_Engine::FixedTeleport < ParticleEffect_Event
end end
end end
#===============================================================================
# By Peter O. # By Peter O.
#===============================================================================
class Particle_Engine::StarTeleport < ParticleEffect_Event class Particle_Engine::StarTeleport < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -494,8 +509,9 @@ class Particle_Engine::StarTeleport < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Smokescreen < ParticleEffect_Event class Particle_Engine::Smokescreen < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -531,8 +547,9 @@ class Particle_Engine::Smokescreen < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Flare < ParticleEffect_Event class Particle_Engine::Flare < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -542,8 +559,9 @@ class Particle_Engine::Flare < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Particle_Engine::Splash < ParticleEffect_Event class Particle_Engine::Splash < ParticleEffect_Event
def initialize(event, viewport) def initialize(event, viewport)
super super
@@ -561,8 +579,9 @@ class Particle_Engine::Splash < ParticleEffect_Event
end end
end end
#===============================================================================
#
#===============================================================================
class Game_Event < Game_Character class Game_Event < Game_Character
attr_accessor :pe_refresh attr_accessor :pe_refresh

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class PictureOrigin class PictureOrigin
TOP_LEFT = 0 TOP_LEFT = 0
CENTER = 1 CENTER = 1
@@ -12,8 +15,9 @@ class PictureOrigin
RIGHT = 8 RIGHT = 8
end end
#===============================================================================
#
#===============================================================================
class Processes class Processes
XY = 0 XY = 0
DELTA_XY = 1 DELTA_XY = 1
@@ -35,8 +39,9 @@ class Processes
CROP_BOTTOM = 17 CROP_BOTTOM = 17
end end
#===============================================================================
#
#===============================================================================
def getCubicPoint2(src, t) def getCubicPoint2(src, t)
x0 = src[0] x0 = src[0]
y0 = src[1] y0 = src[1]
@@ -72,8 +77,6 @@ def getCubicPoint2(src, t)
return [cx, cy] return [cx, cy]
end end
#=============================================================================== #===============================================================================
# PictureEx # PictureEx
#=============================================================================== #===============================================================================
@@ -456,8 +459,6 @@ class PictureEx
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Interpolator class Interpolator
ZOOM_X = 1 ZOOM_X = 1
ZOOM_Y = 2 ZOOM_Y = 2
@@ -83,8 +86,9 @@ class Interpolator
end end
end end
#===============================================================================
#
#===============================================================================
class RectInterpolator class RectInterpolator
def initialize(oldrect, newrect, frames) def initialize(oldrect, newrect, frames)
restart(oldrect, newrect, frames) restart(oldrect, newrect, frames)
@@ -130,8 +134,9 @@ class RectInterpolator
end end
end end
#===============================================================================
#
#===============================================================================
class PointInterpolator class PointInterpolator
attr_reader :x attr_reader :x
attr_reader :y attr_reader :y

View File

@@ -184,9 +184,7 @@ class TilemapRenderer
end end
def current_frame(filename) def current_frame(filename)
if !@current_frames[filename] set_current_frame(filename) if !@current_frames[filename]
set_current_frame(filename)
end
return @current_frames[filename] return @current_frames[filename]
end end

View File

@@ -56,6 +56,8 @@ class TilemapRenderer
return ret return ret
end end
#---------------------------------------------------------------------------
private private
def blitWrappedPixels(destX, destY, dest, src, srcrect) def blitWrappedPixels(destX, destY, dest, src, srcrect)

View File

@@ -1,13 +1,17 @@
#===============================================================================
#
#===============================================================================
class Hangup < Exception; end class Hangup < Exception; end
#===============================================================================
#
#===============================================================================
module RPG module RPG
module Cache module Cache
def self.debug def self.debug
t = Time.now t = Time.now
filename = t.strftime("%H %M %S.%L.txt") filename = t.strftime("%H %M %S.%L.txt")
File.open("cache_" + filename, "wb") { |f| File.open("cache_" + filename, "wb") do |f|
@cache.each do |key, value| @cache.each do |key, value|
if !value if !value
f.write("#{key} (nil)\r\n") f.write("#{key} (nil)\r\n")
@@ -17,7 +21,7 @@ module RPG
f.write("#{key} (#{value.refcount}, #{value.width}x#{value.height})\r\n") f.write("#{key} (#{value.refcount}, #{value.width}x#{value.height})\r\n")
end end
end end
} end
end end
def self.setKey(key, obj) def self.setKey(key, obj)
@@ -106,8 +110,9 @@ module RPG
end end
end end
#===============================================================================
#
#===============================================================================
class BitmapWrapper < Bitmap class BitmapWrapper < Bitmap
attr_reader :refcount attr_reader :refcount
attr_accessor :never_dispose attr_accessor :never_dispose

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module MessageConfig module MessageConfig
LIGHT_TEXT_MAIN_COLOR = Color.new(248, 248, 248) LIGHT_TEXT_MAIN_COLOR = Color.new(248, 248, 248)
LIGHT_TEXT_SHADOW_COLOR = Color.new(72, 80, 88) LIGHT_TEXT_SHADOW_COLOR = Color.new(72, 80, 88)
@@ -163,8 +166,6 @@ module MessageConfig
end end
end end
#=============================================================================== #===============================================================================
# Position a window # Position a window
#=============================================================================== #===============================================================================
@@ -207,9 +208,7 @@ def pbPositionNearMsgWindow(cmdwindow, msgwindow, side)
return if !cmdwindow return if !cmdwindow
if msgwindow if msgwindow
height = [cmdwindow.height, Graphics.height - msgwindow.height].min height = [cmdwindow.height, Graphics.height - msgwindow.height].min
if cmdwindow.height != height cmdwindow.height = height if cmdwindow.height != height
cmdwindow.height = height
end
cmdwindow.y = msgwindow.y - cmdwindow.height cmdwindow.y = msgwindow.y - cmdwindow.height
if cmdwindow.y < 0 if cmdwindow.y < 0
cmdwindow.y = msgwindow.y + msgwindow.height cmdwindow.y = msgwindow.y + msgwindow.height
@@ -256,9 +255,7 @@ def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false)
msgwindow.resizeToFit2(msgwindow.text, Graphics.width * 2 / 3, msgwindow.height) msgwindow.resizeToFit2(msgwindow.text, Graphics.width * 2 / 3, msgwindow.height)
end end
msgwindow.y = event.screen_y - 48 - msgwindow.height msgwindow.y = event.screen_y - 48 - msgwindow.height
if msgwindow.y < 0 msgwindow.y = event.screen_y + 24 if msgwindow.y < 0
msgwindow.y = event.screen_y + 24
end
msgwindow.x = event.screen_x - (msgwindow.width / 2) msgwindow.x = event.screen_x - (msgwindow.width / 2)
msgwindow.x = 0 if msgwindow.x < 0 msgwindow.x = 0 if msgwindow.x < 0
if msgwindow.x > Graphics.width - msgwindow.width if msgwindow.x > Graphics.width - msgwindow.width
@@ -622,24 +619,24 @@ def pbFadeOutInWithMusic(zViewport = 99999)
$game_system.bgm_pause(1.0) $game_system.bgm_pause(1.0)
$game_system.bgs_pause(1.0) $game_system.bgs_pause(1.0)
pos = $game_system.bgm_position pos = $game_system.bgm_position
pbFadeOutIn(zViewport) { pbFadeOutIn(zViewport) do
yield yield
$game_system.bgm_position = pos $game_system.bgm_position = pos
$game_system.bgm_resume(playingBGM) $game_system.bgm_resume(playingBGM)
$game_system.bgs_resume(playingBGS) $game_system.bgs_resume(playingBGS)
} end
end end
def pbFadeOutAndHide(sprites) def pbFadeOutAndHide(sprites)
visiblesprites = {} visiblesprites = {}
numFrames = (Graphics.frame_rate * 0.4).floor numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) { pbDeactivateWindows(sprites) do
(0..numFrames).each do |j| (0..numFrames).each do |j|
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff)) pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff))
(block_given?) ? yield : pbUpdateSpriteHash(sprites) (block_given?) ? yield : pbUpdateSpriteHash(sprites)
end end
} end
sprites.each do |i| sprites.each do |i|
next if !i[1] next if !i[1]
next if pbDisposed?(i[1]) next if pbDisposed?(i[1])
@@ -659,12 +656,12 @@ def pbFadeInAndShow(sprites, visiblesprites = nil)
end end
numFrames = (Graphics.frame_rate * 0.4).floor numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) { pbDeactivateWindows(sprites) do
(0..numFrames).each do |j| (0..numFrames).each do |j|
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff))) pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff)))
(block_given?) ? yield : pbUpdateSpriteHash(sprites) (block_given?) ? yield : pbUpdateSpriteHash(sprites)
end end
} end
end end
# Restores which windows are active for the given sprite hash. # Restores which windows are active for the given sprite hash.
@@ -730,9 +727,7 @@ def addBackgroundPlane(sprites, planename, background, viewport = nil)
else else
sprites[planename].setBitmap(bitmapName) sprites[planename].setBitmap(bitmapName)
sprites.each_value do |spr| sprites.each_value do |spr|
if spr.is_a?(Window) spr.windowskin = nil if spr.is_a?(Window)
spr.windowskin = nil
end
end end
end end
end end
@@ -752,35 +747,31 @@ def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport
sprites[planename] = AnimatedPlane.new(viewport) sprites[planename] = AnimatedPlane.new(viewport)
sprites[planename].setBitmap(bitmapName) sprites[planename].setBitmap(bitmapName)
sprites.each_value do |spr| sprites.each_value do |spr|
if spr.is_a?(Window) spr.windowskin = nil if spr.is_a?(Window)
spr.windowskin = nil
end
end end
end end
end end
#=============================================================================== #===============================================================================
# Ensure required method definitions # Ensure required method definitions.
#=============================================================================== #===============================================================================
module Graphics module Graphics
if !self.respond_to?("width") if !self.respond_to?("width")
def self.width; return 640; end def self.width; return 640; end
end end
if !self.respond_to?("height") if !self.respond_to?("height")
def self.height; return 480; end def self.height; return 480; end
end end
end end
#===============================================================================
# Ensure required method definitions.
#===============================================================================
if !defined?(_INTL) if !defined?(_INTL)
def _INTL(*args) def _INTL(*args)
string = args[0].clone string = args[0].clone
(1...args.length).each do |i| (1...args.length).each { |i| string.gsub!(/\{#{i}\}/, args[i].to_s) }
string.gsub!(/\{#{i}\}/, args[i].to_s)
end
return string return string
end end
end end
@@ -789,9 +780,7 @@ if !defined?(_ISPRINTF)
def _ISPRINTF(*args) def _ISPRINTF(*args)
string = args[0].clone string = args[0].clone
(1...args.length).each do |i| (1...args.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, args[i]) }
next sprintf("%" + $1, args[i])
}
end end
return string return string
end end
@@ -800,9 +789,7 @@ end
if !defined?(_MAPINTL) if !defined?(_MAPINTL)
def _MAPINTL(*args) def _MAPINTL(*args)
string = args[1].clone string = args[1].clone
(2...args.length).each do |i| (2...args.length).each { |i| string.gsub!(/\{#{i}\}/, args[i + 1].to_s) }
string.gsub!(/\{#{i}\}/, args[i + 1].to_s)
end
return string return string
end end
end end

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class WindowCursorRect < Rect class WindowCursorRect < Rect
def initialize(window) def initialize(window)
super(0, 0, 0, 0) super(0, 0, 0, 0)
@@ -39,6 +42,8 @@ class WindowCursorRect < Rect
@window.width = @window.width @window.width = @window.width
end end
#-----------------------------------------------------------------------------
private private
def needs_update?(x, y, width, height) def needs_update?(x, y, width, height)
@@ -46,7 +51,9 @@ class WindowCursorRect < Rect
end end
end end
#===============================================================================
#
#===============================================================================
class Window class Window
attr_reader :tone attr_reader :tone
attr_reader :color attr_reader :color
@@ -318,6 +325,8 @@ class Window
end end
end end
#-----------------------------------------------------------------------------
private private
def ensureBitmap(bitmap, dwidth, dheight) def ensureBitmap(bitmap, dwidth, dheight)

View File

@@ -34,18 +34,19 @@ class SpriteWindow < Window
@_windowskin @_windowskin
end end
# Flags used to preserve compatibility # Flags used to preserve compatibility with RGSS/RGSS2's version of Window
# with RGSS/RGSS2's version of Window
module CompatBits module CompatBits
CorrectZ = 1 CORRECT_Z = 1
ExpandBack = 2 EXPAND_BACK = 2
ShowScrollArrows = 4 SHOW_SCROLL_ARROWS = 4
StretchSides = 8 STRETCH_SIDES = 8
ShowPause = 16 SHOW_PAUSE = 16
ShowCursor = 32 SHOW_CURSOR = 32
end end
attr_reader :compat attr_reader :compat
attr_reader :skinformat
attr_reader :skinrect
def compat=(value) def compat=(value)
@compat = value @compat = value
@@ -76,7 +77,7 @@ class SpriteWindow < Window
@contents = @blankcontents @contents = @blankcontents
@_windowskin = nil @_windowskin = nil
@rpgvx = false @rpgvx = false
@compat = CompatBits::ExpandBack | CompatBits::StretchSides @compat = CompatBits::EXPAND_BACK | CompatBits::STRETCH_SIDES
@x = 0 @x = 0
@y = 0 @y = 0
@width = 0 @width = 0
@@ -324,10 +325,6 @@ class SpriteWindow < Window
end end
end end
#############
attr_reader :skinformat
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
@@ -437,7 +434,8 @@ class SpriteWindow < Window
privRefresh privRefresh
end end
############# #-----------------------------------------------------------------------------
private private
def ensureBitmap(bitmap, dwidth, dheight) def ensureBitmap(bitmap, dwidth, dheight)
@@ -516,9 +514,9 @@ class SpriteWindow < Window
@sprites["back"].visible = @visible @sprites["back"].visible = @visible
@sprites["contents"].visible = @visible && @openness == 255 @sprites["contents"].visible = @visible && @openness == 255
@sprites["pause"].visible = supported && @visible && @pause && @sprites["pause"].visible = supported && @visible && @pause &&
(@combat & CompatBits::ShowPause) (@combat & CompatBits::SHOW_PAUSE)
@sprites["cursor"].visible = supported && @visible && @openness == 255 && @sprites["cursor"].visible = supported && @visible && @openness == 255 &&
(@combat & CompatBits::ShowCursor) (@combat & CompatBits::SHOW_CURSOR)
@sprites["scroll0"].visible = false @sprites["scroll0"].visible = false
@sprites["scroll1"].visible = false @sprites["scroll1"].visible = false
@sprites["scroll2"].visible = false @sprites["scroll2"].visible = false
@@ -541,7 +539,7 @@ class SpriteWindow < Window
@spritekeys.each do |i| @spritekeys.each do |i|
@sprites[i].z = @z @sprites[i].z = @z
end end
if (@compat & CompatBits::CorrectZ) > 0 && @skinformat == 0 && !@rpgvx if (@compat & CompatBits::CORRECT_Z) > 0 && @skinformat == 0 && !@rpgvx
# Compatibility Mode: Cursor, pause, and contents have higher Z # Compatibility Mode: Cursor, pause, and contents have higher Z
@sprites["cursor"].z = @z + 1 @sprites["cursor"].z = @z + 1
@sprites["contents"].z = @z + 2 @sprites["contents"].z = @z + 2
@@ -631,7 +629,7 @@ class SpriteWindow < Window
end end
@sprites["contents"].x = @x + trimStartX @sprites["contents"].x = @x + trimStartX
@sprites["contents"].y = @y + trimStartY @sprites["contents"].y = @y + trimStartY
if (@compat & CompatBits::ShowScrollArrows) > 0 && @skinformat == 0 && if (@compat & CompatBits::SHOW_SCROLL_ARROWS) > 0 && @skinformat == 0 &&
@_windowskin && !@_windowskin.disposed? && @_windowskin && !@_windowskin.disposed? &&
@contents && !@contents.disposed? @contents && !@contents.disposed?
@sprites["scroll0"].visible = @visible && hascontents && @oy > 0 @sprites["scroll0"].visible = @visible && hascontents && @oy > 0
@@ -668,7 +666,7 @@ class SpriteWindow < Window
@sprites["scroll3"].y = @y + @height - 16 @sprites["scroll3"].y = @y + @height - 16
@sprites["cursor"].x = @x + startX + @cursor_rect.x @sprites["cursor"].x = @x + startX + @cursor_rect.x
@sprites["cursor"].y = @y + startY + @cursor_rect.y @sprites["cursor"].y = @y + startY + @cursor_rect.y
if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0 if (@compat & CompatBits::EXPAND_BACK) > 0 && @skinformat == 0
# Compatibility mode: Expand background # Compatibility mode: Expand background
@sprites["back"].x = @x + 2 @sprites["back"].x = @x + 2
@sprites["back"].y = @y + 2 @sprites["back"].y = @y + 2
@@ -743,7 +741,7 @@ class SpriteWindow < Window
@sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight) @sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight)
@sidebitmaps[i].clear @sidebitmaps[i].clear
if sideRects[i].width > 0 && sideRects[i].height > 0 if sideRects[i].width > 0 && sideRects[i].height > 0
if (@compat & CompatBits::StretchSides) > 0 && @skinformat == 0 if (@compat & CompatBits::STRETCH_SIDES) > 0 && @skinformat == 0
# Compatibility mode: Stretch sides # Compatibility mode: Stretch sides
@sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect, @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
@_windowskin, sideRects[i]) @_windowskin, sideRects[i])
@@ -753,7 +751,7 @@ class SpriteWindow < Window
end end
end end
end end
if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0 if (@compat & CompatBits::EXPAND_BACK) > 0 && @skinformat == 0
# Compatibility mode: Expand background # Compatibility mode: Expand background
backwidth = @width - 4 backwidth = @width - 4
backheight = @height - 4 backheight = @height - 4
@@ -813,13 +811,11 @@ class SpriteWindow < Window
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class SpriteWindow_Base < SpriteWindow class SpriteWindow_Base < SpriteWindow
TEXTPADDING = 4 # In pixels TEXT_PADDING = 4 # In pixels
def initialize(x, y, width, height) def initialize(x, y, width, height)
super() super()

View File

@@ -1,8 +1,7 @@
#=============================================================================== #===============================================================================
#
#===============================================================================
# Represents a window with no formatting capabilities. Its text color can be set, # Represents a window with no formatting capabilities. Its text color can be set,
# though, and line breaks are supported, but the text is generally unformatted. # though, and line breaks are supported, but the text is generally unformatted.
#===============================================================================
class Window_UnformattedTextPokemon < SpriteWindow_Base class Window_UnformattedTextPokemon < SpriteWindow_Base
attr_reader :text attr_reader :text
attr_reader :baseColor attr_reader :baseColor
@@ -52,7 +51,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
dims = [0, 0] dims = [0, 0]
cwidth = maxwidth < 0 ? Graphics.width : maxwidth cwidth = maxwidth < 0 ? Graphics.width : maxwidth
getLineBrokenChunks(self.contents, text, getLineBrokenChunks(self.contents, text,
cwidth - self.borderX - SpriteWindow_Base::TEXTPADDING, dims, true) cwidth - self.borderX - SpriteWindow_Base::TEXT_PADDING, dims, true)
return dims return dims
end end
@@ -63,7 +62,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width
dims = resizeToFitInternal(text, maxwidth) dims = resizeToFitInternal(text, maxwidth)
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING
self.height = dims[1] + self.borderY self.height = dims[1] + self.borderY
refresh refresh
end end
@@ -106,8 +105,6 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -214,7 +211,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
dims = resizeToFitInternal(text, maxwidth) dims = resizeToFitInternal(text, maxwidth)
oldstarting = @starting oldstarting = @starting
@starting = true @starting = true
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING
self.height = dims[1] + self.borderY self.height = dims[1] + self.borderY
@starting = oldstarting @starting = oldstarting
redrawText redrawText
@@ -224,7 +221,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
dims = resizeToFitInternal(text, maxwidth) dims = resizeToFitInternal(text, maxwidth)
oldstarting = @starting oldstarting = @starting
@starting = true @starting = true
self.width = [dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING, maxwidth].min self.width = [dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING, maxwidth].min
self.height = [dims[1] + self.borderY, maxheight].min self.height = [dims[1] + self.borderY, maxheight].min
@starting = oldstarting @starting = oldstarting
redrawText redrawText
@@ -309,7 +306,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
if @letterbyletter if @letterbyletter
@fmtchars = [] @fmtchars = []
fmt = getFormattedText(self.contents, 0, 0, fmt = getFormattedText(self.contents, 0, 0,
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1, self.width - self.borderX - SpriteWindow_Base::TEXT_PADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true) shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone @oldfont = self.contents.font.clone
fmt.each do |ch| fmt.each do |ch|
@@ -336,7 +333,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
fmt.clear fmt.clear
else else
@fmtchars = getFormattedText(self.contents, 0, 0, @fmtchars = getFormattedText(self.contents, 0, 0,
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1, self.width - self.borderX - SpriteWindow_Base::TEXT_PADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true) shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone @oldfont = self.contents.font.clone
@fmtchars.each do |ch| @fmtchars.each do |ch|
@@ -589,6 +586,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
@frameskipChanged = false @frameskipChanged = false
end end
#-----------------------------------------------------------------------------
private private
def curcharSkip(skip) def curcharSkip(skip)
@@ -602,8 +601,6 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -709,6 +706,8 @@ class Window_InputNumberPokemon < SpriteWindow_Base
@frame = (@frame + 1) % 30 @frame = (@frame + 1) % 30
end end
#-----------------------------------------------------------------------------
private private
def textHelper(x, y, text, i) def textHelper(x, y, text, i)
@@ -723,8 +722,6 @@ class Window_InputNumberPokemon < SpriteWindow_Base
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -902,6 +899,8 @@ class SpriteWindow_Selectable < SpriteWindow_Base
end end
end end
#-----------------------------------------------------------------------------
private private
def priv_page_row_max def priv_page_row_max
@@ -951,8 +950,6 @@ class SpriteWindow_Selectable < SpriteWindow_Base
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -1016,8 +1013,6 @@ module UpDownArrowMixin
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -1030,8 +1025,6 @@ class SpriteWindow_SelectableEx < SpriteWindow_Selectable
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -1087,7 +1080,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
width = [width, tmpbitmap.text_size(i).width].max width = [width, tmpbitmap.text_size(i).width].max
end end
# one 16 to allow cursor # one 16 to allow cursor
width += 16 + 16 + SpriteWindow_Base::TEXTPADDING width += 16 + 16 + SpriteWindow_Base::TEXT_PADDING
tmpbitmap.dispose tmpbitmap.dispose
end end
# Store suggested width and height of window # Store suggested width and height of window
@@ -1137,8 +1130,6 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -1229,15 +1220,12 @@ class Window_CommandPokemon < Window_DrawableCommand
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class Window_CommandPokemonEx < Window_CommandPokemon class Window_CommandPokemonEx < Window_CommandPokemon
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -1247,7 +1235,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
def textWidth(bitmap, text) def textWidth(bitmap, text)
dims = [nil, 0] dims = [nil, 0]
chars = getFormattedText(bitmap, 0, 0, chars = getFormattedText(bitmap, 0, 0,
Graphics.width - self.borderX - SpriteWindow_Base::TEXTPADDING - 16, Graphics.width - self.borderX - SpriteWindow_Base::TEXT_PADDING - 16,
-1, text, self.rowHeight, true, true) -1, text, self.rowHeight, true, true)
chars.each do |ch| chars.each do |ch|
dims[0] = dims[0] ? [dims[0], ch[1]].min : ch[1] dims[0] = dims[0] ? [dims[0], ch[1]].min : ch[1]
@@ -1350,8 +1338,6 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================

View File

@@ -51,8 +51,6 @@ class IconWindow < SpriteWindow_Base
end end
end end
#=============================================================================== #===============================================================================
# Displays an icon bitmap in a window. Supports animated images. # Displays an icon bitmap in a window. Supports animated images.
# Accepts bitmaps and paths to bitmap files in its constructor. # Accepts bitmaps and paths to bitmap files in its constructor.

View File

@@ -88,8 +88,6 @@ class SpriteWrapper
end end
end end
#=============================================================================== #===============================================================================
# Sprite class that maintains a bitmap of its own. # Sprite class that maintains a bitmap of its own.
# This bitmap can't be changed to a different one. # This bitmap can't be changed to a different one.
@@ -111,8 +109,6 @@ class BitmapSprite < Sprite
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -237,8 +233,6 @@ class AnimatedSprite < Sprite
end end
end end
#=============================================================================== #===============================================================================
# Displays an icon bitmap in a sprite. Supports animated images. # Displays an icon bitmap in a sprite. Supports animated images.
#=============================================================================== #===============================================================================
@@ -310,8 +304,6 @@ class IconSprite < Sprite
end end
end end
#=============================================================================== #===============================================================================
# Sprite class that stores multiple bitmaps, and displays only one at once. # Sprite class that stores multiple bitmaps, and displays only one at once.
#=============================================================================== #===============================================================================

View File

@@ -218,9 +218,9 @@ end
# #
#=============================================================================== #===============================================================================
def pbGetTileBitmap(filename, tile_id, hue, width = 1, height = 1) def pbGetTileBitmap(filename, tile_id, hue, width = 1, height = 1)
return RPG::Cache.tileEx(filename, tile_id, hue, width, height) { |f| return RPG::Cache.tileEx(filename, tile_id, hue, width, height) do |f|
AnimatedBitmap.new("Graphics/Tilesets/" + filename).deanimate AnimatedBitmap.new("Graphics/Tilesets/" + filename).deanimate
} end
end end
def pbGetTileset(name, hue = 0) def pbGetTileset(name, hue = 0)

View File

@@ -64,6 +64,8 @@ class AnimatedPlane < Plane
end end
end end
#-----------------------------------------------------------------------------
private private
def clear_bitmap def clear_bitmap

View File

@@ -54,8 +54,6 @@ def getContrastColor(color)
return color.get_contrast_color return color.get_contrast_color
end end
#=============================================================================== #===============================================================================
# Format text # Format text
#=============================================================================== #===============================================================================
@@ -99,9 +97,7 @@ end
def getFormattedTextForDims(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight, def getFormattedTextForDims(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight,
newlineBreaks = true, explicitBreaksOnly = false) newlineBreaks = true, explicitBreaksOnly = false)
text2 = text.gsub(/<(\/?)(c|c2|c3|o|u|s)(\s*\=\s*([^>]*))?>/i, "") text2 = text.gsub(/<(\/?)(c|c2|c3|o|u|s)(\s*\=\s*([^>]*))?>/i, "")
if newlineBreaks text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n") if newlineBreaks
text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n")
end
return getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, return getFormattedText(bitmap, xDst, yDst, widthDst, heightDst,
text2, lineheight, newlineBreaks, text2, lineheight, newlineBreaks,
explicitBreaksOnly, true) explicitBreaksOnly, true)
@@ -248,76 +244,82 @@ def getLastColors(colorstack, opacitystack, defaultcolors)
return colors return colors
end end
#=============================================================================== #===============================================================================
# Formats a string of text and returns an array containing a list of formatted # Formats a string of text and returns an array containing a list of formatted
# characters. # characters.
#
# Parameters:
# bitmap: Source bitmap. Will be used to determine the default font of
# the text.
# xDst: X coordinate of the text's top left corner.
# yDst: Y coordinate of the text's top left corner.
# widthDst: Width of the text. Used to determine line breaks.
# heightDst: Height of the text. If -1, there is no height restriction.
# If 1 or greater, any characters exceeding the height are
# removed from the returned list.
# newLineBreaks: If true, newline characters will be treated as line breaks.
# The default is true.
#
# Return Values:
# A list of formatted characters. Returns an empty array if _bitmap_ is nil
# or disposed, or if _widthDst_ is 0 or less or _heightDst_ is 0.
#
# Formatting Specification:
# This function uses the following syntax when formatting the text.
#
# <b> ... </b> - Formats the text in bold.
# <i> ... </i> - Formats the text in italics.
# <u> ... </u> - Underlines the text.
# <s> ... </s> - Draws a strikeout line over the text.
# <al> ... </al> - Left-aligns the text. Causes line breaks before and
# after the text.
# <r> - Right-aligns the text until the next line break.
# <ar> ... </ar> - Right-aligns the text. Causes line breaks before and
# after the text.
# <ac> ... </ac> - Centers the text. Causes line breaks before and after
# the text.
# <br> - Causes a line break.
# <c=X> ... </c> - Color specification. A total of four formats are
# supported: RRGGBBAA, RRGGBB, 16-bit RGB, and
# Window_Base color numbers.
# <c2=X> ... </c2> - Color specification where the first half is the base
# color and the second half is the shadow color. 16-bit
# RGB is supported.
#
# Added 2009-10-20
#
# <c3=B,S> ... </c3> - Color specification where B is the base color and S is
# the shadow color. B and/or S can be omitted. A total of
# four formats are supported: RRGGBBAA, RRGGBB, 16-bit
# RGB, and Window_Base color numbers.
#
# Added 2009-9-12
#
# <o=X> - Displays the text in the given opacity (0-255)
#
# Added 2009-10-19
#
# <outln> - Displays the text in outline format.
#
# Added 2010-05-12
#
# <outln2> - Displays the text in outline format (outlines more
# exaggerated.
# <fn=X> ... </fn> - Formats the text in the specified font, or Arial if the
# font doesn't exist.
# <fs=X> ... </fs> - Changes the font size to X.
# <icon=X> - Displays the icon X (in Graphics/Icons/).
#
# In addition, the syntax supports the following:
# &apos; - Converted to "'".
# &lt; - Converted to "<".
# &gt; - Converted to ">".
# &amp; - Converted to "&".
# &quot; - Converted to double quotation mark.
#
# To draw the characters, pass the returned array to the
# _drawFormattedChars_ function.
#=============================================================================== #===============================================================================
=begin
Parameters:
bitmap: Source bitmap. Will be used to determine the default font of
the text.
xDst: X coordinate of the text's top left corner.
yDst: Y coordinate of the text's top left corner.
widthDst: Width of the text. Used to determine line breaks.
heightDst: Height of the text. If -1, there is no height restriction. If
1 or greater, any characters exceeding the height are removed
from the returned list.
newLineBreaks: If true, newline characters will be treated as line breaks. The
default is true.
Return Values:
A list of formatted characters. Returns an empty array if _bitmap_ is nil
or disposed, or if _widthDst_ is 0 or less or _heightDst_ is 0.
Formatting Specification:
This function uses the following syntax when formatting the text.
<b> ... </b> - Formats the text in bold.
<i> ... </i> - Formats the text in italics.
<u> ... </u> - Underlines the text.
<s> ... </s> - Draws a strikeout line over the text.
<al> ... </al> - Left-aligns the text. Causes line breaks before and after
the text.
<r> - Right-aligns the text until the next line break.
<ar> ... </ar> - Right-aligns the text. Causes line breaks before and after
the text.
<ac> ... </ac> - Centers the text. Causes line breaks before and after the
text.
<br> - Causes a line break.
<c=X> ... </c> - Color specification. A total of four formats are supported:
RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers.
<c2=X> ... </c2> - Color specification where the first half is the base color
and the second half is the shadow color. 16-bit RGB is
supported.
Added 2009-10-20
<c3=B,S> ... </c3> - Color specification where B is the base color and S is the
shadow color. B and/or S can be omitted. A total of four
formats are supported:
RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers.
Added 2009-9-12
<o=X> - Displays the text in the given opacity (0-255)
Added 2009-10-19
<outln> - Displays the text in outline format.
Added 2010-05-12
<outln2> - Displays the text in outline format (outlines more
exaggerated.
<fn=X> ... </fn> - Formats the text in the specified font, or Arial if the
font doesn't exist.
<fs=X> ... </fs> - Changes the font size to X.
<icon=X> - Displays the icon X (in Graphics/Icons/).
In addition, the syntax supports the following:
&apos; - Converted to "'".
&lt; - Converted to "<".
&gt; - Converted to ">".
&amp; - Converted to "&".
&quot; - Converted to double quotation mark.
To draw the characters, pass the returned array to the
_drawFormattedChars_ function.
=end
def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = 32, def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = 32,
newlineBreaks = true, explicitBreaksOnly = false, newlineBreaks = true, explicitBreaksOnly = false,
collapseAlignments = false) collapseAlignments = false)
@@ -520,9 +522,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
break break
end end
when "br" # Line break when "br" # Line break
if !endtag nextline += 1 if !endtag
nextline += 1
end
when "r" # Right align this line when "r" # Right align this line
if !endtag if !endtag
x = 0 x = 0
@@ -644,49 +644,47 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end end
# This code looks at whether the text occupies exactly two lines when # This code looks at whether the text occupies exactly two lines when
# displayed. If it does, it balances the length of each line. # displayed. If it does, it balances the length of each line.
=begin # # Count total number of lines
# Count total number of lines # numlines = (x==0 && y>0) ? y : y+1
numlines = (x==0 && y>0) ? y : y+1 # if numlines==2 && realtext && !realtext[/\n/] && realtext.length>=50
if numlines==2 && realtext && !realtext[/\n/] && realtext.length>=50 # # Set half to middle of text (known to contain no formatting)
# Set half to middle of text (known to contain no formatting) # half = realtext.length/2
half = realtext.length/2 # leftSearch = 0
leftSearch = 0 # rightSearch = 0
rightSearch = 0 # # Search left for a space
# Search left for a space # i = half
i = half # while i>=0
while i>=0 # break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space
break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space # leftSearch += 1
leftSearch += 1 # i -= 1
i -= 1 # end
end # # Search right for a space
# Search right for a space # i = half
i = half # while i<realtext.length
while i<realtext.length # break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space
break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space # rightSearch += 1
rightSearch += 1 # i += 1
i += 1 # end
end # # Move half left or right whichever is closer
# Move half left or right whichever is closer # trialHalf = half+((rightSearch<leftSearch) ? rightSearch : -leftSearch)
trialHalf = half+((rightSearch<leftSearch) ? rightSearch : -leftSearch) # if trialHalf!=0 && trialHalf!=realtext.length
if trialHalf!=0 && trialHalf!=realtext.length # # Insert newline and re-call this function (force newlineBreaksOnly)
# Insert newline and re-call this function (force newlineBreaksOnly) # newText = realtext.clone
newText = realtext.clone # if isWaitChar(newText[trialHalf,1])
if isWaitChar(newText[trialHalf,1]) # # insert after wait character
# insert after wait character # newText.insert(trialHalf+1,"\n")
newText.insert(trialHalf+1,"\n") # else
else # # remove spaces after newline
# remove spaces after newline # newText.insert(trialHalf,"\n")
newText.insert(trialHalf,"\n") # newText.gsub!(/\n\s+/,"\n")
newText.gsub!(/\n\s+/,"\n") # end
end # bitmap.font = oldfont
bitmap.font = oldfont # dummybitmap.dispose if dummybitmap
dummybitmap.dispose if dummybitmap # return getFormattedText(dummybitmap ? nil : bitmap,xDst,yDst,
return getFormattedText(dummybitmap ? nil : bitmap,xDst,yDst, # widthDst,heightDst,realtextStart+newText,
widthDst,heightDst,realtextStart+newText, # lineheight,true,explicitBreaksOnly)
lineheight,true,explicitBreaksOnly) # end
end # end
end
=end
if havenl if havenl
# Eliminate spaces before newlines and pause character # Eliminate spaces before newlines and pause character
firstspace = -1 firstspace = -1
@@ -701,9 +699,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end end
firstspace = -1 firstspace = -1
elsif characters[i][0][/[ \r\t]/] elsif characters[i][0][/[ \r\t]/]
if firstspace < 0 firstspace = i if firstspace < 0
firstspace = i
end
else else
firstspace = -1 firstspace = -1
end end
@@ -744,9 +740,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
totalLineWidths = [] totalLineWidths = []
widthblocks.each do |block| widthblocks.each do |block|
y = block[4] y = block[4]
if !totalLineWidths[y] totalLineWidths[y] = 0 if !totalLineWidths[y]
totalLineWidths[y] = 0
end
if totalLineWidths[y] != 0 if totalLineWidths[y] != 0
# padding in case more than one line has different alignments # padding in case more than one line has different alignments
totalLineWidths[y] += 16 totalLineWidths[y] += 16
@@ -774,8 +768,6 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
return characters return characters
end end
#=============================================================================== #===============================================================================
# Draw text and images on a bitmap # Draw text and images on a bitmap
#=============================================================================== #===============================================================================
@@ -881,9 +873,7 @@ def getLineBrokenChunks(bitmap, value, width, dims, plain = false)
x += textwidth x += textwidth
dims[0] = x if dims && dims[0] < x dims[0] = x if dims && dims[0] < x
end end
if textcols[i] color = textcols[i] if textcols[i]
color = textcols[i]
end
end end
end end
dims[1] = y + 32 if dims dims[1] = y + 32 if dims
@@ -1109,8 +1099,6 @@ def pbDrawTextPositions(bitmap, textpos)
end end
end end
#=============================================================================== #===============================================================================
# Draw images on a bitmap # Draw images on a bitmap
#=============================================================================== #===============================================================================

View File

@@ -49,8 +49,6 @@ def pbCurrentEventCommentInput(elements, trigger)
return pbEventCommentInput(event, elements, trigger) return pbEventCommentInput(event, elements, trigger)
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -147,6 +145,8 @@ class ChooseNumberParams
end end
end end
#-----------------------------------------------------------------------------
private private
def clamp(v, mn, mx) def clamp(v, mn, mx)
@@ -164,8 +164,9 @@ class ChooseNumberParams
end end
end end
#===============================================================================
#
#===============================================================================
def pbChooseNumber(msgwindow, params) def pbChooseNumber(msgwindow, params)
return 0 if !params return 0 if !params
ret = 0 ret = 0
@@ -208,8 +209,6 @@ def pbChooseNumber(msgwindow, params)
return ret return ret
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -244,8 +243,6 @@ class FaceWindowVX < SpriteWindow_Base
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -311,8 +308,6 @@ def pbCsvPosInt!(str)
return ret.to_i return ret.to_i
end end
#=============================================================================== #===============================================================================
# Money and coins windows # Money and coins windows
#=============================================================================== #===============================================================================
@@ -368,8 +363,6 @@ def pbDisplayBattlePointsWindow(msgwindow)
return pointswindow return pointswindow
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -410,8 +403,6 @@ def pbDisposeMessageWindow(msgwindow)
msgwindow.dispose msgwindow.dispose
end end
#=============================================================================== #===============================================================================
# Main message-displaying function # Main message-displaying function
#=============================================================================== #===============================================================================
@@ -433,16 +424,13 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
msgback = nil msgback = nil
linecount = (Graphics.height > 400) ? 3 : 2 linecount = (Graphics.height > 400) ? 3 : 2
### Text replacement ### Text replacement
text.gsub!(/\\sign\[([^\]]*)\]/i) { # \sign[something] gets turned into text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into
next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something] next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something]
} end
text.gsub!(/\\\\/, "\5") text.gsub!(/\\\\/, "\5")
text.gsub!(/\\1/, "\1") text.gsub!(/\\1/, "\1")
if $game_actors if $game_actors
text.gsub!(/\\n\[([1-8])\]/i) { text.gsub!(/\\n\[([1-8])\]/i) { next $game_actors[$1.to_i].name }
m = $1.to_i
next $game_actors[m].name
}
end end
text.gsub!(/\\pn/i, $player.name) if $player text.gsub!(/\\pn/i, $player.name) if $player
text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player
@@ -456,7 +444,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
text.gsub!(/\\pog/i, "") text.gsub!(/\\pog/i, "")
text.gsub!(/\\b/i, "<c3=3050C8,D0D0C8>") text.gsub!(/\\b/i, "<c3=3050C8,D0D0C8>")
text.gsub!(/\\r/i, "<c3=E00808,D0D0C8>") text.gsub!(/\\r/i, "<c3=E00808,D0D0C8>")
text.gsub!(/\\[Ww]\[([^\]]*)\]/) { text.gsub!(/\\[Ww]\[([^\]]*)\]/) do
w = $1.to_s w = $1.to_s
if w == "" if w == ""
msgwindow.windowskin = nil msgwindow.windowskin = nil
@@ -464,12 +452,11 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
msgwindow.setSkin("Graphics/Windowskins/#{w}", false) msgwindow.setSkin("Graphics/Windowskins/#{w}", false)
end end
next "" next ""
} end
isDarkSkin = isDarkWindowskin(msgwindow.windowskin) isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
text.gsub!(/\\c\[([0-9]+)\]/i) { text.gsub!(/\\c\[([0-9]+)\]/i) do
m = $1.to_i next getSkinColor(msgwindow.windowskin, $1.to_i, isDarkSkin)
next getSkinColor(msgwindow.windowskin, m, isDarkSkin) end
}
loop do 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] }
@@ -477,10 +464,10 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
end end
loop do loop do
last_text = text.clone last_text = text.clone
text.gsub!(/\\l\[([0-9]+)\]/i) { text.gsub!(/\\l\[([0-9]+)\]/i) do
linecount = [1, $1.to_i].max linecount = [1, $1.to_i].max
next "" next ""
} end
break if text == last_text break if text == last_text
end end
colortag = "" colortag = ""
@@ -675,9 +662,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
$game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel) $game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel)
$game_map.need_refresh = true if $game_map $game_map.need_refresh = true if $game_map
end end
if commandProc ret = commandProc.call(msgwindow) if commandProc
ret = commandProc.call(msgwindow)
end
msgback&.dispose msgback&.dispose
goldwindow&.dispose goldwindow&.dispose
coinwindow&.dispose coinwindow&.dispose
@@ -701,8 +686,6 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
return ret return ret
end end
#=============================================================================== #===============================================================================
# Message-displaying functions # Message-displaying functions
#=============================================================================== #===============================================================================
@@ -711,8 +694,8 @@ def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd =
msgwindow = pbCreateMessageWindow(nil, skin) msgwindow = pbCreateMessageWindow(nil, skin)
if commands if commands
ret = pbMessageDisplay(msgwindow, message, true, ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow| proc { |msgwndw|
next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block) next Kernel.pbShowCommands(msgwndw, commands, cmdIfCancel, defaultCmd, &block)
}, &block) }, &block)
else else
pbMessageDisplay(msgwindow, message, &block) pbMessageDisplay(msgwindow, message, &block)
@@ -733,8 +716,8 @@ end
def pbMessageChooseNumber(message, params, &block) def pbMessageChooseNumber(message, params, &block)
msgwindow = pbCreateMessageWindow(nil, params.messageSkin) msgwindow = pbCreateMessageWindow(nil, params.messageSkin)
ret = pbMessageDisplay(msgwindow, message, true, ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow| proc { |msgwndw|
next pbChooseNumber(msgwindow, params, &block) next pbChooseNumber(msgwndw, params, &block)
}, &block) }, &block)
pbDisposeMessageWindow(msgwindow) pbDisposeMessageWindow(msgwindow)
return ret return ret
@@ -796,9 +779,7 @@ def pbShowCommandsWithHelp(msgwindow, commands, help, cmdIfCancel = 0, defaultCm
Input.update Input.update
oldindex = cmdwindow.index oldindex = cmdwindow.index
cmdwindow.update cmdwindow.update
if oldindex != cmdwindow.index msgwin.text = help[cmdwindow.index] if oldindex != cmdwindow.index
msgwin.text = help[cmdwindow.index]
end
msgwin.update msgwin.update
yield if block_given? yield if block_given?
if Input.trigger?(Input::BACK) if Input.trigger?(Input::BACK)
@@ -835,9 +816,7 @@ def pbMessageWaitForInput(msgwindow, frames, showPause = false)
Input.update Input.update
msgwindow&.update msgwindow&.update
pbUpdateSceneMap pbUpdateSceneMap
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK) break if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
break
end
yield if block_given? yield if block_given?
end end
msgwindow.stopPause if msgwindow && showPause msgwindow.stopPause if msgwindow && showPause
@@ -876,8 +855,8 @@ end
def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block) def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block)
msgwindow = pbCreateMessageWindow msgwindow = pbCreateMessageWindow
retval = pbMessageDisplay(msgwindow, message, true, retval = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow| proc { |msgwndw|
next pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width, &block) next pbFreeText(msgwndw, currenttext, passwordbox, maxlength, width, &block)
}, &block) }, &block)
pbDisposeMessageWindow(msgwindow) pbDisposeMessageWindow(msgwindow)
return retval return retval

View File

@@ -41,9 +41,7 @@ class CharacterEntryHelper
return false if @maxlength >= 0 && chars.length >= @maxlength return false if @maxlength >= 0 && chars.length >= @maxlength
chars.insert(@cursor, ch) chars.insert(@cursor, ch)
@text = "" @text = ""
chars.each do |ch| chars.each { |char| @text += char if char }
@text += ch if ch
end
@cursor += 1 @cursor += 1
return true return true
end end
@@ -66,14 +64,14 @@ class CharacterEntryHelper
return true return true
end end
#-----------------------------------------------------------------------------
private private
def ensure def ensure
return if @maxlength < 0 return if @maxlength < 0
chars = self.text.scan(/./m) chars = self.text.scan(/./m)
if chars.length > @maxlength && @maxlength >= 0 chars = chars[0, @maxlength] if chars.length > @maxlength && @maxlength >= 0
chars = chars[0, @maxlength]
end
@text = "" @text = ""
chars.each do |ch| chars.each do |ch|
@text += ch if ch @text += ch if ch
@@ -81,8 +79,6 @@ class CharacterEntryHelper
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -217,8 +213,6 @@ class Window_TextEntry < SpriteWindow_Base
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -253,8 +247,6 @@ class Window_TextEntry_Keyboard < Window_TextEntry
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================

View File

@@ -18,8 +18,8 @@ end
# Methods that determine the duration of an audio file. # Methods that determine the duration of an audio file.
#=============================================================================== #===============================================================================
def getOggPage(file) def getOggPage(file)
fgetdw = proc { |file| fgetdw = proc { |f|
(file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) (f.eof? ? 0 : (f.read(4).unpack("V")[0] || 0))
} }
dw = fgetdw.call(file) dw = fgetdw.call(file)
return nil if dw != 0x5367674F return nil if dw != 0x5367674F
@@ -35,8 +35,8 @@ end
# internal function # internal function
def oggfiletime(file) def oggfiletime(file)
fgetdw = proc { |file| fgetdw = proc { |f|
(file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0)) (f.eof? ? 0 : (f.read(4).unpack("V")[0] || 0))
} }
pages = [] pages = []
page = nil page = nil
@@ -51,8 +51,8 @@ def oggfiletime(file)
i = -1 i = -1
pcmlengths = [] pcmlengths = []
rates = [] rates = []
pages.each do |page| pages.each do |pg|
header = page[0] header = pg[0]
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]
@@ -65,7 +65,7 @@ def oggfiletime(file)
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 = pg[1]
packtype = (file.read(1)[0].ord rescue 0) packtype = (file.read(1)[0].ord rescue 0)
string = file.read(6) string = file.read(6)
return -1 if string != "vorbis" return -1 if string != "vorbis"
@@ -78,7 +78,7 @@ def oggfiletime(file)
pcmlengths[i] = frameno pcmlengths[i] = frameno
end end
ret = 0.0 ret = 0.0
pcmlengths.each_with_index { |length, i| ret += length.to_f / rates[i] } pcmlengths.each_with_index { |length, j| ret += length.to_f / rates[j] }
return ret * 256.0 return ret * 256.0
end end
@@ -105,7 +105,7 @@ def getPlayTime2(filename)
fgetw = proc { |file| fgetw = proc { |file|
(file.eof? ? 0 : (file.read(2).unpack("v")[0] || 0)) (file.eof? ? 0 : (file.read(2).unpack("v")[0] || 0))
} }
File.open(filename, "rb") { |file| File.open(filename, "rb") do |file|
file.pos = 0 file.pos = 0
fdw = fgetdw.call(file) fdw = fgetdw.call(file)
case fdw case fdw
@@ -165,6 +165,6 @@ def getPlayTime2(filename)
break break
end end
end end
} end
return time return time
end end

View File

@@ -306,6 +306,8 @@ module Transitions
end end
end end
#---------------------------------------------------------------------------
private private
def rand_sign def rand_sign
@@ -1382,29 +1384,29 @@ module Transitions
# Foe sprite appears # Foe sprite appears
proportion = (@timer - @foe_appear_start) / (@foe_appear_end - @foe_appear_start) proportion = (@timer - @foe_appear_start) / (@foe_appear_end - @foe_appear_start)
start_x = Graphics.width + (@foe_bitmap.width / 2) start_x = Graphics.width + (@foe_bitmap.width / 2)
@foe_sprite.x = start_x + (FOE_SPRITE_X_LIMIT - start_x) * proportion @foe_sprite.x = start_x + ((FOE_SPRITE_X_LIMIT - start_x) * proportion)
elsif @timer >= @vs_appear_final elsif @timer >= @vs_appear_final
@vs_1_sprite.visible = false @vs_1_sprite.visible = false
elsif @timer >= @vs_appear_start_2 elsif @timer >= @vs_appear_start_2
# Temp VS sprites enlarge and shrink again # Temp VS sprites enlarge and shrink again
if @vs_2_sprite.visible if @vs_2_sprite.visible
@vs_2_sprite.zoom_x = 1.6 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time @vs_2_sprite.zoom_x = 1.6 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_2_sprite.zoom_x <= 1.2 if @vs_2_sprite.zoom_x <= 1.2
@vs_2_sprite.visible = false @vs_2_sprite.visible = false
@vs_main_sprite.visible = true @vs_main_sprite.visible = true
end end
end end
@vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
elsif @timer >= @vs_appear_start elsif @timer >= @vs_appear_start
# Temp VS sprites appear and start shrinking # Temp VS sprites appear and start shrinking
@vs_2_sprite.visible = true @vs_2_sprite.visible = true
@vs_2_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start) / @vs_shrink_time @vs_2_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2 if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2
@vs_1_sprite.visible = true @vs_1_sprite.visible = true
@vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
end end
elsif @timer >= @bar_appear_end elsif @timer >= @bar_appear_end
@@ -1413,7 +1415,7 @@ module Transitions
start_x = Graphics.width * (1 - (@timer / @bar_appear_end)) start_x = Graphics.width * (1 - (@timer / @bar_appear_end))
color = Color.new(0, 0, 0, 0) # Transparent color = Color.new(0, 0, 0, 0) # Transparent
(@sprites[0].height / 2).times do |i| (@sprites[0].height / 2).times do |i|
x = start_x - BAR_MASK[i % BAR_MASK.length] * 4 x = start_x - (BAR_MASK[i % BAR_MASK.length] * 4)
@bar_mask_sprite.bitmap.fill_rect(x, BAR_Y + (i * 2), @bar_mask_sprite.width - x, 2, color) @bar_mask_sprite.bitmap.fill_rect(x, BAR_Y + (i * 2), @bar_mask_sprite.width - x, 2, color)
end end
end end
@@ -1572,14 +1574,14 @@ module Transitions
# Bars/trainer sprites slide in # Bars/trainer sprites slide in
proportion = (@timer - @bar_appear_start) / (@bar_appear_end - @bar_appear_start) proportion = (@timer - @bar_appear_start) / (@bar_appear_end - @bar_appear_start)
sqrt_proportion = Math.sqrt(proportion) sqrt_proportion = Math.sqrt(proportion)
@player_bar_sprite.x = @player_bar_start_x + (@player_bar_x + BAR_OVERSHOOT - @player_bar_start_x) * sqrt_proportion @player_bar_sprite.x = @player_bar_start_x + ((@player_bar_x + BAR_OVERSHOOT - @player_bar_start_x) * sqrt_proportion)
@player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET @player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET
@foe_bar_sprite.x = @foe_bar_start_x + (@foe_bar_x - BAR_OVERSHOOT - @foe_bar_start_x) * sqrt_proportion @foe_bar_sprite.x = @foe_bar_start_x + ((@foe_bar_x - BAR_OVERSHOOT - @foe_bar_start_x) * sqrt_proportion)
@foe_sprite.x = @foe_bar_sprite.x + (@bar_bitmap.width / 2) - TRAINER_X_OFFSET @foe_sprite.x = @foe_bar_sprite.x + (@bar_bitmap.width / 2) - TRAINER_X_OFFSET
@text_sprite.x = @foe_bar_sprite.x @text_sprite.x = @foe_bar_sprite.x
end end
# Animate bars # Animate bars
if @timer >= @flash_start + 0.33 * @flash_duration if @timer >= @flash_start + (0.33 * @flash_duration)
bar_phase = (@timer * 30).to_i % @num_bar_frames bar_phase = (@timer * 30).to_i % @num_bar_frames
@player_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT @player_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT
@foe_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT @foe_bar_sprite.src_rect.y = bar_phase * BAR_HEIGHT
@@ -1594,23 +1596,23 @@ module Transitions
elsif @timer >= @vs_appear_start_2 elsif @timer >= @vs_appear_start_2
# Temp VS sprites enlarge and shrink again # Temp VS sprites enlarge and shrink again
if @vs_2_sprite.visible if @vs_2_sprite.visible
@vs_2_sprite.zoom_x = 1.6 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time @vs_2_sprite.zoom_x = 1.6 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_2_sprite.zoom_x <= 1.2 if @vs_2_sprite.zoom_x <= 1.2
@vs_2_sprite.visible = false @vs_2_sprite.visible = false
@vs_main_sprite.visible = true @vs_main_sprite.visible = true
end end
end end
@vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start_2) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
elsif @timer >= @vs_appear_start elsif @timer >= @vs_appear_start
# Temp VS sprites appear and start shrinking # Temp VS sprites appear and start shrinking
@vs_2_sprite.visible = true @vs_2_sprite.visible = true
@vs_2_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start) / @vs_shrink_time @vs_2_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start) / @vs_shrink_time)
@vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x @vs_2_sprite.zoom_y = @vs_2_sprite.zoom_x
if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2 if @vs_1_sprite.visible || @vs_2_sprite.zoom_x <= 1.6 # Halfway between 2.0 and 1.2
@vs_1_sprite.visible = true @vs_1_sprite.visible = true
@vs_1_sprite.zoom_x = 2.0 - 0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time @vs_1_sprite.zoom_x = 2.0 - (0.8 * (@timer - @vs_appear_start - (@vs_shrink_time / 2)) / @vs_shrink_time)
@vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x @vs_1_sprite.zoom_y = @vs_1_sprite.zoom_x
end end
end end
@@ -1652,12 +1654,12 @@ module Transitions
@flash_viewport.color.alpha = 255 * proportion @flash_viewport.color.alpha = 255 * proportion
# Move bars and trainer sprites off-screen # Move bars and trainer sprites off-screen
dist = BAR_Y_INDENT + BAR_HEIGHT dist = BAR_Y_INDENT + BAR_HEIGHT
@player_bar_sprite.x = @player_bar_x - dist * proportion @player_bar_sprite.x = @player_bar_x - (dist * proportion)
@player_bar_sprite.y = @player_bar_y - dist * proportion @player_bar_sprite.y = @player_bar_y - (dist * proportion)
@player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET @player_sprite.x = @player_bar_sprite.x + TRAINER_X_OFFSET
@player_sprite.y = @player_bar_sprite.y + BAR_HEIGHT - TRAINER_Y_OFFSET @player_sprite.y = @player_bar_sprite.y + BAR_HEIGHT - TRAINER_Y_OFFSET
@foe_bar_sprite.x = @foe_bar_x + dist * proportion @foe_bar_sprite.x = @foe_bar_x + (dist * proportion)
@foe_bar_sprite.y = @foe_bar_y + dist * proportion @foe_bar_sprite.y = @foe_bar_y + (dist * proportion)
@foe_sprite.x = @foe_bar_sprite.x + (@bar_bitmap.width / 2) - TRAINER_X_OFFSET @foe_sprite.x = @foe_bar_sprite.x + (@bar_bitmap.width / 2) - TRAINER_X_OFFSET
@foe_sprite.y = @foe_bar_sprite.y + @foe_bitmap.height - TRAINER_Y_OFFSET @foe_sprite.y = @foe_bar_sprite.y + @foe_bitmap.height - TRAINER_Y_OFFSET
end end
@@ -1731,8 +1733,8 @@ module Transitions
next if proportion < start_time next if proportion < start_time
single_proportion = (proportion - start_time) / @rocket_appear_time single_proportion = (proportion - start_time) / @rocket_appear_time
sqrt_single_proportion = Math.sqrt(single_proportion) sqrt_single_proportion = Math.sqrt(single_proportion)
sprite.x = (ROCKET_X[i] + (0.5 - ROCKET_X[i]) * sqrt_single_proportion) * Graphics.width sprite.x = (ROCKET_X[i] + ((0.5 - ROCKET_X[i]) * sqrt_single_proportion)) * Graphics.width
sprite.y = (ROCKET_Y[i] + (0.5 - ROCKET_Y[i]) * sqrt_single_proportion) * Graphics.height sprite.y = (ROCKET_Y[i] + ((0.5 - ROCKET_Y[i]) * sqrt_single_proportion)) * Graphics.height
sprite.zoom_x = 2.5 * (1 - single_proportion) sprite.zoom_x = 2.5 * (1 - single_proportion)
sprite.zoom_y = sprite.zoom_x sprite.zoom_y = sprite.zoom_x
sprite.angle = sprite.zoom_x * ROCKET_ANGLE[i] * 360 sprite.angle = sprite.zoom_x * ROCKET_ANGLE[i] * 360
@@ -1867,8 +1869,8 @@ module Transitions
# Slide foe sprite/name off-screen # Slide foe sprite/name off-screen
proportion = (@timer - @foe_disappear_start) / (@foe_disappear_end - @foe_disappear_start) proportion = (@timer - @foe_disappear_start) / (@foe_disappear_end - @foe_disappear_start)
start_x = Graphics.width / 2 start_x = Graphics.width / 2
@foe_sprite.x = start_x - (@foe_bitmap.width + start_x) * proportion * proportion @foe_sprite.x = start_x - ((@foe_bitmap.width + start_x) * proportion * proportion)
@text_sprite.x = @foe_sprite.x - Graphics.width / 2 @text_sprite.x = @foe_sprite.x - (Graphics.width / 2)
elsif @timer >= @flash_end elsif @timer >= @flash_end
@flash_viewport.color.alpha = 0 # Ensure flash has ended @flash_viewport.color.alpha = 0 # Ensure flash has ended
elsif @timer >= @bg_2_appear_end elsif @timer >= @bg_2_appear_end
@@ -1884,8 +1886,8 @@ module Transitions
@bg_2_sprite.opacity = 255 * proportion @bg_2_sprite.opacity = 255 * proportion
# Foe sprite/name appear # Foe sprite/name appear
start_x = Graphics.width + (@foe_bitmap.width / 2) start_x = Graphics.width + (@foe_bitmap.width / 2)
@foe_sprite.x = start_x + ((Graphics.width / 2) - start_x) * Math.sqrt(proportion) @foe_sprite.x = start_x + (((Graphics.width / 2) - start_x) * Math.sqrt(proportion))
@text_sprite.x = @foe_sprite.x - Graphics.width / 2 @text_sprite.x = @foe_sprite.x - (Graphics.width / 2)
@text_sprite.visible = true @text_sprite.visible = true
elsif @timer >= @bg_1_appear_end elsif @timer >= @bg_1_appear_end
@bg_1_sprite.oy = Graphics.height / 2 @bg_1_sprite.oy = Graphics.height / 2

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class PictureSprite < Sprite class PictureSprite < Sprite
def initialize(viewport, picture) def initialize(viewport, picture)
super(viewport) super(viewport)
@@ -50,8 +53,6 @@ class PictureSprite < Sprite
end end
end end
def pbTextBitmap(text, maxwidth = Graphics.width) def pbTextBitmap(text, maxwidth = Graphics.width)
tmp = Bitmap.new(maxwidth, Graphics.height) tmp = Bitmap.new(maxwidth, Graphics.height)
pbSetSystemFont(tmp) pbSetSystemFont(tmp)
@@ -59,10 +60,8 @@ def pbTextBitmap(text, maxwidth = Graphics.width)
return tmp return tmp
end end
#=============================================================================== #===============================================================================
# EventScene #
#=============================================================================== #===============================================================================
class EventScene class EventScene
attr_accessor :onCTrigger, :onBTrigger, :onUpdate attr_accessor :onCTrigger, :onBTrigger, :onUpdate
@@ -80,12 +79,8 @@ class EventScene
def dispose def dispose
return if disposed? return if disposed?
@picturesprites.each do |sprite| @picturesprites.each { |sprite| sprite.dispose }
sprite.dispose @usersprites.each { |sprite| sprite.dispose }
end
@usersprites.each do |sprite|
sprite.dispose
end
@onCTrigger.clear @onCTrigger.clear
@onBTrigger.clear @onBTrigger.clear
@onUpdate.clear @onUpdate.clear
@@ -143,9 +138,7 @@ class EventScene
def pictureWait(extraframes = 0) def pictureWait(extraframes = 0)
loop do loop do
hasRunning = false hasRunning = false
@pictures.each do |pic| @pictures.each { |pic| hasRunning = true if pic.running? }
hasRunning = true if pic.running?
end
break if !hasRunning break if !hasRunning
update update
end end
@@ -156,12 +149,8 @@ class EventScene
return if disposed? return if disposed?
Graphics.update Graphics.update
Input.update Input.update
@pictures.each do |picture| @pictures.each { |picture| picture.update }
picture.update @picturesprites.each { |sprite| sprite.update }
end
@picturesprites.each do |sprite|
sprite.update
end
@usersprites.each do |sprite| @usersprites.each do |sprite|
next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite) next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite)
sprite.update sprite.update
@@ -181,18 +170,14 @@ class EventScene
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
def pbEventScreen(cls) def pbEventScreen(cls)
pbFadeOutIn { pbFadeOutIn do
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999 viewport.z = 99999
PBDebug.logonerr { PBDebug.logonerr { cls.new(viewport).main }
cls.new(viewport).main
}
viewport.dispose viewport.dispose
} end
end end

View File

@@ -266,13 +266,12 @@ module GameData
self.constants.each do |c| self.constants.each do |c|
next if !self.const_get(c).is_a?(Class) next if !self.const_get(c).is_a?(Class)
ret[c] = self.const_get(c)::PBS_BASE_FILENAME if self.const_get(c).const_defined?(:PBS_BASE_FILENAME) ret[c] = self.const_get(c)::PBS_BASE_FILENAME if self.const_get(c).const_defined?(:PBS_BASE_FILENAME)
if ret[c].is_a?(Array) next if !ret[c].is_a?(Array)
ret[c].length.times do |i| ret[c].length.times do |i|
next if i == 0 next if i == 0
ret[(c.to_s + i.to_s).to_sym] = ret[c][i] # :Species1 => "pokemon_forms" ret[(c.to_s + i.to_s).to_sym] = ret[c][i] # :Species1 => "pokemon_forms"
end
ret[c] = ret[c][0] # :Species => "pokemon"
end end
ret[c] = ret[c][0] # :Species => "pokemon"
end end
return ret return ret
end end

View File

@@ -33,7 +33,7 @@ module GameData
# @return [String] the translated name of this region # @return [String] the translated name of this region
def name def name
return pbGetMessageFromHash(MessageTypes::Regions, @real_name) return pbGetMessageFromHash(MessageTypes::REGION_NAMES, @real_name)
end end
def has_flag?(flag) def has_flag?(flag)

View File

@@ -48,7 +48,7 @@ module GameData
# @return [String] the translated name of this item # @return [String] the translated name of this item
def name def name
return pbGetMessageFromHash(MessageTypes::Types, @real_name) return pbGetMessageFromHash(MessageTypes::TYPE_NAMES, @real_name)
end end
def physical?; return !@special_type; end def physical?; return !@special_type; end

View File

@@ -14,10 +14,10 @@ module GameData
include InstanceMethods include InstanceMethods
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
"Description" => [:real_description, "q"], "Description" => [:real_description, "q"],
"Flags" => [:flags, "*s"] "Flags" => [:flags, "*s"]
} }
def initialize(hash) def initialize(hash)
@@ -30,12 +30,12 @@ module GameData
# @return [String] the translated name of this ability # @return [String] the translated name of this ability
def name def name
return pbGetMessageFromHash(MessageTypes::Abilities, @real_name) return pbGetMessageFromHash(MessageTypes::ABILITY_NAMES, @real_name)
end end
# @return [String] the translated description of this ability # @return [String] the translated description of this ability
def description def description
return pbGetMessageFromHash(MessageTypes::AbilityDescriptions, @real_description) return pbGetMessageFromHash(MessageTypes::ABILITY_DESCRIPTIONS, @real_description)
end end
def has_flag?(flag) def has_flag?(flag)

View File

@@ -60,12 +60,12 @@ module GameData
# @return [String] the translated name of this move # @return [String] the translated name of this move
def name def name
return pbGetMessageFromHash(MessageTypes::Moves, @real_name) return pbGetMessageFromHash(MessageTypes::MOVE_NAMES, @real_name)
end end
# @return [String] the translated description of this move # @return [String] the translated description of this move
def description def description
return pbGetMessageFromHash(MessageTypes::MoveDescriptions, @real_description) return pbGetMessageFromHash(MessageTypes::MOVE_DESCRIPTIONS, @real_description)
end end
def has_flag?(flag) def has_flag?(flag)

View File

@@ -31,10 +31,10 @@ module GameData
"Price" => [:price, "u"], "Price" => [:price, "u"],
"SellPrice" => [:sell_price, "u"], "SellPrice" => [:sell_price, "u"],
"BPPrice" => [:bp_price, "u"], "BPPrice" => [:bp_price, "u"],
"FieldUse" => [:field_use, "e", { "OnPokemon" => 1, "Direct" => 2, "FieldUse" => [:field_use, "e", {"OnPokemon" => 1, "Direct" => 2,
"TM" => 3, "HM" => 4, "TR" => 5 }], "TM" => 3, "HM" => 4, "TR" => 5}],
"BattleUse" => [:battle_use, "e", { "OnPokemon" => 1, "OnMove" => 2, "BattleUse" => [:battle_use, "e", {"OnPokemon" => 1, "OnMove" => 2,
"OnBattler" => 3, "OnFoe" => 4, "Direct" => 5 }], "OnBattler" => 3, "OnFoe" => 4, "Direct" => 5}],
"Flags" => [:flags, "*s"], "Flags" => [:flags, "*s"],
"Consumable" => [:consumable, "b"], "Consumable" => [:consumable, "b"],
"Move" => [:move, "e", :Move], "Move" => [:move, "e", :Move],
@@ -133,29 +133,29 @@ module GameData
# @return [String] the translated name of this item # @return [String] the translated name of this item
def name def name
return pbGetMessageFromHash(MessageTypes::Items, @real_name) return pbGetMessageFromHash(MessageTypes::ITEM_NAMES, @real_name)
end end
# @return [String] the translated plural version of the name of this item # @return [String] the translated plural version of the name of this item
def name_plural def name_plural
return pbGetMessageFromHash(MessageTypes::ItemPlurals, @real_name_plural) return pbGetMessageFromHash(MessageTypes::ITEM_NAME_PLURALS, @real_name_plural)
end end
# @return [String] the translated portion name of this item # @return [String] the translated portion name of this item
def portion_name def portion_name
return pbGetMessageFromHash(MessageTypes::ItemPortions, @real_portion_name) if @real_portion_name return pbGetMessageFromHash(MessageTypes::ITEM_PORTION_NAMES, @real_portion_name) if @real_portion_name
return name return name
end end
# @return [String] the translated plural version of the portion name of this item # @return [String] the translated plural version of the portion name of this item
def portion_name_plural def portion_name_plural
return pbGetMessageFromHash(MessageTypes::ItemPortionPlurals, @real_portion_name_plural) if @real_portion_name_plural return pbGetMessageFromHash(MessageTypes::ITEM_PORTION_NAME_PLURALS, @real_portion_name_plural) if @real_portion_name_plural
return name_plural return name_plural
end end
# @return [String] the translated description of this item # @return [String] the translated description of this item
def description def description
return pbGetMessageFromHash(MessageTypes::ItemDescriptions, @real_description) return pbGetMessageFromHash(MessageTypes::ITEM_DESCRIPTIONS, @real_description)
end end
def has_flag?(flag) def has_flag?(flag)

View File

@@ -220,22 +220,22 @@ module GameData
# @return [String] the translated name of this species # @return [String] the translated name of this species
def name def name
return pbGetMessageFromHash(MessageTypes::Species, @real_name) return pbGetMessageFromHash(MessageTypes::SPECIES_NAMES, @real_name)
end end
# @return [String] the translated name of this form of this species # @return [String] the translated name of this form of this species
def form_name def form_name
return pbGetMessageFromHash(MessageTypes::SpeciesForms, @real_form_name) return pbGetMessageFromHash(MessageTypes::SPECIES_FORM_NAMES, @real_form_name)
end end
# @return [String] the translated Pokédex category of this species # @return [String] the translated Pokédex category of this species
def category def category
return pbGetMessageFromHash(MessageTypes::SpeciesCategories, @real_category) return pbGetMessageFromHash(MessageTypes::SPECIES_CATEGORIES, @real_category)
end end
# @return [String] the translated Pokédex entry of this species # @return [String] the translated Pokédex entry of this species
def pokedex_entry def pokedex_entry
return pbGetMessageFromHash(MessageTypes::PokedexEntries, @real_pokedex_entry) return pbGetMessageFromHash(MessageTypes::POKEDEX_ENTRIES, @real_pokedex_entry)
end end
def default_form def default_form

View File

@@ -38,7 +38,7 @@ module GameData
if form > 0 if form > 0
trial = sprintf("%s_%d", species, form).to_sym trial = sprintf("%s_%d", species, form).to_sym
if !DATA.has_key?(trial) if !DATA.has_key?(trial)
self.register({ :id => species }) if !DATA[species] self.register({:id => species}) if !DATA[species]
self.register({ self.register({
:id => trial, :id => trial,
:species => species, :species => species,
@@ -52,7 +52,7 @@ module GameData
end end
return DATA[trial] return DATA[trial]
end end
self.register({ :id => species }) if !DATA[species] self.register({:id => species}) if !DATA[species]
return DATA[species] return DATA[species]
end end
@@ -70,9 +70,7 @@ module GameData
def apply_metrics_to_sprite(sprite, index, shadow = false) def apply_metrics_to_sprite(sprite, index, shadow = false)
if shadow if shadow
if (index & 1) == 1 # Foe Pokémon sprite.x += @shadow_x * 2 if (index & 1) == 1 # Foe Pokémon
sprite.x += @shadow_x * 2
end
elsif (index & 1) == 0 # Player's Pokémon elsif (index & 1) == 0 # Player's Pokémon
sprite.x += @back_sprite[0] * 2 sprite.x += @back_sprite[0] * 2
sprite.y += @back_sprite[1] * 2 sprite.y += @back_sprite[1] * 2

View File

@@ -13,7 +13,7 @@ module GameData
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "e", :Species], "SectionName" => [:id, "e", :Species],
"GaugeSize" => [:gauge_size, "v"], "GaugeSize" => [:gauge_size, "v"],
"Moves" => [:moves, "*m"], # Not enumerated when compiled "Moves" => [:moves, "*e", :Move],
"Flags" => [:flags, "*s"] "Flags" => [:flags, "*s"]
} }
HEART_GAUGE_SIZE = 4000 # Default gauge size HEART_GAUGE_SIZE = 4000 # Default gauge size
@@ -21,6 +21,11 @@ module GameData
extend ClassMethodsSymbols extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
alias __orig__load load unless private_method_defined?(:__orig__load)
def self.load
__orig__load if safeExists?("Data/#{self::DATA_FILENAME}")
end
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE @gauge_size = hash[:gauge_size] || HEART_GAUGE_SIZE

View File

@@ -33,12 +33,12 @@ module GameData
# @return [String] the translated name of this ribbon # @return [String] the translated name of this ribbon
def name def name
return pbGetMessageFromHash(MessageTypes::RibbonNames, @real_name) return pbGetMessageFromHash(MessageTypes::RIBBON_NAMES, @real_name)
end end
# @return [String] the translated description of this ribbon # @return [String] the translated description of this ribbon
def description def description
return pbGetMessageFromHash(MessageTypes::RibbonDescriptions, @real_description) return pbGetMessageFromHash(MessageTypes::RIBBON_DESCRIPTIONS, @real_description)
end end
def has_flag?(flag) def has_flag?(flag)

View File

@@ -18,10 +18,10 @@ module GameData
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
"Gender" => [:gender, "e", { "Male" => 0, "male" => 0, "M" => 0, "m" => 0, "0" => 0, "Gender" => [:gender, "e", {"Male" => 0, "male" => 0, "M" => 0, "m" => 0, "0" => 0,
"Female" => 1, "female" => 1, "F" => 1, "f" => 1, "1" => 1, "Female" => 1, "female" => 1, "F" => 1, "f" => 1, "1" => 1,
"Unknown" => 2, "unknown" => 2, "Other" => 2, "other" => 2, "Unknown" => 2, "unknown" => 2, "Other" => 2, "other" => 2,
"Mixed" => 2, "mixed" => 2, "X" => 2, "x" => 2, "2" => 2 }], "Mixed" => 2, "mixed" => 2, "X" => 2, "x" => 2, "2" => 2}],
"BaseMoney" => [:base_money, "u"], "BaseMoney" => [:base_money, "u"],
"SkillLevel" => [:skill_level, "u"], "SkillLevel" => [:skill_level, "u"],
"Flags" => [:flags, "*s"], "Flags" => [:flags, "*s"],
@@ -113,7 +113,7 @@ module GameData
# @return [String] the translated name of this trainer type # @return [String] the translated name of this trainer type
def name def name
return pbGetMessageFromHash(MessageTypes::TrainerTypes, @real_name) return pbGetMessageFromHash(MessageTypes::TRAINER_TYPE_NAMES, @real_name)
end end
def male?; return @gender == 0; end def male?; return @gender == 0; end

View File

@@ -30,8 +30,8 @@ module GameData
"Ability" => [:ability, "e", :Ability], "Ability" => [:ability, "e", :Ability],
"AbilityIndex" => [:ability_index, "u"], "AbilityIndex" => [:ability_index, "u"],
"Item" => [:item, "e", :Item], "Item" => [:item, "e", :Item],
"Gender" => [:gender, "e", { "M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0, "Gender" => [:gender, "e", {"M" => 0, "m" => 0, "Male" => 0, "male" => 0, "0" => 0,
"F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1 }], "F" => 1, "f" => 1, "Female" => 1, "female" => 1, "1" => 1}],
"Nature" => [:nature, "e", :Nature], "Nature" => [:nature, "e", :Nature],
"IV" => [:iv, "uUUUUU"], "IV" => [:iv, "uUUUUU"],
"EV" => [:ev, "uUUUUU"], "EV" => [:ev, "uUUUUU"],
@@ -102,12 +102,12 @@ module GameData
# @return [String] the translated name of this trainer # @return [String] the translated name of this trainer
def name def name
return pbGetMessageFromHash(MessageTypes::TrainerNames, @real_name) return pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, @real_name)
end end
# @return [String] the translated in-battle lose message of this trainer # @return [String] the translated in-battle lose message of this trainer
def lose_text def lose_text
return pbGetMessageFromHash(MessageTypes::TrainerLoseTexts, @real_lose_text) return pbGetMessageFromHash(MessageTypes::TRAINER_SPEECHES_LOSE, @real_lose_text)
end end
# Creates a battle-ready version of a trainer's data. # Creates a battle-ready version of a trainer's data.

View File

@@ -74,7 +74,7 @@ module GameData
# @return [String] the translated name of the Pokémon Storage creator # @return [String] the translated name of the Pokémon Storage creator
def storage_creator def storage_creator
ret = pbGetMessageFromHash(MessageTypes::StorageCreator, @real_storage_creator) ret = pbGetMessageFromHash(MessageTypes::STORAGE_CREATOR_NAME, @real_storage_creator)
return nil_or_empty?(ret) ? _INTL("Bill") : ret return nil_or_empty?(ret) ? _INTL("Bill") : ret
end end
end end

View File

@@ -115,7 +115,7 @@ module GameData
# @return [String] the translated name of this map # @return [String] the translated name of this map
def name def name
ret = pbGetMessageFromHash(MessageTypes::MapNames, @real_name) ret = pbGetMessageFromHash(MessageTypes::MAP_NAMES, @real_name)
ret = pbGetBasicMapNameFromId(@id) if nil_or_empty?(ret) ret = pbGetBasicMapNameFromId(@id) if nil_or_empty?(ret)
ret.gsub!(/\\PN/, $player.name) if $player ret.gsub!(/\\PN/, $player.name) if $player
return ret return ret

View File

@@ -42,7 +42,7 @@ module GameData
validate tr_type => [Symbol, String] validate tr_type => [Symbol, String]
validate tr_name => [String, NilClass] validate tr_name => [String, NilClass]
key = [tr_type.to_sym, tr_name, tr_version] key = [tr_type.to_sym, tr_name, tr_version]
key = key[0] if key[1] == nil key = key[0] if key[1].nil?
return !self::DATA[key].nil? return !self::DATA[key].nil?
end end

View File

@@ -166,11 +166,11 @@ class Battle
@runCommand = 0 @runCommand = 0
@nextPickupUse = 0 @nextPickupUse = 0
if GameData::Move.exists?(:STRUGGLE) if GameData::Move.exists?(:STRUGGLE)
@struggle = Move.from_pokemon_move(self, Pokemon::Move.new(:STRUGGLE)) @struggle = Move.from_pokemon_move(self, Pokemon::Move.new(:STRUGGLE))
else else
@struggle = Move::Struggle.new(self, nil) @struggle = Move::Struggle.new(self, nil)
end end
@mega_rings = [] @mega_rings = []
GameData::Item.each { |item| @mega_rings.push(item.id) if item.has_flag?("MegaRing") } GameData::Item.each { |item| @mega_rings.push(item.id) if item.has_flag?("MegaRing") }
@battleAI = AI.new(self) @battleAI = AI.new(self)
end end

View File

@@ -211,9 +211,7 @@ class Battle
oldSpAtk = pkmn.spatk oldSpAtk = pkmn.spatk
oldSpDef = pkmn.spdef oldSpDef = pkmn.spdef
oldSpeed = pkmn.speed oldSpeed = pkmn.speed
if battler&.pokemon battler.pokemon.changeHappiness("levelup") if battler&.pokemon
battler.pokemon.changeHappiness("levelup")
end
pkmn.calc_stats pkmn.calc_stats
battler&.pbUpdate(false) battler&.pbUpdate(false)
@scene.pbRefreshOne(battler.index) if battler @scene.pbRefreshOne(battler.index) if battler

View File

@@ -227,7 +227,7 @@ class Battle
end end
# Reorder the priority array # Reorder the priority array
if needRearranging if needRearranging
@priority.sort! { |a, b| @priority.sort! do |a, b|
if a[5] != b[5] if a[5] != b[5]
# Sort by priority (highest value first) # Sort by priority (highest value first)
b[5] <=> a[5] b[5] <=> a[5]
@@ -241,7 +241,7 @@ class Battle
# Sort by speed (highest first), and use tie-breaker if necessary # Sort by speed (highest first), and use tie-breaker if necessary
(a[1] == b[1]) ? b[6] <=> a[6] : b[1] <=> a[1] (a[1] == b[1]) ? b[6] <=> a[6] : b[1] <=> a[1]
end end
} end
# Write the priority order to the debug log # Write the priority order to the debug log
if fullCalc && $INTERNAL if fullCalc && $INTERNAL
logMsg = "[Round order] " logMsg = "[Round order] "

View File

@@ -111,7 +111,7 @@ class Battle
# all instances where the party screen is opened. # all instances where the party screen is opened.
def pbPartyScreen(idxBattler, checkLaxOnly = false, canCancel = false, shouldRegister = false) def pbPartyScreen(idxBattler, checkLaxOnly = false, canCancel = false, shouldRegister = false)
ret = -1 ret = -1
@scene.pbPartyScreen(idxBattler, canCancel) { |idxParty, partyScene| @scene.pbPartyScreen(idxBattler, canCancel) do |idxParty, partyScene|
if checkLaxOnly if checkLaxOnly
next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene) next false if !pbCanSwitchLax?(idxBattler, idxParty, partyScene)
elsif !pbCanSwitch?(idxBattler, idxParty, partyScene) elsif !pbCanSwitch?(idxBattler, idxParty, partyScene)
@@ -122,7 +122,7 @@ class Battle
end end
ret = idxParty ret = idxParty
next true next true
} end
return ret return ret
end end

View File

@@ -64,7 +64,7 @@ class Battle
return true if pbAutoFightMenu(idxBattler) return true if pbAutoFightMenu(idxBattler)
# Regular move selection # Regular move selection
ret = false ret = false
@scene.pbFightMenu(idxBattler, pbCanMegaEvolve?(idxBattler)) { |cmd| @scene.pbFightMenu(idxBattler, pbCanMegaEvolve?(idxBattler)) do |cmd|
case cmd case cmd
when -1 # Cancel when -1 # Cancel
when -2 # Toggle Mega Evolution when -2 # Toggle Mega Evolution
@@ -83,7 +83,7 @@ class Battle
ret = true ret = true
end end
next true next true
} end
return ret return ret
end end
@@ -103,7 +103,7 @@ class Battle
return false return false
end end
ret = false ret = false
@scene.pbItemMenu(idxBattler, firstAction) { |item, useType, idxPkmn, idxMove, itemScene| @scene.pbItemMenu(idxBattler, firstAction) do |item, useType, idxPkmn, idxMove, itemScene|
next false if !item next false if !item
battler = pkmn = nil battler = pkmn = nil
case useType case useType
@@ -133,7 +133,7 @@ class Battle
next false if !pbRegisterItem(idxBattler, item, idxPkmn, idxMove) next false if !pbRegisterItem(idxBattler, item, idxPkmn, idxMove)
ret = true ret = true
next true next true
} end
return ret return ret
end end

View File

@@ -57,9 +57,9 @@ class Battle
pbPursuit(b.index) pbPursuit(b.index)
return if @decision > 0 return if @decision > 0
# Switch Pokémon # Switch Pokémon
allBattlers.each do |b| allBattlers.each do |b2|
b.droppedBelowHalfHP = false b2.droppedBelowHalfHP = false
b.statsDropped = false b2.statsDropped = false
end end
pbRecallAndReplace(b.index, idxNewPkmn) pbRecallAndReplace(b.index, idxNewPkmn)
pbOnBattlerEnteringBattle(b.index, true) pbOnBattlerEnteringBattle(b.index, true)

View File

@@ -143,9 +143,9 @@ class Battle
next if battler.opposes?(side) next if battler.opposes?(side)
next if !battler.takesIndirectDamage? || battler.pbHasType?(:FIRE) next if !battler.takesIndirectDamage? || battler.pbHasType?(:FIRE)
@scene.pbDamageAnimation(battler) @scene.pbDamageAnimation(battler)
battler.pbTakeEffectDamage(battler.totalhp / 8, false) { |hp_lost| battler.pbTakeEffectDamage(battler.totalhp / 8, false) do |hp_lost|
pbDisplay(_INTL("{1} is hurt by the sea of fire!", battler.pbThis)) pbDisplay(_INTL("{1} is hurt by the sea of fire!", battler.pbThis))
} end
end end
end end
end end
@@ -192,11 +192,11 @@ class Battle
recipient = @battlers[battler.effects[PBEffects::LeechSeed]] recipient = @battlers[battler.effects[PBEffects::LeechSeed]]
next if !recipient || recipient.fainted? next if !recipient || recipient.fainted?
pbCommonAnimation("LeechSeed", recipient, battler) pbCommonAnimation("LeechSeed", recipient, battler)
battler.pbTakeEffectDamage(battler.totalhp / 8) { |hp_lost| battler.pbTakeEffectDamage(battler.totalhp / 8) do |hp_lost|
recipient.pbRecoverHPFromDrain(hp_lost, battler, recipient.pbRecoverHPFromDrain(hp_lost, battler,
_INTL("{1}'s health is sapped by Leech Seed!", battler.pbThis)) _INTL("{1}'s health is sapped by Leech Seed!", battler.pbThis))
recipient.pbAbilitiesOnDamageTaken recipient.pbAbilitiesOnDamageTaken
} end
recipient.pbFaint if recipient.fainted? recipient.pbFaint if recipient.fainted?
end end
end end
@@ -259,16 +259,16 @@ class Battle
priority.each do |battler| priority.each do |battler|
battler.effects[PBEffects::Nightmare] = false if !battler.asleep? battler.effects[PBEffects::Nightmare] = false if !battler.asleep?
next if !battler.effects[PBEffects::Nightmare] || !battler.takesIndirectDamage? next if !battler.effects[PBEffects::Nightmare] || !battler.takesIndirectDamage?
battler.pbTakeEffectDamage(battler.totalhp / 4) { |hp_lost| battler.pbTakeEffectDamage(battler.totalhp / 4) do |hp_lost|
pbDisplay(_INTL("{1} is locked in a nightmare!", battler.pbThis)) pbDisplay(_INTL("{1} is locked in a nightmare!", battler.pbThis))
} end
end end
# Curse # Curse
priority.each do |battler| priority.each do |battler|
next if !battler.effects[PBEffects::Curse] || !battler.takesIndirectDamage? next if !battler.effects[PBEffects::Curse] || !battler.takesIndirectDamage?
battler.pbTakeEffectDamage(battler.totalhp / 4) { |hp_lost| battler.pbTakeEffectDamage(battler.totalhp / 4) do |hp_lost|
pbDisplay(_INTL("{1} is afflicted by the curse!", battler.pbThis)) pbDisplay(_INTL("{1} is afflicted by the curse!", battler.pbThis))
} end
end end
end end
@@ -301,9 +301,9 @@ class Battle
hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? battler.totalhp / 6 : battler.totalhp / 8 hpLoss = (Settings::MECHANICS_GENERATION >= 6) ? battler.totalhp / 6 : battler.totalhp / 8
end end
@scene.pbDamageAnimation(battler) @scene.pbDamageAnimation(battler)
battler.pbTakeEffectDamage(hpLoss, false) { |hp_lost| battler.pbTakeEffectDamage(hpLoss, false) do |hp_lost|
pbDisplay(_INTL("{1} is hurt by {2}!", battler.pbThis, move_name)) pbDisplay(_INTL("{1} is hurt by {2}!", battler.pbThis, move_name))
} end
end end
#============================================================================= #=============================================================================
@@ -319,9 +319,9 @@ class Battle
def pbEOREndBattlerEffects(priority) def pbEOREndBattlerEffects(priority)
# Taunt # Taunt
pbEORCountDownBattlerEffect(priority, PBEffects::Taunt) { |battler| pbEORCountDownBattlerEffect(priority, PBEffects::Taunt) do |battler|
pbDisplay(_INTL("{1}'s taunt wore off!", battler.pbThis)) pbDisplay(_INTL("{1}'s taunt wore off!", battler.pbThis))
} end
# Encore # Encore
priority.each do |battler| priority.each do |battler|
next if battler.fainted? || battler.effects[PBEffects::Encore] == 0 next if battler.fainted? || battler.effects[PBEffects::Encore] == 0
@@ -339,34 +339,34 @@ class Battle
end end
end end
# Disable/Cursed Body # Disable/Cursed Body
pbEORCountDownBattlerEffect(priority, PBEffects::Disable) { |battler| pbEORCountDownBattlerEffect(priority, PBEffects::Disable) do |battler|
battler.effects[PBEffects::DisableMove] = nil battler.effects[PBEffects::DisableMove] = nil
pbDisplay(_INTL("{1} is no longer disabled!", battler.pbThis)) pbDisplay(_INTL("{1} is no longer disabled!", battler.pbThis))
} end
# Magnet Rise # Magnet Rise
pbEORCountDownBattlerEffect(priority, PBEffects::MagnetRise) { |battler| pbEORCountDownBattlerEffect(priority, PBEffects::MagnetRise) do |battler|
pbDisplay(_INTL("{1}'s electromagnetism wore off!", battler.pbThis)) pbDisplay(_INTL("{1}'s electromagnetism wore off!", battler.pbThis))
} end
# Telekinesis # Telekinesis
pbEORCountDownBattlerEffect(priority, PBEffects::Telekinesis) { |battler| pbEORCountDownBattlerEffect(priority, PBEffects::Telekinesis) do |battler|
pbDisplay(_INTL("{1} was freed from the telekinesis!", battler.pbThis)) pbDisplay(_INTL("{1} was freed from the telekinesis!", battler.pbThis))
} end
# Heal Block # Heal Block
pbEORCountDownBattlerEffect(priority, PBEffects::HealBlock) { |battler| pbEORCountDownBattlerEffect(priority, PBEffects::HealBlock) do |battler|
pbDisplay(_INTL("{1}'s Heal Block wore off!", battler.pbThis)) pbDisplay(_INTL("{1}'s Heal Block wore off!", battler.pbThis))
} end
# Embargo # Embargo
pbEORCountDownBattlerEffect(priority, PBEffects::Embargo) { |battler| pbEORCountDownBattlerEffect(priority, PBEffects::Embargo) do |battler|
pbDisplay(_INTL("{1} can use items again!", battler.pbThis)) pbDisplay(_INTL("{1} can use items again!", battler.pbThis))
battler.pbItemTerrainStatBoostCheck battler.pbItemTerrainStatBoostCheck
} end
# Yawn # Yawn
pbEORCountDownBattlerEffect(priority, PBEffects::Yawn) { |battler| pbEORCountDownBattlerEffect(priority, PBEffects::Yawn) do |battler|
if battler.pbCanSleepYawn? if battler.pbCanSleepYawn?
PBDebug.log("[Lingering effect] #{battler.pbThis} fell asleep because of Yawn") PBDebug.log("[Lingering effect] #{battler.pbThis} fell asleep because of Yawn")
battler.pbSleep battler.pbSleep
end end
} end
# Perish Song # Perish Song
perishSongUsers = [] perishSongUsers = []
priority.each do |battler| priority.each do |battler|

View File

@@ -145,7 +145,7 @@ class Battle::Battler
def pbResetTypes def pbResetTypes
@types = @pokemon.types @types = @pokemon.types
@effects[PBEffects::ExtraType] = nil @effects[PBEffects::ExtraType] = nil
@effects[PBEffects::BurnUp] = false @effects[PBEffects::BurnUp] = false
@effects[PBEffects::Roost] = false @effects[PBEffects::Roost] = false
end end

View File

@@ -72,10 +72,10 @@ class Battle::Battler
# in and not at any later times, even if a traceable ability turns # in and not at any later times, even if a traceable ability turns
# up later. Essentials ignores this, and allows Trace to trigger # up later. Essentials ignores this, and allows Trace to trigger
# whenever it can even in Gen 5 battle mechanics. # whenever it can even in Gen 5 battle mechanics.
choices = @battle.allOtherSideBattlers(@index).select { |b| choices = @battle.allOtherSideBattlers(@index).select do |b|
next !b.ungainableAbility? && next !b.ungainableAbility? &&
![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id) ![:POWEROFALCHEMY, :RECEIVER, :TRACE].include?(b.ability_id)
} end
if choices.length > 0 if choices.length > 0
choice = choices[@battle.pbRandom(choices.length)] choice = choices[@battle.pbRandom(choices.length)]
@battle.pbShowAbilitySplash(self) @battle.pbShowAbilitySplash(self)

View File

@@ -48,9 +48,7 @@ class Battle::Battler
end end
# Use the move # Use the move
PBDebug.log("[Use move] #{pbThis} (#{@index}) used #{choice[2].name}") PBDebug.log("[Use move] #{pbThis} (#{@index}) used #{choice[2].name}")
PBDebug.logonerr { PBDebug.logonerr { pbUseMove(choice, choice[2] == @battle.struggle) }
pbUseMove(choice, choice[2] == @battle.struggle)
}
@battle.pbJudge @battle.pbJudge
# Update priority order # Update priority order
@battle.pbCalculatePriority if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES @battle.pbCalculatePriority if Settings::RECALCULATE_TURN_ORDER_AFTER_SPEED_CHANGES
@@ -315,9 +313,9 @@ class Battle::Battler
@battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!")) @battle.pbDisplay(_INTL("When the flame touched the powder on the Pokémon, it exploded!"))
user.lastMoveFailed = true user.lastMoveFailed = true
if ![:Rain, :HeavyRain].include?(user.effectiveWeather) && user.takesIndirectDamage? if ![:Rain, :HeavyRain].include?(user.effectiveWeather) && user.takesIndirectDamage?
user.pbTakeEffectDamage((user.totalhp / 4.0).round, false) { |hp_lost| user.pbTakeEffectDamage((user.totalhp / 4.0).round, false) do |hp_lost|
@battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) @battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName))
} end
@battle.pbGainExp # In case user is KO'd by this @battle.pbGainExp # In case user is KO'd by this
end end
pbCancelMoves pbCancelMoves
@@ -531,9 +529,9 @@ class Battle::Battler
@battle.pbDisplay(_INTL("{1} used the move instructed by {2}!", b.pbThis, user.pbThis(true))) @battle.pbDisplay(_INTL("{1} used the move instructed by {2}!", b.pbThis, user.pbThis(true)))
b.effects[PBEffects::Instructed] = true b.effects[PBEffects::Instructed] = true
if b.pbCanChooseMove?(@moves[idxMove], false) if b.pbCanChooseMove?(@moves[idxMove], false)
PBDebug.logonerr { PBDebug.logonerr do
b.pbUseMoveSimple(b.lastMoveUsed, b.lastRegularMoveTarget, idxMove, false) b.pbUseMoveSimple(b.lastMoveUsed, b.lastRegularMoveTarget, idxMove, false)
} end
b.lastRoundMoved = oldLastRoundMoved b.lastRoundMoved = oldLastRoundMoved
@battle.pbJudge @battle.pbJudge
return if @battle.decision > 0 return if @battle.decision > 0
@@ -567,9 +565,7 @@ class Battle::Battler
end end
nextUser.effects[PBEffects::Dancer] = true nextUser.effects[PBEffects::Dancer] = true
if nextUser.pbCanChooseMove?(move, false) if nextUser.pbCanChooseMove?(move, false)
PBDebug.logonerr { PBDebug.logonerr { nextUser.pbUseMoveSimple(move.id, preTarget) }
nextUser.pbUseMoveSimple(move.id, preTarget)
}
nextUser.lastRoundMoved = oldLastRoundMoved nextUser.lastRoundMoved = oldLastRoundMoved
nextUser.effects[PBEffects::Outrage] = oldOutrage nextUser.effects[PBEffects::Outrage] = oldOutrage
nextUser.currentMove = oldCurrentMove nextUser.currentMove = oldCurrentMove
@@ -716,9 +712,7 @@ class Battle::Battler
next if b.damageState.calcDamage == 0 next if b.damageState.calcDamage == 0
chance = move.pbAdditionalEffectChance(user, b) chance = move.pbAdditionalEffectChance(user, b)
next if chance <= 0 next if chance <= 0
if @battle.pbRandom(100) < chance move.pbAdditionalEffect(user, b) if @battle.pbRandom(100) < chance
move.pbAdditionalEffect(user, b)
end
end end
end end
# Make the target flinch (because of an item/ability) # Make the target flinch (because of an item/ability)

View File

@@ -104,11 +104,11 @@ class Battle::Move
def pbFailsAgainstTarget?(user, target, show_message); return false; end def pbFailsAgainstTarget?(user, target, show_message); return false; end
def pbMoveFailedLastInRound?(user, showMessage = true) def pbMoveFailedLastInRound?(user, showMessage = true)
unmoved = @battle.allBattlers.any? { |b| unmoved = @battle.allBattlers.any? do |b|
next b.index != user.index && next b.index != user.index &&
[:UseMove, :Shift].include?(@battle.choices[b.index][0]) && [:UseMove, :Shift].include?(@battle.choices[b.index][0]) &&
!b.movedThisRound? !b.movedThisRound?
} end
if !unmoved if !unmoved
@battle.pbDisplay(_INTL("But it failed!")) if showMessage @battle.pbDisplay(_INTL("But it failed!")) if showMessage
return true return true

View File

@@ -226,16 +226,12 @@ class Battle::Move
def pbModifyDamage(damageMult, user, target); return damageMult; end def pbModifyDamage(damageMult, user, target); return damageMult; end
def pbGetAttackStats(user, target) def pbGetAttackStats(user, target)
if specialMove? return user.spatk, user.stages[:SPECIAL_ATTACK] + 6 if specialMove?
return user.spatk, user.stages[:SPECIAL_ATTACK] + 6
end
return user.attack, user.stages[:ATTACK] + 6 return user.attack, user.stages[:ATTACK] + 6
end end
def pbGetDefenseStats(user, target) def pbGetDefenseStats(user, target)
if specialMove? return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6 if specialMove?
return target.spdef, target.stages[:SPECIAL_DEFENSE] + 6
end
return target.defense, target.stages[:DEFENSE] + 6 return target.defense, target.stages[:DEFENSE] + 6
end end
@@ -400,9 +396,7 @@ class Battle::Move
end end
end end
# Multi-targeting attacks # Multi-targeting attacks
if numTargets > 1 multipliers[:final_damage_multiplier] *= 0.75 if numTargets > 1
multipliers[:final_damage_multiplier] *= 0.75
end
# Weather # Weather
case user.effectiveWeather case user.effectiveWeather
when :Sun, :HarshSun when :Sun, :HarshSun

View File

@@ -366,8 +366,7 @@ class Battle::Move::TwoTurnMove < Battle::Move
@battle.pbDisplay(_INTL("{1} began charging up!", user.pbThis)) @battle.pbDisplay(_INTL("{1} began charging up!", user.pbThis))
end end
def pbAttackingTurnMessage(user, targets) def pbAttackingTurnMessage(user, targets); end
end
def pbEffectAgainstTarget(user, target) def pbEffectAgainstTarget(user, target)
if @damagingTurn if @damagingTurn
@@ -382,8 +381,7 @@ class Battle::Move::TwoTurnMove < Battle::Move
# the latter just records the target is being Sky Dropped # the latter just records the target is being Sky Dropped
end end
def pbAttackingTurnEffect(user, target) def pbAttackingTurnEffect(user, target); end
end
def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true) def pbShowAnimation(id, user, targets, hitNum = 0, showAnimation = true)
hitNum = 1 if @chargingTurn && !@damagingTurn # Charging anim hitNum = 1 if @chargingTurn && !@damagingTurn # Charging anim

View File

@@ -100,9 +100,7 @@ class Battle::Move::OHKO < Battle::Move::FixedDamageMove
def pbHitEffectivenessMessages(user, target, numTargets = 1) def pbHitEffectivenessMessages(user, target, numTargets = 1)
super super
if target.fainted? @battle.pbDisplay(_INTL("It's a one-hit KO!")) if target.fainted?
@battle.pbDisplay(_INTL("It's a one-hit KO!"))
end
end end
end end
@@ -1211,9 +1209,7 @@ end
#=============================================================================== #===============================================================================
class Battle::Move::UseTargetAttackInsteadOfUserAttack < Battle::Move class Battle::Move::UseTargetAttackInsteadOfUserAttack < Battle::Move
def pbGetAttackStats(user, target) def pbGetAttackStats(user, target)
if specialMove? return target.spatk, target.stages[:SPECIAL_ATTACK] + 6 if specialMove?
return target.spatk, target.stages[:SPECIAL_ATTACK] + 6
end
return target.attack, target.stages[:ATTACK] + 6 return target.attack, target.stages[:ATTACK] + 6
end end
end end

View File

@@ -328,7 +328,7 @@ class Battle::Move::UserConsumeBerryRaiseDefense2 < Battle::Move::StatUpMove
@battle.pbDisplay(_INTL("{1} ate its {2}!", user.pbThis, user.itemName)) @battle.pbDisplay(_INTL("{1} ate its {2}!", user.pbThis, user.itemName))
item = user.item item = user.item
user.pbConsumeItem(true, false) # Don't trigger Symbiosis yet user.pbConsumeItem(true, false) # Don't trigger Symbiosis yet
user.pbHeldItemTriggerCheck(item, false) user.pbHeldItemTriggerCheck(item.id, false)
end end
end end
@@ -370,7 +370,7 @@ class Battle::Move::AllBattlersConsumeBerry < Battle::Move
@battle.pbCommonAnimation("EatBerry", target) @battle.pbCommonAnimation("EatBerry", target)
item = target.item item = target.item
target.pbConsumeItem(true, false) # Don't trigger Symbiosis yet target.pbConsumeItem(true, false) # Don't trigger Symbiosis yet
target.pbHeldItemTriggerCheck(item, false) target.pbHeldItemTriggerCheck(item.id, false)
end end
end end
@@ -385,9 +385,11 @@ class Battle::Move::UserConsumeTargetBerry < Battle::Move
return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker return if target.hasActiveAbility?(:STICKYHOLD) && !@battle.moldBreaker
item = target.item item = target.item
itemName = target.itemName itemName = target.itemName
user.setBelched
target.pbRemoveItem target.pbRemoveItem
@battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!", user.pbThis, itemName)) @battle.pbDisplay(_INTL("{1} stole and ate its target's {2}!", user.pbThis, itemName))
user.pbHeldItemTriggerCheck(item, false) user.pbHeldItemTriggerCheck(item.id, false)
user.pbSymbiosis
end end
end end
@@ -445,8 +447,13 @@ class Battle::Move::ThrowUserItemAtTarget < Battle::Move
when :KINGSROCK, :RAZORFANG when :KINGSROCK, :RAZORFANG
target.pbFlinch(user) target.pbFlinch(user)
else else
target.pbHeldItemTriggerCheck(user.item, true) target.pbHeldItemTriggerCheck(user.item_id, true)
end end
# NOTE: The official games only let the target use Belch if the berry flung
# at it has some kind of effect (i.e. it isn't an effectless berry). I
# think this isn't in the spirit of "consuming a berry", so I've said
# that Belch is usable after having any kind of berry flung at you.
target.setBelched if user.item.is_berry?
end end
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers) def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers)

View File

@@ -363,8 +363,7 @@ class Battle::Scene
pbShowWindow(MESSAGE_BOX) pbShowWindow(MESSAGE_BOX)
end end
def pbBeginEndOfRoundPhase def pbBeginEndOfRoundPhase; end
end
def pbEndBattle(_result) def pbEndBattle(_result)
@abortable = false @abortable = false

View File

@@ -98,15 +98,11 @@ class Battle::Scene
if Input.trigger?(Input::LEFT) if Input.trigger?(Input::LEFT)
cw.index -= 1 if (cw.index & 1) == 1 cw.index -= 1 if (cw.index & 1) == 1
elsif Input.trigger?(Input::RIGHT) elsif Input.trigger?(Input::RIGHT)
if battler.moves[cw.index + 1]&.id && (cw.index & 1) == 0 cw.index += 1 if battler.moves[cw.index + 1]&.id && (cw.index & 1) == 0
cw.index += 1
end
elsif Input.trigger?(Input::UP) elsif Input.trigger?(Input::UP)
cw.index -= 2 if (cw.index & 2) == 2 cw.index -= 2 if (cw.index & 2) == 2
elsif Input.trigger?(Input::DOWN) elsif Input.trigger?(Input::DOWN)
if battler.moves[cw.index + 2]&.id && (cw.index & 2) == 0 cw.index += 2 if battler.moves[cw.index + 2]&.id && (cw.index & 2) == 0
cw.index += 2
end
end end
pbPlayCursorSE if cw.index != oldIndex pbPlayCursorSE if cw.index != oldIndex
# Actions # Actions
@@ -449,11 +445,11 @@ class Battle::Scene
# not allow HM moves to be forgotten. # not allow HM moves to be forgotten.
def pbForgetMove(pkmn, moveToLearn) def pbForgetMove(pkmn, moveToLearn)
ret = -1 ret = -1
pbFadeOutIn { pbFadeOutIn do
scene = PokemonSummary_Scene.new scene = PokemonSummary_Scene.new
screen = PokemonSummaryScreen.new(scene) screen = PokemonSummaryScreen.new(scene)
ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn) ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn)
} end
return ret return ret
end end
@@ -468,10 +464,10 @@ class Battle::Scene
# Shows the Pokédex entry screen for a newly caught Pokémon # Shows the Pokédex entry screen for a newly caught Pokémon
#============================================================================= #=============================================================================
def pbShowPokedex(species) def pbShowPokedex(species)
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)
screen.pbDexEntry(species) screen.pbDexEntry(species)
} end
end end
end end

View File

@@ -137,9 +137,7 @@ class Battle::Scene
a[2] = true if a[1].animDone? a[2] = true if a[1].animDone?
end end
pbUpdate pbUpdate
if !inPartyAnimation? && sendOutAnims.none? { |a| !a[2] } break if !inPartyAnimation? && sendOutAnims.none? { |a| !a[2] }
break
end
end end
fadeAnim.dispose fadeAnim.dispose
sendOutAnims.each do |a| sendOutAnims.each do |a|
@@ -498,13 +496,13 @@ class Battle::Scene
target = (targets.is_a?(Array)) ? targets[0] : targets target = (targets.is_a?(Array)) ? targets[0] : targets
animations = pbLoadBattleAnimations animations = pbLoadBattleAnimations
return if !animations return if !animations
pbSaveShadows { pbSaveShadows do
if animID[1] # On opposing side and using OppMove animation if animID[1] # On opposing side and using OppMove animation
pbAnimationCore(animations[anim], target, user, true) pbAnimationCore(animations[anim], target, user, true)
else # On player's side, and/or using Move animation else # On player's side, and/or using Move animation
pbAnimationCore(animations[anim], user, target) pbAnimationCore(animations[anim], user, target)
end end
} end
end end
# Plays a common animation. # Plays a common animation.

View File

@@ -91,8 +91,6 @@ class Battle::Scene::MenuBase
end end
end end
#=============================================================================== #===============================================================================
# Command menu (Fight/Pokémon/Bag/Run) # Command menu (Fight/Pokémon/Bag/Run)
#=============================================================================== #===============================================================================
@@ -194,8 +192,6 @@ class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
end end
end end
#=============================================================================== #===============================================================================
# Fight menu (choose a move) # Fight menu (choose a move)
#=============================================================================== #===============================================================================
@@ -440,8 +436,6 @@ class Battle::Scene::FightMenu < Battle::Scene::MenuBase
end end
end end
#=============================================================================== #===============================================================================
# Target menu (choose a move's target) # Target menu (choose a move's target)
# NOTE: Unlike the command and fight menus, this one doesn't have a textbox-only # NOTE: Unlike the command and fight menus, this one doesn't have a textbox-only

View File

@@ -402,8 +402,6 @@ class Battle::Scene::PokemonDataBox < Sprite
end end
end end
#=============================================================================== #===============================================================================
# Splash bar to announce a triggered ability # Splash bar to announce a triggered ability
#=============================================================================== #===============================================================================
@@ -496,8 +494,6 @@ class Battle::Scene::AbilitySplashBar < Sprite
end end
end end
#=============================================================================== #===============================================================================
# Pokémon sprite (used in battle) # Pokémon sprite (used in battle)
#=============================================================================== #===============================================================================
@@ -624,8 +620,6 @@ class Battle::Scene::BattlerSprite < RPG::Sprite
end end
end end
#=============================================================================== #===============================================================================
# Shadow sprite for Pokémon (used in battle) # Shadow sprite for Pokémon (used in battle)
#=============================================================================== #===============================================================================

View File

@@ -401,8 +401,8 @@ module Battle::Scene::Animation::BallAnimationMixin
angle = rand(360) angle = rand(360)
radian = (angle + 90) * Math::PI / 180 radian = (angle + 90) * Math::PI / 180
start_zoom = rand(50...100) start_zoom = rand(50...100)
ray = addNewSprite(ballX + ray_min_radius * Math.cos(radian), ray = addNewSprite(ballX + (ray_min_radius * Math.cos(radian)),
ballY - ray_min_radius * Math.sin(radian), ballY - (ray_min_radius * Math.sin(radian)),
"Graphics/Battle animations/ballBurst_ray", PictureOrigin::BOTTOM) "Graphics/Battle animations/ballBurst_ray", PictureOrigin::BOTTOM)
ray.setZ(0, 100) ray.setZ(0, 100)
ray.setZoomXY(0, 200, start_zoom) ray.setZoomXY(0, 200, start_zoom)
@@ -411,7 +411,7 @@ module Battle::Scene::Animation::BallAnimationMixin
ray.setVisible(0, false) ray.setVisible(0, false)
ray.setAngle(0, angle) ray.setAngle(0, angle)
# Animate ray # Animate ray
start = delay + i / 2 start = delay + (i / 2)
ray.setVisible(start, true) ray.setVisible(start, true)
ray.moveZoomXY(start, ray_lifetime, 200, start_zoom * 6) ray.moveZoomXY(start, ray_lifetime, 200, start_zoom * 6)
ray.moveOpacity(start, 2, 255) # Quickly fade in ray.moveOpacity(start, 2, 255) # Quickly fade in
@@ -437,7 +437,7 @@ module Battle::Scene::Animation::BallAnimationMixin
particle.setVisible(0, false) particle.setVisible(0, false)
end end
# Animate particles # Animate particles
start = delay + i / 4 start = delay + (i / 4)
max_radius = rand(256...384) max_radius = rand(256...384)
angle = rand(360) angle = rand(360)
radian = angle * Math::PI / 180 radian = angle * Math::PI / 180
@@ -596,7 +596,7 @@ module Battle::Scene::Animation::BallAnimationMixin
else else
glare1.moveZoom(delay, particle_duration, 600) glare1.moveZoom(delay, particle_duration, 600)
end end
glare1.moveOpacity(delay + particle_duration / 2, particle_duration / 2, 0) glare1.moveOpacity(delay + (particle_duration / 2), particle_duration / 2, 0)
[glare1, glare2, glare3].each_with_index do |particle, num| [glare1, glare2, glare3].each_with_index do |particle, num|
particle.moveTone(delay, particle_duration, variances[8 - (3 * num)]) particle.moveTone(delay, particle_duration, variances[8 - (3 * num)])
end end
@@ -604,13 +604,13 @@ module Battle::Scene::Animation::BallAnimationMixin
glare2.moveZoom(delay, particle_duration, 350) glare2.moveZoom(delay, particle_duration, 350)
glare3.moveZoom(delay, particle_duration, 500) glare3.moveZoom(delay, particle_duration, 500)
[glare2, glare3].each_with_index do |particle, num| [glare2, glare3].each_with_index do |particle, num|
particle.moveOpacity(delay + particle_duration / 2, particle_duration / 2, 0) particle.moveOpacity(delay + (particle_duration / 2), particle_duration / 2, 0)
end end
else else
glare2.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 400 : 250) glare2.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 400 : 250)
glare2.moveOpacity(delay + particle_duration / 2, particle_duration / 3, 0) glare2.moveOpacity(delay + (particle_duration / 2), particle_duration / 3, 0)
glare3.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 800 : 500) glare3.moveZoom(delay, particle_duration, (poke_ball == :MASTERBALL) ? 800 : 500)
glare3.moveOpacity(delay + particle_duration / 2, particle_duration / 3, 0) glare3.moveOpacity(delay + (particle_duration / 2), particle_duration / 3, 0)
end end
[glare1, glare2, glare3].each { |p| p.setVisible(delay + particle_duration, false) } [glare1, glare2, glare3].each { |p| p.setVisible(delay + particle_duration, false) }
# Burst particles # Burst particles
@@ -647,12 +647,12 @@ module Battle::Scene::Animation::BallAnimationMixin
prop = 2 - prop if index > particle_duration / 2 prop = 2 - prop if index > particle_duration / 2
radius *= prop radius *= prop
particle1.moveXY(delay + j, 1, particle1.moveXY(delay + j, 1,
ballX + p1_x_offset * index * 2 / particle_duration, ballX + (p1_x_offset * index * 2 / particle_duration),
ballY - p1_y_offset * index * 2 / particle_duration) ballY - (p1_y_offset * index * 2 / particle_duration))
[particle2, particle3].each do |particle| [particle2, particle3].each do |particle|
particle.moveXY(delay + j, 1, particle.moveXY(delay + j, 1,
ballX + radius * Math.cos(radian), ballX + (radius * Math.cos(radian)),
ballY - radius * Math.sin(radian)) ballY - (radius * Math.sin(radian)))
end end
end end
particle1.moveZoom(delay, particle_duration, 0) particle1.moveZoom(delay, particle_duration, 0)
@@ -674,14 +674,14 @@ module Battle::Scene::Animation::BallAnimationMixin
end end
# Zoom out # Zoom out
if ["particle", "dazzle", "ring3", "ring4", "diamond"].include?(variances[12 - (3 * num)]) if ["particle", "dazzle", "ring3", "ring4", "diamond"].include?(variances[12 - (3 * num)])
particle.moveZoom(delay + particle_duration * 2 / 3, particle_duration / 3, 10) particle.moveZoom(delay + (particle_duration * 2 / 3), particle_duration / 3, 10)
else else
particle.moveZoom(delay + particle_duration * 2 / 3, particle_duration / 3, 25) particle.moveZoom(delay + (particle_duration * 2 / 3), particle_duration / 3, 25)
end end
# Rotate (for Premier Ball) # Rotate (for Premier Ball)
particle.moveAngle(delay, particle_duration, -180) if poke_ball == :PREMIERBALL particle.moveAngle(delay, particle_duration, -180) if poke_ball == :PREMIERBALL
# Change tone, fade out # Change tone, fade out
particle.moveTone(delay + particle_duration / 3, (particle_duration.to_f / 3).ceil, variances[14 - (3 * num)]) particle.moveTone(delay + (particle_duration / 3), (particle_duration.to_f / 3).ceil, variances[14 - (3 * num)])
particle.moveOpacity(delay + particle_duration - 3, 3, 128) # Fade out at end particle.moveOpacity(delay + particle_duration - 3, 3, 128) # Fade out at end
end end
[particle1, particle2, particle3].each { |p| p.setVisible(delay + particle_duration, false) } [particle1, particle2, particle3].each { |p| p.setVisible(delay + particle_duration, false) }
@@ -702,7 +702,7 @@ module Battle::Scene::Animation::BallAnimationMixin
web.moveZoom(delay + start + (i * 4), 2, 150) web.moveZoom(delay + start + (i * 4), 2, 150)
web.moveZoom(delay + start + (i * 4) + 2, 2, 120) web.moveZoom(delay + start + (i * 4) + 2, 2, 120)
end end
now = start + (web_duration / 4) * 4 now = start + ((web_duration / 4) * 4)
web.moveZoom(delay + now, particle_duration + ring_duration - now, 150) web.moveZoom(delay + now, particle_duration + ring_duration - now, 150)
web.moveOpacity(delay + particle_duration, ring_duration, 0) web.moveOpacity(delay + particle_duration, ring_duration, 0)
web.setVisible(delay + particle_duration + ring_duration, false) web.setVisible(delay + particle_duration + ring_duration, false)
@@ -747,10 +747,10 @@ module Battle::Scene::Animation::BallAnimationMixin
index = j + 1 index = j + 1
x = 72 * index / star_duration x = 72 * index / star_duration
proportion = index.to_f / star_duration proportion = index.to_f / star_duration
a = (2 * y_pos[2]) - 4 * y_pos[1] a = (2 * y_pos[2]) - (4 * y_pos[1])
b = y_pos[2] - a b = y_pos[2] - a
y = ((a * proportion) + b) * proportion y = ((a * proportion) + b) * proportion
star.moveXY(delay + j, 1, ballX + [-1, 0, 1][i] * x, ballY - y) star.moveXY(delay + j, 1, ballX + ([-1, 0, 1][i] * x), ballY - y)
end end
star.moveAngle(delay, star_duration, start_angle + [144, 0, 45][i]) if i.even? star.moveAngle(delay, star_duration, start_angle + [144, 0, 45][i]) if i.even?
star.moveOpacity(delay, 4, 255) # Fade in star.moveOpacity(delay, 4, 255) # Fade in
@@ -789,17 +789,17 @@ module Battle::Scene::Animation::BallAnimationMixin
prop = j.to_f / (color_duration / 3) prop = j.to_f / (color_duration / 3)
radius *= 0.75 + (prop / 4) radius *= 0.75 + (prop / 4)
elsif j >= burst_duration / 2 elsif j >= burst_duration / 2
prop = (j.to_f - burst_duration / 2) / (burst_duration / 2) prop = (j.to_f - (burst_duration / 2)) / (burst_duration / 2)
radius *= 1 - prop radius *= 1 - prop
end end
if j == 0 if j == 0
particle.setXY(delay + j, ballX + radius * Math.cos(radian), ballY - radius * Math.sin(radian)) particle.setXY(delay + j, ballX + (radius * Math.cos(radian)), ballY - (radius * Math.sin(radian)))
else else
particle.moveXY(delay + j, 1, ballX + radius * Math.cos(radian), ballY - radius * Math.sin(radian)) particle.moveXY(delay + j, 1, ballX + (radius * Math.cos(radian)), ballY - (radius * Math.sin(radian)))
end end
end end
particle.moveZoom(delay, burst_duration, 0) particle.moveZoom(delay, burst_duration, 0)
particle.moveTone(delay + color_duration / 2, color_duration / 2, Tone.new(0, 0, -192)) # Yellow particle.moveTone(delay + (color_duration / 2), color_duration / 2, Tone.new(0, 0, -192)) # Yellow
particle.moveTone(delay + color_duration, shrink_duration, Tone.new(0, -128, -248)) # Dark orange particle.moveTone(delay + color_duration, shrink_duration, Tone.new(0, -128, -248)) # Dark orange
particle.moveOpacity(delay + color_duration, shrink_duration, 0) # Fade out at end particle.moveOpacity(delay + color_duration, shrink_duration, 0) # Fade out at end
particle.setVisible(delay + burst_duration, false) particle.setVisible(delay + burst_duration, false)

View File

@@ -57,8 +57,6 @@ class Battle::Scene::Animation::Intro < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows wild Pokémon fading back to their normal color, and triggers their intro # Shows wild Pokémon fading back to their normal color, and triggers their intro
# animations # animations
@@ -80,8 +78,6 @@ class Battle::Scene::Animation::Intro2 < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Makes a side's party bar and balls appear # Makes a side's party bar and balls appear
#=============================================================================== #===============================================================================
@@ -181,8 +177,6 @@ class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Makes a Pokémon's data box appear # Makes a Pokémon's data box appear
#=============================================================================== #===============================================================================
@@ -202,8 +196,6 @@ class Battle::Scene::Animation::DataBoxAppear < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Makes a Pokémon's data box disappear # Makes a Pokémon's data box disappear
#=============================================================================== #===============================================================================
@@ -222,8 +214,6 @@ class Battle::Scene::Animation::DataBoxDisappear < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Makes a Pokémon's ability bar appear # Makes a Pokémon's ability bar appear
#=============================================================================== #===============================================================================
@@ -242,8 +232,6 @@ class Battle::Scene::Animation::AbilitySplashAppear < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Makes a Pokémon's ability bar disappear # Makes a Pokémon's ability bar disappear
#=============================================================================== #===============================================================================
@@ -262,8 +250,6 @@ class Battle::Scene::Animation::AbilitySplashDisappear < Battle::Scene::Animatio
end end
end end
#=============================================================================== #===============================================================================
# Make an enemy trainer slide on-screen from the right. Makes the previous # Make an enemy trainer slide on-screen from the right. Makes the previous
# trainer slide off to the right first if it is on-screen. # trainer slide off to the right first if it is on-screen.
@@ -296,8 +282,6 @@ class Battle::Scene::Animation::TrainerAppear < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows the player (and partner) and the player party lineup sliding off screen. # Shows the player (and partner) and the player party lineup sliding off screen.
# Shows the player's/partner's throwing animation (if they have one). # Shows the player's/partner's throwing animation (if they have one).
@@ -339,10 +323,10 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
partyBar.setVisible(delay + 12, false) partyBar.setVisible(delay + 12, false)
partyBar.setOpacity(delay + 12, 255) partyBar.setOpacity(delay + 12, 255)
end end
Battle::Scene::NUM_BALLS.times do |i| Battle::Scene::NUM_BALLS.times do |j|
next if !@sprites["partyBall_0_#{i}"] || !@sprites["partyBall_0_#{i}"].visible next if !@sprites["partyBall_0_#{j}"] || !@sprites["partyBall_0_#{j}"].visible
partyBall = addSprite(@sprites["partyBall_0_#{i}"]) partyBall = addSprite(@sprites["partyBall_0_#{j}"])
partyBall.moveDelta(delay + (2 * i), 16, -Graphics.width, 0) if @fullAnim partyBall.moveDelta(delay + (2 * j), 16, -Graphics.width, 0) if @fullAnim
partyBall.moveOpacity(delay, 12, 0) partyBall.moveOpacity(delay, 12, 0)
partyBall.setVisible(delay + 12, false) partyBall.setVisible(delay + 12, false)
partyBall.setOpacity(delay + 12, 255) partyBall.setOpacity(delay + 12, 255)
@@ -350,8 +334,6 @@ class Battle::Scene::Animation::PlayerFade < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows the enemy trainer(s) and the enemy party lineup sliding off screen. # Shows the enemy trainer(s) and the enemy party lineup sliding off screen.
# Doesn't show the ball thrown or the Pokémon. # Doesn't show the ball thrown or the Pokémon.
@@ -384,10 +366,10 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
partyBar.setVisible(delay + 12, false) partyBar.setVisible(delay + 12, false)
partyBar.setOpacity(delay + 12, 255) partyBar.setOpacity(delay + 12, 255)
end end
Battle::Scene::NUM_BALLS.times do |i| Battle::Scene::NUM_BALLS.times do |j|
next if !@sprites["partyBall_1_#{i}"] || !@sprites["partyBall_1_#{i}"].visible next if !@sprites["partyBall_1_#{j}"] || !@sprites["partyBall_1_#{j}"].visible
partyBall = addSprite(@sprites["partyBall_1_#{i}"]) partyBall = addSprite(@sprites["partyBall_1_#{j}"])
partyBall.moveDelta(delay + (2 * i), 16, Graphics.width, 0) if @fullAnim partyBall.moveDelta(delay + (2 * j), 16, Graphics.width, 0) if @fullAnim
partyBall.moveOpacity(delay, 12, 0) partyBall.moveOpacity(delay, 12, 0)
partyBall.setVisible(delay + 12, false) partyBall.setVisible(delay + 12, false)
partyBall.setOpacity(delay + 12, 255) partyBall.setOpacity(delay + 12, 255)
@@ -395,8 +377,6 @@ class Battle::Scene::Animation::TrainerFade < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows a Pokémon being sent out on the player's side (including by a partner). # Shows a Pokémon being sent out on the player's side (including by a partner).
# Includes the Poké Ball being thrown. # Includes the Poké Ball being thrown.
@@ -473,8 +453,6 @@ class Battle::Scene::Animation::PokeballPlayerSendOut < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows a Pokémon being sent out on the opposing side. # Shows a Pokémon being sent out on the opposing side.
# Includes the Poké Ball being "thrown" (although here the Poké Ball just # Includes the Poké Ball being "thrown" (although here the Poké Ball just
@@ -544,8 +522,6 @@ class Battle::Scene::Animation::PokeballTrainerSendOut < Battle::Scene::Animatio
end end
end end
#=============================================================================== #===============================================================================
# Shows a Pokémon being recalled into its Poké Ball # Shows a Pokémon being recalled into its Poké Ball
#=============================================================================== #===============================================================================
@@ -594,8 +570,6 @@ class Battle::Scene::Animation::BattlerRecall < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows a Pokémon flashing after taking damage # Shows a Pokémon flashing after taking damage
#=============================================================================== #===============================================================================
@@ -632,8 +606,6 @@ class Battle::Scene::Animation::BattlerDamage < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows a Pokémon fainting # Shows a Pokémon fainting
#=============================================================================== #===============================================================================
@@ -682,8 +654,6 @@ class Battle::Scene::Animation::BattlerFaint < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows the player's Poké Ball being thrown to capture a Pokémon # Shows the player's Poké Ball being thrown to capture a Pokémon
#=============================================================================== #===============================================================================
@@ -836,8 +806,6 @@ class Battle::Scene::Animation::PokeballThrowCapture < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows the player throwing a Poké Ball and it being deflected # Shows the player throwing a Poké Ball and it being deflected
#=============================================================================== #===============================================================================

View File

@@ -71,8 +71,7 @@ class Battle::DebugSceneNoVisuals
def pbChangePokemon(idxBattler, pkmn); end def pbChangePokemon(idxBattler, pkmn); end
def pbFaintBattler(battler); end def pbFaintBattler(battler); end
def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2); end def pbEXPBar(battler, startExp, endExp, tempExp1, tempExp2); end
def pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense, def pbLevelUp(pkmn, battler, oldTotalHP, oldAttack, oldDefense, oldSpAtk, oldSpDef, oldSpeed); end
oldSpAtk, oldSpDef, oldSpeed); end
def pbForgetMove(pkmn, moveToLearn); return 0; end # Always forget first move def pbForgetMove(pkmn, moveToLearn); return 0; end # Always forget first move
def pbCommandMenu(idxBattler, firstAction) def pbCommandMenu(idxBattler, firstAction)

View File

@@ -26,10 +26,10 @@ module Battle::CatchAndStoreMixin
when 0 # Add to your party when 0 # Add to your party
pbDisplay(_INTL("Choose a Pokémon in your party to send to your Boxes.")) pbDisplay(_INTL("Choose a Pokémon in your party to send to your Boxes."))
party_index = -1 party_index = -1
@scene.pbPartyScreen(0, (@sendToBoxes != 2), 1) { |idxParty, _partyScene| @scene.pbPartyScreen(0, (@sendToBoxes != 2), 1) do |idxParty, _partyScene|
party_index = idxParty party_index = idxParty
next true next true
} end
next if party_index < 0 # Cancelled next if party_index < 0 # Cancelled
party_size = pbPlayer.party.length party_size = pbPlayer.party.length
# Send chosen Pokémon to storage # Send chosen Pokémon to storage
@@ -56,11 +56,11 @@ module Battle::CatchAndStoreMixin
when 1 # Send to a Box when 1 # Send to a Box
break break
when 2 # See X's summary when 2 # See X's summary
pbFadeOutIn { pbFadeOutIn do
summary_scene = PokemonSummary_Scene.new summary_scene = PokemonSummary_Scene.new
summary_screen = PokemonSummaryScreen.new(summary_scene, true) summary_screen = PokemonSummaryScreen.new(summary_scene, true)
summary_screen.pbStartScreen([pkmn], 0) summary_screen.pbStartScreen([pkmn], 0)
} end
when 3 # Check party when 3 # Check party
@scene.pbPartyScreen(0, true, 2) @scene.pbPartyScreen(0, true, 2)
end end

View File

@@ -51,8 +51,9 @@ class Battle
end end
end end
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
unless @__clauses__aliased unless @__clauses__aliased
alias __clauses__pbCanSleep? pbCanSleep? alias __clauses__pbCanSleep? pbCanSleep?
@@ -100,9 +101,10 @@ class Battle::Battler
end end
end end
#===============================================================================
# Double Team
class Battle::Move::RaiseUserEvasion1 # Double Team #===============================================================================
class Battle::Move::RaiseUserEvasion1
unless method_defined?(:__clauses__pbMoveFailed?) unless method_defined?(:__clauses__pbMoveFailed?)
alias __clauses__pbMoveFailed? pbMoveFailed? alias __clauses__pbMoveFailed? pbMoveFailed?
end end
@@ -116,9 +118,10 @@ class Battle::Move::RaiseUserEvasion1 # Double Team
end end
end end
#===============================================================================
# Minimize
class Battle::Move::RaiseUserEvasion2MinimizeUser # Minimize #===============================================================================
class Battle::Move::RaiseUserEvasion2MinimizeUser
unless method_defined?(:__clauses__pbMoveFailed?) unless method_defined?(:__clauses__pbMoveFailed?)
alias __clauses__pbMoveFailed? pbMoveFailed? alias __clauses__pbMoveFailed? pbMoveFailed?
end end
@@ -132,9 +135,10 @@ class Battle::Move::RaiseUserEvasion2MinimizeUser # Minimize
end end
end end
#===============================================================================
# Skill Swap
class Battle::Move::UserTargetSwapAbilities # Skill Swap #===============================================================================
class Battle::Move::UserTargetSwapAbilities
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
end end
@@ -148,9 +152,10 @@ class Battle::Move::UserTargetSwapAbilities # Skill Swap
end end
end end
#===============================================================================
# Sonic Boom
class Battle::Move::FixedDamage20 # Sonic Boom #===============================================================================
class Battle::Move::FixedDamage20
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
end end
@@ -164,9 +169,10 @@ class Battle::Move::FixedDamage20 # Sonic Boom
end end
end end
#===============================================================================
# Dragon Rage
class Battle::Move::FixedDamage40 # Dragon Rage #===============================================================================
class Battle::Move::FixedDamage40
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
end end
@@ -180,8 +186,9 @@ class Battle::Move::FixedDamage40 # Dragon Rage
end end
end end
#===============================================================================
#
#===============================================================================
class Battle::Move::OHKO class Battle::Move::OHKO
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
@@ -196,8 +203,9 @@ class Battle::Move::OHKO
end end
end end
#===============================================================================
#
#===============================================================================
class Battle::Move::OHKOIce class Battle::Move::OHKOIce
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
@@ -212,8 +220,9 @@ class Battle::Move::OHKOIce
end end
end end
#===============================================================================
#
#===============================================================================
class Battle::Move::OHKOHitsUndergroundTarget class Battle::Move::OHKOHitsUndergroundTarget
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
@@ -228,9 +237,10 @@ class Battle::Move::OHKOHitsUndergroundTarget
end end
end end
#===============================================================================
# Self-Destruct
class Battle::Move::UserFaintsExplosive # Self-Destruct #===============================================================================
class Battle::Move::UserFaintsExplosive
unless method_defined?(:__clauses__pbMoveFailed?) unless method_defined?(:__clauses__pbMoveFailed?)
alias __clauses__pbMoveFailed? pbMoveFailed? alias __clauses__pbMoveFailed? pbMoveFailed?
end end
@@ -259,9 +269,10 @@ class Battle::Move::UserFaintsExplosive # Self-Destruct
end end
end end
#===============================================================================
# Perish Song
class Battle::Move::StartPerishCountsForAllBattlers # Perish Song #===============================================================================
class Battle::Move::StartPerishCountsForAllBattlers
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
end end
@@ -276,9 +287,10 @@ class Battle::Move::StartPerishCountsForAllBattlers # Perish Song
end end
end end
#===============================================================================
# Destiny Bond
class Battle::Move::AttackerFaintsIfUserFaints # Destiny Bond #===============================================================================
class Battle::Move::AttackerFaintsIfUserFaints
unless method_defined?(:__clauses__pbFailsAgainstTarget?) unless method_defined?(:__clauses__pbFailsAgainstTarget?)
alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget? alias __clauses__pbFailsAgainstTarget? pbFailsAgainstTarget?
end end

View File

@@ -29,8 +29,6 @@ class AnimFrame
FOCUS = 26 FOCUS = 26
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -166,8 +164,6 @@ def pbConvertRPGAnimation(animation)
return pbAnim return pbAnim
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -230,8 +226,6 @@ class RPG::Animation
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -310,7 +304,7 @@ class PBAnimTiming
text = sprintf("[%d] Set FG: \"%s\"", @frame + 1, name) text = sprintf("[%d] Set FG: \"%s\"", @frame + 1, name)
text += sprintf(" (color=%s,%s,%s,%s)", text += sprintf(" (color=%s,%s,%s,%s)",
@colorRed || "-", @colorRed || "-",
@colorGreen | "-", @colorGreen || "-",
@colorBlue || "-", @colorBlue || "-",
@colorAlpha || "-") @colorAlpha || "-")
text += sprintf(" (opacity=%d)", @opacity) text += sprintf(" (opacity=%d)", @opacity)
@@ -333,8 +327,6 @@ class PBAnimTiming
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -397,8 +389,6 @@ class PBAnimations < Array
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -598,8 +588,6 @@ class PBAnimation < Array
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -678,8 +666,6 @@ def pbSpriteSetAnimFrame(sprite, frame, user = nil, target = nil, inEditor = fal
end end
end end
#=============================================================================== #===============================================================================
# Animation player # Animation player
#=============================================================================== #===============================================================================

View File

@@ -888,10 +888,7 @@ Battle::AbilityEffects::MoveBlocking.add(:DAZZLING,
next false if battle.choices[user.index][4] <= 0 next false if battle.choices[user.index][4] <= 0
next false if !bearer.opposes?(user) next false if !bearer.opposes?(user)
ret = false ret = false
targets.each do |b| targets.each { |b| ret = true if b.opposes?(user) }
next if !b.opposes?(user)
ret = true
end
next ret next ret
} }
) )
@@ -1243,9 +1240,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:DRAGONSMAW,
Battle::AbilityEffects::DamageCalcFromUser.add(:FLAREBOOST, Battle::AbilityEffects::DamageCalcFromUser.add(:FLAREBOOST,
proc { |ability, user, target, move, mults, baseDmg, type| proc { |ability, user, target, move, mults, baseDmg, type|
if user.burned? && move.specialMove? mults[:base_damage_multiplier] *= 1.5 if user.burned? && move.specialMove?
mults[:base_damage_multiplier] *= 1.5
end
} }
) )
@@ -1387,9 +1382,7 @@ Battle::AbilityEffects::DamageCalcFromUser.add(:SOLARPOWER,
Battle::AbilityEffects::DamageCalcFromUser.add(:SNIPER, Battle::AbilityEffects::DamageCalcFromUser.add(:SNIPER,
proc { |ability, user, target, move, mults, baseDmg, type| proc { |ability, user, target, move, mults, baseDmg, type|
if target.damageState.critical mults[:final_damage_multiplier] *= 1.5 if target.damageState.critical
mults[:final_damage_multiplier] *= 1.5
end
} }
) )
@@ -1549,9 +1542,7 @@ Battle::AbilityEffects::DamageCalcFromTarget.add(:FURCOAT,
Battle::AbilityEffects::DamageCalcFromTarget.add(:GRASSPELT, Battle::AbilityEffects::DamageCalcFromTarget.add(:GRASSPELT,
proc { |ability, user, target, move, mults, baseDmg, type| proc { |ability, user, target, move, mults, baseDmg, type|
if user.battle.field.terrain == :Grassy mults[:defense_multiplier] *= 1.5 if user.battle.field.terrain == :Grassy
mults[:defense_multiplier] *= 1.5
end
} }
) )
@@ -1613,9 +1604,7 @@ Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:PRISMARMOR,
Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:SHADOWSHIELD, Battle::AbilityEffects::DamageCalcFromTargetNonIgnorable.add(:SHADOWSHIELD,
proc { |ability, user, target, move, mults, baseDmg, type| proc { |ability, user, target, move, mults, baseDmg, type|
if target.hp == target.totalhp mults[:final_damage_multiplier] /= 2 if target.hp == target.totalhp
mults[:final_damage_multiplier] /= 2
end
} }
) )
@@ -2428,7 +2417,7 @@ Battle::AbilityEffects::EndOfRoundEffect.add(:BADDREAMS,
next if !b.near?(battler) || !b.asleep? next if !b.near?(battler) || !b.asleep?
battle.pbShowAbilitySplash(battler) battle.pbShowAbilitySplash(battler)
next if !b.takesIndirectDamage?(Battle::Scene::USE_ABILITY_SPLASH) next if !b.takesIndirectDamage?(Battle::Scene::USE_ABILITY_SPLASH)
b.pbTakeEffectDamage(b.totalhp / 8) { |hp_lost| b.pbTakeEffectDamage(b.totalhp / 8) do |hp_lost|
if Battle::Scene::USE_ABILITY_SPLASH if Battle::Scene::USE_ABILITY_SPLASH
battle.pbDisplay(_INTL("{1} is tormented!", b.pbThis)) battle.pbDisplay(_INTL("{1} is tormented!", b.pbThis))
else else
@@ -2436,7 +2425,7 @@ Battle::AbilityEffects::EndOfRoundEffect.add(:BADDREAMS,
b.pbThis, battler.pbThis(true), battler.abilityName)) b.pbThis, battler.pbThis(true), battler.abilityName))
end end
battle.pbHideAbilitySplash(battler) battle.pbHideAbilitySplash(battler)
} end
end end
} }
) )

View File

@@ -889,9 +889,7 @@ Battle::ItemEffects::DamageCalcFromUser.add(:LIFEORB,
Battle::ItemEffects::DamageCalcFromUser.add(:LIGHTBALL, Battle::ItemEffects::DamageCalcFromUser.add(:LIGHTBALL,
proc { |item, user, target, move, mults, baseDmg, type| proc { |item, user, target, move, mults, baseDmg, type|
if user.isSpecies?(:PIKACHU) mults[:attack_multiplier] *= 2 if user.isSpecies?(:PIKACHU)
mults[:attack_multiplier] *= 2
end
} }
) )
@@ -1844,9 +1842,9 @@ Battle::ItemEffects::EndOfRoundHealing.add(:BLACKSLUDGE,
battler.pbThis, battler.itemName)) battler.pbThis, battler.itemName))
elsif battler.takesIndirectDamage? elsif battler.takesIndirectDamage?
battle.pbCommonAnimation("UseItem", battler) battle.pbCommonAnimation("UseItem", battler)
battler.pbTakeEffectDamage(battler.totalhp / 8) { |hp_lost| battler.pbTakeEffectDamage(battler.totalhp / 8) do |hp_lost|
battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName))
} end
end end
} }
) )
@@ -1876,9 +1874,9 @@ Battle::ItemEffects::EndOfRoundEffect.add(:STICKYBARB,
proc { |item, battler, battle| proc { |item, battler, battle|
next if !battler.takesIndirectDamage? next if !battler.takesIndirectDamage?
battle.scene.pbDamageAnimation(battler) battle.scene.pbDamageAnimation(battler)
battler.pbTakeEffectDamage(battler.totalhp / 8, false) { |hp_lost| battler.pbTakeEffectDamage(battler.totalhp / 8, false) do |hp_lost|
battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName)) battle.pbDisplay(_INTL("{1} is hurt by its {2}!", battler.pbThis, battler.itemName))
} end
} }
) )

View File

@@ -54,8 +54,6 @@ class Battle::FakeBattler
def pbReset; end def pbReset; end
end end
#=============================================================================== #===============================================================================
# Data box for safari battles # Data box for safari battles
#=============================================================================== #===============================================================================
@@ -93,8 +91,6 @@ class Battle::Scene::SafariDataBox < Sprite
end end
end end
#=============================================================================== #===============================================================================
# Shows the player throwing bait at a wild Pokémon in a Safari battle. # Shows the player throwing bait at a wild Pokémon in a Safari battle.
#=============================================================================== #===============================================================================
@@ -159,8 +155,6 @@ class Battle::Scene::Animation::ThrowBait < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Shows the player throwing a rock at a wild Pokémon in a Safari battle. # Shows the player throwing a rock at a wild Pokémon in a Safari battle.
#=============================================================================== #===============================================================================
@@ -222,8 +216,6 @@ class Battle::Scene::Animation::ThrowRock < Battle::Scene::Animation
end end
end end
#=============================================================================== #===============================================================================
# Safari Zone battle scene (the visuals of the battle) # Safari Zone battle scene (the visuals of the battle)
#=============================================================================== #===============================================================================
@@ -280,8 +272,6 @@ class Battle::Scene
end end
end end
#=============================================================================== #===============================================================================
# Safari Zone battle class # Safari Zone battle class
#=============================================================================== #===============================================================================
@@ -308,9 +298,9 @@ class SafariBattle
def pbRandom(x); return rand(x); end def pbRandom(x); return rand(x); end
#============================================================================= #-----------------------------------------------------------------------------
# Initialize the battle class # Initialize the battle class
#============================================================================= #-----------------------------------------------------------------------------
def initialize(scene, player, party2) def initialize(scene, player, party2)
@scene = scene @scene = scene
@peer = Battle::Peer.new @peer = Battle::Peer.new
@@ -335,9 +325,9 @@ class SafariBattle
def defaultWeather=(value); @weather = value; end def defaultWeather=(value); @weather = value; end
def defaultTerrain=(value); end def defaultTerrain=(value); end
#============================================================================= #-----------------------------------------------------------------------------
# Information about the type and size of the battle # Information about the type and size of the battle
#============================================================================= #-----------------------------------------------------------------------------
def wildBattle?; return true; end def wildBattle?; return true; end
def trainerBattle?; return false; end def trainerBattle?; return false; end
@@ -347,9 +337,9 @@ class SafariBattle
return @sideSizes[index % 2] return @sideSizes[index % 2]
end end
#============================================================================= #-----------------------------------------------------------------------------
# Trainers and owner-related # Trainers and owner-related
#============================================================================= #-----------------------------------------------------------------------------
def pbPlayer; return @player[0]; end def pbPlayer; return @player[0]; end
def opponent; return nil; end def opponent; return nil; end
@@ -374,18 +364,18 @@ class SafariBattle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Get party info (counts all teams on the same side) # Get party info (counts all teams on the same side)
#============================================================================= #-----------------------------------------------------------------------------
def pbParty(idxBattler) def pbParty(idxBattler)
return (opposes?(idxBattler)) ? @party2 : nil return (opposes?(idxBattler)) ? @party2 : nil
end end
def pbAllFainted?(idxBattler = 0); return false; end def pbAllFainted?(idxBattler = 0); return false; end
#============================================================================= #-----------------------------------------------------------------------------
# Battler-related # Battler-related
#============================================================================= #-----------------------------------------------------------------------------
def opposes?(idxBattler1, idxBattler2 = 0) def opposes?(idxBattler1, idxBattler2 = 0)
idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index") idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index")
idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index") idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index")
@@ -395,9 +385,9 @@ class SafariBattle
def pbRemoveFromParty(idxBattler, idxParty); end def pbRemoveFromParty(idxBattler, idxParty); end
def pbGainExp; end def pbGainExp; end
#============================================================================= #-----------------------------------------------------------------------------
# Messages and animations # Messages and animations
#============================================================================= #-----------------------------------------------------------------------------
def pbDisplay(msg, &block) def pbDisplay(msg, &block)
@scene.pbDisplayMessage(msg, &block) @scene.pbDisplayMessage(msg, &block)
end end
@@ -414,17 +404,15 @@ class SafariBattle
return @scene.pbDisplayConfirmMessage(msg) return @scene.pbDisplayConfirmMessage(msg)
end end
class BattleAbortedException < Exception; end class BattleAbortedException < Exception; end
def pbAbort def pbAbort
raise BattleAbortedException.new("Battle aborted") raise BattleAbortedException.new("Battle aborted")
end end
#============================================================================= #-----------------------------------------------------------------------------
# Safari battle-specific methods # Safari battle-specific methods
#============================================================================= #-----------------------------------------------------------------------------
def pbEscapeRate(catch_rate) def pbEscapeRate(catch_rate)
return 125 if catch_rate <= 45 # Escape factor 9 (45%) return 125 if catch_rate <= 45 # Escape factor 9 (45%)
return 100 if catch_rate <= 60 # Escape factor 7 (35%) return 100 if catch_rate <= 60 # Escape factor 7 (35%)

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