Lots of rubocop

This commit is contained in:
Maruno17
2023-01-28 15:21:12 +00:00
parent 2d056052ce
commit 13aab8d911
159 changed files with 1679 additions and 1931 deletions
+31
View File
@@ -63,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
#=============================================================================== #===============================================================================
@@ -85,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:
@@ -110,6 +136,11 @@ 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 # The alernative is ->(x) { x } which is less English than "lambda". This style
# makes lambda definitions require the word "lambda". # makes lambda definitions require the word "lambda".
Style/Lambda: Style/Lambda:
@@ -45,7 +45,7 @@ class Dir
# 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)
@@ -56,7 +56,7 @@ class Dir
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
@@ -86,7 +86,6 @@ class File
# 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
@@ -121,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
@@ -152,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
@@ -211,12 +210,12 @@ module RTP
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
@@ -230,13 +229,13 @@ 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
@@ -248,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
@@ -308,7 +307,7 @@ end
# NOTE: pbGetFileChar checks anything added in MKXP's RTP setting, and matching # NOTE: pbGetFileChar checks anything added in MKXP's RTP setting, and matching
# mount points added through System.mount. # mount points added through System.mount.
def pbRgssExists?(filename) def pbRgssExists?(filename)
return pbGetFileChar(filename) != nil if safeExists?("./Game.rgssad") return !pbGetFileChar(filename).nil? if safeExists?("./Game.rgssad")
filename = canonicalize(filename) filename = canonicalize(filename)
return safeExists?(filename) return safeExists?(filename)
end end
@@ -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
@@ -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,
@@ -169,23 +169,25 @@ 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
+73 -75
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")
@@ -296,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
@@ -317,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
@@ -325,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)
@@ -371,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
@@ -452,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
@@ -570,16 +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, @default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS,
array, nil, map_id) 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(MessageTypes::EventTexts, @default_game_messages[MessageTypes::EVENT_TEXTS][map_id] = priv_add_to_hash(MessageTypes::EVENT_TEXTS,
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)
@@ -610,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
@@ -645,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
@@ -670,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
@@ -766,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
@@ -782,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
@@ -812,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
+1 -3
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
@@ -136,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
@@ -412,7 +410,7 @@ module PluginManager
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)
@@ -456,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]
+6 -18
View File
@@ -56,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
@@ -97,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
@@ -113,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
@@ -469,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
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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
@@ -143,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:"
@@ -1081,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
@@ -40,9 +40,7 @@ class Game_Screen
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
def start_flash(color, duration) def start_flash(color, duration)
@@ -103,9 +103,7 @@ class Game_Picture
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
@@ -371,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)
@@ -5,69 +5,68 @@
# 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
#=============================================================================== #===============================================================================
# #
@@ -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
@@ -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
@@ -40,9 +40,7 @@ class Game_CommonEvent
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
@@ -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
@@ -84,7 +84,7 @@ class Game_FollowerFactory
@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
@@ -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
@@ -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
@@ -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)
@@ -11,7 +11,7 @@ module RPG
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")
@@ -21,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)
@@ -208,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
@@ -257,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
@@ -623,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])
@@ -660,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.
@@ -731,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
@@ -753,9 +747,7 @@ 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
@@ -767,6 +759,7 @@ 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
@@ -778,9 +771,7 @@ end
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
@@ -42,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)
@@ -323,6 +325,8 @@ class Window
end end
end end
#-----------------------------------------------------------------------------
private private
def ensureBitmap(bitmap, dwidth, dheight) def ensureBitmap(bitmap, dwidth, dheight)
@@ -34,15 +34,14 @@ 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
@@ -78,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
@@ -435,7 +434,7 @@ class SpriteWindow < Window
privRefresh privRefresh
end end
#=============================================================================== #-----------------------------------------------------------------------------
private private
@@ -515,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
@@ -540,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
@@ -630,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
@@ -667,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
@@ -742,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])
@@ -752,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
@@ -816,7 +815,7 @@ 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()
@@ -51,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
@@ -62,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
@@ -211,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
@@ -221,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
@@ -306,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|
@@ -333,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|
@@ -586,6 +586,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
@frameskipChanged = false @frameskipChanged = false
end end
#-----------------------------------------------------------------------------
private private
def curcharSkip(skip) def curcharSkip(skip)
@@ -704,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)
@@ -895,6 +899,8 @@ class SpriteWindow_Selectable < SpriteWindow_Base
end end
end end
#-----------------------------------------------------------------------------
private private
def priv_page_row_max def priv_page_row_max
@@ -1074,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
@@ -1229,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]
@@ -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)
@@ -64,6 +64,8 @@ class AnimatedPlane < Plane
end end
end end
#-----------------------------------------------------------------------------
private private
def clear_bitmap def clear_bitmap
@@ -97,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)
@@ -249,70 +247,79 @@ 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)
@@ -515,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
@@ -639,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
@@ -696,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
@@ -739,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
@@ -874,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
@@ -145,6 +145,8 @@ class ChooseNumberParams
end end
end end
#-----------------------------------------------------------------------------
private private
def clamp(v, mn, mx) def clamp(v, mn, mx)
@@ -422,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
@@ -445,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
@@ -453,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] }
@@ -466,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 = ""
@@ -664,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
@@ -698,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)
@@ -720,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
@@ -783,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)
@@ -822,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
@@ -863,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
@@ -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
+10 -10
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
+25 -23
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
+8 -20
View File
@@ -79,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
@@ -142,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
@@ -155,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
@@ -184,12 +174,10 @@ 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
+1 -2
View File
@@ -266,14 +266,13 @@ 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 end
ret[c] = ret[c][0] # :Species => "pokemon" ret[c] = ret[c][0] # :Species => "pokemon"
end end
end
return ret return ret
end end
end end
@@ -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)
@@ -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
@@ -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)
@@ -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)
@@ -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)
@@ -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
@@ -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
@@ -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)
@@ -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
@@ -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.
@@ -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
@@ -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
@@ -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
@@ -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
logMsg = (fullCalc) ? "[Round order] " : "[Round order recalculated] " logMsg = (fullCalc) ? "[Round order] " : "[Round order recalculated] "
comma = false comma = false
@@ -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
@@ -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
@@ -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)
@@ -141,9 +141,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
@@ -190,11 +190,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
@@ -257,16 +257,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
@@ -299,9 +299,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
#============================================================================= #=============================================================================
@@ -317,9 +317,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
@@ -337,34 +337,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|
@@ -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)
@@ -48,9 +48,7 @@ class Battle::Battler
end end
# Use the move # Use the move
PBDebug.log("[Move usage] #{pbThis} started using #{choice[2].name}") PBDebug.log("[Move usage] #{pbThis} started using #{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)
@@ -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
@@ -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
@@ -396,9 +392,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
@@ -356,8 +356,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
@@ -372,8 +371,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
@@ -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
@@ -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
@@ -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
@@ -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.
@@ -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)
@@ -323,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)
@@ -366,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)
@@ -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
@@ -1240,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
} }
) )
@@ -1384,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
} }
) )
@@ -1546,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
} }
) )
@@ -1610,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
} }
) )
@@ -2425,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
@@ -2433,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
} }
) )
@@ -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
} }
) )
@@ -271,10 +271,10 @@ class Battle::Scene
msgwindow = pbCreateMessageWindow msgwindow = pbCreateMessageWindow
dimmingvp = Viewport.new(0, 0, Graphics.width, Graphics.height - msgwindow.height) dimmingvp = Viewport.new(0, 0, Graphics.width, Graphics.height - msgwindow.height)
pbMessageDisplay(msgwindow, pbMessageDisplay(msgwindow,
_INTL("REFEREE: That's it! We will now go to judging to determine the winner!\\wtnp[20]")) { _INTL("REFEREE: That's it! We will now go to judging to determine the winner!\\wtnp[20]")) do
pbBattleArenaUpdate pbBattleArenaUpdate
dimmingvp.update dimmingvp.update
} end
dimmingvp.z = 99999 dimmingvp.z = 99999
infowindow = SpriteWindow_Base.new(80, 0, 320, 224) infowindow = SpriteWindow_Base.new(80, 0, 320, 224)
infowindow.contents = Bitmap.new(infowindow.width - infowindow.borderX, infowindow.contents = Bitmap.new(infowindow.width - infowindow.borderX,
@@ -299,25 +299,25 @@ class Battle::Scene
end end
updateJudgment(infowindow, 1, battler1, battler2, ratings1, ratings2) updateJudgment(infowindow, 1, battler1, battler2, ratings1, ratings2)
pbMessageDisplay(msgwindow, pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judging category 1, Mind!\nThe Pokémon showing the most guts!\\wtnp[40]")) { _INTL("REFEREE: Judging category 1, Mind!\nThe Pokémon showing the most guts!\\wtnp[40]")) do
pbBattleArenaUpdate pbBattleArenaUpdate
dimmingvp.update dimmingvp.update
infowindow.update infowindow.update
} end
updateJudgment(infowindow, 2, battler1, battler2, ratings1, ratings2) updateJudgment(infowindow, 2, battler1, battler2, ratings1, ratings2)
pbMessageDisplay(msgwindow, pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judging category 2, Skill!\nThe Pokémon using moves the best!\\wtnp[40]")) { _INTL("REFEREE: Judging category 2, Skill!\nThe Pokémon using moves the best!\\wtnp[40]")) do
pbBattleArenaUpdate pbBattleArenaUpdate
dimmingvp.update dimmingvp.update
infowindow.update infowindow.update
} end
updateJudgment(infowindow, 3, battler1, battler2, ratings1, ratings2) updateJudgment(infowindow, 3, battler1, battler2, ratings1, ratings2)
pbMessageDisplay(msgwindow, pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judging category 3, Body!\nThe Pokémon with the most vitality!\\wtnp[40]")) { _INTL("REFEREE: Judging category 3, Body!\nThe Pokémon with the most vitality!\\wtnp[40]")) do
pbBattleArenaUpdate pbBattleArenaUpdate
dimmingvp.update dimmingvp.update
infowindow.update infowindow.update
} end
total1 = 0 total1 = 0
total2 = 0 total2 = 0
3.times do |i| 3.times do |i|
@@ -326,27 +326,27 @@ class Battle::Scene
end end
if total1 == total2 if total1 == total2
pbMessageDisplay(msgwindow, pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]", total1, total2)) { _INTL("REFEREE: Judgment: {1} to {2}!\nWe have a draw!\\wtnp[40]", total1, total2)) do
pbBattleArenaUpdate pbBattleArenaUpdate
dimmingvp.update dimmingvp.update
infowindow.update infowindow.update
} end
elsif total1 > total2 elsif total1 > total2
pbMessageDisplay(msgwindow, pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}'s {4}!\\wtnp[40]", _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}'s {4}!\\wtnp[40]",
total1, total2, @battle.pbGetOwnerName(battler1.index), battler1.name)) { total1, total2, @battle.pbGetOwnerName(battler1.index), battler1.name)) do
pbBattleArenaUpdate pbBattleArenaUpdate
dimmingvp.update dimmingvp.update
infowindow.update infowindow.update
} end
else else
pbMessageDisplay(msgwindow, pbMessageDisplay(msgwindow,
_INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}!\\wtnp[40]", _INTL("REFEREE: Judgment: {1} to {2}!\nThe winner is {3}!\\wtnp[40]",
total1, total2, battler2.name)) { total1, total2, battler2.name)) do
pbBattleArenaUpdate pbBattleArenaUpdate
dimmingvp.update dimmingvp.update
infowindow.update infowindow.update
} end
end end
infowindow.visible = false infowindow.visible = false
msgwindow.visible = false msgwindow.visible = false
+56 -56
View File
@@ -448,52 +448,52 @@ end
# Event movement # Event movement
#=============================================================================== #===============================================================================
module PBMoveRoute module PBMoveRoute
Down = 1 DOWN = 1
Left = 2 LEFT = 2
Right = 3 RRIGHT = 3
Up = 4 UP = 4
LowerLeft = 5 LOWER_LEFT = 5
LowerRight = 6 LOWER_RIGHT = 6
UpperLeft = 7 UPPER_LEFT = 7
UpperRight = 8 UPPER_RIGHT = 8
Random = 9 RANDOM = 9
TowardPlayer = 10 TOWARD_PLAYER = 10
AwayFromPlayer = 11 AWAY_FROM_PLAYER = 11
Forward = 12 FORWARD = 12
Backward = 13 BACKWARD = 13
Jump = 14 # xoffset, yoffset JUMP = 14 # xoffset, yoffset
Wait = 15 # frames WAIT = 15 # frames
TurnDown = 16 TURN_DOWN = 16
TurnLeft = 17 TURN_LEFT = 17
TurnRight = 18 TURN_RIGHT = 18
TurnUp = 19 TURN_UP = 19
TurnRight90 = 20 TURN_RIGHT90 = 20
TurnLeft90 = 21 TURN_LEFT90 = 21
Turn180 = 22 TURN180 = 22
TurnRightOrLeft90 = 23 TURN_RIGHT_OR_LEFT90 = 23
TurnRandom = 24 TURN_RANDOM = 24
TurnTowardPlayer = 25 TURN_TOWARD_PLAYER = 25
TurnAwayFromPlayer = 26 TURN_AWAY_FROM_PLAYER = 26
SwitchOn = 27 # 1 param SWITCH_ON = 27 # 1 param
SwitchOff = 28 # 1 param SWITCH_OFF = 28 # 1 param
ChangeSpeed = 29 # 1 param CHANGE_SPEED = 29 # 1 param
ChangeFreq = 30 # 1 param CHANGE_FREQUENCY = 30 # 1 param
WalkAnimeOn = 31 WALK_ANIME_ON = 31
WalkAnimeOff = 32 WALK_ANIME_OFF = 32
StepAnimeOn = 33 STEP_ANIME_ON = 33
StepAnimeOff = 34 STEP_ANIME_OFF = 34
DirectionFixOn = 35 DIRECTION_FIX_ON = 35
DirectionFixOff = 36 DIRECTION_FIX_OFF = 36
ThroughOn = 37 THROUGH_ON = 37
ThroughOff = 38 THROUGH_OFF = 38
AlwaysOnTopOn = 39 ALWAYS_ON_TOP_ON = 39
AlwaysOnTopOff = 40 ALWAYS_ON_TOP_OFF = 40
Graphic = 41 # Name, hue, direction, pattern GRAPHIC = 41 # Name, hue, direction, pattern
Opacity = 42 # 1 param OPACITY = 42 # 1 param
Blending = 43 # 1 param BLENDING = 43 # 1 param
PlaySE = 44 # 1 param PLAY_SE = 44 # 1 param
Script = 45 # 1 param SCRIPT = 45 # 1 param
ScriptAsync = 101 # 1 param SCRIPT_ASYNC = 101 # 1 param
end end
def pbMoveRoute(event, commands, waitComplete = false) def pbMoveRoute(event, commands, waitComplete = false)
@@ -501,23 +501,23 @@ def pbMoveRoute(event, commands, waitComplete = false)
route.repeat = false route.repeat = false
route.skippable = true route.skippable = true
route.list.clear route.list.clear
route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn)) route.list.push(RPG::MoveCommand.new(PBMoveRoute::THROUGH_ON))
i = 0 i = 0
while i < commands.length while i < commands.length
case commands[i] case commands[i]
when PBMoveRoute::Wait, PBMoveRoute::SwitchOn, PBMoveRoute::SwitchOff, when PBMoveRoute::WAIT, PBMoveRoute::SWITCH_ON, PBMoveRoute::SWITCH_OFF,
PBMoveRoute::ChangeSpeed, PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity, PBMoveRoute::CHANGE_SPEED, PBMoveRoute::CHANGE_FREQUENCY, PBMoveRoute::OPACITY,
PBMoveRoute::Blending, PBMoveRoute::PlaySE, PBMoveRoute::Script PBMoveRoute::BLENDING, PBMoveRoute::PLAY_SE, PBMoveRoute::SCRIPT
route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1]])) route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1]]))
i += 1 i += 1
when PBMoveRoute::ScriptAsync when PBMoveRoute::SCRIPT_ASYNC
route.list.push(RPG::MoveCommand.new(PBMoveRoute::Script, [commands[i + 1]])) route.list.push(RPG::MoveCommand.new(PBMoveRoute::SCRIPT, [commands[i + 1]]))
route.list.push(RPG::MoveCommand.new(PBMoveRoute::Wait, [0])) route.list.push(RPG::MoveCommand.new(PBMoveRoute::WAIT, [0]))
i += 1 i += 1
when PBMoveRoute::Jump when PBMoveRoute::JUMP
route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1], commands[i + 2]])) route.list.push(RPG::MoveCommand.new(commands[i], [commands[i + 1], commands[i + 2]]))
i += 2 i += 2
when PBMoveRoute::Graphic when PBMoveRoute::GRAPHIC
route.list.push(RPG::MoveCommand.new(commands[i], route.list.push(RPG::MoveCommand.new(commands[i],
[commands[i + 1], commands[i + 2], [commands[i + 1], commands[i + 2],
commands[i + 3], commands[i + 4]])) commands[i + 3], commands[i + 4]]))
@@ -527,7 +527,7 @@ def pbMoveRoute(event, commands, waitComplete = false)
end end
i += 1 i += 1
end end
route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOff)) route.list.push(RPG::MoveCommand.new(PBMoveRoute::THROUGH_OFF))
route.list.push(RPG::MoveCommand.new(0)) route.list.push(RPG::MoveCommand.new(0))
event&.force_move_route(route) event&.force_move_route(route)
return route return route
@@ -390,12 +390,10 @@ class WildBattle
$game_temp.clear_battle_rules $game_temp.clear_battle_rules
# Perform the battle itself # Perform the battle itself
outcome = 0 outcome = 0
pbBattleAnimation(pbGetWildBattleBGM(foe_party), (foe_party.length == 1) ? 0 : 2, foe_party) { pbBattleAnimation(pbGetWildBattleBGM(foe_party), (foe_party.length == 1) ? 0 : 2, foe_party) do
pbSceneStandby { pbSceneStandby { outcome = battle.pbStartBattle }
outcome = battle.pbStartBattle
}
BattleCreationHelperMethods.after_battle(outcome, can_lose) BattleCreationHelperMethods.after_battle(outcome, can_lose)
} end
Input.update Input.update
# Save the result of the battle in a Game Variable (1 by default) # Save the result of the battle in a Game Variable (1 by default)
BattleCreationHelperMethods.set_outcome(outcome, outcome_variable) BattleCreationHelperMethods.set_outcome(outcome, outcome_variable)
@@ -512,12 +510,10 @@ class TrainerBattle
$game_temp.clear_battle_rules $game_temp.clear_battle_rules
# Perform the battle itself # Perform the battle itself
outcome = 0 outcome = 0
pbBattleAnimation(pbGetTrainerBattleBGM(foe_trainers), (battle.singleBattle?) ? 1 : 3, foe_trainers) { pbBattleAnimation(pbGetTrainerBattleBGM(foe_trainers), (battle.singleBattle?) ? 1 : 3, foe_trainers) do
pbSceneStandby { pbSceneStandby { outcome = battle.pbStartBattle }
outcome = battle.pbStartBattle
}
BattleCreationHelperMethods.after_battle(outcome, can_lose) BattleCreationHelperMethods.after_battle(outcome, can_lose)
} end
Input.update Input.update
# Save the result of the battle in a Game Variable (1 by default) # Save the result of the battle in a Game Variable (1 by default)
BattleCreationHelperMethods.set_outcome(outcome, outcome_variable, true) BattleCreationHelperMethods.set_outcome(outcome, outcome_variable, true)
@@ -219,9 +219,7 @@ HiddenMoveHandlers::UseMove.add(:CUT, proc { |move, pokemon|
end end
$stats.cut_count += 1 $stats.cut_count += 1
facingEvent = $game_player.pbFacingEvent facingEvent = $game_player.pbFacingEvent
if facingEvent pbSmashEvent(facingEvent) if facingEvent
pbSmashEvent(facingEvent)
end
next true next true
}) })
@@ -232,13 +230,10 @@ def pbSmashEvent(event)
elsif event.name[/smashrock/i] elsif event.name[/smashrock/i]
pbSEPlay("Rock Smash", 80) pbSEPlay("Rock Smash", 80)
end end
pbMoveRoute(event, [PBMoveRoute::Wait, 2, pbMoveRoute(event, [PBMoveRoute::WAIT, 2,
PBMoveRoute::TurnLeft, PBMoveRoute::TURN_LEFT, PBMoveRoute::WAIT, 2,
PBMoveRoute::Wait, 2, PBMoveRoute::TURN_RIGHT, PBMoveRoute::WAIT, 2,
PBMoveRoute::TurnRight, PBMoveRoute::TURN_UP, PBMoveRoute::WAIT, 2])
PBMoveRoute::Wait, 2,
PBMoveRoute::TurnUp,
PBMoveRoute::Wait, 2])
pbWait(Graphics.frame_rate * 4 / 10) pbWait(Graphics.frame_rate * 4 / 10)
event.erase event.erase
$PokemonMap&.addErasedEvent(event.id) $PokemonMap&.addErasedEvent(event.id)
@@ -273,7 +268,7 @@ HiddenMoveHandlers::UseMove.add(:DIG, proc { |move, pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name))
end end
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = escape[0] $game_temp.player_new_map_id = escape[0]
$game_temp.player_new_x = escape[1] $game_temp.player_new_x = escape[1]
$game_temp.player_new_y = escape[2] $game_temp.player_new_y = escape[2]
@@ -282,7 +277,7 @@ HiddenMoveHandlers::UseMove.add(:DIG, proc { |move, pokemon|
$scene.transfer_player $scene.transfer_player
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
} end
pbEraseEscapePoint pbEraseEscapePoint
next true next true
end end
@@ -306,7 +301,7 @@ def pbDive
speciesname = (movefinder) ? movefinder.name : $player.name speciesname = (movefinder) ? movefinder.name : $player.name
pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = map_metadata.dive_map_id $game_temp.player_new_map_id = map_metadata.dive_map_id
$game_temp.player_new_x = $game_player.x $game_temp.player_new_x = $game_player.x
$game_temp.player_new_y = $game_player.y $game_temp.player_new_y = $game_player.y
@@ -318,7 +313,7 @@ def pbDive
$scene.transfer_player(false) $scene.transfer_player(false)
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
} end
return true return true
end end
return false return false
@@ -344,7 +339,7 @@ def pbSurfacing
speciesname = (movefinder) ? movefinder.name : $player.name speciesname = (movefinder) ? movefinder.name : $player.name
pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name)) pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name))
pbHiddenMoveAnimation(movefinder) pbHiddenMoveAnimation(movefinder)
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = surface_map_id $game_temp.player_new_map_id = surface_map_id
$game_temp.player_new_x = $game_player.x $game_temp.player_new_x = $game_player.x
$game_temp.player_new_y = $game_player.y $game_temp.player_new_y = $game_player.y
@@ -356,7 +351,7 @@ def pbSurfacing
surfbgm = GameData::Metadata.get.surf_BGM surfbgm = GameData::Metadata.get.surf_BGM
(surfbgm) ? pbBGMPlay(surfbgm) : $game_map.autoplayAsCue (surfbgm) ? pbBGMPlay(surfbgm) : $game_map.autoplayAsCue
$game_map.refresh $game_map.refresh
} end
return true return true
end end
return false return false
@@ -365,7 +360,7 @@ end
# @deprecated This method is slated to be removed in v21. # @deprecated This method is slated to be removed in v21.
def pbTransferUnderwater(mapid, x, y, direction = $game_player.direction) def pbTransferUnderwater(mapid, x, y, direction = $game_player.direction)
Deprecation.warn_method("pbTransferUnderwater", "v21", '"Transfer Player" event command') Deprecation.warn_method("pbTransferUnderwater", "v21", '"Transfer Player" event command')
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = mapid $game_temp.player_new_map_id = mapid
$game_temp.player_new_x = x $game_temp.player_new_x = x
$game_temp.player_new_y = y $game_temp.player_new_y = y
@@ -373,7 +368,7 @@ def pbTransferUnderwater(mapid, x, y, direction = $game_player.direction)
$scene.transfer_player(false) $scene.transfer_player(false)
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
} end
end end
EventHandlers.add(:on_player_interact, :diving, EventHandlers.add(:on_player_interact, :diving,
@@ -438,7 +433,7 @@ HiddenMoveHandlers::UseMove.add(:DIVE, proc { |move, pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name))
end end
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = dive_map_id $game_temp.player_new_map_id = dive_map_id
$game_temp.player_new_x = $game_player.x $game_temp.player_new_x = $game_player.x
$game_temp.player_new_y = $game_player.y $game_temp.player_new_y = $game_player.y
@@ -449,7 +444,7 @@ HiddenMoveHandlers::UseMove.add(:DIVE, proc { |move, pokemon|
$scene.transfer_player(false) $scene.transfer_player(false)
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
} end
next true next true
}) })
@@ -518,7 +513,7 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY)
pbMessage(_INTL("{1} used {2}!", name, GameData::Move.get(move).name)) pbMessage(_INTL("{1} used {2}!", name, GameData::Move.get(move).name))
end end
$stats.fly_count += 1 $stats.fly_count += 1
pbFadeOutIn { pbFadeOutIn do
pbSEPlay("Fly") pbSEPlay("Fly")
$game_temp.player_new_map_id = $game_temp.fly_destination[0] $game_temp.player_new_map_id = $game_temp.fly_destination[0]
$game_temp.player_new_x = $game_temp.fly_destination[1] $game_temp.player_new_x = $game_temp.fly_destination[1]
@@ -531,7 +526,7 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY)
$game_map.refresh $game_map.refresh
yield if block_given? yield if block_given?
pbWait(Graphics.frame_rate / 4) pbWait(Graphics.frame_rate / 4)
} end
pbEraseEscapePoint pbEraseEscapePoint
return true return true
end end
@@ -763,7 +758,7 @@ end
# @deprecated This method is slated to be removed in v21. # @deprecated This method is slated to be removed in v21.
def pbTransferSurfing(mapid, xcoord, ycoord, direction = $game_player.direction) def pbTransferSurfing(mapid, xcoord, ycoord, direction = $game_player.direction)
Deprecation.warn_method("pbTransferSurfing", "v21", '"Transfer Player" event command') Deprecation.warn_method("pbTransferSurfing", "v21", '"Transfer Player" event command')
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = mapid $game_temp.player_new_map_id = mapid
$game_temp.player_new_x = xcoord $game_temp.player_new_x = xcoord
$game_temp.player_new_y = ycoord $game_temp.player_new_y = ycoord
@@ -771,7 +766,7 @@ def pbTransferSurfing(mapid, xcoord, ycoord, direction = $game_player.direction)
$scene.transfer_player(false) $scene.transfer_player(false)
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
} end
end end
EventHandlers.add(:on_player_interact, :start_surfing, EventHandlers.add(:on_player_interact, :start_surfing,
@@ -923,7 +918,7 @@ HiddenMoveHandlers::UseMove.add(:TELEPORT, proc { |move, pokemon|
if !pbHiddenMoveAnimation(pokemon) if !pbHiddenMoveAnimation(pokemon)
pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name)) pbMessage(_INTL("{1} used {2}!", pokemon.name, GameData::Move.get(move).name))
end end
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = healing[0] $game_temp.player_new_map_id = healing[0]
$game_temp.player_new_x = healing[1] $game_temp.player_new_x = healing[1]
$game_temp.player_new_y = healing[2] $game_temp.player_new_y = healing[2]
@@ -932,7 +927,7 @@ HiddenMoveHandlers::UseMove.add(:TELEPORT, proc { |move, pokemon|
$scene.transfer_player $scene.transfer_player
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
} end
pbEraseEscapePoint pbEraseEscapePoint
next true next true
}) })
@@ -50,33 +50,27 @@ def pbFishing(hasEncounter, rodType = 1)
message = "" message = ""
time.times { message += ". " } time.times { message += ". " }
if pbWaitMessage(msgWindow, time) if pbWaitMessage(msgWindow, time)
pbFishingEnd { pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("Not even a nibble...")) }
pbMessageDisplay(msgWindow, _INTL("Not even a nibble..."))
}
break break
end end
if hasEncounter && rand(100) < biteChance if hasEncounter && rand(100) < biteChance
$scene.spriteset.addUserAnimation(Settings::EXCLAMATION_ANIMATION_ID, $game_player.x, $game_player.y, true, 3) $scene.spriteset.addUserAnimation(Settings::EXCLAMATION_ANIMATION_ID, $game_player.x, $game_player.y, true, 3)
frames = Graphics.frame_rate - rand(Graphics.frame_rate / 2) # 0.5-1 second frames = Graphics.frame_rate - rand(Graphics.frame_rate / 2) # 0.5-1 second
if !pbWaitForInput(msgWindow, message + _INTL("\r\nOh! A bite!"), frames) if !pbWaitForInput(msgWindow, message + _INTL("\r\nOh! A bite!"), frames)
pbFishingEnd { pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("The Pokémon got away...")) }
pbMessageDisplay(msgWindow, _INTL("The Pokémon got away..."))
}
break break
end end
if Settings::FISHING_AUTO_HOOK || rand(100) < hookChance if Settings::FISHING_AUTO_HOOK || rand(100) < hookChance
pbFishingEnd { pbFishingEnd do
pbMessageDisplay(msgWindow, _INTL("Landed a Pokémon!")) if !Settings::FISHING_AUTO_HOOK pbMessageDisplay(msgWindow, _INTL("Landed a Pokémon!")) if !Settings::FISHING_AUTO_HOOK
} end
ret = true ret = true
break break
end end
# biteChance += 15 # biteChance += 15
# hookChance += 15 # hookChance += 15
else else
pbFishingEnd { pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("Not even a nibble...")) }
pbMessageDisplay(msgWindow, _INTL("Not even a nibble..."))
}
break break
end end
end end
@@ -381,11 +381,11 @@ def pbBerryPlant
[_INTL("Fertilize"), _INTL("Plant Berry"), _INTL("Exit")], -1) [_INTL("Fertilize"), _INTL("Plant Berry"), _INTL("Exit")], -1)
when 0 # Fertilize when 0 # Fertilize
mulch = nil mulch = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
mulch = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_mulch? }) mulch = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_mulch? })
} end
return if !mulch return if !mulch
mulch_data = GameData::Item.get(mulch) mulch_data = GameData::Item.get(mulch)
if mulch_data.is_mulch? if mulch_data.is_mulch?
@@ -408,11 +408,11 @@ def pbBerryPlant
ask_to_plant = false ask_to_plant = false
end end
if !ask_to_plant || pbConfirmMessage(_INTL("Want to plant a Berry?")) if !ask_to_plant || pbConfirmMessage(_INTL("Want to plant a Berry?"))
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
berry = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_berry? }) berry = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_berry? })
} end
if berry if berry
$stats.berries_planted += 1 $stats.berries_planted += 1
berry_plant.plant(berry) berry_plant.plant(berry)
@@ -404,7 +404,7 @@ class DayCare
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
def self.count def self.count
return $PokemonGlobal.day_care.count return $PokemonGlobal.day_care.count
@@ -494,7 +494,7 @@ class DayCare
day_care.reset_egg_counters day_care.reset_egg_counters
end end
#============================================================================= #-----------------------------------------------------------------------------
private private
@@ -512,8 +512,8 @@ module RandomDungeon
start = nil start = nil
maxWidth = @usable_width - (@buffer_x * 2) maxWidth = @usable_width - (@buffer_x * 2)
maxHeight = @usable_height - (@buffer_y * 2) maxHeight = @usable_height - (@buffer_y * 2)
for y in 0...maxHeight maxHeight.times do |y|
for x in 0...maxWidth maxWidth.times do |x|
next if !tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) next if !tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0])
start = [x, y] start = [x, y]
break break
@@ -535,10 +535,10 @@ module RandomDungeon
checking = to_check.shift checking = to_check.shift
x1, x2, y, dy = checking x1, x2, y, dy = checking
x = x1 x = x1
if !visited[y * maxWidth + x] && tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) if !visited[(y * maxWidth) + x] && tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0])
loop do loop do
break if visited[y * maxWidth + x - 1] || !tile_is_ground?(@map_data[x - 1 + @buffer_x, y + @buffer_y, 0]) break if visited[(y * maxWidth) + x - 1] || !tile_is_ground?(@map_data[x - 1 + @buffer_x, y + @buffer_y, 0])
visited[y * maxWidth + x - 1] = true visited[(y * maxWidth) + x - 1] = true
x -= 1 x -= 1
end end
end end
@@ -546,8 +546,8 @@ module RandomDungeon
loop do loop do
break if x1 > x2 break if x1 > x2
loop do loop do
break if visited[y * maxWidth + x1] || !tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0]) break if visited[(y * maxWidth) + x1] || !tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0])
visited[y * maxWidth + x1] = true visited[(y * maxWidth) + x1] = true
to_check.push([x, x1, y + dy, dy]) to_check.push([x, x1, y + dy, dy])
to_check.push([x2 + 1, x1, y - dy, -dy]) if x1 > x2 to_check.push([x2 + 1, x1, y - dy, -dy]) if x1 > x2
x1 += 1 x1 += 1
@@ -555,16 +555,16 @@ module RandomDungeon
x1 += 1 x1 += 1
loop do loop do
break if x1 >= x2 break if x1 >= x2
break if !visited[y * maxWidth + x1] && tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0]) break if !visited[(y * maxWidth) + x1] && tile_is_ground?(@map_data[x1 + @buffer_x, y + @buffer_y, 0])
x1 += 1 x1 += 1
end end
x = x1 x = x1
end end
end end
# Check for unflooded floor tiles # Check for unflooded floor tiles
for y in 0...maxHeight maxHeight.times do |y|
for x in 0...maxWidth maxWidth.times do |x|
next if visited[y * maxWidth + x] || !tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0]) next if visited[(y * maxWidth) + x] || !tile_is_ground?(@map_data[x + @buffer_x, y + @buffer_y, 0])
@need_redraw = true @need_redraw = true
break break
end end
@@ -824,9 +824,9 @@ module RandomDungeon
def get_wall_tile_for_coord(x, y, layer = 0) def get_wall_tile_for_coord(x, y, layer = 0)
if layer == 0 if layer == 0
is_neighbour = lambda { |x, y| return tile_is_ground?(@map_data.value(x, y)) } is_neighbour = lambda { |x2, y2| return tile_is_ground?(@map_data.value(x2, y2)) }
else else
is_neighbour = lambda { |x, y| return tile_is_wall?(@map_data[x, y, 1]) } is_neighbour = lambda { |x2, y2| return tile_is_wall?(@map_data[x2, y2, 1]) }
end end
neighbours = 0 neighbours = 0
neighbours |= 0x01 if is_neighbour.call(x, y - 1) # N neighbours |= 0x01 if is_neighbour.call(x, y - 1) # N
@@ -863,8 +863,8 @@ module RandomDungeon
(maxWidth / @parameters.cell_width).times do |i| (maxWidth / @parameters.cell_width).times do |i|
next if rand(100) >= @parameters.floor_patch_chance next if rand(100) >= @parameters.floor_patch_chance
# Random placing of floor patch tiles # Random placing of floor patch tiles
mid_x = i * @parameters.cell_width + rand(@parameters.cell_width) mid_x = (i * @parameters.cell_width) + rand(@parameters.cell_width)
mid_y = j * @parameters.cell_height + rand(@parameters.cell_height) mid_y = (j * @parameters.cell_height) + rand(@parameters.cell_height)
((mid_y - @parameters.floor_patch_radius)..(mid_y + @parameters.floor_patch_radius)).each do |y| ((mid_y - @parameters.floor_patch_radius)..(mid_y + @parameters.floor_patch_radius)).each do |y|
((mid_x - @parameters.floor_patch_radius)..(mid_x + @parameters.floor_patch_radius)).each do |x| ((mid_x - @parameters.floor_patch_radius)..(mid_x + @parameters.floor_patch_radius)).each do |x|
if @tileset.floor_patch_under_walls if @tileset.floor_patch_under_walls
@@ -989,7 +989,7 @@ module RandomDungeon
when :void_decoration_large, :floor_decoration_large when :void_decoration_large, :floor_decoration_large
4.times do |c| 4.times do |c|
tile = @tileset.get_random_tile_of_type(tile_type, self, i, j, layer) tile = @tileset.get_random_tile_of_type(tile_type, self, i, j, layer)
tile += (c % 2) + 8 * (c / 2) if tile >= 384 # Regular tile tile += (c % 2) + (8 * (c / 2)) if tile >= 384 # Regular tile
map.data[i + (c % 2), j + (c / 2), layer] = tile map.data[i + (c % 2), j + (c / 2), layer] = tile
end end
else else
+14 -14
View File
@@ -190,13 +190,13 @@ def pbChangeLevel(pkmn, new_level, scene)
# Check for evolution # Check for evolution
new_species = pkmn.check_evolution_on_level_up new_species = pkmn.check_evolution_on_level_up
if new_species if new_species
pbFadeOutInWithMusic { pbFadeOutInWithMusic do
evo = PokemonEvolutionScene.new evo = PokemonEvolutionScene.new
evo.pbStartScreen(pkmn, new_species) evo.pbStartScreen(pkmn, new_species)
evo.pbEvolution evo.pbEvolution
evo.pbEndScreen evo.pbEndScreen
scene.pbRefresh if scene.is_a?(PokemonPartyScreen) scene.pbRefresh if scene.is_a?(PokemonPartyScreen)
} end
end end
end end
end end
@@ -299,13 +299,13 @@ def pbChangeExp(pkmn, new_exp, scene)
# Check for evolution # Check for evolution
new_species = pkmn.check_evolution_on_level_up new_species = pkmn.check_evolution_on_level_up
if new_species if new_species
pbFadeOutInWithMusic { pbFadeOutInWithMusic do
evo = PokemonEvolutionScene.new evo = PokemonEvolutionScene.new
evo.pbStartScreen(pkmn, new_species) evo.pbStartScreen(pkmn, new_species)
evo.pbEvolution evo.pbEvolution
evo.pbEndScreen evo.pbEndScreen
scene.pbRefresh if scene.is_a?(PokemonPartyScreen) scene.pbRefresh if scene.is_a?(PokemonPartyScreen)
} end
end end
end end
end end
@@ -624,11 +624,11 @@ end
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
@@ -653,7 +653,7 @@ def pbUseItem(bag, item, bagscene = nil)
annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE")) annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
end end
end end
pbFadeOutIn { pbFadeOutIn do
scene = PokemonParty_Scene.new scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene, $player.party) screen = PokemonPartyScreen.new(scene, $player.party)
screen.pbStartScene(_INTL("Use on which Pokémon?"), false, annot) screen.pbStartScene(_INTL("Use on which Pokémon?"), false, annot)
@@ -685,7 +685,7 @@ def pbUseItem(bag, item, bagscene = nil)
end end
screen.pbEndScene screen.pbEndScene
bagscene&.pbRefresh bagscene&.pbRefresh
} end
return (ret) ? 1 : 0 return (ret) ? 1 : 0
elsif useType == 2 || itm.is_machine? # Item is usable from Bag or teaches a move elsif useType == 2 || itm.is_machine? # Item is usable from Bag or teaches a move
intret = ItemHandlers.triggerUseFromBag(item) intret = ItemHandlers.triggerUseFromBag(item)
@@ -853,33 +853,33 @@ end
#=============================================================================== #===============================================================================
def pbChooseItem(var = 0, *args) def pbChooseItem(var = 0, *args)
ret = nil ret = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
ret = screen.pbChooseItemScreen ret = screen.pbChooseItemScreen
} end
$game_variables[var] = ret || :NONE if var > 0 $game_variables[var] = ret || :NONE if var > 0
return ret return ret
end end
def pbChooseApricorn(var = 0) def pbChooseApricorn(var = 0)
ret = nil ret = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_apricorn? }) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_apricorn? })
} end
$game_variables[var] = ret || :NONE if var > 0 $game_variables[var] = ret || :NONE if var > 0
return ret return ret
end end
def pbChooseFossil(var = 0) def pbChooseFossil(var = 0)
ret = nil ret = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_fossil? }) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).is_fossil? })
} end
$game_variables[var] = ret || :NONE if var > 0 $game_variables[var] = ret || :NONE if var > 0
return ret return ret
end end
+47 -49
View File
@@ -54,13 +54,13 @@ ItemHandlers::UseFromBag.add(:ITEMFINDER, proc { |item|
ItemHandlers::UseFromBag.copy(:ITEMFINDER, :DOWSINGMCHN, :DOWSINGMACHINE) ItemHandlers::UseFromBag.copy(:ITEMFINDER, :DOWSINGMCHN, :DOWSINGMACHINE)
ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item| ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item|
pbFadeOutIn { pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false) scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene) screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen ret = screen.pbStartScreen
$game_temp.fly_destination = ret if ret $game_temp.fly_destination = ret if ret
next 99999 if ret # Ugly hack to make Bag scene not reappear if flying next 99999 if ret # Ugly hack to make Bag scene not reappear if flying
} end
next ($game_temp.fly_destination) ? 2 : 0 next ($game_temp.fly_destination) ? 2 : 0
}) })
@@ -148,11 +148,11 @@ EventHandlers.add(:on_player_step_taken, :repel_counter,
end end
next if !pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?")) next if !pbConfirmMessage(_INTL("The repellent's effect wore off! Would you like to use another one?"))
ret = nil ret = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
ret = screen.pbChooseItemScreen(proc { |item| repels.include?(item) }) ret = screen.pbChooseItemScreen(proc { |item| repels.include?(item) })
} end
pbUseItem($bag, ret) if ret pbUseItem($bag, ret) if ret
} }
) )
@@ -190,7 +190,7 @@ ItemHandlers::UseInField.add(:ESCAPEROPE, proc { |item|
next false next false
end end
pbUseItemMessage(item) pbUseItemMessage(item)
pbFadeOutIn { pbFadeOutIn do
$game_temp.player_new_map_id = escape[0] $game_temp.player_new_map_id = escape[0]
$game_temp.player_new_x = escape[1] $game_temp.player_new_x = escape[1]
$game_temp.player_new_y = escape[2] $game_temp.player_new_y = escape[2]
@@ -199,7 +199,7 @@ ItemHandlers::UseInField.add(:ESCAPEROPE, proc { |item|
$scene.transfer_player $scene.transfer_player
$game_map.autoplay $game_map.autoplay
$game_map.refresh $game_map.refresh
} end
pbEraseEscapePoint pbEraseEscapePoint
next true next true
}) })
@@ -220,7 +220,7 @@ ItemHandlers::UseInField.add(:SACREDASH, proc { |item|
next false next false
end end
revived = 0 revived = 0
pbFadeOutIn { pbFadeOutIn do
scene = PokemonParty_Scene.new scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene, $player.party) screen = PokemonPartyScreen.new(scene, $player.party)
screen.pbStartScene(_INTL("Using item..."), false) screen.pbStartScene(_INTL("Using item..."), false)
@@ -231,11 +231,9 @@ ItemHandlers::UseInField.add(:SACREDASH, proc { |item|
screen.pbRefreshSingle(i) screen.pbRefreshSingle(i)
screen.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name)) screen.pbDisplay(_INTL("{1}'s HP was restored.", pkmn.name))
end end
if revived == 0 screen.pbDisplay(_INTL("It won't have any effect.")) if revived == 0
screen.pbDisplay(_INTL("It won't have any effect."))
end
screen.pbEndScene screen.pbEndScene
} end
next (revived > 0) next (revived > 0)
}) })
@@ -371,7 +369,7 @@ ItemHandlers::UseOnPokemon.addIf(:evolution_stones,
end end
newspecies = pkmn.check_evolution_on_use_item(item) newspecies = pkmn.check_evolution_on_use_item(item)
if newspecies if newspecies
pbFadeOutInWithMusic { pbFadeOutInWithMusic do
evo = PokemonEvolutionScene.new evo = PokemonEvolutionScene.new
evo.pbStartScreen(pkmn, newspecies) evo.pbStartScreen(pkmn, newspecies)
evo.pbEvolution(false) evo.pbEvolution(false)
@@ -380,7 +378,7 @@ ItemHandlers::UseOnPokemon.addIf(:evolution_stones,
scene.pbRefreshAnnotations(proc { |p| !p.check_evolution_on_use_item(item).nil? }) scene.pbRefreshAnnotations(proc { |p| !p.check_evolution_on_use_item(item).nil? })
scene.pbRefresh scene.pbRefresh
end end
} end
next true next true
end end
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
@@ -896,13 +894,13 @@ ItemHandlers::UseOnPokemon.add(:RARECANDY, proc { |item, qty, pkmn, scene|
next false next false
end end
# Check for evolution # Check for evolution
pbFadeOutInWithMusic { pbFadeOutInWithMusic do
evo = PokemonEvolutionScene.new evo = PokemonEvolutionScene.new
evo.pbStartScreen(pkmn, new_species) evo.pbStartScreen(pkmn, new_species)
evo.pbEvolution evo.pbEvolution
evo.pbEndScreen evo.pbEndScreen
scene.pbRefresh if scene.is_a?(PokemonPartyScreen) scene.pbRefresh if scene.is_a?(PokemonPartyScreen)
} end
next true next true
end end
# Level up # Level up
@@ -1093,10 +1091,10 @@ ItemHandlers::UseOnPokemon.add(:GRACIDEA, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false next false
end end
pkmn.setForm(1) { pkmn.setForm(1) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
next true next true
}) })
@@ -1108,10 +1106,10 @@ ItemHandlers::UseOnPokemon.add(:REDNECTAR, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false next false
end end
pkmn.setForm(0) { pkmn.setForm(0) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed form!", pkmn.name))
} end
next true next true
}) })
@@ -1123,10 +1121,10 @@ ItemHandlers::UseOnPokemon.add(:YELLOWNECTAR, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false next false
end end
pkmn.setForm(1) { pkmn.setForm(1) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed form!", pkmn.name))
} end
next true next true
}) })
@@ -1138,10 +1136,10 @@ ItemHandlers::UseOnPokemon.add(:PINKNECTAR, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false next false
end end
pkmn.setForm(2) { pkmn.setForm(2) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed form!", pkmn.name))
} end
next true next true
}) })
@@ -1153,10 +1151,10 @@ ItemHandlers::UseOnPokemon.add(:PURPLENECTAR, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon.")) scene.pbDisplay(_INTL("This can't be used on the fainted Pokémon."))
next false next false
end end
pkmn.setForm(3) { pkmn.setForm(3) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} changed form!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed form!", pkmn.name))
} end
next true next true
}) })
@@ -1171,10 +1169,10 @@ ItemHandlers::UseOnPokemon.add(:REVEALGLASS, proc { |item, qty, pkmn, scene|
next false next false
end end
newForm = (pkmn.form == 0) ? 1 : 0 newForm = (pkmn.form == 0) ? 1 : 0
pkmn.setForm(newForm) { pkmn.setForm(newForm) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
next true next true
}) })
@@ -1187,10 +1185,10 @@ ItemHandlers::UseOnPokemon.add(:PRISONBOTTLE, proc { |item, qty, pkmn, scene|
next false next false
end end
newForm = (pkmn.form == 0) ? 1 : 0 newForm = (pkmn.form == 0) ? 1 : 0
pkmn.setForm(newForm) { pkmn.setForm(newForm) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
next true next true
}) })
@@ -1217,10 +1215,10 @@ ItemHandlers::UseOnPokemon.add(:ROTOMCATALOG, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("It won't have any effect.")) scene.pbDisplay(_INTL("It won't have any effect."))
next false next false
elsif new_form > 0 && new_form < choices.length - 1 elsif new_form > 0 && new_form < choices.length - 1
pkmn.setForm(new_form) { pkmn.setForm(new_form) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} transformed!", pkmn.name)) scene.pbDisplay(_INTL("{1} transformed!", pkmn.name))
} end
next true next true
end end
next false next false
@@ -1238,10 +1236,10 @@ ItemHandlers::UseOnPokemon.add(:ZYGARDECUBE, proc { |item, qty, pkmn, scene|
[_INTL("Change form"), _INTL("Change Ability"), _INTL("Cancel")]) [_INTL("Change form"), _INTL("Change Ability"), _INTL("Cancel")])
when 0 # Change form when 0 # Change form
newForm = (pkmn.form == 0) ? 1 : 0 newForm = (pkmn.form == 0) ? 1 : 0
pkmn.setForm(newForm) { pkmn.setForm(newForm) do
scene.pbRefresh scene.pbRefresh
scene.pbDisplay(_INTL("{1} transformed!", pkmn.name)) scene.pbDisplay(_INTL("{1} transformed!", pkmn.name))
} end
next true next true
when 1 # Change ability when 1 # Change ability
new_abil = (pkmn.ability_index + 1) % 2 new_abil = (pkmn.ability_index + 1) % 2
@@ -1282,12 +1280,12 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS, proc { |item, qty, pkmn, scene|
newForm = 0 newForm = 0
newForm = 1 if other_pkmn.isSpecies?(:RESHIRAM) newForm = 1 if other_pkmn.isSpecies?(:RESHIRAM)
newForm = 2 if other_pkmn.isSpecies?(:ZEKROM) newForm = 2 if other_pkmn.isSpecies?(:ZEKROM)
pkmn.setForm(newForm) { pkmn.setForm(newForm) do
pkmn.fused = other_pkmn pkmn.fused = other_pkmn
$player.remove_pokemon_at_index(chosen) $player.remove_pokemon_at_index(chosen)
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:DNASPLICERS, :DNASPLICERSUSED) $bag.replace_item(:DNASPLICERS, :DNASPLICERSUSED)
next true next true
}) })
@@ -1304,12 +1302,12 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERSUSED, proc { |item, qty, pkmn, scene|
next false next false
end end
# Unfusing # Unfusing
pkmn.setForm(0) { pkmn.setForm(0) do
$player.party[$player.party.length] = pkmn.fused $player.party[$player.party.length] = pkmn.fused
pkmn.fused = nil pkmn.fused = nil
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:DNASPLICERSUSED, :DNASPLICERS) $bag.replace_item(:DNASPLICERSUSED, :DNASPLICERS)
next true next true
}) })
@@ -1339,12 +1337,12 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("It cannot be fused with that Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
next false next false
end end
pkmn.setForm(1) { pkmn.setForm(1) do
pkmn.fused = other_pkmn pkmn.fused = other_pkmn
$player.remove_pokemon_at_index(chosen) $player.remove_pokemon_at_index(chosen)
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:NSOLARIZER, :NSOLARIZERUSED) $bag.replace_item(:NSOLARIZER, :NSOLARIZERUSED)
next true next true
}) })
@@ -1361,12 +1359,12 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZERUSED, proc { |item, qty, pkmn, scene|
next false next false
end end
# Unfusing # Unfusing
pkmn.setForm(0) { pkmn.setForm(0) do
$player.party[$player.party.length] = pkmn.fused $player.party[$player.party.length] = pkmn.fused
pkmn.fused = nil pkmn.fused = nil
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:NSOLARIZERUSED, :NSOLARIZER) $bag.replace_item(:NSOLARIZERUSED, :NSOLARIZER)
next true next true
}) })
@@ -1396,12 +1394,12 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER, proc { |item, qty, pkmn, scene|
scene.pbDisplay(_INTL("It cannot be fused with that Pokémon.")) scene.pbDisplay(_INTL("It cannot be fused with that Pokémon."))
next false next false
end end
pkmn.setForm(2) { pkmn.setForm(2) do
pkmn.fused = other_pkmn pkmn.fused = other_pkmn
$player.remove_pokemon_at_index(chosen) $player.remove_pokemon_at_index(chosen)
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:NLUNARIZER, :NLUNARIZERUSED) $bag.replace_item(:NLUNARIZER, :NLUNARIZERUSED)
next true next true
}) })
@@ -1418,12 +1416,12 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZERUSED, proc { |item, qty, pkmn, scene|
next false next false
end end
# Unfusing # Unfusing
pkmn.setForm(0) { pkmn.setForm(0) do
$player.party[$player.party.length] = pkmn.fused $player.party[$player.party.length] = pkmn.fused
pkmn.fused = nil pkmn.fused = nil
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:NLUNARIZERUSED, :NLUNARIZER) $bag.replace_item(:NLUNARIZERUSED, :NLUNARIZER)
next true next true
}) })
@@ -1457,12 +1455,12 @@ ItemHandlers::UseOnPokemon.add(:REINSOFUNITY, proc { |item, qty, pkmn, scene|
newForm = 0 newForm = 0
newForm = 1 if other_pkmn.isSpecies?(:GLASTRIER) newForm = 1 if other_pkmn.isSpecies?(:GLASTRIER)
newForm = 2 if other_pkmn.isSpecies?(:SPECTRIER) newForm = 2 if other_pkmn.isSpecies?(:SPECTRIER)
pkmn.setForm(newForm) { pkmn.setForm(newForm) do
pkmn.fused = other_pkmn pkmn.fused = other_pkmn
$player.remove_pokemon_at_index(chosen) $player.remove_pokemon_at_index(chosen)
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:REINSOFUNITY, :REINSOFUNITYUSED) $bag.replace_item(:REINSOFUNITY, :REINSOFUNITYUSED)
next true next true
}) })
@@ -1479,12 +1477,12 @@ ItemHandlers::UseOnPokemon.add(:REINSOFUNITYUSED, proc { |item, qty, pkmn, scene
next false next false
end end
# Unfusing # Unfusing
pkmn.setForm(0) { pkmn.setForm(0) do
$player.party[$player.party.length] = pkmn.fused $player.party[$player.party.length] = pkmn.fused
pkmn.fused = nil pkmn.fused = nil
scene.pbHardRefresh scene.pbHardRefresh
scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name)) scene.pbDisplay(_INTL("{1} changed Forme!", pkmn.name))
} end
$bag.replace_item(:REINSOFUNITYUSED, :REINSOFUNITY) $bag.replace_item(:REINSOFUNITYUSED, :REINSOFUNITY)
next true next true
}) })
+12 -19
View File
@@ -88,12 +88,10 @@ class Phone
if contact if contact
contact.visible = true contact.visible = true
@contacts.delete(contact) @contacts.delete(contact)
@contacts.push(contact)
else else
contact = Contact.new(true, args[0].map_id, args[0].id, contact = Contact.new(true, args[0].map_id, args[0].id,
trainer_type, name, args[3], args[4], args[5]) trainer_type, name, args[3], args[4], args[5])
contact.increment_version contact.increment_version
@contacts.push(contact)
end end
elsif args[1].is_a?(Numeric) elsif args[1].is_a?(Numeric)
# Trainer # Trainer
@@ -104,12 +102,10 @@ class Phone
if contact if contact
contact.visible = true contact.visible = true
@contacts.delete(contact) @contacts.delete(contact)
@contacts.push(contact)
else else
contact = Contact.new(true, args[0], args[1], contact = Contact.new(true, args[0], args[1],
trainer_type, name, args[4], args[5], args[6]) trainer_type, name, args[4], args[5], args[6])
contact.increment_version contact.increment_version
@contacts.push(contact)
end end
else else
# Non-trainer # Non-trainer
@@ -118,12 +114,11 @@ class Phone
if contact if contact
contact.visible = true contact.visible = true
@contacts.delete(contact) @contacts.delete(contact)
@contacts.push(contact)
else else
contact = Contact.new(false, *args) contact = Contact.new(false, *args)
end
end
@contacts.push(contact) @contacts.push(contact)
end
end
sort_contacts sort_contacts
return true return true
end end
@@ -264,9 +259,9 @@ class Phone
# Map ID, name, common event ID # Map ID, name, common event ID
def initialize(trainer, *args) def initialize(trainer, *args)
@trainer = trainer @trainer = trainer
@map_id = args[0]
if @trainer if @trainer
# Trainer # Trainer
@map_id = args[0]
@event_id = args[1] @event_id = args[1]
@trainer_type = args[2] @trainer_type = args[2]
@name = args[3] @name = args[3]
@@ -279,7 +274,6 @@ class Phone
@common_event_id = args[6] || 0 @common_event_id = args[6] || 0
else else
# Non-trainer # Non-trainer
@map_id = args[0]
@name = args[1] @name = args[1]
@common_event_id = args[2] || 0 @common_event_id = args[2] || 0
end end
@@ -320,7 +314,7 @@ class Phone
def display_name def display_name
if trainer? if trainer?
return sprintf("%s %s", GameData::TrainerType.get(@trainer_type).name, return sprintf("%s %s", GameData::TrainerType.get(@trainer_type).name,
pbGetMessageFromHash(MessageTypes::TrainerNames, @name)) pbGetMessageFromHash(MessageTypes::TRAINER_NAMES, @name))
end end
return _INTL(@name) return _INTL(@name)
end end
@@ -482,11 +476,11 @@ class Phone
messages = GameData::PhoneMessage.try_get(contact.trainer_type, contact.name, contact.start_version) if !messages messages = GameData::PhoneMessage.try_get(contact.trainer_type, contact.name, contact.start_version) if !messages
messages = GameData::PhoneMessage::DATA["default"] if !messages messages = GameData::PhoneMessage::DATA["default"] if !messages
# Create lambda for choosing a random message and translating it # Create lambda for choosing a random message and translating it
get_random_message = lambda do |messages| get_random_message = lambda do |msgs|
return "" if !messages return "" if !msgs
msg = messages.sample msg = msgs.sample
return "" if !msg return "" if !msg
return pbGetMessageFromHash(MessageTypes::PhoneMessages, msg) return pbGetMessageFromHash(MessageTypes::PHONE_MESSAGES, msg)
end end
# Choose random greeting depending on time of day # Choose random greeting depending on time of day
ret = get_random_message.call(messages.intro) ret = get_random_message.call(messages.intro)
@@ -505,10 +499,11 @@ class Phone
# Choose main message set # Choose main message set
if Phone.rematches_enabled && contact.rematch_flag > 0 if Phone.rematches_enabled && contact.rematch_flag > 0
# Trainer is ready for a rematch, so tell/remind the player # Trainer is ready for a rematch, so tell/remind the player
if contact.rematch_flag == 1 # Tell the player case contact.rematch_flag
when 1 # Tell the player
ret += get_random_message.call(messages.battle_request) ret += get_random_message.call(messages.battle_request)
contact.rematch_flag = 2 # Ready for rematch and told player contact.rematch_flag = 2 # Ready for rematch and told player
elsif contact.rematch_flag == 2 # Remind the player when 2 # Remind the player
if messages.battle_remind if messages.battle_remind
ret += get_random_message.call(messages.battle_remind) ret += get_random_message.call(messages.battle_remind)
else else
@@ -555,9 +550,7 @@ class Phone
species = get_species_from_table.call(enc_tables[:Land]) species = get_species_from_table.call(enc_tables[:Land])
if !species if !species
species = get_species_from_table.call(enc_tables[:Cave]) species = get_species_from_table.call(enc_tables[:Cave])
if !species species = get_species_from_table.call(enc_tables[:Water]) if !species
species = get_species_from_table.call(enc_tables[:Water])
end
end end
return "" if !species return "" if !species
return GameData::Species.get(species).name return GameData::Species.get(species).name
@@ -264,9 +264,7 @@ MultipleForms.register(:ROTOM, {
MultipleForms.register(:GIRATINA, { MultipleForms.register(:GIRATINA, {
"getForm" => proc { |pkmn| "getForm" => proc { |pkmn|
next 1 if pkmn.hasItem?(:GRISEOUSORB) next 1 if pkmn.hasItem?(:GRISEOUSORB)
if $game_map && $game_map.metadata&.has_flag?("DistortionWorld") next 1 if $game_map&.metadata&.has_flag?("DistortionWorld")
next 1
end
next 0 next 0
} }
}) })
@@ -1,17 +1,15 @@
=begin # All types except Shadow have Shadow as a weakness.
All types except Shadow have Shadow as a weakness. # Shadow has Shadow as a resistance.
Shadow has Shadow as a resistance. # On a side note, the Shadow moves in Colosseum will not be affected by
On a side note, the Shadow moves in Colosseum will not be affected by Weaknesses # Weaknesses or Resistances, while in XD the Shadow-type is Super-Effective
or Resistances, while in XD the Shadow-type is Super-Effective against all other # against all other types.
types. # 2/5 - display nature
2/5 - display nature #
# XD - Shadow Rush -- 55, 100 - Deals damage.
XD - Shadow Rush -- 55, 100 - Deals damage. # Colosseum - Shadow Rush -- 90, 100
Colosseum - Shadow Rush -- 90, 100 # If this attack is successful, user loses half of HP lost by opponent due to
If this attack is successful, user loses half of HP lost by opponent due to this # this attack (recoil). If user is in Hyper Mode, this attack has a good chance
attack (recoil). If user is in Hyper Mode, this attack has a good chance for a # for a critical hit.
critical hit.
=end
#=============================================================================== #===============================================================================
# Purify a Shadow Pokémon. # Purify a Shadow Pokémon.
@@ -63,8 +61,7 @@ end
# Relic Stone scene. # Relic Stone scene.
#=============================================================================== #===============================================================================
class RelicStoneScene class RelicStoneScene
def pbPurify def pbPurify; end
end
def pbUpdate def pbUpdate
pbUpdateSpriteHash(@sprites) pbUpdateSpriteHash(@sprites)
@@ -136,11 +133,11 @@ end
#=============================================================================== #===============================================================================
def pbRelicStoneScreen(pkmn) def pbRelicStoneScreen(pkmn)
retval = true retval = true
pbFadeOutIn { pbFadeOutIn do
scene = RelicStoneScene.new scene = RelicStoneScene.new
screen = RelicStoneScreen.new(scene) screen = RelicStoneScreen.new(scene)
retval = screen.pbStartScreen(pkmn) retval = screen.pbStartScreen(pkmn)
} end
return retval return retval
end end
@@ -187,9 +184,7 @@ class Battle::Battler
alias __shadow__pbInitPokemon pbInitPokemon unless method_defined?(:__shadow__pbInitPokemon) alias __shadow__pbInitPokemon pbInitPokemon unless method_defined?(:__shadow__pbInitPokemon)
def pbInitPokemon(*arg) def pbInitPokemon(*arg)
if self.pokemonIndex > 0 && inHyperMode? self.pokemon.hyper_mode = false if self.pokemonIndex > 0 && inHyperMode?
self.pokemon.hyper_mode = false
end
__shadow__pbInitPokemon(*arg) __shadow__pbInitPokemon(*arg)
# Called into battle # Called into battle
if shadowPokemon? if shadowPokemon?
@@ -284,9 +284,7 @@ class RegionalStorage
if @rgnmap < 0 if @rgnmap < 0
raise _INTL("The current map has no region set. Please set the MapPosition metadata setting for this map.") raise _INTL("The current map has no region set. Please set the MapPosition metadata setting for this map.")
end end
if !@storages[@rgnmap] @storages[@rgnmap] = PokemonStorage.new if !@storages[@rgnmap]
@storages[@rgnmap] = PokemonStorage.new
end
return @storages[@rgnmap] return @storages[@rgnmap]
end end
+12 -12
View File
@@ -974,49 +974,49 @@ class Pokemon
# Checks whether this Pokemon can evolve because of levelling up. # Checks whether this Pokemon can evolve because of levelling up.
# @return [Symbol, nil] the ID of the species to evolve into # @return [Symbol, nil] the ID of the species to evolve into
def check_evolution_on_level_up def check_evolution_on_level_up
return check_evolution_internal { |pkmn, new_species, method, parameter| return check_evolution_internal do |pkmn, new_species, method, parameter|
success = GameData::Evolution.get(method).call_level_up(pkmn, parameter) success = GameData::Evolution.get(method).call_level_up(pkmn, parameter)
next (success) ? new_species : nil next (success) ? new_species : nil
} end
end end
# Checks whether this Pokemon can evolve because of using an item on it. # Checks whether this Pokemon can evolve because of using an item on it.
# @param item_used [Symbol, GameData::Item, nil] the item being used # @param item_used [Symbol, GameData::Item, nil] the item being used
# @return [Symbol, nil] the ID of the species to evolve into # @return [Symbol, nil] the ID of the species to evolve into
def check_evolution_on_use_item(item_used) def check_evolution_on_use_item(item_used)
return check_evolution_internal { |pkmn, new_species, method, parameter| return check_evolution_internal do |pkmn, new_species, method, parameter|
success = GameData::Evolution.get(method).call_use_item(pkmn, parameter, item_used) success = GameData::Evolution.get(method).call_use_item(pkmn, parameter, item_used)
next (success) ? new_species : nil next (success) ? new_species : nil
} end
end end
# Checks whether this Pokemon can evolve because of being traded. # Checks whether this Pokemon can evolve because of being traded.
# @param other_pkmn [Pokemon] the other Pokémon involved in the trade # @param other_pkmn [Pokemon] the other Pokémon involved in the trade
# @return [Symbol, nil] the ID of the species to evolve into # @return [Symbol, nil] the ID of the species to evolve into
def check_evolution_on_trade(other_pkmn) def check_evolution_on_trade(other_pkmn)
return check_evolution_internal { |pkmn, new_species, method, parameter| return check_evolution_internal do |pkmn, new_species, method, parameter|
success = GameData::Evolution.get(method).call_on_trade(pkmn, parameter, other_pkmn) success = GameData::Evolution.get(method).call_on_trade(pkmn, parameter, other_pkmn)
next (success) ? new_species : nil next (success) ? new_species : nil
} end
end end
# Checks whether this Pokemon can evolve after a battle. # Checks whether this Pokemon can evolve after a battle.
# @return [Symbol, nil] the ID of the species to evolve into # @return [Symbol, nil] the ID of the species to evolve into
def check_evolution_after_battle(party_index) def check_evolution_after_battle(party_index)
return check_evolution_internal { |pkmn, new_species, method, parameter| return check_evolution_internal do |pkmn, new_species, method, parameter|
success = GameData::Evolution.get(method).call_after_battle(pkmn, party_index, parameter) success = GameData::Evolution.get(method).call_after_battle(pkmn, party_index, parameter)
next (success) ? new_species : nil next (success) ? new_species : nil
} end
end end
# Checks whether this Pokemon can evolve by a triggered event. # Checks whether this Pokemon can evolve by a triggered event.
# @param value [Integer] a value that may be used by the evolution method # @param value [Integer] a value that may be used by the evolution method
# @return [Symbol, nil] the ID of the species to evolve into # @return [Symbol, nil] the ID of the species to evolve into
def check_evolution_by_event(value = 0) def check_evolution_by_event(value = 0)
return check_evolution_internal { |pkmn, new_species, method, parameter| return check_evolution_internal do |pkmn, new_species, method, parameter|
success = GameData::Evolution.get(method).call_event(pkmn, parameter, value) success = GameData::Evolution.get(method).call_event(pkmn, parameter, value)
next (success) ? new_species : nil next (success) ? new_species : nil
} end
end end
# Called after this Pokémon evolves, to remove its held item (if the evolution # Called after this Pokémon evolves, to remove its held item (if the evolution
@@ -1047,12 +1047,12 @@ class Pokemon
def trigger_event_evolution(number) def trigger_event_evolution(number)
new_species = check_evolution_by_event(number) new_species = check_evolution_by_event(number)
if new_species if new_species
pbFadeOutInWithMusic { pbFadeOutInWithMusic do
evo = PokemonEvolutionScene.new evo = PokemonEvolutionScene.new
evo.pbStartScreen(self, new_species) evo.pbStartScreen(self, new_species)
evo.pbEvolution evo.pbEvolution
evo.pbEndScreen evo.pbEndScreen
} end
return true return true
end end
return false return false
@@ -62,7 +62,7 @@ end
def pbConvertTrainerData def pbConvertTrainerData
tr_type_names = [] tr_type_names = []
GameData::TrainerType.each { |t| tr_type_names.push(t.real_name) } GameData::TrainerType.each { |t| tr_type_names.push(t.real_name) }
MessageTypes.setMessagesAsHash(MessageTypes::TrainerTypes, tr_type_names) MessageTypes.setMessagesAsHash(MessageTypes::TRAINER_TYPE_NAMES, tr_type_names)
Compiler.write_trainer_types Compiler.write_trainer_types
Compiler.write_trainers Compiler.write_trainers
end end
@@ -139,7 +139,7 @@ class Player < Trainer
@last_seen_forms[species] = [gender, form, shiny] @last_seen_forms[species] = [gender, form, shiny]
end end
#=========================================================================== #---------------------------------------------------------------------------
# Sets the given species as owned in the Pokédex. # Sets the given species as owned in the Pokédex.
# @param species [Symbol, GameData::Species] species to set as owned # @param species [Symbol, GameData::Species] species to set as owned
@@ -185,7 +185,7 @@ class Player < Trainer
return self.count_species(@owned, dex) return self.count_species(@owned, dex)
end end
#=========================================================================== #---------------------------------------------------------------------------
# @param species [Pokemon, Symbol, GameData::Species] Pokemon to register as seen # @param species [Pokemon, Symbol, GameData::Species] Pokemon to register as seen
# @param gender [Integer] gender to register (0=male, 1=female, 2=genderless) # @param gender [Integer] gender to register (0=male, 1=female, 2=genderless)
@@ -227,7 +227,7 @@ class Player < Trainer
@last_seen_forms[pkmn.species] = [pkmn.gender, form, pkmn.shiny?] @last_seen_forms[pkmn.species] = [pkmn.gender, form, pkmn.shiny?]
end end
#=========================================================================== #---------------------------------------------------------------------------
# @param species [Symbol, GameData::Species] species to check # @param species [Symbol, GameData::Species] species to check
# @return [Integer] the number of Pokémon of the given species that have # @return [Integer] the number of Pokémon of the given species that have
@@ -272,7 +272,7 @@ class Player < Trainer
@defeated_counts[species_id] += 1 @defeated_counts[species_id] += 1
end end
#=========================================================================== #---------------------------------------------------------------------------
# Unlocks the given Dex, -1 being the National Dex. # Unlocks the given Dex, -1 being the National Dex.
# @param dex [Integer] Dex ID (-1 is the National Dex) # @param dex [Integer] Dex ID (-1 is the National Dex)
@@ -321,9 +321,7 @@ class Player < Trainer
return return
end end
if dexes_count == 1 # Only National Dex is defined if dexes_count == 1 # Only National Dex is defined
if self.unlocked?(0) && self.seen_any? @accessible_dexes.push(-1) if self.unlocked?(0) && self.seen_any?
@accessible_dexes.push(-1)
end
else # Regional Dexes + National Dex else # Regional Dexes + National Dex
dexes_count.times do |i| dexes_count.times do |i|
dex_list_to_check = (i == dexes_count - 1) ? -1 : i dex_list_to_check = (i == dexes_count - 1) ? -1 : i
@@ -334,7 +332,7 @@ class Player < Trainer
end end
end end
#=========================================================================== #---------------------------------------------------------------------------
private private
@@ -109,11 +109,11 @@ class PokemonEggHatch_Scene
if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex
pbMessage(_INTL("{1}'s data was added to the Pokédex.", @pokemon.name)) { update } pbMessage(_INTL("{1}'s data was added to the Pokédex.", @pokemon.name)) { update }
$player.pokedex.register_last_seen(@pokemon) $player.pokedex.register_last_seen(@pokemon)
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)
screen.pbDexEntry(@pokemon.species) screen.pbDexEntry(@pokemon.species)
} end
end end
# Nickname the Pokémon # Nickname the Pokémon
if $PokemonSystem.givenicknames == 0 && if $PokemonSystem.givenicknames == 0 &&
@@ -195,11 +195,11 @@ end
#=============================================================================== #===============================================================================
def pbHatchAnimation(pokemon) def pbHatchAnimation(pokemon)
pbMessage(_INTL("Huh?\1")) pbMessage(_INTL("Huh?\1"))
pbFadeOutInWithMusic { pbFadeOutInWithMusic do
scene = PokemonEggHatch_Scene.new scene = PokemonEggHatch_Scene.new
screen = PokemonEggHatchScreen.new(scene) screen = PokemonEggHatchScreen.new(scene)
screen.pbStartScreen(pokemon) screen.pbStartScreen(pokemon)
} end
return true return true
end end
@@ -226,11 +226,11 @@ def pbHatch(pokemon)
if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex if Settings::SHOW_NEW_SPECIES_POKEDEX_ENTRY_MORE_OFTEN && !was_owned && $player.has_pokedex
pbMessage(_INTL("{1}'s data was added to the Pokédex.", speciesname)) pbMessage(_INTL("{1}'s data was added to the Pokédex.", speciesname))
$player.pokedex.register_last_seen(pokemon) $player.pokedex.register_last_seen(pokemon)
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)
screen.pbDexEntry(pokemon.species) screen.pbDexEntry(pokemon.species)
} end
end end
# Nickname the Pokémon # Nickname the Pokémon
if $PokemonSystem.givenicknames == 0 && if $PokemonSystem.givenicknames == 0 &&
@@ -617,13 +617,13 @@ class PokemonEvolutionScene
pbMessageDisplay(@sprites["msgwindow"], pbMessageDisplay(@sprites["msgwindow"],
_INTL("{1}'s data was added to the Pokédex.", newspeciesname)) { pbUpdate } _INTL("{1}'s data was added to the Pokédex.", newspeciesname)) { pbUpdate }
$player.pokedex.register_last_seen(@pokemon) $player.pokedex.register_last_seen(@pokemon)
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)
screen.pbDexEntry(@pokemon.species) screen.pbDexEntry(@pokemon.species)
@sprites["msgwindow"].text = "" if moves_to_learn.length > 0 @sprites["msgwindow"].text = "" if moves_to_learn.length > 0
pbEndScreen(false) if moves_to_learn.length == 0 pbEndScreen(false) if moves_to_learn.length == 0
} end
end end
# Learn moves upon evolution for evolved species # Learn moves upon evolution for evolved species
moves_to_learn.each do |move| moves_to_learn.each do |move|
@@ -195,12 +195,12 @@ class PokemonTrade_Scene
pbMessageDisplay(@sprites["msgwindow"], pbMessageDisplay(@sprites["msgwindow"],
_INTL("{1}'s data was added to the Pokédex.", speciesname2)) { pbUpdate } _INTL("{1}'s data was added to the Pokédex.", speciesname2)) { pbUpdate }
$player.pokedex.register_last_seen(@pokemon2) $player.pokedex.register_last_seen(@pokemon2)
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)
screen.pbDexEntry(@pokemon2.species) screen.pbDexEntry(@pokemon2.species)
pbEndScreen(false) pbEndScreen(false)
} end
end end
end end
end end
@@ -227,11 +227,11 @@ def pbStartTrade(pokemonIndex, newpoke, nickname, trainerName, trainerGender = 0
yourPokemon.obtain_method = 2 # traded yourPokemon.obtain_method = 2 # traded
yourPokemon.reset_moves if resetmoves yourPokemon.reset_moves if resetmoves
yourPokemon.record_first_moves yourPokemon.record_first_moves
pbFadeOutInWithMusic { pbFadeOutInWithMusic do
evo = PokemonTrade_Scene.new evo = PokemonTrade_Scene.new
evo.pbStartScreen(myPokemon, yourPokemon, $player.name, trainerName) evo.pbStartScreen(myPokemon, yourPokemon, $player.name, trainerName)
evo.pbTrade evo.pbTrade
evo.pbEndScreen evo.pbEndScreen
} end
$player.party[pokemonIndex] = yourPokemon $player.party[pokemonIndex] = yourPokemon
end end
+20 -20
View File
@@ -137,27 +137,27 @@ MenuHandlers.add(:pause_menu, :pokedex, {
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
if Settings::USE_CURRENT_REGION_DEX if Settings::USE_CURRENT_REGION_DEX
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedex_Scene.new scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene) screen = PokemonPokedexScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
menu.pbRefresh menu.pbRefresh
} end
elsif $player.pokedex.accessible_dexes.length == 1 elsif $player.pokedex.accessible_dexes.length == 1
$PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[0] $PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[0]
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedex_Scene.new scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene) screen = PokemonPokedexScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
menu.pbRefresh menu.pbRefresh
} end
else else
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedexMenu_Scene.new scene = PokemonPokedexMenu_Scene.new
screen = PokemonPokedexMenuScreen.new(scene) screen = PokemonPokedexMenuScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
menu.pbRefresh menu.pbRefresh
} end
end end
next false next false
} }
@@ -170,12 +170,12 @@ MenuHandlers.add(:pause_menu, :party, {
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
hidden_move = nil hidden_move = nil
pbFadeOutIn { pbFadeOutIn do
sscene = PokemonParty_Scene.new sscene = PokemonParty_Scene.new
sscreen = PokemonPartyScreen.new(sscene, $player.party) sscreen = PokemonPartyScreen.new(sscene, $player.party)
hidden_move = sscreen.pbPokemonScreen hidden_move = sscreen.pbPokemonScreen
(hidden_move) ? menu.pbEndScene : menu.pbRefresh (hidden_move) ? menu.pbEndScene : menu.pbRefresh
} end
next false if !hidden_move next false if !hidden_move
$game_temp.in_menu = false $game_temp.in_menu = false
pbUseHiddenMove(hidden_move[0], hidden_move[1]) pbUseHiddenMove(hidden_move[0], hidden_move[1])
@@ -190,12 +190,12 @@ MenuHandlers.add(:pause_menu, :bag, {
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
item = nil item = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
item = screen.pbStartScreen item = screen.pbStartScreen
(item) ? menu.pbEndScene : menu.pbRefresh (item) ? menu.pbEndScene : menu.pbRefresh
} end
next false if !item next false if !item
$game_temp.in_menu = false $game_temp.in_menu = false
pbUseKeyItemInField(item) pbUseKeyItemInField(item)
@@ -209,12 +209,12 @@ MenuHandlers.add(:pause_menu, :pokegear, {
"condition" => proc { next $player.has_pokegear }, "condition" => proc { next $player.has_pokegear },
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokegear_Scene.new scene = PokemonPokegear_Scene.new
screen = PokemonPokegearScreen.new(scene) screen = PokemonPokegearScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh ($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh
} end
next pbFlyToNewLocation next pbFlyToNewLocation
} }
}) })
@@ -225,13 +225,13 @@ MenuHandlers.add(:pause_menu, :town_map, {
"condition" => proc { next !$player.has_pokegear && $bag.has?(:TOWNMAP) }, "condition" => proc { next !$player.has_pokegear && $bag.has?(:TOWNMAP) },
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false) scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene) screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen ret = screen.pbStartScreen
$game_temp.fly_destination = ret if ret $game_temp.fly_destination = ret if ret
($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh ($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh
} end
next pbFlyToNewLocation next pbFlyToNewLocation
} }
}) })
@@ -241,12 +241,12 @@ MenuHandlers.add(:pause_menu, :trainer_card, {
"order" => 50, "order" => 50,
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn do
scene = PokemonTrainerCard_Scene.new scene = PokemonTrainerCard_Scene.new
screen = PokemonTrainerCardScreen.new(scene) screen = PokemonTrainerCardScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
menu.pbRefresh menu.pbRefresh
} end
next false next false
} }
}) })
@@ -276,13 +276,13 @@ MenuHandlers.add(:pause_menu, :options, {
"order" => 70, "order" => 70,
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn do
scene = PokemonOption_Scene.new scene = PokemonOption_Scene.new
screen = PokemonOptionScreen.new(scene) screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
pbUpdateSceneMap pbUpdateSceneMap
menu.pbRefresh menu.pbRefresh
} end
next false next false
} }
}) })
@@ -293,10 +293,10 @@ MenuHandlers.add(:pause_menu, :debug, {
"condition" => proc { next $DEBUG }, "condition" => proc { next $DEBUG },
"effect" => proc { |menu| "effect" => proc { |menu|
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn do
pbDebugMenu pbDebugMenu
menu.pbRefresh menu.pbRefresh
} end
next false next false
} }
}) })
+2 -2
View File
@@ -114,11 +114,11 @@ class PokemonPokedexMenuScreen
cmd = @scene.pbScene cmd = @scene.pbScene
break if cmd < 0 || cmd >= commands2.length # Cancel/Exit break if cmd < 0 || cmd >= commands2.length # Cancel/Exit
$PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[cmd] $PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[cmd]
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedex_Scene.new scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene) screen = PokemonPokedexScreen.new(scene)
screen.pbStartScreen screen.pbStartScreen
} end
end end
@scene.pbEndScene @scene.pbEndScene
end end
+26 -33
View File
@@ -272,15 +272,13 @@ class PokemonPokedex_Scene
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999 @viewport.z = 99999
addBackgroundPlane(@sprites, "background", "Pokedex/bg_list", @viewport) addBackgroundPlane(@sprites, "background", "Pokedex/bg_list", @viewport)
=begin # Suggestion for changing the background depending on region. You can
# Suggestion for changing the background depending on region. You can change # comment out the line above and uncomment the following lines:
# the line above with the following: # if pbGetPokedexRegion == -1 # Using national Pokédex
if pbGetPokedexRegion==-1 # Using national Pokédex # addBackgroundPlane(@sprites, "background", "Pokedex/bg_national", @viewport)
addBackgroundPlane(@sprites,"background","Pokedex/bg_national",@viewport) # elsif pbGetPokedexRegion == 0 # Using first regional Pokédex
elsif pbGetPokedexRegion==0 # Using first regional Pokédex # addBackgroundPlane(@sprites, "background", "Pokedex/bg_regional", @viewport)
addBackgroundPlane(@sprites,"background","Pokedex/bg_regional",@viewport) # end
end
=end
addBackgroundPlane(@sprites, "searchbg", "Pokedex/bg_search", @viewport) addBackgroundPlane(@sprites, "searchbg", "Pokedex/bg_search", @viewport)
@sprites["searchbg"].visible = false @sprites["searchbg"].visible = false
@sprites["pokedex"] = Window_Pokedex.new(206, 30, 276, 364, @viewport) @sprites["pokedex"] = Window_Pokedex.new(206, 30, 276, 364, @viewport)
@@ -766,9 +764,8 @@ class PokemonPokedex_Scene
end end
def setIconBitmap(species) def setIconBitmap(species)
gender, form, shiny = $player.pokedex.last_form_seen(species) gender, form, _shiny = $player.pokedex.last_form_seen(species)
shiny = false @sprites["icon"].setSpeciesBitmap(species, gender, form, false)
@sprites["icon"].setSpeciesBitmap(species, gender, form, shiny)
end end
def pbSearchDexList(params) def pbSearchDexList(params)
@@ -777,17 +774,17 @@ class PokemonPokedex_Scene
# Filter by name # Filter by name
if params[1] >= 0 if params[1] >= 0
scanNameCommand = @nameCommands[params[1]].scan(/./) scanNameCommand = @nameCommands[params[1]].scan(/./)
dexlist = dexlist.find_all { |item| dexlist = dexlist.find_all do |item|
next false if !$player.seen?(item[:species]) next false if !$player.seen?(item[:species])
firstChar = item[:name][0, 1] firstChar = item[:name][0, 1]
next scanNameCommand.any? { |v| v == firstChar } next scanNameCommand.any? { |v| v == firstChar }
} end
end end
# Filter by type # Filter by type
if params[2] >= 0 || params[3] >= 0 if params[2] >= 0 || params[3] >= 0
stype1 = (params[2] >= 0) ? @typeCommands[params[2]].id : nil stype1 = (params[2] >= 0) ? @typeCommands[params[2]].id : nil
stype2 = (params[3] >= 0) ? @typeCommands[params[3]].id : nil stype2 = (params[3] >= 0) ? @typeCommands[params[3]].id : nil
dexlist = dexlist.find_all { |item| dexlist = dexlist.find_all do |item|
next false if !$player.owned?(item[:species]) next false if !$player.owned?(item[:species])
types = item[:types] types = item[:types]
if stype1 && stype2 if stype1 && stype2
@@ -802,43 +799,41 @@ class PokemonPokedex_Scene
else else
next false next false
end end
} end
end end
# Filter by height range # Filter by height range
if params[4] >= 0 || params[5] >= 0 if params[4] >= 0 || params[5] >= 0
minh = (params[4] < 0) ? 0 : (params[4] >= @heightCommands.length) ? 999 : @heightCommands[params[4]] minh = (params[4] < 0) ? 0 : (params[4] >= @heightCommands.length) ? 999 : @heightCommands[params[4]]
maxh = (params[5] < 0) ? 999 : (params[5] >= @heightCommands.length) ? 0 : @heightCommands[params[5]] maxh = (params[5] < 0) ? 999 : (params[5] >= @heightCommands.length) ? 0 : @heightCommands[params[5]]
dexlist = dexlist.find_all { |item| dexlist = dexlist.find_all do |item|
next false if !$player.owned?(item[:species]) next false if !$player.owned?(item[:species])
height = item[:height] height = item[:height]
next height >= minh && height <= maxh next height >= minh && height <= maxh
} end
end end
# Filter by weight range # Filter by weight range
if params[6] >= 0 || params[7] >= 0 if params[6] >= 0 || params[7] >= 0
minw = (params[6] < 0) ? 0 : (params[6] >= @weightCommands.length) ? 9999 : @weightCommands[params[6]] minw = (params[6] < 0) ? 0 : (params[6] >= @weightCommands.length) ? 9999 : @weightCommands[params[6]]
maxw = (params[7] < 0) ? 9999 : (params[7] >= @weightCommands.length) ? 0 : @weightCommands[params[7]] maxw = (params[7] < 0) ? 9999 : (params[7] >= @weightCommands.length) ? 0 : @weightCommands[params[7]]
dexlist = dexlist.find_all { |item| dexlist = dexlist.find_all do |item|
next false if !$player.owned?(item[:species]) next false if !$player.owned?(item[:species])
weight = item[:weight] weight = item[:weight]
next weight >= minw && weight <= maxw next weight >= minw && weight <= maxw
} end
end end
# Filter by color # Filter by color
if params[8] >= 0 if params[8] >= 0
scolor = @colorCommands[params[8]].id scolor = @colorCommands[params[8]].id
dexlist = dexlist.find_all { |item| dexlist = dexlist.find_all do |item|
next false if !$player.seen?(item[:species]) next $player.seen?(item[:species]) && item[:color] == scolor
next item[:color] == scolor end
}
end end
# Filter by shape # Filter by shape
if params[9] >= 0 if params[9] >= 0
sshape = @shapeCommands[params[9]].id sshape = @shapeCommands[params[9]].id
dexlist = dexlist.find_all { |item| dexlist = dexlist.find_all do |item|
next false if !$player.seen?(item[:species]) next $player.seen?(item[:species]) && item[:shape] == sshape
next item[:shape] == sshape end
}
end end
# Remove all unseen species from the results # Remove all unseen species from the results
dexlist = dexlist.find_all { |item| next $player.seen?(item[:species]) } dexlist = dexlist.find_all { |item| next $player.seen?(item[:species]) }
@@ -924,9 +919,7 @@ class PokemonPokedex_Scene
oldindex = index oldindex = index
minmax = 1 minmax = 1
oldminmax = minmax oldminmax = minmax
if [3, 4].include?(mode) index = oldindex = selindex[minmax] if [3, 4].include?(mode)
index = oldindex = selindex[minmax]
end
@sprites["searchcursor"].mode = mode @sprites["searchcursor"].mode = mode
@sprites["searchcursor"].cmds = cmds.length @sprites["searchcursor"].cmds = cmds.length
@sprites["searchcursor"].minmax = minmax @sprites["searchcursor"].minmax = minmax
@@ -1260,7 +1253,7 @@ class PokemonPokedex_Scene
end end
def pbPokedex def pbPokedex
pbActivateWindow(@sprites, "pokedex") { pbActivateWindow(@sprites, "pokedex") do
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
@@ -1290,7 +1283,7 @@ class PokemonPokedex_Scene
end end
end end
end end
} end
end end
end end
+5 -9
View File
@@ -161,9 +161,9 @@ class PokemonPokedexInfo_Scene
real_gender = 2 if sp.gender_ratio == :Genderless real_gender = 2 if sp.gender_ratio == :Genderless
ret.push([sp.form_name, real_gender, sp.form]) ret.push([sp.form_name, real_gender, sp.form])
else # Both male and female else # Both male and female
2.times do |real_gender| 2.times do |real_gndr|
next if !$player.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS next if !$player.pokedex.seen_form?(@species, real_gndr, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
ret.push([sp.form_name, real_gender, sp.form]) ret.push([sp.form_name, real_gndr, sp.form])
break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form
end end
end end
@@ -210,9 +210,7 @@ class PokemonPokedexInfo_Scene
base = Color.new(88, 88, 80) base = Color.new(88, 88, 80)
shadow = Color.new(168, 184, 184) shadow = Color.new(168, 184, 184)
imagepos = [] imagepos = []
if @brief imagepos.push([_INTL("Graphics/UI/Pokedex/overlay_info"), 0, 0]) if @brief
imagepos.push([_INTL("Graphics/UI/Pokedex/overlay_info"), 0, 0])
end
species_data = GameData::Species.get_species_form(@species, @form) species_data = GameData::Species.get_species_form(@species, @form)
# Write various bits of text # Write various bits of text
indexText = "???" indexText = "???"
@@ -536,9 +534,7 @@ class PokemonPokedexInfo_Scene
dorefresh = true dorefresh = true
end end
end end
if dorefresh drawPage(@page) if dorefresh
drawPage(@page)
end
end end
return @index return @index
end end
+26 -26
View File
@@ -559,7 +559,7 @@ class PokemonParty_Scene
@sprites["messagebox"].text = text @sprites["messagebox"].text = text
@sprites["messagebox"].visible = true @sprites["messagebox"].visible = true
@sprites["helpwindow"].visible = false @sprites["helpwindow"].visible = false
using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) do
cmdwindow.visible = false cmdwindow.visible = false
pbBottomRight(cmdwindow) pbBottomRight(cmdwindow)
cmdwindow.y -= @sprites["messagebox"].height cmdwindow.y -= @sprites["messagebox"].height
@@ -580,7 +580,7 @@ class PokemonParty_Scene
end end
end end
end end
} end
@sprites["messagebox"].visible = false @sprites["messagebox"].visible = false
@sprites["helpwindow"].visible = true @sprites["helpwindow"].visible = true
return ret return ret
@@ -590,7 +590,7 @@ class PokemonParty_Scene
ret = -1 ret = -1
helpwindow = @sprites["helpwindow"] helpwindow = @sprites["helpwindow"]
helpwindow.visible = true helpwindow.visible = true
using(cmdwindow = Window_CommandPokemonColor.new(commands)) { using(cmdwindow = Window_CommandPokemonColor.new(commands)) do
cmdwindow.z = @viewport.z + 1 cmdwindow.z = @viewport.z + 1
cmdwindow.index = index cmdwindow.index = index
pbBottomRight(cmdwindow) pbBottomRight(cmdwindow)
@@ -612,7 +612,7 @@ class PokemonParty_Scene
break break
end end
end end
} end
return ret return ret
end end
@@ -705,18 +705,18 @@ class PokemonParty_Scene
def pbChooseItem(bag) def pbChooseItem(bag)
ret = nil ret = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, bag) screen = PokemonBagScreen.new(scene, bag)
ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? }) ret = screen.pbChooseItemScreen(proc { |item| GameData::Item.get(item).can_hold? })
yield if block_given? yield if block_given?
} end
return ret return ret
end end
def pbUseItem(bag, pokemon) def pbUseItem(bag, pokemon)
ret = nil ret = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, bag) screen = PokemonBagScreen.new(scene, bag)
ret = screen.pbChooseItemScreen(proc { |item| ret = screen.pbChooseItemScreen(proc { |item|
@@ -730,7 +730,7 @@ class PokemonParty_Scene
next true next true
}) })
yield if block_given? yield if block_given?
} end
return ret return ret
end end
@@ -764,12 +764,12 @@ class PokemonParty_Scene
cancelsprite = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 1 : 0) cancelsprite = Settings::MAX_PARTY_SIZE + ((@multiselect) ? 1 : 0)
if Input.trigger?(Input::SPECIAL) && @can_access_storage && canswitch != 2 if Input.trigger?(Input::SPECIAL) && @can_access_storage && canswitch != 2
pbPlayDecisionSE pbPlayDecisionSE
pbFadeOutIn { pbFadeOutIn do
scene = PokemonStorageScene.new scene = PokemonStorageScene.new
screen = PokemonStorageScreen.new(scene, $PokemonStorage) screen = PokemonStorageScreen.new(scene, $PokemonStorage)
screen.pbStartScreen(0) screen.pbStartScreen(0)
pbHardRefresh pbHardRefresh
} end
elsif Input.trigger?(Input::ACTION) && canswitch == 1 && @activecmd != cancelsprite elsif Input.trigger?(Input::ACTION) && canswitch == 1 && @activecmd != cancelsprite
pbPlayDecisionSE pbPlayDecisionSE
return [1, @activecmd] return [1, @activecmd]
@@ -1121,9 +1121,9 @@ class PokemonPartyScreen
statuses[pkmnid] = 1 statuses[pkmnid] = 1
pbRefreshSingle(pkmnid) pbRefreshSingle(pkmnid)
elsif cmdSummary >= 0 && command == cmdSummary elsif cmdSummary >= 0 && command == cmdSummary
@scene.pbSummary(pkmnid) { @scene.pbSummary(pkmnid) do
@scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) @scene.pbSetHelpText((@party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
} end
end end
end end
@scene.pbEndScene @scene.pbEndScene
@@ -1314,9 +1314,9 @@ MenuHandlers.add(:party_menu, :summary, {
"name" => _INTL("Summary"), "name" => _INTL("Summary"),
"order" => 10, "order" => 10,
"effect" => proc { |screen, party, party_idx| "effect" => proc { |screen, party, party_idx|
screen.scene.pbSummary(party_idx) { screen.scene.pbSummary(party_idx) do
screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
} end
} }
}) })
@@ -1351,10 +1351,10 @@ MenuHandlers.add(:party_menu, :mail, {
[_INTL("Read"), _INTL("Take"), _INTL("Cancel")]) [_INTL("Read"), _INTL("Take"), _INTL("Cancel")])
case command case command
when 0 # Read when 0 # Read
pbFadeOutIn { pbFadeOutIn do
pbDisplayMail(pkmn.mail, pkmn) pbDisplayMail(pkmn.mail, pkmn)
screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
} end
when 1 # Take when 1 # Take
if pbTakeItemFromPokemon(pkmn, screen) if pbTakeItemFromPokemon(pkmn, screen)
screen.pbRefreshSingle(party_idx) screen.pbRefreshSingle(party_idx)
@@ -1388,9 +1388,9 @@ MenuHandlers.add(:party_menu_item, :use, {
"order" => 10, "order" => 10,
"effect" => proc { |screen, party, party_idx| "effect" => proc { |screen, party, party_idx|
pkmn = party[party_idx] pkmn = party[party_idx]
item = screen.scene.pbUseItem($bag, pkmn) { item = screen.scene.pbUseItem($bag, pkmn) do
screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
} end
next if !item next if !item
pbUseItemOnPokemon(item, pkmn, screen) pbUseItemOnPokemon(item, pkmn, screen)
screen.pbRefreshSingle(party_idx) screen.pbRefreshSingle(party_idx)
@@ -1402,9 +1402,9 @@ MenuHandlers.add(:party_menu_item, :give, {
"order" => 20, "order" => 20,
"effect" => proc { |screen, party, party_idx| "effect" => proc { |screen, party, party_idx|
pkmn = party[party_idx] pkmn = party[party_idx]
item = screen.scene.pbChooseItem($bag) { item = screen.scene.pbChooseItem($bag) do
screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel.")) screen.scene.pbSetHelpText((party.length > 1) ? _INTL("Choose a Pokémon.") : _INTL("Choose Pokémon or cancel."))
} end
next if !item || !pbGiveItemToPokemon(item, pkmn, screen, party_idx) next if !item || !pbGiveItemToPokemon(item, pkmn, screen, party_idx)
screen.pbRefreshSingle(party_idx) screen.pbRefreshSingle(party_idx)
} }
@@ -1480,11 +1480,11 @@ MenuHandlers.add(:party_menu_item, :move, {
# Open the party screen # Open the party screen
#=============================================================================== #===============================================================================
def pbPokemonScreen def pbPokemonScreen
pbFadeOutIn { pbFadeOutIn do
sscene = PokemonParty_Scene.new sscene = PokemonParty_Scene.new
sscreen = PokemonPartyScreen.new(sscene, $player.party) sscreen = PokemonPartyScreen.new(sscene, $player.party)
sscreen.pbPokemonScreen sscreen.pbPokemonScreen
} end
end end
#=============================================================================== #===============================================================================
@@ -1495,7 +1495,7 @@ end
# variable _nameVarNumber_; result is -1 if no Pokémon was chosen # variable _nameVarNumber_; result is -1 if no Pokémon was chosen
def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false) def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false)
chosen = 0 chosen = 0
pbFadeOutIn { pbFadeOutIn do
scene = PokemonParty_Scene.new scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene, $player.party) screen = PokemonPartyScreen.new(scene, $player.party)
if ableProc if ableProc
@@ -1505,7 +1505,7 @@ def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligib
chosen = screen.pbChoosePokemon chosen = screen.pbChoosePokemon
screen.pbEndScene screen.pbEndScene
end end
} end
pbSet(variableNumber, chosen) pbSet(variableNumber, chosen)
if chosen >= 0 if chosen >= 0
pbSet(nameVarNumber, $player.party[chosen].name) pbSet(nameVarNumber, $player.party[chosen].name)
@@ -1525,7 +1525,7 @@ end
# Same as pbChoosePokemon, but prevents choosing an egg or a Shadow Pokémon. # Same as pbChoosePokemon, but prevents choosing an egg or a Shadow Pokémon.
def pbChooseTradablePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false) def pbChooseTradablePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false)
chosen = 0 chosen = 0
pbFadeOutIn { pbFadeOutIn do
scene = PokemonParty_Scene.new scene = PokemonParty_Scene.new
screen = PokemonPartyScreen.new(scene, $player.party) screen = PokemonPartyScreen.new(scene, $player.party)
if ableProc if ableProc
@@ -1535,7 +1535,7 @@ def pbChooseTradablePokemon(variableNumber, nameVarNumber, ableProc = nil, allow
chosen = screen.pbChoosePokemon chosen = screen.pbChoosePokemon
screen.pbEndScene screen.pbEndScene
end end
} end
pbSet(variableNumber, chosen) pbSet(variableNumber, chosen)
if chosen >= 0 if chosen >= 0
pbSet(nameVarNumber, $player.party[chosen].name) pbSet(nameVarNumber, $player.party[chosen].name)
+12 -18
View File
@@ -233,7 +233,7 @@ class PokemonSummary_Scene
ret = -1 ret = -1
@sprites["messagebox"].text = text @sprites["messagebox"].text = text
@sprites["messagebox"].visible = true @sprites["messagebox"].visible = true
using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) { using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) do
cmdwindow.z = @viewport.z + 1 cmdwindow.z = @viewport.z + 1
cmdwindow.visible = false cmdwindow.visible = false
pbBottomRight(cmdwindow) pbBottomRight(cmdwindow)
@@ -254,14 +254,14 @@ class PokemonSummary_Scene
end end
end end
end end
} end
@sprites["messagebox"].visible = false @sprites["messagebox"].visible = false
return ret return ret
end end
def pbShowCommands(commands, index = 0) def pbShowCommands(commands, index = 0)
ret = -1 ret = -1
using(cmdwindow = Window_CommandPokemon.new(commands)) { using(cmdwindow = Window_CommandPokemon.new(commands)) do
cmdwindow.z = @viewport.z + 1 cmdwindow.z = @viewport.z + 1
cmdwindow.index = index cmdwindow.index = index
pbBottomRight(cmdwindow) pbBottomRight(cmdwindow)
@@ -280,7 +280,7 @@ class PokemonSummary_Scene
break break
end end
end end
} end
return ret return ret
end end
@@ -328,9 +328,7 @@ class PokemonSummary_Scene
imagepos.push([sprintf("Graphics/UI/Summary/icon_pokerus"), 176, 100]) imagepos.push([sprintf("Graphics/UI/Summary/icon_pokerus"), 176, 100])
end end
# Show shininess star # Show shininess star
if @pokemon.shiny? imagepos.push([sprintf("Graphics/UI/shiny"), 2, 134]) if @pokemon.shiny?
imagepos.push([sprintf("Graphics/UI/shiny"), 2, 134])
end
# Draw all images # Draw all images
pbDrawImagePositions(overlay, imagepos) pbDrawImagePositions(overlay, imagepos)
# Write various bits of text # Write various bits of text
@@ -1193,23 +1191,21 @@ class PokemonSummary_Scene
command = pbShowCommands(commands) command = pbShowCommands(commands)
if cmdGiveItem >= 0 && command == cmdGiveItem if cmdGiveItem >= 0 && command == cmdGiveItem
item = nil item = nil
pbFadeOutIn { pbFadeOutIn do
scene = PokemonBag_Scene.new scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag) screen = PokemonBagScreen.new(scene, $bag)
item = screen.pbChooseItemScreen(proc { |itm| GameData::Item.get(itm).can_hold? }) item = screen.pbChooseItemScreen(proc { |itm| GameData::Item.get(itm).can_hold? })
}
if item
dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex)
end end
dorefresh = pbGiveItemToPokemon(item, @pokemon, self, @partyindex) if item
elsif cmdTakeItem >= 0 && command == cmdTakeItem elsif cmdTakeItem >= 0 && command == cmdTakeItem
dorefresh = pbTakeItemFromPokemon(@pokemon, self) dorefresh = pbTakeItemFromPokemon(@pokemon, self)
elsif cmdPokedex >= 0 && command == cmdPokedex elsif cmdPokedex >= 0 && command == cmdPokedex
$player.pokedex.register_last_seen(@pokemon) $player.pokedex.register_last_seen(@pokemon)
pbFadeOutIn { pbFadeOutIn do
scene = PokemonPokedexInfo_Scene.new scene = PokemonPokedexInfo_Scene.new
screen = PokemonPokedexInfoScreen.new(scene) screen = PokemonPokedexInfoScreen.new(scene)
screen.pbStartSceneSingle(@pokemon.species) screen.pbStartSceneSingle(@pokemon.species)
} end
dorefresh = true dorefresh = true
elsif cmdMark >= 0 && command == cmdMark elsif cmdMark >= 0 && command == cmdMark
dorefresh = pbMarking(@pokemon) dorefresh = pbMarking(@pokemon)
@@ -1318,9 +1314,7 @@ class PokemonSummary_Scene
dorefresh = true dorefresh = true
end end
end end
if dorefresh drawPage(@page) if dorefresh
drawPage(@page)
end
end end
return @partyindex return @partyindex
end end
@@ -1375,11 +1369,11 @@ end
def pbChooseMove(pokemon, variableNumber, nameVarNumber) def pbChooseMove(pokemon, variableNumber, nameVarNumber)
return if !pokemon return if !pokemon
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([pokemon], 0, nil) ret = screen.pbStartForgetScreen([pokemon], 0, nil)
} end
$game_variables[variableNumber] = ret $game_variables[variableNumber] = ret
if ret >= 0 if ret >= 0
$game_variables[nameVarNumber] = pokemon.moves[ret].name $game_variables[nameVarNumber] = pokemon.moves[ret].name

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