More or less standardised separator comments in the code

This commit is contained in:
Maruno17
2024-06-27 21:21:26 +01:00
parent 225549bfce
commit 509a414f37
198 changed files with 1907 additions and 1263 deletions

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module PBDebug module PBDebug
@@log = [] @@log = []

View File

@@ -1,6 +1,8 @@
#===============================================================================
# To use the console, use the executable explicitly built with the console # To use the console, use the executable explicitly built with the console
# enabled on Windows. On Linux and macOS, just launch the executable directly # enabled on Windows. On Linux and macOS, just launch the executable directly
# from a terminal. # from a terminal.
#===============================================================================
module Console module Console
def self.setup_console def self.setup_console
return unless $DEBUG return unless $DEBUG
@@ -33,6 +35,9 @@ module Console
end end
end end
#===============================================================================
#
#===============================================================================
module Kernel module Kernel
def echo(string) def echo(string)
return unless $DEBUG return unless $DEBUG
@@ -48,14 +53,15 @@ end
Console.setup_console Console.setup_console
#=============================================================================== #===============================================================================
# Console message formatting # Console message formatting
#=============================================================================== #===============================================================================
module Console module Console
module_function module_function
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# echo string into console (example shorthand for common options) # echo string into console (example shorthand for common options)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# heading 1 # heading 1
def echo_h1(msg) def echo_h1(msg)
echoln markup_style("*** #{msg} ***", text: :brown) echoln markup_style("*** #{msg} ***", text: :brown)
@@ -130,6 +136,7 @@ module Console
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Markup options # Markup options
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def string_colors def string_colors
{ {
default: "38", black: "30", red: "31", green: "32", brown: "33", default: "38", black: "30", red: "31", green: "32", brown: "33",

View File

@@ -4,6 +4,9 @@
class Reset < Exception class Reset < Exception
end end
#===============================================================================
#
#===============================================================================
class EventScriptError < Exception class EventScriptError < Exception
attr_accessor :event_message attr_accessor :event_message
@@ -13,6 +16,9 @@ class EventScriptError < Exception
end end
end end
#===============================================================================
#
#===============================================================================
def pbGetExceptionMessage(e, _script = "") def pbGetExceptionMessage(e, _script = "")
return e.event_message.dup if e.is_a?(EventScriptError) # Message with map/event ID generated elsewhere return e.event_message.dup if e.is_a?(EventScriptError) # Message with map/event ID generated elsewhere
emessage = e.message.dup emessage = e.message.dup

View File

@@ -1,4 +1,6 @@
#===============================================================================
# The Kernel module is extended to include the validate method. # The Kernel module is extended to include the validate method.
#===============================================================================
module Kernel module Kernel
private private

View File

@@ -1,5 +1,7 @@
#===============================================================================
# The Deprecation module is used to warn game & plugin creators of deprecated # The Deprecation module is used to warn game & plugin creators of deprecated
# methods. # methods.
#===============================================================================
module Deprecation module Deprecation
module_function module_function
@@ -19,7 +21,10 @@ module Deprecation
end end
end end
# The Module class is extended to allow easy deprecation of instance and class methods. #===============================================================================
# The Module class is extended to allow easy deprecation of instance and class
# methods.
#===============================================================================
class Module class Module
private private

View File

@@ -1,5 +1,7 @@
#===============================================================================
# Using mkxp-z v2.4.2/c9378cf - built 2023-07-07 # Using mkxp-z v2.4.2/c9378cf - built 2023-07-07
# https://github.com/mkxp-z/mkxp-z/actions/runs/5482601942 # https://github.com/mkxp-z/mkxp-z/actions/runs/5482601942
#===============================================================================
$VERBOSE = nil $VERBOSE = nil
Font.default_shadow = false if Font.respond_to?(:default_shadow) Font.default_shadow = false if Font.respond_to?(:default_shadow)
Encoding.default_internal = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8
@@ -9,6 +11,23 @@ def pbSetWindowText(string)
System.set_window_title(string || System.game_title) System.set_window_title(string || System.game_title)
end end
def pbSetResizeFactor(factor)
if !$ResizeInitialized
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
$ResizeInitialized = true
end
if factor < 0 || factor == 4
Graphics.fullscreen = true if !Graphics.fullscreen
else
Graphics.fullscreen = false if Graphics.fullscreen
Graphics.scale = (factor + 1) * 0.5
Graphics.center
end
end
#===============================================================================
#
#===============================================================================
class Bitmap class Bitmap
attr_accessor :text_offset_y attr_accessor :text_offset_y
@@ -27,20 +46,9 @@ class Bitmap
end end
end end
def pbSetResizeFactor(factor) #===============================================================================
if !$ResizeInitialized #
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT) #===============================================================================
$ResizeInitialized = true
end
if factor < 0 || factor == 4
Graphics.fullscreen = true if !Graphics.fullscreen
else
Graphics.fullscreen = false if Graphics.fullscreen
Graphics.scale = (factor + 1) * 0.5
Graphics.center
end
end
if System::VERSION != Essentials::MKXPZ_VERSION if System::VERSION != Essentials::MKXPZ_VERSION
printf(sprintf("\e[1;33mWARNING: mkxp-z version %s detected, but this version of Pokémon Essentials was designed for mkxp-z version %s.\e[0m\r\n", printf(sprintf("\e[1;33mWARNING: mkxp-z version %s detected, but this version of Pokémon Essentials was designed for mkxp-z version %s.\e[0m\r\n",
System::VERSION, Essentials::MKXPZ_VERSION)) System::VERSION, Essentials::MKXPZ_VERSION))

View File

@@ -1,5 +1,5 @@
#=============================================================================== #===============================================================================
# Reads files of certain format from a directory # Reads files of certain format from a directory
#=============================================================================== #===============================================================================
class Dir class Dir
# Reads all files in a directory # Reads all files in a directory

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module FileInputMixin module FileInputMixin
def fgetb def fgetb
ret = 0 ret = 0
@@ -85,6 +88,9 @@ module FileInputMixin
end end
end end
#===============================================================================
#
#===============================================================================
module FileOutputMixin module FileOutputMixin
def fputb(b) def fputb(b)
b &= 0xFF b &= 0xFF
@@ -108,6 +114,9 @@ module FileOutputMixin
end end
end end
#===============================================================================
#
#===============================================================================
class File < IO class File < IO
# unless defined?(debugopen) # unless defined?(debugopen)
# class << self # class << self
@@ -128,6 +137,9 @@ class File < IO
include FileOutputMixin include FileOutputMixin
end end
#===============================================================================
#
#===============================================================================
class StringInput class StringInput
include FileInputMixin include FileInputMixin
@@ -144,6 +156,9 @@ class StringInput
def binmode; end def binmode; end
end end
#===============================================================================
#
#===============================================================================
class StringOutput class StringOutput
include FileOutputMixin include FileOutputMixin
end end

View File

@@ -211,6 +211,8 @@ module Translator
end end
end end
#-----------------------------------------------------------------------------
def normalize_value(value) def normalize_value(value)
if value[/[\r\n\t\x01]|^[\[\]]/] if value[/[\r\n\t\x01]|^[\[\]]/]
ret = value.dup ret = value.dup
@@ -709,51 +711,53 @@ module MessageTypes
POKEMON_NICKNAMES = 30 POKEMON_NICKNAMES = 30
@@messages = Translation.new @@messages = Translation.new
def self.load_default_messages module_function
def load_default_messages
@@messages.load_default_messages @@messages.load_default_messages
end end
def self.load_message_files(filename) def load_message_files(filename)
@@messages.load_message_files(filename) @@messages.load_message_files(filename)
end end
def self.save_default_messages def save_default_messages
@@messages.save_default_messages @@messages.save_default_messages
end end
def self.setMessages(type, array) def setMessages(type, array)
@@messages.setMessages(type, array) @@messages.setMessages(type, array)
end end
def self.addMessages(type, array) def addMessages(type, array)
@@messages.addMessages(type, array) @@messages.addMessages(type, array)
end end
def self.setMessagesAsHash(type, array) def setMessagesAsHash(type, array)
@@messages.setMessagesAsHash(type, array) @@messages.setMessagesAsHash(type, array)
end end
def self.addMessagesAsHash(type, array) def addMessagesAsHash(type, array)
@@messages.addMessagesAsHash(type, array) @@messages.addMessagesAsHash(type, array)
end end
def self.setMapMessagesAsHash(type, array) def setMapMessagesAsHash(type, array)
@@messages.setMapMessagesAsHash(type, array) @@messages.setMapMessagesAsHash(type, array)
end end
def self.addMapMessagesAsHash(type, array) def addMapMessagesAsHash(type, array)
@@messages.addMapMessagesAsHash(type, array) @@messages.addMapMessagesAsHash(type, array)
end end
def self.get(type, id) def get(type, id)
return @@messages.get(type, id) return @@messages.get(type, id)
end end
def self.getFromHash(type, key) def getFromHash(type, key)
return @@messages.getFromHash(type, key) return @@messages.getFromHash(type, key)
end end
def self.getFromMapHash(type, key) def getFromMapHash(type, key)
return @@messages.getFromMapHash(type, key) return @@messages.getFromMapHash(type, key)
end end
end end

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module Input module Input
USE = C USE = C
BACK = B BACK = B
@@ -20,11 +23,12 @@ module Input
end end
end end
#===============================================================================
#
#===============================================================================
module Mouse module Mouse
module_function
# Returns the position of the mouse relative to the game window. # Returns the position of the mouse relative to the game window.
def getMousePos(catch_anywhere = false) def self.getMousePos(catch_anywhere = false)
return nil unless Input.mouse_in_window || catch_anywhere return nil unless Input.mouse_in_window || catch_anywhere
return Input.mouse_x, Input.mouse_y return Input.mouse_x, Input.mouse_y
end end

View File

@@ -102,7 +102,6 @@
#------------------------------------------------------------------------------# #------------------------------------------------------------------------------#
# Please give credit when using this. # # Please give credit when using this. #
#==============================================================================# #==============================================================================#
module PluginManager module PluginManager
# Holds all registered plugin data. # Holds all registered plugin data.
@@Plugins = {} @@Plugins = {}

View File

@@ -1,8 +1,10 @@
#===============================================================================
# The SaveData module is used to manipulate save data. It contains the {Value}s # The SaveData module is used to manipulate save data. It contains the {Value}s
# that make up the save data and {Conversion}s for resolving incompatibilities # that make up the save data and {Conversion}s for resolving incompatibilities
# between Essentials and game versions. # between Essentials and game versions.
# @see SaveData.register # @see SaveData.register
# @see SaveData.register_conversion # @see SaveData.register_conversion
#===============================================================================
module SaveData module SaveData
# Contains the file path of the save file. # Contains the file path of the save file.
FILE_PATH = if File.directory?(System.data_directory) FILE_PATH = if File.directory?(System.data_directory)

View File

@@ -1,15 +1,21 @@
#===============================================================================
#
#===============================================================================
module SaveData module SaveData
# Contains Value objects for each save element. # Contains Value objects for each save element.
# Populated during runtime by SaveData.register calls. # Populated during runtime by SaveData.register calls.
# @type [Array<Value>] # @type [Array<Value>]
@values = [] @values = []
#=============================================================================
# An error raised if an invalid save value is being saved or loaded. # An error raised if an invalid save value is being saved or loaded.
#=============================================================================
class InvalidValueError < RuntimeError; end class InvalidValueError < RuntimeError; end
#============================================================================= #=============================================================================
# Represents a single value in save data. # Represents a single value in save data.
# New values are added using {SaveData.register}. # New values are added using {SaveData.register}.
#=============================================================================
class Value class Value
# @return [Symbol] the value id # @return [Symbol] the value id
attr_reader :id attr_reader :id
@@ -160,7 +166,8 @@ module SaveData
# @!endgroup # @!endgroup
end end
#============================================================================= #---------------------------------------------------------------------------
# Registers a {Value} to be saved into save data. # Registers a {Value} to be saved into save data.
# Takes a block which defines the value's saving ({Value#save_value}) # Takes a block which defines the value's saving ({Value#save_value})
# and loading ({Value#load_value}) procedures. # and loading ({Value#load_value}) procedures.

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module SaveData module SaveData
# Contains Conversion objects for each defined conversion: # Contains Conversion objects for each defined conversion:
# { # {
@@ -21,6 +24,7 @@ module SaveData
#============================================================================= #=============================================================================
# Represents a conversion made to save data. # Represents a conversion made to save data.
# New conversions are added using {SaveData.register_conversion}. # New conversions are added using {SaveData.register_conversion}.
#=============================================================================
class Conversion class Conversion
# @return [Symbol] conversion ID # @return [Symbol] conversion ID
attr_reader :id attr_reader :id
@@ -134,7 +138,8 @@ module SaveData
# @!endgroup # @!endgroup
end end
#============================================================================= #---------------------------------------------------------------------------
# Registers a {Conversion} to occur for save data that meets the given criteria. # Registers a {Conversion} to occur for save data that meets the given criteria.
# Two types of criteria can be defined: {Conversion#essentials_version} and # Two types of criteria can be defined: {Conversion#essentials_version} and
# {Conversion#game_version}. The conversion is automatically run on save data # {Conversion#game_version}. The conversion is automatically run on save data

View File

@@ -1,4 +1,6 @@
#===============================================================================
# Contains the save values defined in Essentials by default. # Contains the save values defined in Essentials by default.
#===============================================================================
SaveData.register(:player) do SaveData.register(:player) do
ensure_class :Player ensure_class :Player

View File

@@ -1,7 +1,11 @@
#===============================================================================
# The Game module contains methods for saving and loading the game. # The Game module contains methods for saving and loading the game.
#===============================================================================
module Game module Game
module_function
# Initializes various global variables and loads the game data. # Initializes various global variables and loads the game data.
def self.initialize def initialize
$game_temp = Game_Temp.new $game_temp = Game_Temp.new
$game_system = Game_System.new $game_system = Game_System.new
$data_animations = load_data("Data/Animations.rxdata") $data_animations = load_data("Data/Animations.rxdata")
@@ -18,7 +22,7 @@ module Game
# Loads bootup data from save file (if it exists) or creates bootup data (if # Loads bootup data from save file (if it exists) or creates bootup data (if
# it doesn't). # it doesn't).
def self.set_up_system def set_up_system
save_data = (SaveData.exists?) ? SaveData.read_from_file(SaveData::FILE_PATH) : {} save_data = (SaveData.exists?) ? SaveData.read_from_file(SaveData::FILE_PATH) : {}
if save_data.empty? if save_data.empty?
SaveData.initialize_bootup_values SaveData.initialize_bootup_values
@@ -36,7 +40,7 @@ module Game
# Called when starting a new game. Initializes global variables # Called when starting a new game. Initializes global variables
# and transfers the player into the map scene. # and transfers the player into the map scene.
def self.start_new def start_new
if $game_map&.events if $game_map&.events
$game_map.events.each_value { |event| event.clear_starting } $game_map.events.each_value { |event| event.clear_starting }
end end
@@ -60,12 +64,12 @@ module Game
# Loads the game from the given save data and starts the map scene. # Loads the game from the given save data and starts the map scene.
# @param save_data [Hash] hash containing the save data # @param save_data [Hash] hash containing the save data
# @raise [SaveData::InvalidValueError] if an invalid value is being loaded # @raise [SaveData::InvalidValueError] if an invalid value is being loaded
def self.load(save_data) def load(save_data)
validate save_data => Hash validate save_data => Hash
SaveData.load_all_values(save_data) SaveData.load_all_values(save_data)
$game_temp.last_uptime_refreshed_play_time = System.uptime $game_temp.last_uptime_refreshed_play_time = System.uptime
$stats.play_sessions += 1 $stats.play_sessions += 1
self.load_map load_map
pbAutoplayOnSave pbAutoplayOnSave
$game_map.update $game_map.update
$PokemonMap.updateMap $PokemonMap.updateMap
@@ -73,7 +77,7 @@ module Game
end end
# Loads and validates the map. Called when loading a saved game. # Loads and validates the map. Called when loading a saved game.
def self.load_map def load_map
$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
@@ -108,7 +112,7 @@ module Game
# @param safe [Boolean] whether $PokemonGlobal.safesave should be set to true # @param safe [Boolean] whether $PokemonGlobal.safesave should be set to true
# @return [Boolean] whether the operation was successful # @return [Boolean] whether the operation was successful
# @raise [SaveData::InvalidValueError] if an invalid value is being saved # @raise [SaveData::InvalidValueError] if an invalid value is being saved
def self.save(save_file = SaveData::FILE_PATH, safe: false) def save(save_file = SaveData::FILE_PATH, safe: false)
validate save_file => String, safe => [TrueClass, FalseClass] validate save_file => String, safe => [TrueClass, FalseClass]
$PokemonGlobal.safesave = safe $PokemonGlobal.safesave = safe
$game_system.save_count += 1 $game_system.save_count += 1

View File

@@ -1,7 +1,5 @@
#=============================================================================== #===============================================================================
# ** Modified Scene_Map class for Pokémon. # Modified Scene_Map class for Pokémon.
#-------------------------------------------------------------------------------
#
#=============================================================================== #===============================================================================
class Scene_Map class Scene_Map
attr_reader :spritesetGlobal attr_reader :spritesetGlobal

View File

@@ -42,24 +42,26 @@
module EventHandlers module EventHandlers
@@events = {} @@events = {}
module_function
# Add a named callback for the given event. # Add a named callback for the given event.
def self.add(event, key, proc) def add(event, key, proc)
@@events[event] = NamedEvent.new if !@@events.has_key?(event) @@events[event] = NamedEvent.new if !@@events.has_key?(event)
@@events[event].add(key, proc) @@events[event].add(key, proc)
end end
# Remove a named callback from the given event. # Remove a named callback from the given event.
def self.remove(event, key) def remove(event, key)
@@events[event]&.remove(key) @@events[event]&.remove(key)
end end
# Clear all callbacks for the given event. # Clear all callbacks for the given event.
def self.clear(key) def clear(key)
@@events[key]&.clear @@events[key]&.clear
end end
# Trigger all callbacks from an Event if it has been defined. # Trigger all callbacks from an Event if it has been defined.
def self.trigger(event, *args) def trigger(event, *args)
return @@events[event]&.trigger(*args) return @@events[event]&.trigger(*args)
end end
end end
@@ -80,25 +82,27 @@ end
module MenuHandlers module MenuHandlers
@@handlers = {} @@handlers = {}
def self.add(menu, option, hash) module_function
def add(menu, option, hash)
@@handlers[menu] = HandlerHash.new if !@@handlers.has_key?(menu) @@handlers[menu] = HandlerHash.new if !@@handlers.has_key?(menu)
@@handlers[menu].add(option, hash) @@handlers[menu].add(option, hash)
end end
def self.remove(menu, option) def remove(menu, option)
@@handlers[menu]&.remove(option) @@handlers[menu]&.remove(option)
end end
def self.clear(menu) def clear(menu)
@@handlers[menu]&.clear @@handlers[menu]&.clear
end end
def self.each(menu) def each(menu)
return if !@@handlers.has_key?(menu) return if !@@handlers.has_key?(menu)
@@handlers[menu].each { |option, hash| yield option, hash } @@handlers[menu].each { |option, hash| yield option, hash }
end end
def self.each_available(menu, *args) def each_available(menu, *args)
return if !@@handlers.has_key?(menu) return if !@@handlers.has_key?(menu)
options = @@handlers[menu] options = @@handlers[menu]
keys = options.keys keys = options.keys
@@ -115,7 +119,7 @@ module MenuHandlers
end end
end end
def self.call(menu, option, function, *args) def call(menu, option, function, *args)
option_hash = @@handlers[menu][option] option_hash = @@handlers[menu][option]
return nil if !option_hash || !option_hash[function] return nil if !option_hash || !option_hash[function]
return option_hash[function].call(*args) return option_hash[function].call(*args)

View File

@@ -47,9 +47,6 @@ class Game_Temp
attr_accessor :darkness_sprite # DarknessSprite or nil attr_accessor :darkness_sprite # DarknessSprite or nil
attr_accessor :mart_prices attr_accessor :mart_prices
#-----------------------------------------------------------------------------
# * Object Initialization
#-----------------------------------------------------------------------------
def initialize def initialize
# Flags requesting something to happen # Flags requesting something to happen
@menu_calling = false @menu_calling = false

View File

@@ -39,6 +39,30 @@ class Game_System
@bgs_position = 0 @bgs_position = 0
end end
def battle_bgm
return (@battle_bgm) ? @battle_bgm : $data_system.battle_bgm
end
attr_writer :battle_bgm
def battle_end_me
return (@battle_end_me) ? @battle_end_me : $data_system.battle_end_me
end
attr_writer :battle_end_me
def windowskin_name
return $data_system.windowskin_name if @windowskin_name.nil?
return @windowskin_name
end
attr_writer :windowskin_name
def timer
return 0 if !@timer_start || !$stats
return @timer_duration - $stats.play_time + @timer_start
end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def bgm_play(bgm, track = nil) def bgm_play(bgm, track = nil)
@@ -250,32 +274,6 @@ class Game_System
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def battle_bgm
return (@battle_bgm) ? @battle_bgm : $data_system.battle_bgm
end
attr_writer :battle_bgm
def battle_end_me
return (@battle_end_me) ? @battle_end_me : $data_system.battle_end_me
end
attr_writer :battle_end_me
#-----------------------------------------------------------------------------
def windowskin_name
return $data_system.windowskin_name if @windowskin_name.nil?
return @windowskin_name
end
attr_writer :windowskin_name
def timer
return 0 if !@timer_start || !$stats
return @timer_duration - $stats.play_time + @timer_start
end
def update def update
if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1, "Cut Scene") if Input.trigger?(Input::SPECIAL) && pbCurrentEventCommentInput(1, "Cut Scene")
event = @map_interpreter.get_self event = @map_interpreter.get_self

View File

@@ -1,5 +1,5 @@
#=============================================================================== #===============================================================================
# Map Factory (allows multiple maps to be loaded at once and connected) # Map Factory (allows multiple maps to be loaded at once and connected).
#=============================================================================== #===============================================================================
class PokemonMapFactory class PokemonMapFactory
attr_reader :maps attr_reader :maps
@@ -384,12 +384,14 @@ module MapFactoryHelper
@@MapConnections = nil @@MapConnections = nil
@@MapDims = nil @@MapDims = nil
def self.clear module_function
def clear
@@MapConnections = nil @@MapConnections = nil
@@MapDims = nil @@MapDims = nil
end end
def self.getMapConnections def getMapConnections
if !@@MapConnections if !@@MapConnections
@@MapConnections = [] @@MapConnections = []
conns = load_data("Data/map_connections.dat") conns = load_data("Data/map_connections.dat")
@@ -427,26 +429,26 @@ module MapFactoryHelper
return @@MapConnections return @@MapConnections
end end
def self.hasConnections?(id) def hasConnections?(id)
conns = MapFactoryHelper.getMapConnections conns = MapFactoryHelper.getMapConnections
return conns[id] ? true : false return conns[id] ? true : false
end end
def self.mapsConnected?(id1, id2) def mapsConnected?(id1, id2)
MapFactoryHelper.eachConnectionForMap(id1) do |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 end
return false return false
end end
def self.eachConnectionForMap(id) def eachConnectionForMap(id)
conns = MapFactoryHelper.getMapConnections conns = MapFactoryHelper.getMapConnections
return if !conns[id] return if !conns[id]
conns[id].each { |conn| yield conn } conns[id].each { |conn| yield conn }
end end
# Gets the height and width of the map with id # Gets the height and width of the map with id.
def self.getMapDims(id) def getMapDims(id)
# Create cache if doesn't exist # Create cache if doesn't exist
@@MapDims = [] if !@@MapDims @@MapDims = [] if !@@MapDims
# Add map to cache if can't be found # Add map to cache if can't be found
@@ -464,7 +466,7 @@ module MapFactoryHelper
# Returns the X or Y coordinate of an edge on the map with id. # Returns the X or Y coordinate of an edge on the map with id.
# Considers the special strings "N","W","E","S" # Considers the special strings "N","W","E","S"
def self.getMapEdge(id, edge) def getMapEdge(id, edge)
return 0 if ["N", "W"].include?(edge) return 0 if ["N", "W"].include?(edge)
dims = getMapDims(id) # Get dimensions dims = getMapDims(id) # Get dimensions
return dims[0] if edge == "E" return dims[0] if edge == "E"
@@ -472,7 +474,7 @@ module MapFactoryHelper
return dims[0] # real dimension (use width) return dims[0] # real dimension (use width)
end end
def self.mapInRange?(map) def mapInRange?(map)
range = 6 # Number of tiles range = 6 # Number of tiles
dispx = map.display_x dispx = map.display_x
dispy = map.display_y dispy = map.display_y
@@ -483,7 +485,7 @@ module MapFactoryHelper
return true return true
end end
def self.mapInRangeById?(id, dispx, dispy) def mapInRangeById?(id, dispx, dispy)
range = 6 # Number of tiles range = 6 # Number of tiles
dims = MapFactoryHelper.getMapDims(id) dims = MapFactoryHelper.getMapDims(id)
return false if dispx >= (dims[0] + range) * Game_Map::REAL_RES_X return false if dispx >= (dims[0] + range) * Game_Map::REAL_RES_X

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Game_Character class Game_Character
attr_reader :id attr_reader :id
attr_reader :original_x attr_reader :original_x
@@ -194,9 +197,10 @@ class Game_Character
@direction = @prelock_direction if !@direction_fix && @prelock_direction != 0 @direction = @prelock_direction if !@direction_fix && @prelock_direction != 0
end end
#============================================================================= #-----------------------------------------------------------------------------
# Information from map data # Information from map data
#============================================================================= #-----------------------------------------------------------------------------
def map def map
return (@map) ? @map : $game_map return (@map) ? @map : $game_map
end end
@@ -242,9 +246,10 @@ class Game_Character
return 0 return 0
end end
#============================================================================= #-----------------------------------------------------------------------------
# Passability # Passability
#============================================================================= #-----------------------------------------------------------------------------
def passable?(x, y, dir, strict = false) def passable?(x, y, dir, strict = false)
new_x = x + (dir == 6 ? 1 : dir == 4 ? -1 : 0) new_x = x + (dir == 6 ? 1 : dir == 4 ? -1 : 0)
new_y = y + (dir == 2 ? 1 : dir == 8 ? -1 : 0) new_y = y + (dir == 2 ? 1 : dir == 8 ? -1 : 0)
@@ -313,9 +318,10 @@ class Game_Character
return can_move_from_coordinate?(@x, @y, dir, strict) return can_move_from_coordinate?(@x, @y, dir, strict)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Screen position of the character # Screen position of the character
#============================================================================= #-----------------------------------------------------------------------------
def screen_x def screen_x
ret = ((@real_x.to_f - self.map.display_x) / Game_Map::X_SUBPIXELS).round ret = ((@real_x.to_f - self.map.display_x) / Game_Map::X_SUBPIXELS).round
ret += @width * Game_Map::TILE_WIDTH / 2 ret += @width * Game_Map::TILE_WIDTH / 2
@@ -353,9 +359,10 @@ class Game_Character
return z + ((height > Game_Map::TILE_HEIGHT) ? Game_Map::TILE_HEIGHT - 1 : 0) return z + ((height > Game_Map::TILE_HEIGHT) ? Game_Map::TILE_HEIGHT - 1 : 0)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Movement # Movement
#============================================================================= #-----------------------------------------------------------------------------
def moving? def moving?
return !@move_timer.nil? return !@move_timer.nil?
end end
@@ -410,9 +417,10 @@ class Game_Character
triggerLeaveTile triggerLeaveTile
end end
#============================================================================= #-----------------------------------------------------------------------------
# Movement commands # Movement commands
#============================================================================= #-----------------------------------------------------------------------------
def move_type_random def move_type_random
case rand(6) case rand(6)
when 0..3 then move_random when 0..3 then move_random
@@ -906,9 +914,10 @@ class Game_Character
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Updating # Updating
#============================================================================= #-----------------------------------------------------------------------------
def update def update
return if $game_temp.in_menu return if $game_temp.in_menu
time_now = System.uptime time_now = System.uptime

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Game_Event < Game_Character class Game_Event < Game_Character
attr_reader :map_id attr_reader :map_id
attr_reader :trigger attr_reader :trigger

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Sprite_Picture class Sprite_Picture
def initialize(viewport, picture) def initialize(viewport, picture)
@viewport = viewport @viewport = viewport

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Sprite_Timer class Sprite_Timer
def initialize(viewport = nil) def initialize(viewport = nil)
@viewport = viewport @viewport = viewport

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Sprite_Reflection class Sprite_Reflection
attr_reader :visible attr_reader :visible

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Sprite_SurfBase class Sprite_SurfBase
attr_reader :visible attr_reader :visible

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Spriteset_Global class Spriteset_Global
attr_reader :playersprite attr_reader :playersprite

View File

@@ -1,23 +1,28 @@
#===============================================================================
#
#===============================================================================
module ScreenPosHelper module ScreenPosHelper
def self.pbScreenZoomX(ch) @heightcache = {}
module_function
def pbScreenZoomX(ch)
return Game_Map::TILE_WIDTH / 32.0 return Game_Map::TILE_WIDTH / 32.0
end end
def self.pbScreenZoomY(ch) def pbScreenZoomY(ch)
return Game_Map::TILE_HEIGHT / 32.0 return Game_Map::TILE_HEIGHT / 32.0
end end
def self.pbScreenX(ch) def pbScreenX(ch)
return ch.screen_x return ch.screen_x
end end
def self.pbScreenY(ch) def pbScreenY(ch)
return ch.screen_y return ch.screen_y
end end
@heightcache = {} def bmHeight(bm)
def self.bmHeight(bm)
h = @heightcache[bm] h = @heightcache[bm]
if !h if !h
bmap = AnimatedBitmap.new("Graphics/Characters/" + bm, 0) bmap = AnimatedBitmap.new("Graphics/Characters/" + bm, 0)
@@ -28,7 +33,7 @@ module ScreenPosHelper
return h return h
end end
def self.pbScreenZ(ch, height = nil) def pbScreenZ(ch, height = nil)
if height.nil? if height.nil?
height = 0 height = 0
if ch.tile_id > 0 if ch.tile_id > 0

View File

@@ -259,9 +259,8 @@ class TilemapRenderer
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
#
#=============================================================================
def initialize(viewport) def initialize(viewport)
@tilesets = TilesetBitmaps.new @tilesets = TilesetBitmaps.new
@autotiles = AutotileBitmaps.new @autotiles = AutotileBitmaps.new
@@ -319,7 +318,7 @@ class TilemapRenderer
return @disposed return @disposed
end end
#============================================================================= #-----------------------------------------------------------------------------
def add_tileset(filename) def add_tileset(filename)
@tilesets.add(filename) @tilesets.add(filename)
@@ -351,7 +350,7 @@ class TilemapRenderer
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
def refresh def refresh
@need_refresh = true @need_refresh = true
@@ -436,7 +435,7 @@ class TilemapRenderer
tile.need_refresh = false tile.need_refresh = false
end end
#============================================================================= #-----------------------------------------------------------------------------
def check_if_screen_moved def check_if_screen_moved
ret = false ret = false
@@ -522,7 +521,7 @@ class TilemapRenderer
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
def update def update
# Update tone # Update tone

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class TilemapRenderer class TilemapRenderer
module AutotileExpander module AutotileExpander
MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024 MAX_TEXTURE_SIZE = (Bitmap.max_size / 1024) * 1024

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class TileDrawingHelper class TileDrawingHelper
attr_accessor :tileset attr_accessor :tileset
attr_accessor :autotiles attr_accessor :autotiles
@@ -81,6 +84,8 @@ class TileDrawingHelper
return self.new(bmtileset, bmautotiles) return self.new(bmtileset, bmautotiles)
end end
#-----------------------------------------------------------------------------
def initialize(tileset, autotiles) def initialize(tileset, autotiles)
if tileset.mega? if tileset.mega?
@tileset = TilemapRenderer::TilesetWrapper.wrapTileset(tileset) @tileset = TilemapRenderer::TilesetWrapper.wrapTileset(tileset)

View File

@@ -32,7 +32,9 @@ module MessageConfig
@@smallFont = nil @@smallFont = nil
@@narrowFont = nil @@narrowFont = nil
def self.pbDefaultSystemFrame module_function
def pbDefaultSystemFrame
if $PokemonSystem if $PokemonSystem
return pbResolveBitmap("Graphics/Windowskins/" + Settings::MENU_WINDOWSKINS[$PokemonSystem.frame]) || "" return pbResolveBitmap("Graphics/Windowskins/" + Settings::MENU_WINDOWSKINS[$PokemonSystem.frame]) || ""
else else
@@ -40,7 +42,7 @@ module MessageConfig
end end
end end
def self.pbDefaultSpeechFrame def pbDefaultSpeechFrame
if $PokemonSystem if $PokemonSystem
return pbResolveBitmap("Graphics/Windowskins/" + Settings::SPEECH_WINDOWSKINS[$PokemonSystem.textskin]) || "" return pbResolveBitmap("Graphics/Windowskins/" + Settings::SPEECH_WINDOWSKINS[$PokemonSystem.textskin]) || ""
else else
@@ -48,7 +50,7 @@ module MessageConfig
end end
end end
def self.pbDefaultWindowskin def pbDefaultWindowskin
skin = ($data_system) ? $data_system.windowskin_name : nil skin = ($data_system) ? $data_system.windowskin_name : nil
if skin && skin != "" if skin && skin != ""
skin = pbResolveBitmap("Graphics/Windowskins/" + skin) || "" skin = pbResolveBitmap("Graphics/Windowskins/" + skin) || ""
@@ -58,7 +60,7 @@ module MessageConfig
return skin || "" return skin || ""
end end
def self.pbGetSystemFrame def pbGetSystemFrame
if !@@systemFrame if !@@systemFrame
skin = MessageConfig.pbDefaultSystemFrame skin = MessageConfig.pbDefaultSystemFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@ -67,7 +69,7 @@ module MessageConfig
return @@systemFrame return @@systemFrame
end end
def self.pbGetSpeechFrame def pbGetSpeechFrame
if !@@defaultTextSkin if !@@defaultTextSkin
skin = MessageConfig.pbDefaultSpeechFrame skin = MessageConfig.pbDefaultSpeechFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin) skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@ -76,32 +78,32 @@ module MessageConfig
return @@defaultTextSkin return @@defaultTextSkin
end end
def self.pbSetSystemFrame(value) def pbSetSystemFrame(value)
@@systemFrame = pbResolveBitmap(value) || "" @@systemFrame = pbResolveBitmap(value) || ""
end end
def self.pbSetSpeechFrame(value) def pbSetSpeechFrame(value)
@@defaultTextSkin = pbResolveBitmap(value) || "" @@defaultTextSkin = pbResolveBitmap(value) || ""
end end
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def self.pbDefaultTextSpeed def pbDefaultTextSpeed
return ($PokemonSystem) ? pbSettingToTextSpeed($PokemonSystem.textspeed) : pbSettingToTextSpeed(nil) return ($PokemonSystem) ? pbSettingToTextSpeed($PokemonSystem.textspeed) : pbSettingToTextSpeed(nil)
end end
def self.pbGetTextSpeed def pbGetTextSpeed
@@textSpeed = pbDefaultTextSpeed if !@@textSpeed @@textSpeed = pbDefaultTextSpeed if !@@textSpeed
return @@textSpeed return @@textSpeed
end end
def self.pbSetTextSpeed(value) def pbSetTextSpeed(value)
@@textSpeed = value @@textSpeed = value
end end
# Text speed is the delay in seconds between two adjacent characters being # Text speed is the delay in seconds between two adjacent characters being
# shown. # shown.
def self.pbSettingToTextSpeed(speed) def pbSettingToTextSpeed(speed)
case speed case speed
when 0 then return 4 / 80.0 # Slow when 0 then return 4 / 80.0 # Slow
when 1 then return 2 / 80.0 # Medium when 1 then return 2 / 80.0 # Medium
@@ -113,49 +115,49 @@ module MessageConfig
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def self.pbDefaultSystemFontName def pbDefaultSystemFontName
return MessageConfig.pbTryFonts(FONT_NAME) return MessageConfig.pbTryFonts(FONT_NAME)
end end
def self.pbDefaultSmallFontName def pbDefaultSmallFontName
return MessageConfig.pbTryFonts(SMALL_FONT_NAME) return MessageConfig.pbTryFonts(SMALL_FONT_NAME)
end end
def self.pbDefaultNarrowFontName def pbDefaultNarrowFontName
return MessageConfig.pbTryFonts(NARROW_FONT_NAME) return MessageConfig.pbTryFonts(NARROW_FONT_NAME)
end end
def self.pbGetSystemFontName def pbGetSystemFontName
@@systemFont = pbDefaultSystemFontName if !@@systemFont @@systemFont = pbDefaultSystemFontName if !@@systemFont
return @@systemFont return @@systemFont
end end
def self.pbGetSmallFontName def pbGetSmallFontName
@@smallFont = pbDefaultSmallFontName if !@@smallFont @@smallFont = pbDefaultSmallFontName if !@@smallFont
return @@smallFont return @@smallFont
end end
def self.pbGetNarrowFontName def pbGetNarrowFontName
@@narrowFont = pbDefaultNarrowFontName if !@@narrowFont @@narrowFont = pbDefaultNarrowFontName if !@@narrowFont
return @@narrowFont return @@narrowFont
end end
def self.pbSetSystemFontName(value) def pbSetSystemFontName(value)
@@systemFont = MessageConfig.pbTryFonts(value) @@systemFont = MessageConfig.pbTryFonts(value)
@@systemFont = MessageConfig.pbDefaultSystemFontName if @@systemFont == "" @@systemFont = MessageConfig.pbDefaultSystemFontName if @@systemFont == ""
end end
def self.pbSetSmallFontName(value) def pbSetSmallFontName(value)
@@smallFont = MessageConfig.pbTryFonts(value) @@smallFont = MessageConfig.pbTryFonts(value)
@@smallFont = MessageConfig.pbDefaultSmallFontName if @@smallFont == "" @@smallFont = MessageConfig.pbDefaultSmallFontName if @@smallFont == ""
end end
def self.pbSetNarrowFontName(value) def pbSetNarrowFontName(value)
@@narrowFont = MessageConfig.pbTryFonts(value) @@narrowFont = MessageConfig.pbTryFonts(value)
@@narrowFont = MessageConfig.pbDefaultNarrowFontName if @@narrowFont == "" @@narrowFont = MessageConfig.pbDefaultNarrowFontName if @@narrowFont == ""
end end
def self.pbTryFonts(*args) def pbTryFonts(*args)
args.each do |a| args.each do |a|
next if !a next if !a
case a case a
@@ -173,7 +175,7 @@ module MessageConfig
end end
#=============================================================================== #===============================================================================
# Position a window # Position a window.
#=============================================================================== #===============================================================================
def pbBottomRight(window) def pbBottomRight(window)
window.x = Graphics.width - window.width window.x = Graphics.width - window.width
@@ -277,7 +279,7 @@ def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false)
end end
#=============================================================================== #===============================================================================
# Determine the colour of a background # Determine the colour of a background.
#=============================================================================== #===============================================================================
def isDarkBackground(background, rect = nil) def isDarkBackground(background, rect = nil)
return true if !background || background.disposed? return true if !background || background.disposed?
@@ -328,7 +330,7 @@ def isDarkWindowskin(windowskin)
end end
#=============================================================================== #===============================================================================
# Determine which text colours to use based on the darkness of the background # Determine which text colours to use based on the darkness of the background.
#=============================================================================== #===============================================================================
def get_text_colors_for_windowskin(windowskin, color, isDarkSkin) def get_text_colors_for_windowskin(windowskin, color, isDarkSkin)
# VX windowskin # VX windowskin
@@ -394,7 +396,7 @@ def getDefaultTextColors(windowskin)
end end
#=============================================================================== #===============================================================================
# Makes sure a bitmap exists # Makes sure a bitmap exists.
#=============================================================================== #===============================================================================
def pbDoEnsureBitmap(bitmap, dwidth, dheight) def pbDoEnsureBitmap(bitmap, dwidth, dheight)
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
@@ -408,7 +410,7 @@ def pbDoEnsureBitmap(bitmap, dwidth, dheight)
end end
#=============================================================================== #===============================================================================
# Set a bitmap's font # Set a bitmap's font.
#=============================================================================== #===============================================================================
# Sets a bitmap's font to the system font. # Sets a bitmap's font to the system font.
def pbSetSystemFont(bitmap) def pbSetSystemFont(bitmap)
@@ -432,7 +434,7 @@ def pbSetNarrowFont(bitmap)
end end
#=============================================================================== #===============================================================================
# Blend colours, set the colour of all bitmaps in a sprite hash # Blend colours, set the colour of all bitmaps in a sprite hash.
#=============================================================================== #===============================================================================
def pbAlphaBlend(dstColor, srcColor) def pbAlphaBlend(dstColor, srcColor)
r = (255 * (srcColor.red - dstColor.red) / 255) + dstColor.red r = (255 * (srcColor.red - dstColor.red) / 255) + dstColor.red
@@ -478,7 +480,7 @@ def pbSetSpritesToColor(sprites, color)
end end
#=============================================================================== #===============================================================================
# Update and dispose sprite hashes # Update and dispose sprite hashes.
#=============================================================================== #===============================================================================
def using(window) def using(window)
begin begin
@@ -538,7 +540,7 @@ def pbDisposed?(x)
end end
#=============================================================================== #===============================================================================
# Fades and window activations for sprite hashes # Fades and window activations for sprite hashes.
#=============================================================================== #===============================================================================
def pbPushFade def pbPushFade
$game_temp.fadestate = [$game_temp.fadestate + 1, 0].max if $game_temp $game_temp.fadestate = [$game_temp.fadestate + 1, 0].max if $game_temp
@@ -728,7 +730,7 @@ def pbActivateWindow(sprites, key)
end end
#=============================================================================== #===============================================================================
# Create background planes for a sprite hash # Create background planes for a sprite hash.
#=============================================================================== #===============================================================================
# Adds a background to the sprite hash. # Adds a background to the sprite hash.
# _planename_ is the hash key of the background. # _planename_ is the hash key of the background.

View File

@@ -34,7 +34,7 @@ class SpriteWindow < Window
@_windowskin @_windowskin
end end
# Flags used to preserve compatibility with RGSS/RGSS2's version of Window # Flags used to preserve compatibility with RGSS/RGSS2's version of Window.
module CompatBits module CompatBits
CORRECT_Z = 1 CORRECT_Z = 1
EXPAND_BACK = 2 EXPAND_BACK = 2

View File

@@ -1,5 +1,5 @@
#=============================================================================== #===============================================================================
# Text colors # Text colors.
#=============================================================================== #===============================================================================
# Unused # Unused
def ctag(color) def ctag(color)
@@ -70,7 +70,7 @@ def getContrastColor(color)
end end
#=============================================================================== #===============================================================================
# Format text # Format text.
#=============================================================================== #===============================================================================
FORMATREGEXP = /<(\/?)(c|c2|c3|o|fn|br|fs|i|b|r|pg|pog|u|s|icon|img|ac|ar|al|outln|outln2)(\s*\=\s*([^>]*))?>/i FORMATREGEXP = /<(\/?)(c|c2|c3|o|fn|br|fs|i|b|r|pg|pog|u|s|icon|img|ac|ar|al|outln|outln2)(\s*\=\s*([^>]*))?>/i
@@ -790,7 +790,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end end
#=============================================================================== #===============================================================================
# Draw text and images on a bitmap # Draw text and images on a bitmap.
#=============================================================================== #===============================================================================
def getLineBrokenText(bitmap, value, width, dims) def getLineBrokenText(bitmap, value, width, dims)
x = 0 x = 0
@@ -1134,7 +1134,7 @@ def pbDrawTextPositions(bitmap, textpos)
end end
#=============================================================================== #===============================================================================
# Draw images on a bitmap # Draw images on a bitmap.
#=============================================================================== #===============================================================================
def pbCopyBitmap(dstbm, srcbm, x, y, opacity = 255) def pbCopyBitmap(dstbm, srcbm, x, y, opacity = 255)
rc = Rect.new(0, 0, srcbm.width, srcbm.height) rc = Rect.new(0, 0, srcbm.width, srcbm.height)

View File

@@ -305,7 +305,7 @@ def pbCsvPosInt!(str)
end end
#=============================================================================== #===============================================================================
# Money and coins windows # Money and coins windows.
#=============================================================================== #===============================================================================
def pbGetGoldString def pbGetGoldString
return _INTL("${1}", $player.money.to_s_formatted) return _INTL("${1}", $player.money.to_s_formatted)
@@ -400,7 +400,7 @@ def pbDisposeMessageWindow(msgwindow)
end end
#=============================================================================== #===============================================================================
# Main message-displaying function # Main message-displaying function.
#=============================================================================== #===============================================================================
def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil) def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil)
return if !msgwindow return if !msgwindow
@@ -685,7 +685,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
end end
#=============================================================================== #===============================================================================
# Message-displaying functions # Message-displaying functions.
#=============================================================================== #===============================================================================
def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = 0, &block) def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = 0, &block)
ret = 0 ret = 0

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
def pbStringToAudioFile(str) def pbStringToAudioFile(str)
if str[/^(.*)\:\s*(\d+)\s*\:\s*(\d+)\s*$/] # Of the format "XXX: ###: ###" if str[/^(.*)\:\s*(\d+)\s*\:\s*(\d+)\s*$/] # Of the format "XXX: ###: ###"
file = $1 file = $1
@@ -39,7 +42,8 @@ def pbResolveAudioFile(str, volume = nil, pitch = nil)
end end
#=============================================================================== #===============================================================================
#
#===============================================================================
# Plays a BGM file. # Plays a BGM file.
# param -- Either a string showing the filename # param -- Either a string showing the filename
# (relative to Audio/BGM/) or an RPG::AudioFile object. # (relative to Audio/BGM/) or an RPG::AudioFile object.
@@ -89,7 +93,8 @@ def pbBGMStop(timeInSeconds = 0.0)
end end
#=============================================================================== #===============================================================================
#
#===============================================================================
# Plays an ME file. # Plays an ME file.
# param -- Either a string showing the filename # param -- Either a string showing the filename
# (relative to Audio/ME/) or an RPG::AudioFile object. # (relative to Audio/ME/) or an RPG::AudioFile object.
@@ -139,7 +144,8 @@ def pbMEStop(timeInSeconds = 0.0)
end end
#=============================================================================== #===============================================================================
#
#===============================================================================
# Plays a BGS file. # Plays a BGS file.
# param -- Either a string showing the filename # param -- Either a string showing the filename
# (relative to Audio/BGS/) or an RPG::AudioFile object. # (relative to Audio/BGS/) or an RPG::AudioFile object.
@@ -189,7 +195,8 @@ def pbBGSStop(timeInSeconds = 0.0)
end end
#=============================================================================== #===============================================================================
#
#===============================================================================
# Plays an SE file. # Plays an SE file.
# param -- Either a string showing the filename # param -- Either a string showing the filename
# (relative to Audio/SE/) or an RPG::AudioFile object. # (relative to Audio/SE/) or an RPG::AudioFile object.
@@ -232,8 +239,6 @@ def pbSEStop(_timeInSeconds = 0.0)
end end
end end
#===============================================================================
# Plays a sound effect that plays when the player moves the cursor. # Plays a sound effect that plays when the player moves the cursor.
def pbPlayCursorSE def pbPlayCursorSE
if !nil_or_empty?($data_system&.cursor_se&.name) if !nil_or_empty?($data_system&.cursor_se&.name)

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
#============================================================================= #=============================================================================
# A mixin module for data classes which provides common class methods (called # A mixin module for data classes which provides common class methods (called

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class GrowthRate class GrowthRate
attr_reader :id attr_reader :id
@@ -24,6 +27,8 @@ module GameData
return Settings::MAXIMUM_LEVEL return Settings::MAXIMUM_LEVEL
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -72,6 +77,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::GrowthRate.register({ GameData::GrowthRate.register({

View File

@@ -1,7 +1,9 @@
#===============================================================================
# If a Pokémon's gender ratio is none of :AlwaysMale, :AlwaysFemale or # If a Pokémon's gender ratio is none of :AlwaysMale, :AlwaysFemale or
# :Genderless, then it will choose a random number between 0 and 255 inclusive, # :Genderless, then it will choose a random number between 0 and 255 inclusive,
# and compare it to the @female_chance. If the random number is lower than this # and compare it to the @female_chance. If the random number is lower than this
# chance, it will be female; otherwise, it will be male. # chance, it will be female; otherwise, it will be male.
#===============================================================================
module GameData module GameData
class GenderRatio class GenderRatio
attr_reader :id attr_reader :id
@@ -16,6 +18,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -35,6 +39,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::GenderRatio.register({ GameData::GenderRatio.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class EggGroup class EggGroup
attr_reader :id attr_reader :id
@@ -11,6 +14,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -23,6 +28,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::EggGroup.register({ GameData::EggGroup.register({

View File

@@ -1,7 +1,9 @@
#===============================================================================
# NOTE: The order these shapes are registered are the order they are listed in # NOTE: The order these shapes are registered are the order they are listed in
# the Pokédex search screen. # the Pokédex search screen.
# "Graphics/UI/Pokedex/icon_shapes.png" contains icons for these # "Graphics/UI/Pokedex/icon_shapes.png" contains icons for these
# shapes. # shapes.
#===============================================================================
module GameData module GameData
class BodyShape class BodyShape
attr_reader :id attr_reader :id
@@ -16,6 +18,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -29,6 +33,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::BodyShape.register({ GameData::BodyShape.register({

View File

@@ -1,5 +1,7 @@
#===============================================================================
# NOTE: The order these colors are registered are the order they are listed in # NOTE: The order these colors are registered are the order they are listed in
# the Pokédex search screen. # the Pokédex search screen.
#===============================================================================
module GameData module GameData
class BodyColor class BodyColor
attr_reader :id attr_reader :id
@@ -13,6 +15,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -25,6 +29,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::BodyColor.register({ GameData::BodyColor.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Habitat class Habitat
attr_reader :id attr_reader :id
@@ -11,6 +14,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -23,6 +28,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::Habitat.register({ GameData::Habitat.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Evolution class Evolution
attr_reader :id attr_reader :id
@@ -20,6 +23,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:id].to_s || "Unnamed" @real_name = hash[:id].to_s || "Unnamed"
@@ -71,12 +76,18 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::Evolution.register({ GameData::Evolution.register({
:id => :None :id => :None
}) })
#===============================================================================
#
#===============================================================================
GameData::Evolution.register({ GameData::Evolution.register({
:id => :Level, :id => :Level,
:parameter => Integer, :parameter => Integer,
@@ -545,6 +556,7 @@ GameData::Evolution.register({
#=============================================================================== #===============================================================================
# Evolution methods that trigger when levelling up in battle. # Evolution methods that trigger when levelling up in battle.
#=============================================================================== #===============================================================================
GameData::Evolution.register({ GameData::Evolution.register({
:id => :LevelBattle, :id => :LevelBattle,
:parameter => Integer, :parameter => Integer,
@@ -556,6 +568,7 @@ GameData::Evolution.register({
#=============================================================================== #===============================================================================
# Evolution methods that trigger when using an item on the Pokémon. # Evolution methods that trigger when using an item on the Pokémon.
#=============================================================================== #===============================================================================
GameData::Evolution.register({ GameData::Evolution.register({
:id => :Item, :id => :Item,
:parameter => :Item, :parameter => :Item,
@@ -607,6 +620,7 @@ GameData::Evolution.register({
#=============================================================================== #===============================================================================
# Evolution methods that trigger when the Pokémon is obtained in a trade. # Evolution methods that trigger when the Pokémon is obtained in a trade.
#=============================================================================== #===============================================================================
GameData::Evolution.register({ GameData::Evolution.register({
:id => :Trade, :id => :Trade,
:on_trade_proc => proc { |pkmn, parameter, other_pkmn| :on_trade_proc => proc { |pkmn, parameter, other_pkmn|
@@ -666,6 +680,7 @@ GameData::Evolution.register({
#=============================================================================== #===============================================================================
# Evolution methods that are triggered after any battle. # Evolution methods that are triggered after any battle.
#=============================================================================== #===============================================================================
GameData::Evolution.register({ GameData::Evolution.register({
:id => :AfterBattleCounter, :id => :AfterBattleCounter,
:parameter => Integer, :parameter => Integer,

View File

@@ -1,8 +1,10 @@
#===============================================================================
# The pbs_order value determines the order in which the stats are written in # The pbs_order value determines the order in which the stats are written in
# several PBS files, where base stats/IVs/EVs/EV yields are defined. Only stats # several PBS files, where base stats/IVs/EVs/EV yields are defined. Only stats
# which are yielded by the "each_main" method can have stat numbers defined in # which are yielded by the "each_main" method can have stat numbers defined in
# those places. The values of pbs_order defined below should start with 0 and # those places. The values of pbs_order defined below should start with 0 and
# increase without skipping any numbers. # increase without skipping any numbers.
#===============================================================================
module GameData module GameData
class Stat class Stat
attr_reader :id attr_reader :id
@@ -34,6 +36,8 @@ module GameData
self.each { |s| yield s if [:main_battle, :battle].include?(s.type) } self.each { |s| yield s if [:main_battle, :battle].include?(s.type) }
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -54,6 +58,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::Stat.register({ GameData::Stat.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Nature class Nature
attr_reader :id attr_reader :id
@@ -12,6 +15,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -25,6 +30,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::Nature.register({ GameData::Nature.register({

View File

@@ -1,9 +1,11 @@
#===============================================================================
# NOTE: "Graphics/UI/statuses.png" also contains icons for being fainted and for # NOTE: "Graphics/UI/statuses.png" also contains icons for being fainted and for
# having Pokérus, in that order, at the bottom of the graphic. # having Pokérus, in that order, at the bottom of the graphic.
# "Graphics/UI/Battle/icon_statuses.png" also contains an icon for bad # "Graphics/UI/Battle/icon_statuses.png" also contains an icon for bad
# poisoning (toxic), at the bottom of the graphic. # poisoning (toxic), at the bottom of the graphic.
# Both graphics automatically handle varying numbers of defined statuses, # Both graphics automatically handle varying numbers of defined statuses,
# as long as their extra icons remain at the bottom of them. # as long as their extra icons remain at the bottom of them.
#===============================================================================
module GameData module GameData
class Status class Status
attr_reader :id attr_reader :id
@@ -21,6 +23,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -35,6 +39,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::Status.register({ GameData::Status.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class TerrainTag class TerrainTag
attr_reader :id attr_reader :id
@@ -40,6 +43,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@id_number = hash[:id_number] @id_number = hash[:id_number]
@@ -72,6 +77,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::TerrainTag.register({ GameData::TerrainTag.register({

View File

@@ -1,3 +1,4 @@
#===============================================================================
# Category has the following effects: # Category has the following effects:
# - Determines the in-battle weather. # - Determines the in-battle weather.
# - Some abilities reduce the encounter rate in certain categories of weather. # - Some abilities reduce the encounter rate in certain categories of weather.
@@ -8,6 +9,7 @@
# Delta values are per second. # Delta values are per second.
# For the tone_proc, strength goes from 0 to RPG::Weather::MAX_SPRITES (60) and # For the tone_proc, strength goes from 0 to RPG::Weather::MAX_SPRITES (60) and
# will typically be the maximum. # will typically be the maximum.
#===============================================================================
module GameData module GameData
class Weather class Weather
attr_reader :id attr_reader :id
@@ -30,6 +32,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@id_number = hash[:id_number] @id_number = hash[:id_number]
@@ -60,6 +64,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::Weather.register({ GameData::Weather.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class EncounterType class EncounterType
attr_reader :id attr_reader :id
@@ -13,6 +16,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:id].to_s || "Unnamed" @real_name = hash[:id].to_s || "Unnamed"
@@ -24,6 +29,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::EncounterType.register({ GameData::EncounterType.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Environment class Environment
attr_reader :id attr_reader :id
@@ -12,6 +15,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -25,6 +30,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::Environment.register({ GameData::Environment.register({

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class BattleWeather class BattleWeather
attr_reader :id attr_reader :id
@@ -12,6 +15,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -25,6 +30,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::BattleWeather.register({ GameData::BattleWeather.register({

View File

@@ -1,4 +1,6 @@
#===============================================================================
# These are in-battle terrain effects caused by moves like Electric Terrain. # These are in-battle terrain effects caused by moves like Electric Terrain.
#===============================================================================
module GameData module GameData
class BattleTerrain class BattleTerrain
attr_reader :id attr_reader :id
@@ -13,6 +15,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -26,6 +30,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
GameData::BattleTerrain.register({ GameData::BattleTerrain.register({

View File

@@ -1,3 +1,4 @@
#===============================================================================
# NOTE: If adding a new target, you will need to add code in several places to # NOTE: If adding a new target, you will need to add code in several places to
# make them work properly: # make them work properly:
# - def pbFindTargets # - def pbFindTargets
@@ -5,6 +6,7 @@
# - def pbCreateTargetTexts # - def pbCreateTargetTexts
# - def pbFirstTarget # - def pbFirstTarget
# - def pbTargetsMultiple? # - def pbTargetsMultiple?
#===============================================================================
module GameData module GameData
class Target class Target
attr_reader :id attr_reader :id
@@ -23,6 +25,8 @@ module GameData
def self.load; end def self.load; end
def self.save; end def self.save; end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:name] || "Unnamed" @real_name = hash[:name] || "Unnamed"
@@ -48,6 +52,8 @@ module GameData
end end
end end
#===============================================================================
#
#=============================================================================== #===============================================================================
# Bide, Counter, Metal Burst, Mirror Coat (calculate a target) # Bide, Counter, Metal Burst, Mirror Coat (calculate a target)

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class TownMap class TownMap
attr_reader :id attr_reader :id
@@ -10,7 +13,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "town_map.dat" DATA_FILENAME = "town_map.dat"
PBS_BASE_FILENAME = "town_map" PBS_BASE_FILENAME = "town_map"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "u"], "SectionName" => [:id, "u"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -22,6 +24,8 @@ module GameData
extend ClassMethodsIDNumbers extend ClassMethodsIDNumbers
include InstanceMethods include InstanceMethods
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "???" @real_name = hash[:real_name] || "???"

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Type class Type
attr_reader :id attr_reader :id
@@ -14,7 +17,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "types.dat" DATA_FILENAME = "types.dat"
PBS_BASE_FILENAME = "types" PBS_BASE_FILENAME = "types"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -26,12 +28,13 @@ module GameData
"Immunities" => [:immunities, "*m"], "Immunities" => [:immunities, "*m"],
"Flags" => [:flags, "*s"] "Flags" => [:flags, "*s"]
} }
ICON_SIZE = [64, 28] ICON_SIZE = [64, 28]
extend ClassMethodsSymbols extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"
@@ -71,7 +74,8 @@ module GameData
end end
#=============================================================================== #===============================================================================
#
#===============================================================================
module Effectiveness module Effectiveness
INEFFECTIVE = 0 INEFFECTIVE = 0
NOT_VERY_EFFECTIVE = 1 NOT_VERY_EFFECTIVE = 1

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Ability class Ability
attr_reader :id attr_reader :id
@@ -9,10 +12,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "abilities.dat" DATA_FILENAME = "abilities.dat"
PBS_BASE_FILENAME = "abilities" PBS_BASE_FILENAME = "abilities"
extend ClassMethodsSymbols
include InstanceMethods
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -20,6 +19,11 @@ module GameData
"Flags" => [:flags, "*s"] "Flags" => [:flags, "*s"]
} }
extend ClassMethodsSymbols
include InstanceMethods
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Move class Move
attr_reader :id attr_reader :id
@@ -18,7 +21,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "moves.dat" DATA_FILENAME = "moves.dat"
PBS_BASE_FILENAME = "moves" PBS_BASE_FILENAME = "moves"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -34,12 +36,13 @@ module GameData
"EffectChance" => [:effect_chance, "u"], "EffectChance" => [:effect_chance, "u"],
"Description" => [:real_description, "q"] "Description" => [:real_description, "q"]
} }
CATEGORY_ICON_SIZE = [64, 28] CATEGORY_ICON_SIZE = [64, 28]
extend ClassMethodsSymbols extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Item class Item
attr_reader :id attr_reader :id
@@ -21,7 +24,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "items.dat" DATA_FILENAME = "items.dat"
PBS_BASE_FILENAME = "items" PBS_BASE_FILENAME = "items"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -116,6 +118,8 @@ module GameData
return pbResolveBitmap(ret) ? ret : nil return pbResolveBitmap(ret) ? ret : nil
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class BerryPlant class BerryPlant
attr_reader :id attr_reader :id
@@ -9,14 +12,12 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "berry_plants.dat" DATA_FILENAME = "berry_plants.dat"
PBS_BASE_FILENAME = "berry_plants" PBS_BASE_FILENAME = "berry_plants"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"HoursPerStage" => [:hours_per_stage, "v"], "HoursPerStage" => [:hours_per_stage, "v"],
"DryingPerHour" => [:drying_per_hour, "u"], "DryingPerHour" => [:drying_per_hour, "u"],
"Yield" => [:yield, "uv"] "Yield" => [:yield, "uv"]
} }
NUMBER_OF_REPLANTS = 9 NUMBER_OF_REPLANTS = 9
NUMBER_OF_GROWTH_STAGES = 4 NUMBER_OF_GROWTH_STAGES = 4
NUMBER_OF_FULLY_GROWN_STAGES = 4 NUMBER_OF_FULLY_GROWN_STAGES = 4
@@ -25,6 +26,8 @@ module GameData
extend ClassMethodsSymbols extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@hours_per_stage = hash[:hours_per_stage] || 3 @hours_per_stage = hash[:hours_per_stage] || 3

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Species class Species
attr_reader :id attr_reader :id
@@ -176,6 +179,8 @@ module GameData
return ret return ret
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@species = hash[:species] || @id @species = hash[:species] || @id

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Species class Species
def self.check_graphic_file(path, species, form = 0, gender = 0, shiny = false, shadow = false, subfolder = "") def self.check_graphic_file(path, species, form = 0, gender = 0, shiny = false, shadow = false, subfolder = "")
@@ -108,7 +111,7 @@ module GameData
return ret return ret
end end
#=========================================================================== #---------------------------------------------------------------------------
def self.egg_icon_filename(species, form) def self.egg_icon_filename(species, form)
ret = self.check_egg_graphic_file("Graphics/Pokemon/Eggs/", species, form, "_icon") ret = self.check_egg_graphic_file("Graphics/Pokemon/Eggs/", species, form, "_icon")
@@ -139,7 +142,7 @@ module GameData
return self.icon_bitmap(pkmn.species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?, pkmn.egg?) return self.icon_bitmap(pkmn.species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?, pkmn.egg?)
end end
#=========================================================================== #---------------------------------------------------------------------------
def self.footprint_filename(species, form = 0) def self.footprint_filename(species, form = 0)
species_data = self.get_species_form(species, form) species_data = self.get_species_form(species, form)
@@ -151,7 +154,7 @@ module GameData
return pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%s", species_data.species)) return pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%s", species_data.species))
end end
#=========================================================================== #---------------------------------------------------------------------------
def self.shadow_filename(species, form = 0) def self.shadow_filename(species, form = 0)
species_data = self.get_species_form(species, form) species_data = self.get_species_form(species, form)
@@ -178,7 +181,7 @@ module GameData
return (filename) ? AnimatedBitmap.new(filename) : nil return (filename) ? AnimatedBitmap.new(filename) : nil
end end
#=========================================================================== #---------------------------------------------------------------------------
def self.check_cry_file(species, form, suffix = "") def self.check_cry_file(species, form, suffix = "")
species_data = self.get_species_form(species, form) species_data = self.get_species_form(species, form)

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class SpeciesMetrics class SpeciesMetrics
attr_reader :id attr_reader :id
@@ -13,7 +16,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "species_metrics.dat" DATA_FILENAME = "species_metrics.dat"
PBS_BASE_FILENAME = "pokemon_metrics" PBS_BASE_FILENAME = "pokemon_metrics"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "eV", :Species], "SectionName" => [:id, "eV", :Species],
"BackSprite" => [:back_sprite, "ii"], "BackSprite" => [:back_sprite, "ii"],
@@ -56,6 +58,8 @@ module GameData
return DATA[species] return DATA[species]
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@species = hash[:species] || @id @species = hash[:species] || @id

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class ShadowPokemon class ShadowPokemon
attr_reader :id attr_reader :id
@@ -12,7 +15,6 @@ module GameData
DATA_FILENAME = "shadow_pokemon.dat" DATA_FILENAME = "shadow_pokemon.dat"
PBS_BASE_FILENAME = "shadow_pokemon" PBS_BASE_FILENAME = "shadow_pokemon"
OPTIONAL = true OPTIONAL = true
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "eV", :Species], "SectionName" => [:id, "eV", :Species],
"GaugeSize" => [:gauge_size, "v"], "GaugeSize" => [:gauge_size, "v"],
@@ -43,6 +45,8 @@ module GameData
return (DATA.has_key?(species_form)) ? DATA[species_form] : nil return (DATA.has_key?(species_form)) ? DATA[species_form] : nil
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@species = hash[:species] || @id @species = hash[:species] || @id

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Ribbon class Ribbon
attr_reader :id attr_reader :id
@@ -10,7 +13,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "ribbons.dat" DATA_FILENAME = "ribbons.dat"
PBS_BASE_FILENAME = "ribbons" PBS_BASE_FILENAME = "ribbons"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -22,6 +24,8 @@ module GameData
extend ClassMethodsSymbols extend ClassMethodsSymbols
include InstanceMethods include InstanceMethods
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Encounter class Encounter
attr_accessor :id attr_accessor :id
@@ -59,6 +62,8 @@ module GameData
end end
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@map = hash[:map] @map = hash[:map]

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class TrainerType class TrainerType
attr_reader :id attr_reader :id
@@ -15,7 +18,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "trainer_types.dat" DATA_FILENAME = "trainer_types.dat"
PBS_BASE_FILENAME = "trainer_types" PBS_BASE_FILENAME = "trainer_types"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "m"], "SectionName" => [:id, "m"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -101,6 +103,8 @@ module GameData
return self.check_file(tr_type, "Graphics/UI/Town Map/player_", sprintf("_%d", outfit)) return self.check_file(tr_type, "Graphics/UI/Town Map/player_", sprintf("_%d", outfit))
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] || "Unnamed" @real_name = hash[:real_name] || "Unnamed"

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Trainer class Trainer
attr_reader :id attr_reader :id
@@ -12,7 +15,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "trainers.dat" DATA_FILENAME = "trainers.dat"
PBS_BASE_FILENAME = "trainers" PBS_BASE_FILENAME = "trainers"
# "Pokemon" is specially mentioned in def compile_trainers and def # "Pokemon" is specially mentioned in def compile_trainers and def
# write_trainers, and acts as a subheading for a particular Pokémon. # write_trainers, and acts as a subheading for a particular Pokémon.
SCHEMA = { SCHEMA = {
@@ -83,6 +85,8 @@ module GameData
return (self::DATA.has_key?(key)) ? self::DATA[key] : nil return (self::DATA.has_key?(key)) ? self::DATA[key] : nil
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@trainer_type = hash[:trainer_type] @trainer_type = hash[:trainer_type]

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class Metadata class Metadata
attr_reader :id attr_reader :id
@@ -17,7 +20,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "metadata.dat" DATA_FILENAME = "metadata.dat"
PBS_BASE_FILENAME = "metadata" PBS_BASE_FILENAME = "metadata"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "u"], "SectionName" => [:id, "u"],
"StartMoney" => [:start_money, "u"], "StartMoney" => [:start_money, "u"],
@@ -56,6 +58,8 @@ module GameData
return DATA[0] return DATA[0]
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] || 0 @id = hash[:id] || 0
@start_money = hash[:start_money] || 3000 @start_money = hash[:start_money] || 3000

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class PlayerMetadata class PlayerMetadata
attr_reader :id attr_reader :id
@@ -8,7 +11,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "player_metadata.dat" DATA_FILENAME = "player_metadata.dat"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "u"], "SectionName" => [:id, "u"],
"TrainerType" => [:trainer_type, "e", :TrainerType], "TrainerType" => [:trainer_type, "e", :TrainerType],
@@ -48,6 +50,8 @@ module GameData
return self::DATA[1] return self::DATA[1]
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@trainer_type = hash[:trainer_type] @trainer_type = hash[:trainer_type]

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class MapMetadata class MapMetadata
attr_reader :id attr_reader :id
@@ -29,7 +32,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "map_metadata.dat" DATA_FILENAME = "map_metadata.dat"
PBS_BASE_FILENAME = "map_metadata" PBS_BASE_FILENAME = "map_metadata"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "u"], "SectionName" => [:id, "u"],
"Name" => [:real_name, "s"], "Name" => [:real_name, "s"],
@@ -89,6 +91,8 @@ module GameData
] ]
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@real_name = hash[:real_name] @real_name = hash[:real_name]

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class DungeonTileset class DungeonTileset
attr_reader :id attr_reader :id
@@ -15,7 +18,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "dungeon_tilesets.dat" DATA_FILENAME = "dungeon_tilesets.dat"
PBS_BASE_FILENAME = "dungeon_tilesets" PBS_BASE_FILENAME = "dungeon_tilesets"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "u"], "SectionName" => [:id, "u"],
"Autotile" => [:autotile, "^um"], "Autotile" => [:autotile, "^um"],
@@ -41,6 +43,8 @@ module GameData
return (self::DATA.has_key?(other)) ? self::DATA[other] : self.get(self::DATA.keys.first) return (self::DATA.has_key?(other)) ? self::DATA[other] : self.get(self::DATA.keys.first)
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@snap_to_large_grid = hash[:snap_to_large_grid] || false @snap_to_large_grid = hash[:snap_to_large_grid] || false

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class DungeonParameters class DungeonParameters
attr_reader :id, :area, :version attr_reader :id, :area, :version
@@ -29,7 +32,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "dungeon_parameters.dat" DATA_FILENAME = "dungeon_parameters.dat"
PBS_BASE_FILENAME = "dungeon_parameters" PBS_BASE_FILENAME = "dungeon_parameters"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "mV"], "SectionName" => [:id, "mV"],
"DungeonSize" => [:dungeon_size, "vv"], "DungeonSize" => [:dungeon_size, "vv"],
@@ -65,6 +67,8 @@ module GameData
return (DATA.has_key?(area_version)) ? DATA[area_version] : self.new({}) return (DATA.has_key?(area_version)) ? DATA[area_version] : self.new({})
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@area = hash[:area] @area = hash[:area]

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
module GameData module GameData
class PhoneMessage class PhoneMessage
attr_reader :id attr_reader :id
@@ -11,7 +14,6 @@ module GameData
DATA = {} DATA = {}
DATA_FILENAME = "phone.dat" DATA_FILENAME = "phone.dat"
PBS_BASE_FILENAME = "phone" PBS_BASE_FILENAME = "phone"
SCHEMA = { SCHEMA = {
"SectionName" => [:id, "q"], "SectionName" => [:id, "q"],
"Intro" => [:intro, "^q"], "Intro" => [:intro, "^q"],
@@ -69,6 +71,8 @@ module GameData
return (self::DATA.has_key?(key)) ? self::DATA[key] : nil return (self::DATA.has_key?(key)) ? self::DATA[key] : nil
end end
#---------------------------------------------------------------------------
def initialize(hash) def initialize(hash)
@id = hash[:id] @id = hash[:id]
@trainer_type = hash[:trainer_type] @trainer_type = hash[:trainer_type]

View File

@@ -1,3 +1,4 @@
#===============================================================================
# Results of battle (see module Outcome): # Results of battle (see module Outcome):
# 0 - Undecided or aborted # 0 - Undecided or aborted
# 1 - Player won # 1 - Player won
@@ -36,7 +37,7 @@
# class Game_Temp # class Game_Temp
# def add_battle_rule # def add_battle_rule
# (There is no guarantee that this list is complete.) # (There is no guarantee that this list is complete.)
#===============================================================================
class Battle class Battle
module Outcome module Outcome
UNDECIDED = 0 UNDECIDED = 0
@@ -115,9 +116,8 @@ class Battle
def pbRandom(x); return rand(x); end def pbRandom(x); return rand(x); end
#============================================================================= #-----------------------------------------------------------------------------
# Creating the battle class
#=============================================================================
def initialize(scene, p1, p2, player, opponent) def initialize(scene, p1, p2, player, opponent)
if p1.length == 0 if p1.length == 0
raise ArgumentError.new(_INTL("Party 1 has no Pokémon.")) raise ArgumentError.new(_INTL("Party 1 has no Pokémon."))
@@ -200,9 +200,10 @@ class Battle
return Outcome.decided?(@decision) return Outcome.decided?(@decision)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Information about the type and size of the battle # Information about the type and size of the battle.
#============================================================================= #-----------------------------------------------------------------------------
def wildBattle?; return @opponent.nil?; end def wildBattle?; return @opponent.nil?; end
def trainerBattle?; return !@opponent.nil?; end def trainerBattle?; return !@opponent.nil?; end
@@ -236,9 +237,10 @@ class Battle
return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : (pbSideSize(1) * 2) - 1 return (pbSideSize(0) > pbSideSize(1)) ? (pbSideSize(0) - 1) * 2 : (pbSideSize(1) * 2) - 1
end end
#============================================================================= #-----------------------------------------------------------------------------
# Trainers and owner-related methods # Trainers and owner-related methods.
#============================================================================= #-----------------------------------------------------------------------------
def pbPlayer; return @player[0]; end def pbPlayer; return @player[0]; end
# Given a battler index, returns the index within @player/@opponent of the # Given a battler index, returns the index within @player/@opponent of the
@@ -324,9 +326,10 @@ class Battle
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Get party information (counts all teams on the same side) # Get party information (counts all teams on the same side).
#============================================================================= #-----------------------------------------------------------------------------
def pbParty(idxBattler) def pbParty(idxBattler)
return (opposes?(idxBattler)) ? @party2 : @party1 return (opposes?(idxBattler)) ? @party2 : @party1
end end
@@ -407,10 +410,11 @@ class Battle
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Get team information (a team is only the Pokémon owned by a particular # Get team information (a team is only the Pokémon owned by a particular
# trainer) # trainer).
#============================================================================= #-----------------------------------------------------------------------------
def pbTeamIndexRangeFromBattlerIndex(idxBattler) def pbTeamIndexRangeFromBattlerIndex(idxBattler)
partyStarts = pbPartyStarts(idxBattler) partyStarts = pbPartyStarts(idxBattler)
idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler) idxTrainer = pbGetOwnerIndexFromBattlerIndex(idxBattler)
@@ -464,9 +468,10 @@ class Battle
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Iterate through battlers # Iterate through battlers.
#============================================================================= #-----------------------------------------------------------------------------
# Unused # Unused
def eachBattler def eachBattler
@battlers.each { |b| yield b if b && !b.fainted? } @battlers.each { |b| yield b if b && !b.fainted? }
@@ -577,9 +582,10 @@ class Battle
return [idxBattler] return [idxBattler]
end end
#============================================================================= #-----------------------------------------------------------------------------
# Comparing the positions of two battlers # Comparing the positions of two battlers.
#============================================================================= #-----------------------------------------------------------------------------
def opposes?(idxBattler1, idxBattler2 = 0) def opposes?(idxBattler1, idxBattler2 = 0)
idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index") idxBattler1 = idxBattler1.index if idxBattler1.respond_to?("index")
idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index") idxBattler2 = idxBattler2.index if idxBattler2.respond_to?("index")
@@ -612,9 +618,10 @@ class Battle
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Altering a party or rearranging battlers # Altering a party or rearranging battlers.
#============================================================================= #-----------------------------------------------------------------------------
def pbRemoveFromParty(idxBattler, idxParty) def pbRemoveFromParty(idxBattler, idxParty)
party = pbParty(idxBattler) party = pbParty(idxBattler)
# Erase the Pokémon from the party # Erase the Pokémon from the party
@@ -670,9 +677,10 @@ class Battle
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# #
#============================================================================= #-----------------------------------------------------------------------------
# Returns the battler representing the Pokémon at index idxParty in its party, # Returns the battler representing the Pokémon at index idxParty in its party,
# on the same side as a battler with battler index of idxBattlerOther. # on the same side as a battler with battler index of idxBattlerOther.
def pbFindBattler(idxParty, idxBattlerOther = 0) def pbFindBattler(idxParty, idxBattlerOther = 0)
@@ -724,9 +732,10 @@ class Battle
return @nextPickupUse return @nextPickupUse
end end
#============================================================================= #-----------------------------------------------------------------------------
# Weather # Weather.
#============================================================================= #-----------------------------------------------------------------------------
def defaultWeather=(value) def defaultWeather=(value)
@field.defaultWeather = value @field.defaultWeather = value
@field.weather = value @field.weather = value
@@ -811,9 +820,10 @@ class Battle
# NOTE: The ability splash is hidden again in def pbStartWeather. # NOTE: The ability splash is hidden again in def pbStartWeather.
end end
#============================================================================= #-----------------------------------------------------------------------------
# Terrain # Terrain.
#============================================================================= #-----------------------------------------------------------------------------
def defaultTerrain=(value) def defaultTerrain=(value)
@field.defaultTerrain = value @field.defaultTerrain = value
@field.terrain = value @field.terrain = value
@@ -847,9 +857,10 @@ class Battle
allBattlers.each { |b| b.pbItemTerrainStatBoostCheck } allBattlers.each { |b| b.pbItemTerrainStatBoostCheck }
end end
#============================================================================= #-----------------------------------------------------------------------------
# Messages and animations # Messages and animations.
#============================================================================= #-----------------------------------------------------------------------------
def pbDisplay(msg, &block) def pbDisplay(msg, &block)
@scene.pbDisplayMessage(msg, &block) @scene.pbDisplayMessage(msg, &block)
end end

View File

@@ -1,18 +1,21 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
class BattleAbortedException < Exception; end class BattleAbortedException < Exception; end
#-----------------------------------------------------------------------------
def pbAbort def pbAbort
raise BattleAbortedException.new("Battle aborted") raise BattleAbortedException.new("Battle aborted")
end end
#=============================================================================
# Makes sure all Pokémon exist that need to. Alter the type of battle if # Makes sure all Pokémon exist that need to. Alter the type of battle if
# necessary. Will never try to create battler positions, only delete them # necessary. Will never try to create battler positions, only delete them
# (except for wild Pokémon whose number of positions are fixed). Reduces the # (except for wild Pokémon whose number of positions are fixed). Reduces the
# size of each side by 1 and tries again. If the side sizes are uneven, only # size of each side by 1 and tries again. If the side sizes are uneven, only
# the larger side's size will be reduced by 1 each time, until both sides are # the larger side's size will be reduced by 1 each time, until both sides are
# an equal size (then both sides will be reduced equally). # an equal size (then both sides will be reduced equally).
#=============================================================================
def pbEnsureParticipants def pbEnsureParticipants
# Prevent battles larger than 2v2 if both sides have multiple trainers # Prevent battles larger than 2v2 if both sides have multiple trainers
# NOTE: This is necessary to ensure that battlers can never become unable to # NOTE: This is necessary to ensure that battlers can never become unable to
@@ -103,9 +106,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Set up all battlers # Set up all battlers
#============================================================================= #-----------------------------------------------------------------------------
def pbCreateBattler(idxBattler, pkmn, idxParty) def pbCreateBattler(idxBattler, pkmn, idxParty)
if !@battlers[idxBattler].nil? if !@battlers[idxBattler].nil?
raise _INTL("Battler index {1} already exists", idxBattler) raise _INTL("Battler index {1} already exists", idxBattler)
@@ -164,9 +168,10 @@ class Battle
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Send out all battlers at the start of battle # Send out all battlers at the start of battle.
#============================================================================= #-----------------------------------------------------------------------------
def pbStartBattleSendOut(sendOuts) def pbStartBattleSendOut(sendOuts)
# "Want to battle" messages # "Want to battle" messages
if wildBattle? if wildBattle?
@@ -241,9 +246,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Start a battle # Start a battle.
#============================================================================= #-----------------------------------------------------------------------------
def pbStartBattle def pbStartBattle
PBDebug.log("") PBDebug.log("")
PBDebug.log("================================================================") PBDebug.log("================================================================")
@@ -317,9 +323,10 @@ class Battle
pbBattleLoop pbBattleLoop
end end
#============================================================================= #-----------------------------------------------------------------------------
# Main battle loop # Main battle loop.
#============================================================================= #-----------------------------------------------------------------------------
def pbBattleLoop def pbBattleLoop
@turnCount = 0 @turnCount = 0
loop do # Now begin the battle loop loop do # Now begin the battle loop
@@ -347,9 +354,10 @@ class Battle
pbEndOfBattle pbEndOfBattle
end end
#============================================================================= #-----------------------------------------------------------------------------
# End of battle # End of battle.
#============================================================================= #-----------------------------------------------------------------------------
def pbGainMoney def pbGainMoney
return if !@internalBattle || !@moneyGain return if !@internalBattle || !@moneyGain
# Money rewarded from opposing trainers # Money rewarded from opposing trainers
@@ -511,9 +519,10 @@ class Battle
return @decision return @decision
end end
#============================================================================= #-----------------------------------------------------------------------------
# Judging # Judging.
#============================================================================= #-----------------------------------------------------------------------------
def pbJudgeCheckpoint(user, move = nil); end def pbJudgeCheckpoint(user, move = nil); end
def pbDecisionOnTime def pbDecisionOnTime

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Gaining Experience # Gaining Experience.
#============================================================================= #-----------------------------------------------------------------------------
def pbGainExp def pbGainExp
# Play wild victory music if it's the end of the battle (has to be here) # Play wild victory music if it's the end of the battle (has to be here)
@scene.pbWildBattleSuccess if wildBattle? && pbAllFainted?(1) && !pbAllFainted?(0) @scene.pbWildBattleSuccess if wildBattle? && pbAllFainted?(1) && !pbAllFainted?(0)
@@ -223,9 +227,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Learning a move # Learning a move.
#============================================================================= #-----------------------------------------------------------------------------
def pbLearnMove(idxParty, newMove) def pbLearnMove(idxParty, newMove)
pkmn = pbParty(0)[idxParty] pkmn = pbParty(0)[idxParty]
return if !pkmn return if !pkmn

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Choosing a move/target # Choosing a move/target.
#============================================================================= #-----------------------------------------------------------------------------
def pbCanChooseMove?(idxBattler, idxMove, showMessages, sleepTalk = false) def pbCanChooseMove?(idxBattler, idxMove, showMessages, sleepTalk = false)
battler = @battlers[idxBattler] battler = @battlers[idxBattler]
move = battler.moves[idxMove] move = battler.moves[idxMove]
@@ -130,9 +134,9 @@ class Battle
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Turn order calculation (priority) # Turn order calculation (priority).
#============================================================================= #-----------------------------------------------------------------------------
def pbCalculatePriority(fullCalc = false, indexArray = nil) def pbCalculatePriority(fullCalc = false, indexArray = nil)
needRearranging = false needRearranging = false
if fullCalc if fullCalc

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Choosing Pokémon to switch # Choosing Pokémon to switch.
#============================================================================= #-----------------------------------------------------------------------------
# Checks whether the replacement Pokémon (at party index idxParty) can enter # Checks whether the replacement Pokémon (at party index idxParty) can enter
# battle. # battle.
# NOTE: Messages are only shown while in the party screen when choosing a # NOTE: Messages are only shown while in the party screen when choosing a
@@ -104,10 +108,11 @@ class Battle
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Open the party screen and potentially pick a replacement Pokémon (or AI # Open the party screen and potentially pick a replacement Pokémon (or AI
# chooses replacement) # chooses replacement).
#============================================================================= #-----------------------------------------------------------------------------
# Open party screen and potentially choose a Pokémon to switch with. Used in # Open party screen and potentially choose a Pokémon to switch with. Used in
# 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)
@@ -134,9 +139,10 @@ class Battle
return @battleAI.pbDefaultChooseNewEnemy(idxBattler) return @battleAI.pbDefaultChooseNewEnemy(idxBattler)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Switching Pokémon # Switching Pokémon.
#============================================================================= #-----------------------------------------------------------------------------
# General switching method that checks if any Pokémon need to be sent out and, # General switching method that checks if any Pokémon need to be sent out and,
# if so, does. Called at the end of each round. # if so, does. Called at the end of each round.
def pbEORSwitch(favorDraws = false) def pbEORSwitch(favorDraws = false)
@@ -296,9 +302,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Effects upon a Pokémon entering battle # Effects upon a Pokémon entering battle.
#============================================================================= #-----------------------------------------------------------------------------
# Called at the start of battle only. # Called at the start of battle only.
def pbOnAllBattlersEnteringBattle def pbOnAllBattlersEnteringBattle
pbCalculatePriority(true) pbCalculatePriority(true)

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Choosing to use an item # Choosing to use an item.
#============================================================================= #-----------------------------------------------------------------------------
def pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages = true) def pbCanUseItemOnPokemon?(item, pkmn, battler, scene, showMessages = true)
if !pkmn || pkmn.egg? if !pkmn || pkmn.egg?
scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages scene.pbDisplay(_INTL("It won't have any effect.")) if showMessages
@@ -43,9 +47,10 @@ class Battle
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Using an item # Using an item.
#============================================================================= #-----------------------------------------------------------------------------
def pbConsumeItemInBag(item, idxBattler) def pbConsumeItemInBag(item, idxBattler)
return if !item return if !item
return if !GameData::Item.get(item).consumed_after_use? return if !GameData::Item.get(item).consumed_after_use?

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Running from battle # Running from battle
#============================================================================= #-----------------------------------------------------------------------------
def pbCanRun?(idxBattler) def pbCanRun?(idxBattler)
return false if trainerBattle? return false if trainerBattle?
battler = @battlers[idxBattler] battler = @battlers[idxBattler]

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Shifting a battler to another position in a battle larger than double # Shifting a battler to another position in a battle larger than double.
#============================================================================= #-----------------------------------------------------------------------------
def pbCanShift?(idxBattler) def pbCanShift?(idxBattler)
return false if pbSideSize(0) <= 2 && pbSideSize(1) <= 2 # Double battle or smaller return false if pbSideSize(0) <= 2 && pbSideSize(1) <= 2 # Double battle or smaller
idxOther = -1 idxOther = -1
@@ -25,9 +29,10 @@ class Battle
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Calling at a battler # Calling at a battler.
#============================================================================= #-----------------------------------------------------------------------------
def pbRegisterCall(idxBattler) def pbRegisterCall(idxBattler)
@choices[idxBattler][0] = :Call @choices[idxBattler][0] = :Call
@choices[idxBattler][1] = 0 @choices[idxBattler][1] = 0
@@ -61,9 +66,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Choosing to Mega Evolve a battler # Choosing to Mega Evolve a battler.
#============================================================================= #-----------------------------------------------------------------------------
def pbHasMegaRing?(idxBattler) def pbHasMegaRing?(idxBattler)
if pbOwnedByPlayer?(idxBattler) if pbOwnedByPlayer?(idxBattler)
@mega_rings.each { |item| return true if $bag.has?(item) } @mega_rings.each { |item| return true if $bag.has?(item) }
@@ -129,9 +135,10 @@ class Battle
return @megaEvolution[side][owner] == idxBattler return @megaEvolution[side][owner] == idxBattler
end end
#============================================================================= #-----------------------------------------------------------------------------
# Mega Evolving a battler # Mega Evolving a battler.
#============================================================================= #-----------------------------------------------------------------------------
def pbMegaEvolve(idxBattler) def pbMegaEvolve(idxBattler)
battler = @battlers[idxBattler] battler = @battlers[idxBattler]
return if !battler || !battler.pokemon return if !battler || !battler.pokemon
@@ -174,9 +181,10 @@ class Battle
pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION pbCalculatePriority(false, [idxBattler]) if Settings::RECALCULATE_TURN_ORDER_AFTER_MEGA_EVOLUTION
end end
#============================================================================= #-----------------------------------------------------------------------------
# Primal Reverting a battler # Primal Reverting a battler.
#============================================================================= #-----------------------------------------------------------------------------
def pbPrimalReversion(idxBattler) def pbPrimalReversion(idxBattler)
battler = @battlers[idxBattler] battler = @battlers[idxBattler]
return if !battler || !battler.pokemon || battler.fainted? return if !battler || !battler.pokemon || battler.fainted?

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Clear commands # Clear commands.
#============================================================================= #-----------------------------------------------------------------------------
def pbClearChoice(idxBattler) def pbClearChoice(idxBattler)
@choices[idxBattler] = [] if !@choices[idxBattler] @choices[idxBattler] = [] if !@choices[idxBattler]
@choices[idxBattler][0] = :None @choices[idxBattler][0] = :None
@@ -22,16 +26,18 @@ class Battle
pbClearChoice(idxBattler) pbClearChoice(idxBattler)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Use main command menu (Fight/Pokémon/Bag/Run) # Use main command menu (Fight/Pokémon/Bag/Run).
#============================================================================= #-----------------------------------------------------------------------------
def pbCommandMenu(idxBattler, firstAction) def pbCommandMenu(idxBattler, firstAction)
return @scene.pbCommandMenu(idxBattler, firstAction) return @scene.pbCommandMenu(idxBattler, firstAction)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Check whether actions can be taken # Check whether actions can be taken.
#============================================================================= #-----------------------------------------------------------------------------
def pbCanShowCommands?(idxBattler) def pbCanShowCommands?(idxBattler)
battler = @battlers[idxBattler] battler = @battlers[idxBattler]
return false if !battler || battler.fainted? return false if !battler || battler.fainted?
@@ -53,9 +59,10 @@ class Battle
return usable return usable
end end
#============================================================================= #-----------------------------------------------------------------------------
# Use sub-menus to choose an action, and register it if is allowed # Use sub-menus to choose an action, and register it if is allowed.
#============================================================================= #-----------------------------------------------------------------------------
# Returns true if a choice was made, false if cancelled. # Returns true if a choice was made, false if cancelled.
def pbFightMenu(idxBattler) def pbFightMenu(idxBattler)
# Auto-use Encored move or no moves choosable, so auto-use Struggle # Auto-use Encored move or no moves choosable, so auto-use Struggle
@@ -168,9 +175,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Command phase # Command phase.
#============================================================================= #-----------------------------------------------------------------------------
def pbCommandPhase def pbCommandPhase
@command_phase = true @command_phase = true
@scene.pbBeginCommandPhase @scene.pbBeginCommandPhase

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# Attack phase actions # Attack phase actions.
#============================================================================= #-----------------------------------------------------------------------------
# Quick Claw, Custap Berry's "X let it move first!" message. # Quick Claw, Custap Berry's "X let it move first!" message.
def pbAttackPhasePriorityChangeMessages def pbAttackPhasePriorityChangeMessages
pbPriority.each do |b| pbPriority.each do |b|
@@ -170,9 +174,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Attack phase # Attack phase.
#============================================================================= #-----------------------------------------------------------------------------
def pbAttackPhase def pbAttackPhase
@scene.pbBeginAttackPhase @scene.pbBeginAttackPhase
# Reset certain effects # Reset certain effects

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle class Battle
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round end weather check and weather effects # End Of Round end weather check and weather effects.
#============================================================================= #-----------------------------------------------------------------------------
def pbEOREndWeather(priority) def pbEOREndWeather(priority)
# NOTE: Primordial weather doesn't need to be checked here, because if it # NOTE: Primordial weather doesn't need to be checked here, because if it
# could wear off here, it will have worn off already. # could wear off here, it will have worn off already.
@@ -74,9 +78,10 @@ class Battle
battler.pbFaint if battler.fainted? battler.pbFaint if battler.fainted?
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round use delayed moves (Future Sight, Doom Desire) # End Of Round use delayed moves (Future Sight, Doom Desire).
#============================================================================= #-----------------------------------------------------------------------------
def pbEORUseFutureSight(position, position_index) def pbEORUseFutureSight(position, position_index)
return if !position || position.effects[PBEffects::FutureSightCounter] == 0 return if !position || position.effects[PBEffects::FutureSightCounter] == 0
position.effects[PBEffects::FutureSightCounter] -= 1 position.effects[PBEffects::FutureSightCounter] -= 1
@@ -116,9 +121,10 @@ class Battle
position.effects[PBEffects::FutureSightUserPartyIndex] = -1 position.effects[PBEffects::FutureSightUserPartyIndex] = -1
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round healing from Wish # End Of Round healing from Wish.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORWishHealing def pbEORWishHealing
@positions.each_with_index do |pos, idxPos| @positions.each_with_index do |pos, idxPos|
next if !pos || pos.effects[PBEffects::Wish] == 0 next if !pos || pos.effects[PBEffects::Wish] == 0
@@ -131,9 +137,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round Sea of Fire damage (Fire Pledge + Grass Pledge combination) # End Of Round Sea of Fire damage (Fire Pledge + Grass Pledge combination).
#============================================================================= #-----------------------------------------------------------------------------
def pbEORSeaOfFireDamage(priority) def pbEORSeaOfFireDamage(priority)
2.times do |side| 2.times do |side|
next if sides[side].effects[PBEffects::SeaOfFire] == 0 next if sides[side].effects[PBEffects::SeaOfFire] == 0
@@ -152,9 +159,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round healing from Grassy Terrain # End Of Round healing from Grassy Terrain.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORTerrainHealing(battler) def pbEORTerrainHealing(battler)
return if battler.fainted? return if battler.fainted?
# Grassy Terrain (healing) # Grassy Terrain (healing)
@@ -165,9 +173,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round various healing effects # End Of Round various healing effects.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORHealingEffects(priority) def pbEORHealingEffects(priority)
# Aqua Ring # Aqua Ring
priority.each do |battler| priority.each do |battler|
@@ -205,9 +214,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round deal damage from status problems # End Of Round deal damage from status problems.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORStatusProblemDamage(priority) def pbEORStatusProblemDamage(priority)
# Damage from poisoning # Damage from poisoning
priority.each do |battler| priority.each do |battler|
@@ -255,9 +265,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round deal damage from effects (except by trapping) # End Of Round deal damage from effects (except by trapping).
#============================================================================= #-----------------------------------------------------------------------------
def pbEOREffectDamage(priority) def pbEOREffectDamage(priority)
# Damage from sleep (Nightmare) # Damage from sleep (Nightmare)
priority.each do |battler| priority.each do |battler|
@@ -278,9 +289,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round deal damage to trapped battlers # End Of Round deal damage to trapped battlers.
#============================================================================= #-----------------------------------------------------------------------------
TRAPPING_MOVE_COMMON_ANIMATIONS = { TRAPPING_MOVE_COMMON_ANIMATIONS = {
:BIND => "Bind", :BIND => "Bind",
:CLAMP => "Clamp", :CLAMP => "Clamp",
@@ -312,9 +324,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round end effects that apply to a battler # End Of Round end effects that apply to a battler.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORCountDownBattlerEffect(priority, effect) def pbEORCountDownBattlerEffect(priority, effect)
priority.each do |battler| priority.each do |battler|
next if battler.fainted? || battler.effects[effect] == 0 next if battler.fainted? || battler.effects[effect] == 0
@@ -394,9 +407,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round end effects that apply to one side of the field # End Of Round end effects that apply to one side of the field.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORCountDownSideEffect(side, effect, msg) def pbEORCountDownSideEffect(side, effect, msg)
return if @sides[side].effects[effect] <= 0 return if @sides[side].effects[effect] <= 0
@sides[side].effects[effect] -= 1 @sides[side].effects[effect] -= 1
@@ -436,9 +450,10 @@ class Battle
_INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam)) _INTL("{1}'s Aurora Veil wore off!", @battlers[side].pbTeam))
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round end effects that apply to the whole field # End Of Round end effects that apply to the whole field.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORCountDownFieldEffect(effect, msg) def pbEORCountDownFieldEffect(effect, msg)
return if @field.effects[effect] <= 0 return if @field.effects[effect] <= 0
@field.effects[effect] -= 1 @field.effects[effect] -= 1
@@ -470,9 +485,10 @@ class Battle
_INTL("Magic Room wore off, and held items' effects returned to normal!")) _INTL("Magic Room wore off, and held items' effects returned to normal!"))
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round end terrain check # End Of Round end terrain check.
#============================================================================= #-----------------------------------------------------------------------------
def pbEOREndTerrain def pbEOREndTerrain
# Count down terrain duration # Count down terrain duration
@field.terrainDuration -= 1 if @field.terrainDuration > 0 @field.terrainDuration -= 1 if @field.terrainDuration > 0
@@ -509,9 +525,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round end self-inflicted effects on battler # End Of Round end self-inflicted effects on battler.
#============================================================================= #-----------------------------------------------------------------------------
def pbEOREndBattlerSelfEffects(battler) def pbEOREndBattlerSelfEffects(battler)
return if battler.fainted? return if battler.fainted?
# Hyper Mode (Shadow Pokémon) # Hyper Mode (Shadow Pokémon)
@@ -541,9 +558,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# End Of Round shift distant battlers to middle positions # End Of Round shift distant battlers to middle positions.
#============================================================================= #-----------------------------------------------------------------------------
def pbEORShiftDistantBattlers def pbEORShiftDistantBattlers
# Move battlers around if none are near to each other # Move battlers around if none are near to each other
# NOTE: This code assumes each side has a maximum of 3 battlers on it, and # NOTE: This code assumes each side has a maximum of 3 battlers on it, and
@@ -596,9 +614,10 @@ class Battle
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Main End Of Round phase method # Main End Of Round phase method.
#============================================================================= #-----------------------------------------------------------------------------
def pbEndOfRoundPhase def pbEndOfRoundPhase
PBDebug.log("") PBDebug.log("")
PBDebug.log("[End of round #{@turnCount + 1}]") PBDebug.log("[End of round #{@turnCount + 1}]")

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
# Fundamental to this object # Fundamental to this object
attr_reader :battle attr_reader :battle
@@ -52,9 +55,10 @@ class Battle::Battler
ACC_EVA_STAGE_DIVISORS = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3] ACC_EVA_STAGE_DIVISORS = [9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3]
STAT_STAGE_MAXIMUM = 6 # Is also the minimum (-6) STAT_STAGE_MAXIMUM = 6 # Is also the minimum (-6)
#============================================================================= #-----------------------------------------------------------------------------
# Complex accessors # Complex accessors.
#============================================================================= #-----------------------------------------------------------------------------
attr_reader :level attr_reader :level
def level=(value) def level=(value)
@@ -130,18 +134,20 @@ class Battle::Battler
@battle.scene.pbRefreshOne(@index) @battle.scene.pbRefreshOne(@index)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Properties from Pokémon # Properties from Pokémon.
#============================================================================= #-----------------------------------------------------------------------------
def happiness; return @pokemon ? @pokemon.happiness : 0; end def happiness; return @pokemon ? @pokemon.happiness : 0; end
def affection_level; return @pokemon ? @pokemon.affection_level : 2; end def affection_level; return @pokemon ? @pokemon.affection_level : 2; end
def gender; return @pokemon ? @pokemon.gender : 0; end def gender; return @pokemon ? @pokemon.gender : 0; end
def nature; return @pokemon ? @pokemon.nature : nil; end def nature; return @pokemon ? @pokemon.nature : nil; end
def pokerusStage; return @pokemon ? @pokemon.pokerusStage : 0; end def pokerusStage; return @pokemon ? @pokemon.pokerusStage : 0; end
#============================================================================= #-----------------------------------------------------------------------------
# Mega Evolution, Primal Reversion, Shadow Pokémon # Mega Evolution, Primal Reversion, Shadow Pokémon.
#============================================================================= #-----------------------------------------------------------------------------
def hasMega? def hasMega?
return false if @effects[PBEffects::Transform] return false if @effects[PBEffects::Transform]
return @pokemon&.hasMegaForm? return @pokemon&.hasMegaForm?
@@ -160,9 +166,10 @@ class Battle::Battler
def inHyperMode?; return false; end def inHyperMode?; return false; end
#============================================================================= #-----------------------------------------------------------------------------
# Display-only properties # Display-only properties.
#============================================================================= #-----------------------------------------------------------------------------
def name def name
return @effects[PBEffects::Illusion].name if @effects[PBEffects::Illusion] return @effects[PBEffects::Illusion].name if @effects[PBEffects::Illusion]
return @name return @name
@@ -242,9 +249,10 @@ class Battle::Battler
return lowerCase ? _INTL("the opposing team") : _INTL("The opposing team") return lowerCase ? _INTL("the opposing team") : _INTL("The opposing team")
end end
#============================================================================= #-----------------------------------------------------------------------------
# Calculated properties # Calculated properties.
#============================================================================= #-----------------------------------------------------------------------------
def pbSpeed def pbSpeed
return 1 if fainted? return 1 if fainted?
stage = @stages[:SPEED] + STAT_STAGE_MAXIMUM stage = @stages[:SPEED] + STAT_STAGE_MAXIMUM
@@ -287,9 +295,10 @@ class Battle::Battler
return [ret, 1].max return [ret, 1].max
end end
#============================================================================= #-----------------------------------------------------------------------------
# Queries about what the battler has # Queries about what the battler has.
#============================================================================= #-----------------------------------------------------------------------------
def plainStats def plainStats
ret = {} ret = {}
ret[:ATTACK] = self.attack ret[:ATTACK] = self.attack
@@ -698,9 +707,10 @@ class Battle::Battler
@battle.belch[@index & 1][@pokemonIndex] = true @battle.belch[@index & 1][@pokemonIndex] = true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Methods relating to this battler's position on the battlefield # Methods relating to this battler's position on the battlefield.
#============================================================================= #-----------------------------------------------------------------------------
# Returns whether the given position belongs to the opposing Pokémon's side. # Returns whether the given position belongs to the opposing Pokémon's side.
def opposes?(i = 0) def opposes?(i = 0)
i = i.index if i.respond_to?("index") i = i.index if i.respond_to?("index")

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= #-----------------------------------------------------------------------------
# Creating a battler # Creating a battler.
#============================================================================= #-----------------------------------------------------------------------------
def initialize(btl, idxBattler) def initialize(btl, idxBattler)
@battle = btl @battle = btl
@index = idxBattler @index = idxBattler
@@ -282,9 +286,10 @@ class Battle::Battler
@effects[PBEffects::Yawn] = 0 @effects[PBEffects::Yawn] = 0
end end
#============================================================================= #-----------------------------------------------------------------------------
# Refreshing a battler's properties # Refreshing a battler's properties.
#============================================================================= #-----------------------------------------------------------------------------
def pbUpdate(fullChange = false) def pbUpdate(fullChange = false)
return if !@pokemon return if !@pokemon
@pokemon.calc_stats @pokemon.calc_stats

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= #-----------------------------------------------------------------------------
# Change HP # Change HP.
#============================================================================= #-----------------------------------------------------------------------------
def pbReduceHP(amt, anim = true, registerDamage = true, anyAnim = true) def pbReduceHP(amt, anim = true, registerDamage = true, anyAnim = true)
amt = amt.round amt = amt.round
amt = @hp if amt > @hp amt = @hp if amt > @hp
@@ -93,9 +97,10 @@ class Battle::Battler
@battle.pbEndPrimordialWeather @battle.pbEndPrimordialWeather
end end
#============================================================================= #-----------------------------------------------------------------------------
# Move PP # Move PP.
#============================================================================= #-----------------------------------------------------------------------------
def pbSetPP(move, pp) def pbSetPP(move, pp)
move.pp = pp move.pp = pp
# No need to care about @effects[PBEffects::Mimic], since Mimic can't copy # No need to care about @effects[PBEffects::Mimic], since Mimic can't copy
@@ -118,9 +123,10 @@ class Battle::Battler
pbSetPP(move, move.pp - 1) if move.pp > 0 pbSetPP(move, move.pp - 1) if move.pp > 0
end end
#============================================================================= #-----------------------------------------------------------------------------
# Change type # Change type.
#============================================================================= #-----------------------------------------------------------------------------
def pbChangeTypes(newType) def pbChangeTypes(newType)
if newType.is_a?(Battle::Battler) if newType.is_a?(Battle::Battler)
newTypes = newType.pbTypes newTypes = newType.pbTypes
@@ -147,9 +153,10 @@ class Battle::Battler
@effects[PBEffects::Roost] = false @effects[PBEffects::Roost] = false
end end
#============================================================================= #-----------------------------------------------------------------------------
# Forms # Forms.
#============================================================================= #-----------------------------------------------------------------------------
def pbChangeForm(newForm, msg) def pbChangeForm(newForm, msg)
return if fainted? || @effects[PBEffects::Transform] || @form == newForm return if fainted? || @effects[PBEffects::Transform] || @form == newForm
oldForm = @form oldForm = @form

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= #-----------------------------------------------------------------------------
# Generalised checks for whether a status problem can be inflicted # Generalised checks for whether a status problem can be inflicted.
#============================================================================= #-----------------------------------------------------------------------------
# NOTE: Not all "does it have this status?" checks use this method. If the # NOTE: Not all "does it have this status?" checks use this method. If the
# check is leading up to curing self of that status condition, then it # check is leading up to curing self of that status condition, then it
# will look at the value of @status directly instead - if it is that # will look at the value of @status directly instead - if it is that
@@ -212,9 +216,10 @@ class Battle::Battler
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Generalised infliction of status problem # Generalised infliction of status problem.
#============================================================================= #-----------------------------------------------------------------------------
def pbInflictStatus(newStatus, newStatusCount = 0, msg = nil, user = nil) def pbInflictStatus(newStatus, newStatusCount = 0, msg = nil, user = nil)
# Inflict the new status # Inflict the new status
self.status = newStatus self.status = newStatus
@@ -269,9 +274,10 @@ class Battle::Battler
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Sleep # Sleep.
#============================================================================= #-----------------------------------------------------------------------------
def asleep? def asleep?
return pbHasStatus?(:SLEEP) return pbHasStatus?(:SLEEP)
end end
@@ -323,9 +329,10 @@ class Battle::Battler
return duration return duration
end end
#============================================================================= #-----------------------------------------------------------------------------
# Poison # Poison.
#============================================================================= #-----------------------------------------------------------------------------
def poisoned? def poisoned?
return pbHasStatus?(:POISON) return pbHasStatus?(:POISON)
end end
@@ -342,9 +349,10 @@ class Battle::Battler
pbInflictStatus(:POISON, (toxic) ? 1 : 0, msg, user) pbInflictStatus(:POISON, (toxic) ? 1 : 0, msg, user)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Burn # Burn.
#============================================================================= #-----------------------------------------------------------------------------
def burned? def burned?
return pbHasStatus?(:BURN) return pbHasStatus?(:BURN)
end end
@@ -361,9 +369,10 @@ class Battle::Battler
pbInflictStatus(:BURN, 0, msg, user) pbInflictStatus(:BURN, 0, msg, user)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Paralyze # Paralyze.
#============================================================================= #-----------------------------------------------------------------------------
def paralyzed? def paralyzed?
return pbHasStatus?(:PARALYSIS) return pbHasStatus?(:PARALYSIS)
end end
@@ -380,9 +389,10 @@ class Battle::Battler
pbInflictStatus(:PARALYSIS, 0, msg, user) pbInflictStatus(:PARALYSIS, 0, msg, user)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Freeze # Freeze.
#============================================================================= #-----------------------------------------------------------------------------
def frozen? def frozen?
return pbHasStatus?(:FROZEN) return pbHasStatus?(:FROZEN)
end end
@@ -395,9 +405,10 @@ class Battle::Battler
pbInflictStatus(:FROZEN, 0, msg, user) pbInflictStatus(:FROZEN, 0, msg, user)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Generalised status displays # Generalised status displays.
#============================================================================= #-----------------------------------------------------------------------------
def pbContinueStatus def pbContinueStatus
if self.status == :POISON && @statusCount > 0 if self.status == :POISON && @statusCount > 0
@battle.pbCommonAnimation("Toxic", self) @battle.pbCommonAnimation("Toxic", self)
@@ -436,9 +447,10 @@ class Battle::Battler
PBDebug.log("[Status change] #{pbThis}'s status was cured") if !showMessages PBDebug.log("[Status change] #{pbThis}'s status was cured") if !showMessages
end end
#============================================================================= #-----------------------------------------------------------------------------
# Confusion # Confusion.
#============================================================================= #-----------------------------------------------------------------------------
def pbCanConfuse?(user = nil, showMessages = true, move = nil, selfInflicted = false) def pbCanConfuse?(user = nil, showMessages = true, move = nil, selfInflicted = false)
return false if fainted? return false if fainted?
if @effects[PBEffects::Confusion] > 0 if @effects[PBEffects::Confusion] > 0
@@ -499,9 +511,10 @@ class Battle::Battler
@effects[PBEffects::Confusion] = 0 @effects[PBEffects::Confusion] = 0
end end
#============================================================================= #-----------------------------------------------------------------------------
# Attraction # Attraction.
#============================================================================= #-----------------------------------------------------------------------------
def pbCanAttract?(user, showMessages = true) def pbCanAttract?(user, showMessages = true)
return false if fainted? return false if fainted?
return false if !user || user.fainted? return false if !user || user.fainted?
@@ -562,9 +575,10 @@ class Battle::Battler
@effects[PBEffects::Attract] = -1 @effects[PBEffects::Attract] = -1
end end
#============================================================================= #-----------------------------------------------------------------------------
# Flinching # Flinching.
#============================================================================= #-----------------------------------------------------------------------------
def pbFlinch(_user = nil) def pbFlinch(_user = nil)
return if hasActiveAbility?(:INNERFOCUS) && !beingMoldBroken? return if hasActiveAbility?(:INNERFOCUS) && !beingMoldBroken?
@effects[PBEffects::Flinch] = true @effects[PBEffects::Flinch] = true

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= #-----------------------------------------------------------------------------
# Increase stat stages # Increase stat stages.
#============================================================================= #-----------------------------------------------------------------------------
def statStageAtMax?(stat) def statStageAtMax?(stat)
return @stages[stat] >= STAT_STAGE_MAXIMUM return @stages[stat] >= STAT_STAGE_MAXIMUM
end end
@@ -113,9 +117,10 @@ class Battle::Battler
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Decrease stat stages # Decrease stat stages.
#============================================================================= #-----------------------------------------------------------------------------
def statStageAtMin?(stat) def statStageAtMin?(stat)
return @stages[stat] <= -STAT_STAGE_MAXIMUM return @stages[stat] <= -STAT_STAGE_MAXIMUM
end end
@@ -364,9 +369,10 @@ class Battle::Battler
return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName) return pbLowerStatStageByCause(:ATTACK, 1, user, user.abilityName)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Reset stat stages # Reset stat stages.
#============================================================================= #-----------------------------------------------------------------------------
def hasAlteredStatStages? def hasAlteredStatStages?
GameData::Stat.each_battle { |s| return true if @stages[s.id] != 0 } GameData::Stat.each_battle { |s| return true if @stages[s.id] != 0 }
return false return false

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= #-----------------------------------------------------------------------------
# Ability trigger checks # Ability trigger checks.
#============================================================================= #-----------------------------------------------------------------------------
def pbAbilitiesOnSwitchOut def pbAbilitiesOnSwitchOut
if abilityActive? if abilityActive?
Battle::AbilityEffects.triggerOnSwitchOut(self.ability, self, false) Battle::AbilityEffects.triggerOnSwitchOut(self.ability, self, false)
@@ -98,9 +102,10 @@ class Battle::Battler
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Ability curing # Ability curing.
#============================================================================= #-----------------------------------------------------------------------------
# Cures status conditions, confusion and infatuation. # Cures status conditions, confusion and infatuation.
def pbAbilityStatusCureCheck def pbAbilityStatusCureCheck
if abilityActive? if abilityActive?
@@ -108,9 +113,10 @@ class Battle::Battler
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Ability effects # Ability effects.
#============================================================================= #-----------------------------------------------------------------------------
# For abilities that grant immunity to moves of a particular type, and raises # For abilities that grant immunity to moves of a particular type, and raises
# one of the ability's bearer's stats instead. # one of the ability's bearer's stats instead.
def pbMoveImmunityStatRaisingAbility(user, move, moveType, immuneType, stat, increment, show_message) def pbMoveImmunityStatRaisingAbility(user, move, moveType, immuneType, stat, increment, show_message)
@@ -165,9 +171,10 @@ class Battle::Battler
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Ability change # Ability change.
#============================================================================= #-----------------------------------------------------------------------------
def pbOnLosingAbility(oldAbil, suppressed = false) def pbOnLosingAbility(oldAbil, suppressed = false)
if oldAbil == :NEUTRALIZINGGAS && (suppressed || !@effects[PBEffects::GastroAcid]) if oldAbil == :NEUTRALIZINGGAS && (suppressed || !@effects[PBEffects::GastroAcid])
pbAbilitiesOnNeutralizingGasEnding pbAbilitiesOnNeutralizingGasEnding
@@ -206,9 +213,10 @@ class Battle::Battler
@battle.pbEndPrimordialWeather @battle.pbEndPrimordialWeather
end end
#============================================================================= #-----------------------------------------------------------------------------
# Held item consuming/removing # Held item consuming/removing.
#============================================================================= #-----------------------------------------------------------------------------
def canConsumeBerry? def canConsumeBerry?
return false if @battle.pbCheckOpposingAbility([:UNNERVE, :ASONECHILLINGNEIGH, :ASONEGRIMNEIGH], @index) return false if @battle.pbCheckOpposingAbility([:UNNERVE, :ASONECHILLINGNEIGH, :ASONEGRIMNEIGH], @index)
return true return true
@@ -285,9 +293,10 @@ class Battle::Battler
pbSymbiosis if !own_item && !fling # Bug Bite/Pluck users trigger Symbiosis pbSymbiosis if !own_item && !fling # Bug Bite/Pluck users trigger Symbiosis
end end
#============================================================================= #-----------------------------------------------------------------------------
# Held item trigger checks # Held item trigger checks.
#============================================================================= #-----------------------------------------------------------------------------
# NOTE: A Pokémon using Bug Bite/Pluck, and a Pokémon having an item thrown at # NOTE: A Pokémon using Bug Bite/Pluck, and a Pokémon having an item thrown at
# it via Fling, will gain the effect of the item even if the Pokémon is # it via Fling, will gain the effect of the item even if the Pokémon is
# affected by item-negating effects. # affected by item-negating effects.
@@ -393,9 +402,10 @@ class Battle::Battler
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Item effects # Item effects.
#============================================================================= #-----------------------------------------------------------------------------
def pbConfusionBerry(item_to_use, forced, confuse_stat, confuse_msg) def pbConfusionBerry(item_to_use, forced, confuse_stat, confuse_msg)
return false if !forced && !canHeal? return false if !forced && !canHeal?
return false if !forced && !canConsumePinchBerry?(Settings::MECHANICS_GENERATION >= 7) return false if !forced && !canConsumePinchBerry?(Settings::MECHANICS_GENERATION >= 7)

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= #-----------------------------------------------------------------------------
# Turn processing # Turn processing.
#============================================================================= #-----------------------------------------------------------------------------
def pbProcessTurn(choice, tryFlee = true) def pbProcessTurn(choice, tryFlee = true)
return false if fainted? return false if fainted?
# Wild roaming Pokémon always flee if possible # Wild roaming Pokémon always flee if possible
@@ -55,9 +59,10 @@ class Battle::Battler
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# #
#============================================================================= #-----------------------------------------------------------------------------
def pbBeginTurn(_choice) def pbBeginTurn(_choice)
# Cancel some lingering effects which only apply until the user next moves # Cancel some lingering effects which only apply until the user next moves
@effects[PBEffects::DestinyBondPrevious] = @effects[PBEffects::DestinyBond] @effects[PBEffects::DestinyBondPrevious] = @effects[PBEffects::DestinyBond]
@@ -131,10 +136,11 @@ class Battle::Battler
pbItemHPHealCheck pbItemHPHealCheck
end end
#============================================================================= #-----------------------------------------------------------------------------
# Simple "use move" method, used when a move calls another move and for Future # Simple "use move" method, used when a move calls another move and for Future
# Sight's attack # Sight's attack.
#============================================================================= #-----------------------------------------------------------------------------
def pbUseMoveSimple(moveID, target = -1, idxMove = -1, specialUsage = true) def pbUseMoveSimple(moveID, target = -1, idxMove = -1, specialUsage = true)
choice = [] choice = []
choice[0] = :UseMove # "Use move" choice[0] = :UseMove # "Use move"
@@ -150,9 +156,10 @@ class Battle::Battler
pbUseMove(choice, specialUsage) pbUseMove(choice, specialUsage)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Master "use move" method # Master "use move" method.
#============================================================================= #-----------------------------------------------------------------------------
def pbUseMove(choice, specialUsage = false) def pbUseMove(choice, specialUsage = false)
# NOTE: This is intentionally determined before a multi-turn attack can # NOTE: This is intentionally determined before a multi-turn attack can
# set specialUsage to true. # set specialUsage to true.
@@ -582,9 +589,10 @@ class Battle::Battler
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Attack a single target # Attack a single target.
#============================================================================= #-----------------------------------------------------------------------------
def pbProcessMoveHit(move, user, targets, hitNum, skipAccuracyCheck) def pbProcessMoveHit(move, user, targets, hitNum, skipAccuracyCheck)
return false if user.fainted? return false if user.fainted?
# For two-turn attacks being used in a single turn # For two-turn attacks being used in a single turn

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= #-----------------------------------------------------------------------------
# Get move's user # Get move's user.
#============================================================================= #-----------------------------------------------------------------------------
def pbFindUser(_choice, _move) def pbFindUser(_choice, _move)
return self return self
end end
@@ -30,9 +34,10 @@ class Battle::Battler
return user return user
end end
#============================================================================= #-----------------------------------------------------------------------------
# Get move's default target(s) # Get move's default target(s).
#============================================================================= #-----------------------------------------------------------------------------
def pbFindTargets(choice, move, user) def pbFindTargets(choice, move, user)
preTarget = choice[3] # A target that was already chosen preTarget = choice[3] # A target that was already chosen
targets = [] targets = []
@@ -90,9 +95,10 @@ class Battle::Battler
return targets return targets
end end
#============================================================================= #-----------------------------------------------------------------------------
# Redirect attack to another target # Redirect attack to another target.
#============================================================================= #-----------------------------------------------------------------------------
def pbChangeTargets(move, user, targets) def pbChangeTargets(move, user, targets)
target_data = move.pbTarget(user) target_data = move.pbTarget(user)
return targets if @battle.switching # For Pursuit interrupting a switch return targets if @battle.switching # For Pursuit interrupting a switch
@@ -167,9 +173,10 @@ class Battle::Battler
return targets return targets
end end
#============================================================================= #-----------------------------------------------------------------------------
# Register target # Register target.
#============================================================================= #-----------------------------------------------------------------------------
def pbAddTarget(targets, user, target, move, nearOnly = true, allowUser = false) def pbAddTarget(targets, user, target, move, nearOnly = true, allowUser = false)
return false if !target || (target.fainted? && !move.targetsPosition?) return false if !target || (target.fainted? && !move.targetsPosition?)
return false if !allowUser && target == user return false if !allowUser && target == user

View File

@@ -1,12 +1,13 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#=============================================================================
# Decide whether the trainer is allowed to tell the Pokémon to use the given # Decide whether the trainer is allowed to tell the Pokémon to use the given
# move. Called when choosing a command for the round. # move. Called when choosing a command for the round.
# Also called when processing the Pokémon's action, because these effects also # Also called when processing the Pokémon's action, because these effects also
# prevent Pokémon action. Relevant because these effects can become active # prevent Pokémon action. Relevant because these effects can become active
# earlier in the same round (after choosing the command but before using the # earlier in the same round (after choosing the command but before using the
# move) or an unusable move may be called by another move such as Metronome. # move) or an unusable move may be called by another move such as Metronome.
#=============================================================================
def pbCanChooseMove?(move, commandPhase, showMessages = true, specialUsage = false) def pbCanChooseMove?(move, commandPhase, showMessages = true, specialUsage = false)
# Disable # Disable
if @effects[PBEffects::DisableMove] == move.id && !specialUsage if @effects[PBEffects::DisableMove] == move.id && !specialUsage
@@ -99,9 +100,9 @@ class Battle::Battler
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Obedience check
#============================================================================= # Obedience check.
# Return true if Pokémon continues attacking (although it may have chosen to # Return true if Pokémon continues attacking (although it may have chosen to
# use a different move in disobedience), or false if attack stops. # use a different move in disobedience), or false if attack stops.
def pbObedienceCheck?(choice) def pbObedienceCheck?(choice)
@@ -175,11 +176,11 @@ class Battle::Battler
return false return false
end end
#============================================================================= #-----------------------------------------------------------------------------
# Check whether the user (self) is able to take action at all. # Check whether the user (self) is able to take action at all.
# If this returns true, and if PP isn't a problem, the move will be considered # If this returns true, and if PP isn't a problem, the move will be considered
# to have been used (even if it then fails for whatever reason). # to have been used (even if it then fails for whatever reason).
#=============================================================================
def pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck) def pbTryUseMove(choice, move, specialUsage, skipAccuracyCheck)
# Check whether it's possible for self to use the given move # Check whether it's possible for self to use the given move
# NOTE: Encore has already changed the move being used, no need to have a # NOTE: Encore has already changed the move being used, no need to have a
@@ -296,10 +297,10 @@ class Battle::Battler
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Initial success check against the target. Done once before the first hit. # Initial success check against the target. Done once before the first hit.
# Includes move-specific failure conditions, protections and type immunities. # Includes move-specific failure conditions, protections and type immunities.
#=============================================================================
def pbSuccessCheckAgainstTarget(move, user, target, targets) def pbSuccessCheckAgainstTarget(move, user, target, targets)
show_message = move.pbShowFailMessages?(targets) show_message = move.pbShowFailMessages?(targets)
typeMod = move.pbCalcTypeMod(move.calcType, user, target) typeMod = move.pbCalcTypeMod(move.calcType, user, target)
@@ -595,10 +596,10 @@ class Battle::Battler
return true return true
end end
#============================================================================= #-----------------------------------------------------------------------------
# Per-hit success check against the target. # Per-hit success check against the target.
# Includes semi-invulnerable move use and accuracy calculation. # Includes semi-invulnerable move use and accuracy calculation.
#=============================================================================
def pbSuccessCheckPerHit(move, user, target, skipAccuracyCheck) def pbSuccessCheckPerHit(move, user, target, skipAccuracyCheck)
# Two-turn attacks can't fail here in the charging turn # Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack] return true if user.effects[PBEffects::TwoTurnAttack]
@@ -617,9 +618,9 @@ class Battle::Battler
return false return false
end end
#============================================================================= #-----------------------------------------------------------------------------
# Message shown when a move fails the per-hit success check above. # Message shown when a move fails the per-hit success check above.
#=============================================================================
def pbMissMessage(move, user, target) def pbMissMessage(move, user, target)
if target.damageState.affection_missed if target.damageState.affection_missed
@battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis)) @battle.pbDisplay(_INTL("{1} avoided the move in time with your shout!", target.pbThis))

View File

@@ -1,7 +1,8 @@
#===============================================================================
#
#===============================================================================
class Battle::Battler class Battle::Battler
#============================================================================= # Effect per hit.
# Effect per hit
#=============================================================================
def pbEffectsOnMakingHit(move, user, target) def pbEffectsOnMakingHit(move, user, target)
if target.damageState.calcDamage > 0 && !target.damageState.substitute if target.damageState.calcDamage > 0 && !target.damageState.substitute
# Target's ability # Target's ability
@@ -82,9 +83,7 @@ class Battle::Battler
end end
end end
#============================================================================= # Effects after all hits (i.e. at end of move usage).
# Effects after all hits (i.e. at end of move usage)
#=============================================================================
def pbEffectsAfterMove(user, targets, move, numHits) def pbEffectsAfterMove(user, targets, move, numHits)
# Defrost # Defrost
if move.damagingMove? if move.damagingMove?

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class Battle::Move class Battle::Move
attr_reader :battle attr_reader :battle
attr_reader :realMove attr_reader :realMove
@@ -28,9 +31,10 @@ class Battle::Move
return @power return @power
end end
#============================================================================= #-----------------------------------------------------------------------------
# Creating a move # Creating a move.
#============================================================================= #-----------------------------------------------------------------------------
def initialize(battle, move) def initialize(battle, move)
@battle = battle @battle = battle
@realMove = move @realMove = move
@@ -68,9 +72,10 @@ class Battle::Move
return Battle::Move::Unimplemented.new(battle, move) return Battle::Move::Unimplemented.new(battle, move)
end end
#============================================================================= #-----------------------------------------------------------------------------
# About the move # About the move.
#============================================================================= #-----------------------------------------------------------------------------
def pbTarget(_user); return GameData::Target.get(@target); end def pbTarget(_user); return GameData::Target.get(@target); end
def total_pp def total_pp

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Move class Battle::Move
#============================================================================= #-----------------------------------------------------------------------------
# Effect methods per move usage # Effect methods per move usage.
#============================================================================= #-----------------------------------------------------------------------------
def pbCanChooseMove?(user, commandPhase, showMessages); return true; end # For Belch def pbCanChooseMove?(user, commandPhase, showMessages); return true; end # For Belch
def pbDisplayChargeMessage(user); end # For Focus Punch/shell Trap/Beak Blast def pbDisplayChargeMessage(user); end # For Focus Punch/shell Trap/Beak Blast
def pbOnStartUse(user, targets); end def pbOnStartUse(user, targets); end
@@ -24,9 +28,10 @@ class Battle::Move
def pbShowFailMessages?(targets); return true; end def pbShowFailMessages?(targets); return true; end
def pbMissMessage(user, target); return false; end def pbMissMessage(user, target); return false; end
#============================================================================= #-----------------------------------------------------------------------------
# #
#============================================================================= #-----------------------------------------------------------------------------
# Whether the move is currently in the "charging" turn of a two-turn move. # Whether the move is currently in the "charging" turn of a two-turn move.
# Is false if Power Herb or another effect lets a two-turn move charge and # Is false if Power Herb or another effect lets a two-turn move charge and
# attack in the same turn. # attack in the same turn.
@@ -56,9 +61,10 @@ class Battle::Move
# For two-turn moves when they charge and attack in the same turn. # For two-turn moves when they charge and attack in the same turn.
def pbQuickChargingMove(user, targets); end def pbQuickChargingMove(user, targets); end
#============================================================================= #-----------------------------------------------------------------------------
# Effect methods per hit # Effect methods per hit.
#============================================================================= #-----------------------------------------------------------------------------
def pbOverrideSuccessCheckPerHit(user, target); return false; end def pbOverrideSuccessCheckPerHit(user, target); return false; end
def pbCrashDamage(user); end def pbCrashDamage(user); end
def pbInitialEffect(user, targets, hitNum); end def pbInitialEffect(user, targets, hitNum); end
@@ -83,9 +89,10 @@ class Battle::Move
def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers); end def pbSwitchOutTargetEffect(user, targets, numHits, switched_battlers); end
def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers); end def pbEndOfMoveUsageEffect(user, targets, numHits, switchedBattlers); end
#============================================================================= #-----------------------------------------------------------------------------
# Check if target is immune to the move because of its ability # Check if target is immune to the move because of its ability.
#============================================================================= #-----------------------------------------------------------------------------
def pbImmunityByAbility(user, target, show_message) def pbImmunityByAbility(user, target, show_message)
ret = false ret = false
if target.abilityActive? && !target.beingMoldBroken? if target.abilityActive? && !target.beingMoldBroken?
@@ -95,9 +102,10 @@ class Battle::Move
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Move failure checks # Move failure checks.
#============================================================================= #-----------------------------------------------------------------------------
# Check whether the move fails completely due to move-specific requirements. # Check whether the move fails completely due to move-specific requirements.
def pbMoveFailed?(user, targets); return false; end def pbMoveFailed?(user, targets); return false; end
# Checks whether the move will be ineffective against the target. # Checks whether the move will be ineffective against the target.
@@ -156,9 +164,10 @@ class Battle::Move
return false return false
end end
#============================================================================= #-----------------------------------------------------------------------------
# Weaken the damage dealt (doesn't actually change a battler's HP) # Weaken the damage dealt (doesn't actually change a battler's HP).
#============================================================================= #-----------------------------------------------------------------------------
def pbCheckDamageAbsorption(user, target) def pbCheckDamageAbsorption(user, target)
# Substitute will take the damage # Substitute will take the damage
if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) && if target.effects[PBEffects::Substitute] > 0 && !ignoresSubstitute?(user) &&
@@ -225,9 +234,10 @@ class Battle::Move
target.damageState.totalHPLost += damage target.damageState.totalHPLost += damage
end end
#============================================================================= #-----------------------------------------------------------------------------
# Change the target's HP by the amount calculated above # Change the target's HP by the amount calculated above.
#============================================================================= #-----------------------------------------------------------------------------
def pbInflictHPDamage(target) def pbInflictHPDamage(target)
if target.damageState.substitute if target.damageState.substitute
target.effects[PBEffects::Substitute] -= target.damageState.hpLost target.effects[PBEffects::Substitute] -= target.damageState.hpLost
@@ -236,9 +246,10 @@ class Battle::Move
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Animate the damage dealt, including lowering the HP # Animate the damage dealt, including lowering the HP.
#============================================================================= #-----------------------------------------------------------------------------
# Animate being damaged and losing HP (by a move) # Animate being damaged and losing HP (by a move)
def pbAnimateHitAndHPLost(user, targets) def pbAnimateHitAndHPLost(user, targets)
# Animate allies first, then foes # Animate allies first, then foes
@@ -269,9 +280,10 @@ class Battle::Move
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Messages upon being hit # Messages upon being hit.
#============================================================================= #-----------------------------------------------------------------------------
def pbEffectivenessMessage(user, target, numTargets = 1) def pbEffectivenessMessage(user, target, numTargets = 1)
return if self.is_a?(Battle::Move::FixedDamageMove) return if self.is_a?(Battle::Move::FixedDamageMove)
return if target.damageState.disguise || target.damageState.iceFace return if target.damageState.disguise || target.damageState.iceFace

View File

@@ -1,7 +1,11 @@
#===============================================================================
#
#===============================================================================
class Battle::Move class Battle::Move
#============================================================================= #-----------------------------------------------------------------------------
# Move's type calculation # Move's type calculation.
#============================================================================= #-----------------------------------------------------------------------------
def pbBaseType(user) def pbBaseType(user)
ret = @type ret = @type
if ret && user.abilityActive? if ret && user.abilityActive?
@@ -26,9 +30,10 @@ class Battle::Move
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Type effectiveness calculation # Type effectiveness calculation.
#============================================================================= #-----------------------------------------------------------------------------
def pbCalcTypeModSingle(moveType, defType, user, target) def pbCalcTypeModSingle(moveType, defType, user, target)
ret = Effectiveness.calculate(moveType, defType) ret = Effectiveness.calculate(moveType, defType)
if Effectiveness.ineffective_type?(moveType, defType) if Effectiveness.ineffective_type?(moveType, defType)
@@ -78,9 +83,10 @@ class Battle::Move
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Accuracy check # Accuracy check.
#============================================================================= #-----------------------------------------------------------------------------
def pbBaseAccuracy(user, target); return @accuracy; end def pbBaseAccuracy(user, target); return @accuracy; end
# Accuracy calculations for one-hit KO moves are handled elsewhere. # Accuracy calculations for one-hit KO moves are handled elsewhere.
@@ -166,9 +172,10 @@ class Battle::Move
modifiers[:evasion_stage] = 0 if user.hasActiveAbility?(:MINDSEYE) modifiers[:evasion_stage] = 0 if user.hasActiveAbility?(:MINDSEYE)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Critical hit check # Critical hit check.
#============================================================================= #-----------------------------------------------------------------------------
# Return values: # Return values:
# -1: Never a critical hit. # -1: Never a critical hit.
# 0: Calculate normally. # 0: Calculate normally.
@@ -220,9 +227,10 @@ class Battle::Move
return false return false
end end
#============================================================================= #-----------------------------------------------------------------------------
# Damage calculation # Damage calculation.
#============================================================================= #-----------------------------------------------------------------------------
def pbBaseDamage(baseDmg, user, target); return baseDmg; end def pbBaseDamage(baseDmg, user, target); return baseDmg; end
def pbBaseDamageMultiplier(damageMult, user, target); return damageMult; end def pbBaseDamageMultiplier(damageMult, user, target); return damageMult; end
def pbModifyDamage(damageMult, user, target); return damageMult; end def pbModifyDamage(damageMult, user, target); return damageMult; end
@@ -505,9 +513,10 @@ class Battle::Move
multipliers[:final_damage_multiplier] = pbModifyDamage(multipliers[:final_damage_multiplier], user, target) multipliers[:final_damage_multiplier] = pbModifyDamage(multipliers[:final_damage_multiplier], user, target)
end end
#============================================================================= #-----------------------------------------------------------------------------
# Additional effect chance # Additional effect chance.
#============================================================================= #-----------------------------------------------------------------------------
def pbAdditionalEffectChance(user, target, effectChance = 0) def pbAdditionalEffectChance(user, target, effectChance = 0)
return 0 if target.hasActiveAbility?(:SHIELDDUST) && !target.beingMoldBroken? return 0 if target.hasActiveAbility?(:SHIELDDUST) && !target.beingMoldBroken?
ret = (effectChance > 0) ? effectChance : @addlEffect ret = (effectChance > 0) ? effectChance : @addlEffect

View File

@@ -1,4 +1,6 @@
#===============================================================================
# Battle scene (the visuals of the battle) # Battle scene (the visuals of the battle)
#===============================================================================
class Battle::Scene class Battle::Scene
attr_accessor :abortable # For non-interactive battles, can quit immediately attr_accessor :abortable # For non-interactive battles, can quit immediately
attr_reader :viewport attr_reader :viewport
@@ -73,9 +75,10 @@ class Battle::Scene
return ret return ret
end end
#============================================================================= #-----------------------------------------------------------------------------
# Updating and refreshing # Updating and refreshing.
#============================================================================= #-----------------------------------------------------------------------------
def pbUpdate(cw = nil) def pbUpdate(cw = nil)
pbGraphicsUpdate pbGraphicsUpdate
pbInputUpdate pbInputUpdate
@@ -139,17 +142,19 @@ class Battle::Scene
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Party lineup # Party lineup.
#============================================================================= #-----------------------------------------------------------------------------
# Returns whether the party line-ups are currently coming on-screen # Returns whether the party line-ups are currently coming on-screen
def inPartyAnimation? def inPartyAnimation?
return @animations.length > 0 return @animations.length > 0
end end
#============================================================================= #-----------------------------------------------------------------------------
# Window displays # Window displays.
#============================================================================= #-----------------------------------------------------------------------------
def pbShowWindow(windowType) def pbShowWindow(windowType)
# NOTE: If you are not using fancy graphics for the command/fight menus, you # NOTE: If you are not using fancy graphics for the command/fight menus, you
# will need to make "messageBox" also visible if the windowtype if # will need to make "messageBox" also visible if the windowtype if
@@ -307,9 +312,10 @@ class Battle::Scene
end end
end end
#============================================================================= #-----------------------------------------------------------------------------
# Sprites # Sprites.
#============================================================================= #-----------------------------------------------------------------------------
def pbAddSprite(id, x, y, filename, viewport) def pbAddSprite(id, x, y, filename, viewport)
sprite = @sprites[id] || IconSprite.new(x, y, viewport) sprite = @sprites[id] || IconSprite.new(x, y, viewport)
if filename if filename
@@ -348,9 +354,10 @@ class Battle::Scene
pbRefresh pbRefresh
end end
#============================================================================= #-----------------------------------------------------------------------------
# Phases # Phases.
#============================================================================= #-----------------------------------------------------------------------------
def pbBeginCommandPhase def pbBeginCommandPhase
@sprites["messageWindow"].text = "" @sprites["messageWindow"].text = ""
end end
@@ -371,9 +378,10 @@ class Battle::Scene
pbDisposeSprites pbDisposeSprites
end end
#============================================================================= #-----------------------------------------------------------------------------
# #
#============================================================================= #-----------------------------------------------------------------------------
def pbSelectBattler(idxBattler, selectMode = 1) def pbSelectBattler(idxBattler, selectMode = 1)
numWindows = @battle.sideSizes.max * 2 numWindows = @battle.sideSizes.max * 2
numWindows.times do |i| numWindows.times do |i|
@@ -401,9 +409,10 @@ class Battle::Scene
@lastMove[idxBattler] = 0 @lastMove[idxBattler] = 0
end end
#============================================================================= #-----------------------------------------------------------------------------
# #
#============================================================================= #-----------------------------------------------------------------------------
# This method is called when the player wins a wild Pokémon battle. # This method is called when the player wins a wild Pokémon battle.
# This method can change the battle's music for example. # This method can change the battle's music for example.
def pbWildBattleSuccess def pbWildBattleSuccess

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