|
#1
|
||||
|
||||
|
Este es el evento:
Código:
Pagina 1 bacía. Pagina 2: Detonante de inicio: Inicio automatico. Condiciones de aparición: Interruptor 2 activado. Contenido: Reproducir efecto sonoro: 'saint6':80,100 Esperar 100 frames. Parar efecto sonoro. Activar interruptor 3 Pagina 3: Detonante de inicio: Inicio automatico. Condiciones de aparición: interruptor 3 activado. Contenido: Llamar script: $game_message.shown_lines = 5 $game_message.message_height += 24 Texto+ Texto+ Texto+ [SPOILER] Código:
#==============================================================================
# Advanced Text System
# Version: 2.0c
# Author: modern algebra (rmrk.net)
# Date: September 21, 2008
# First Version Date: March 18, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Thanks: *Zeriab*, for his excellent tutorial on Regular Expressions. Without
# it, this script could not exist. As well, his help with the Paragraph
# Formatter and his algorithm for set width fonts is invaluable. As well,
# he added in the \se feature, and by extension, \me feature
# *Seasons In the Abyss*, for a few of the ideas that he had in some of
# his message systems from RMXP
# *Arrow-1*, for the idea of animated facesets, \se, and the primary
# motivation for this script
# *Irock*, for the idea of termination/opening sound effects
# *PhantomH* for the suggestion of the ability to directly set the
# position of the Choicebox and Namebox, instead of it being determined
# only in relation to the message box
# *StoneWall* Switch Conditioned Options in the Choice box
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
# Basically: paste this script above Main and Below Materials in the Script
# Editor. If you intend to use the Paragraph Format feature of this script,
# then it is also necessary to paste the Paragraph Formatter above this entry
# in the editor. The Paragraph formatter can be found in the RMVX Scripts
# Database of rmrk.net - http://rmrk.net/index.php/topic,25129.0.html
#
# Now, the best way to learn how to use this script is to refer to the demo
# and the Configuration area of this script (starting at line 215), but I will
# here provide a list of commands and special message codes for reference.
#
# ~~Settings~~
# Settings can be changed in either $game_ats or $game_message, the primary
# difference being that $game_ats modifies the default settings of the script,
# while $game_message only modifies the settings for the next Show Text
# command (or multiple Show Text commands if .appended_text is true). So that
# means that modifying $game_ats will change that setting for every message,
# while $game_message only for the one immediately following. One
# thing to be noted is that when you do change the $game_ats, you will need
# to use the code $game_message.clear to make it so that they will apply to
# the very next message, rather than just all messages after that. Anyway,
# this is the complete list of setting commands. Note that I only use .command
# to indicate that it could be either $game_ats or $game_message prefacing
# these commands.
#
# .message_x = integer (-1 for default placement)
# .message_y = integer (-1 for default placement)
# .message_width = positive integer
# .message_height = positive integer
# .message_opacity = integer (between 0 and 255)
# .message_fontname = ["font", font"] EX: ["Arial", "Times New Roman"]
# .message_fontsize = integer > 8
# .message_colour = integer between 0 and 31 or Color object
# .message_windowskin = "Window File"
# .skip_disabled = true/false
# .wlh = integer (Window Line Height)
# .paragraph_format = true/false
# .justified_text = true/false
# .appended_text = true/false
# .scrolling = true/false
# .shown_lines = positive integer
# .autopause = true/false
# .faceside = true/false (true => Left, false => Right
# .face_x = integer (-1 for default placement)
# .face_y = integer (-1 for default placement)
# .face_width = positive integer
# .face_height = positive integer
# .face_offset_x = integer
# .face_offset_y = integer
# .face_mirror = true/false
# .face_opacity = integer (between 0 and 255)
# .face_window = true/false
# .face_window_opacity = integer (between 0 and 255)
# .face_windowskin = "Window File"
# .choicebox = true/false
# .choices_appended = true/false
# .choicebox_on_line = true/false
# .choicebox_fitted = true/false
# .choicebox_width = integer
# .choicebox_opacity = integer (between 0 and 255)
# .choicebox_windowskin
# .choicebox_fontname = ["font", font"] EX: ["Arial", "Times New Roman"]
# .choicebox_colour = integer between 0 and 31 or Color object
# .choicebox_offset_x = integer
# .choicebox_offset_y = integer
# .choicebox_x = integer (-1 for default placement)
# .choicebox_y = integer (-1 for default placement)
# .row_max = integer
# .column_max = integer
# .lbl_se = true/false
# .message_se = "filename", volume, pitch (volume / pitch not necessary)
# .mt_se = true/false
# .termination_se = "filename", volume, pitch (volume / pitch not necessary)
# .mp_se = true/false
# .pause_se = "filename", volume, pitch (volume / pitch not necessary)
# .ms_se = true/false
# .start_se = "filename", volume, pitch (volume / pitch not necessary)
# .mf_se = true/false
# .finish_se = "filename", volume, pitch (volume / pitch not necessary)
# .letter_frames = positive integer
# .face_letters = positive integer
# .sound_letters = positive integer
# .namebox_windowskin = "Window File"
# .namebox_colour = integer between 0 and 31 or Color object
# .namebox_fontname = ["font", font"] EX: ["Arial", "Times New Roman"]
# .namebox_fontsize = integer > 8
# .namebox_offset_x = integer
# .namebox_offset_y = integer
# .namebox_x = integer (-1 for default placement)
# .namebox_y = integer (-1 for default placement)
# .namebox_opacity = integer (between 0 and 255)
# .back_sprite = "Name of File in Graphics/System"
#
# Two codes to exist in $game_message and not $game_ats are:
# $game_message.character = event_id or 0 for player
# $game_message.char_ref = 0-3 referring to Under, Left, Right, and Above
#
# Those codes set the text box to appear in position with reference to a
# character on the map. They are the same as the \uc (Under) \lc (Left)
# \rc (Right) and \oc (Over) commands. For more info, read below.
#
# ~~Special Message Codes~~
# Retained Codes:
# \v[x] - Shows the value located in the variable x
# \n[x] - Shows the name of the Actor with ID x
# \c[x] - Changes the colour of the text to x. x can be 0 - 31
# \g - Shows the gold window
# \. - A short pause of 15 frames (1/4 second) before continuing drawing
# \| - A longer pause of 60 frames (1 second) before continuing drawing
# \! - Pause. Waits for user input before continuing
# \^ - Pause Skip. Forgoes user input at next pause. Can autoclose message
# Modified Codes:
# \> - Speeds up the letter by letter process
# \< - Slows down the drawing of the text
# \@ - Show Line Fast (the current line gets displayed quickly). This
# replaces the old functionality of \>, \<
# \@@ - Show message fast (to next scroll)
# New Codes:
# \pid[x] - Shows Actor ID of Party Member in position X (0-3)
# \nc[x]- Shows the name of class with ID x
# \np[x]- Shows the name of the Party Member with index x
# \ne[x]- Shows the name of Event with ID x on the map
# \nm[x]- Shows the name of Monster with ID x
# \ni[x]- Shows the name of Item with ID x
# \nw[x]- Shows the name of Weapon with ID x
# \na[x]- Shows the name of Armour with ID x
# \pi[x]- Shows the price of Item with ID x
# \pw[x]- Shows the price of Weapon with ID x
# \pa[x]- Shows the price of Armour with ID x
# \iicon[x] - Shows the Icon of Item with ID x
# \wicon[x] - Shows the Icon of Weapon with ID x
# \aicon[x] - Shows the Icon of Armour with ID x
# \icon[x] - Shows the Icon with ID x
# \fn[font name] - Changes the font to font name chosen
# \fs[x] - Changes the font size to x
# \name[name] - Shows a name box with name displayed in the box
# \nb[name] - same as \name - just a shorter code
# \ani[target_id,animation_id] - Shows animation_id on target_id. 0 => player,
# other numbers indicate the ID of the event
# \bln[target_id,balloon_id] - Same as ani, but shows a balloon
# \lb - Line Break. Applies only when Paragraph Formatting and it goes
# to next line
# \% - Disable Text Skip through user input
# \se[sound effect name] - Plays a sound effect
# \me[music effect name] - Plays a musical effect
# \oc[character_id] - positions the message box over character. 0 => player;
# other positive integers indicate events on map
# \uc[character_id] - same as oc, but places box under character
# \lc[character_id] - same as oc, but places box to left of character
# \rc[character_id] - same as oc, but places box to right of character
# \mxy[x, y] - Sets the message box's position to x, y
# \fxy[x, y] - Sets the face box's position to x, y
# \vocab[value] - prints vocab for that item type. Suitable values for this
# are: level, level_a, hp, hp_a, mp, mp_a, atk, def, spi,
# agi, weapon, armor1, armor2, armor3, armor4, weapon1,
# weapon2, attack, skill, guard, item, equip, status, save,
# game_end, fight, escape, new_game, shutdown, to_title,
# continue, cancel, gold
# \f[key] - Show Filter phrase attached to key
# \b - Toggles Bold
# \i - Toggles Italic
# \u - Toggles Underline
# \s - Toggles Shadow
# \hl[x] - Highlights with color x. \hl toggles off
# \ac[x]- Shows class of actor with ID x
# \a..[x] - Shows the .. of Actor X. .. can be any of the following:
# hp, maxhp, mp, maxmp, atk, def, spi, agi, exp_s, next_exp_s,
# next_rest_exp_s, level, weapon_id, armor1_id, armor2_id,
# armor3_id, armor4_id - and any other methods from Game_Actor.
# \c - Centres text
# \r - Sets right alignment to text
#
# There are two commands that can be used only in a choicebox, and these are:
# \SOFF[switch ID]
# \SON[switch ID]
# These two commands mean that the choice they appear in will only be
# available if the switch with ID switch ID is OFF or ON respectively. Thus,
# having \SON[5] means the choice will only be possible itf Switch 5 is on.
#==============================================================================
#==============================================================================
# ** Game_ATS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This class holds all of the default data for the Advanced Text options
#==============================================================================
class Game_ATS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * CONFIGURATION
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Default X,Y position of Window --
# This option allows you to set a default value for the X position of the
# message window. Setting this value to -1 will make the window obey the
# default position settings of the Top/Middle/Bottom options
MESSAGE_WINDOW_X = -1
MESSAGE_WINDOW_Y = -1
# Default Width of Message Window
DEFAULT_WINDOW_WIDTH = 544
# Default Height of Message Window
DEFAULT_WINDOW_HEIGHT = 128
# The back opacity of the Message Window
MESSAGE_OPACITY = 200
# The default colour of messages
MESSAGE_COLOUR = 0 # The default colour of text in message window [0-31]
# The font of the Message Window
FONT_NAME = ["Verdana", "Arial", "Courier New"]
# The Size of the font in the message window
FONT_SIZE = 20
# The ability to skip the letter by letter drawing text
SKIP_DISABLED = false
# Message Box Windowskin
WINDOWSKIN = "Window"
# How many pixels between the y_position of one line and the next. This
# overrides the WLH constant of Window_Base, but only for messages. It
# remains the same for all other scripts
WLH = 24
# Redistributes the lines dependent on line length. The Paragraph Formatter
# v. 1.1 is required for this to work. You can find it at:
# http://rmrk.net/index.php/topic,25129.0.html
PARAGRAPH_FORMAT = true
# Should each line end at the same point? Icons and inaccurate text_size
# commands may cause this to be inaccurate.
JUSTIFIED_TEXT = false
# Is text from adjacent messages shown in the same message box?
APPENDED_TEXT = true
# Should the message box not wait for input when displaying appended text
# boxes?
SCROLLING = true
# How many lines should be drawn before the text scrolls. This overrides
# Window_Message::MAX_LINES
SHOWN_LINES = 4
# Should a pause be inserted before scrolling each visible block?
AUTO_PAUSE_ON_SCROLL = false
# Which side of the message window the face is on: true => left, false => right
FACE_SIDE = true
# Default Face Position. If this is set to -1 it will obey the regular ways of
# setting face position. If they are any other numbers it will default to that
# position always
FACE_X = -1
FACE_Y = -1
# Default Size of Faces
FACE_WIDTH = 96
FACE_HEIGHT = 96
# If Face position set to message window, should there be an offset to the
# default?
FACE_OFFSET_X = 0
FACE_OFFSET_Y = 0
# Default should faces be drawn mirrored?
FACE_MIRROR = false
# What should face opacity itself be
FACE_OPACITY = 255
# Should the face be in it's own window?
FACE_WINDOW = false
# What should the opacity of the Face Window be?
FACE_WINDOW_OPACITY = 255
# Windowskin for Face?
FACE_WINDOWSKIN = "Window"
# Whether to use traditional choice branching or special. It essentially
# makes the choices appear in a box, rather than in the Message Window
CHOICEBOX = true
# The following indented constants only matter when CHOICEBOX is true
# When Choice branches are subsequent, the choice branches are made into one
CHOICES_APPENDED = true
# Choicebox position. true => adjacent to Message Window;
# false => above Message Window
# Paragraph Format recommended if CHOICEBOX_ON_LINE set to true
CHOICEBOX_ON_LINE = false
# Should the Choicebox be as large as necessry to accomodate the longest
# option?
CHOICEBOX_FITTED = true
# The width of the choicebox, assuming CHOICEBOX_FITTED is false
CHOICEBOX_WIDTH = 160
# The back opacity of the choicebox
CHOICEBOX_OPACITY = 200
# The windowskin of the choicebox
CHOICEBOX_WINDOWSKIN = "Window"
# The font of the choicebox
CHOICEBOX_FONTNAME = ["Verdana", "Arial", "Courier New"]
# The Default Choice Colour
CHOICE_COLOUR = 0 # The default colour of text in the Choicebox [0-31]
# The offset in the X direction of the Choice Box
CHOICEBOX_OFFSET_X = 16
CHOICEBOX_OFFSET_Y = 16
# CHOICEBOX_X,Y - if these values are > -1 or < width of the screen, normal
# choicebox placement based on message window is ignored and the choicebox
# is set directly by these values
CHOICEBOX_X = -1
CHOICEBOX_Y = -1
# The number of rows before the box starts scrolling
MAX_ROWS = 4
MAX_COLUMNS = 1
# When this is true, it will play aa sound effect as it is drawing text
LETTER_BY_LETTER_SOUND = true
# The SE played when LETTER_BY_LETTER_SOUND is true
MESSAGE_SE = "Cursor"
# Should an SE be played when a message is terminated? true => yes, false => no
MESSAGE_TERMINATION_SOUND = false
# What SE ought to be played upon message termination
TERMINATION_SE = 'Cancel'
# Should an SE be played when player passes a pause?
MESSAGE_PAUSE_SOUND = false
# What SE ought to be played upon resuming
PAUSE_SE = 'Decision2'
# Should an SE be played when the message opens?
MESSAGE_START_SOUND = false
# What SE ought to be played upon message start
START_SE = 'Chime2'
# Should an SE be played when the message finishes?
MESSAGE_FINISH_SOUND = false
# What SE ought to be played upon finishing
FINISH_SE = 'Chime1'
# How many frames between drawing each letter, in general
LETTER_FRAMES = 1
# How many letters drawn between face toggling with animated facesets?
LETTERS_PER_FACE = 3
# How many letters drawn between playing the sound effect?
LETTERS_PER_SOUND = 2
# ~Namebox Settings~
NAMEBOX_WINDOWSKIN = "Window" # The windowskin for the name box
NAMEBOX_COLOUR = 0 # The Color of the text in the namebox [0-31]
NAMEBOX_FONTNAME = ["Verdana", "Arial", "Courier New"] # The Font of the namebox
NAMEBOX_FONTSIZE = 20 # The Size of the text in the namebox
NAMEBOX_OFFSET_X = 16 # How much the Namebox is in the X direction away from default
NAMEBOX_OFFSET_Y = 16 # How much the Namebox is in the Y direction away from default
# NAMEBOX_X,Y - if these values are > -1 or < width of the screen, normal
# choicebox placement based on message window is ignored and the choicebox
# is set directly by these values
NAMEBOX_X = -1
NAMEBOX_Y = -1
NAMEBOX_OPACITY = 160 # The opacity of the name box
BACK_SPRITE = "MessageBack" # The sprite shown when option selected
FILTERS = {}
# FILTERS allows you to set a filter and replace any \F[x] code with it's
# corresponding Entry in the Hash. Leave the FILTERS = {} line alone and
# below it, you can set all of the codes you will want to be able to put
# as an argument in the \F code.
FILTERS['ATS'] = '\c[1]Advanced Text System\c[0], Version 2.0'
FILTERS[0] = 'Numbered filters work too'
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :message_x
attr_accessor :message_y
attr_accessor :message_width
attr_accessor :message_height
attr_accessor :message_opacity
attr_accessor :message_fontname
attr_accessor :message_fontsize
attr_accessor :message_colour
attr_accessor :message_windowskin
attr_accessor :skip_disabled
attr_accessor :wlh
attr_accessor :paragraph_format
attr_accessor :justified_text
attr_accessor :appended_text
attr_accessor :scrolling
attr_accessor :shown_lines
attr_accessor :autopause
attr_accessor :faceside
attr_accessor :face_x
attr_accessor :face_y
attr_accessor :face_width
attr_accessor :face_height
attr_accessor :face_offset_x
attr_accessor :face_offset_y
attr_accessor :face_mirror
attr_accessor :face_opacity
attr_accessor :face_window
attr_accessor :face_window_opacity
attr_accessor :face_windowskin
attr_accessor :choicebox
attr_accessor :choices_appended
attr_accessor :choicebox_on_line
attr_accessor :choicebox_fitted
attr_accessor :choicebox_width
attr_accessor :choicebox_opacity
attr_accessor :choicebox_windowskin
attr_accessor :choicebox_fontname
attr_accessor :choicebox_colour
attr_accessor :choicebox_offset_x
attr_accessor :choicebox_offset_y
attr_accessor :choicebox_x
attr_accessor :choicebox_y
attr_accessor :row_max
attr_accessor :column_max
attr_accessor :lbl_se
attr_reader :message_se
attr_accessor :mt_se
attr_reader :termination_se
attr_accessor :mp_se
attr_reader :pause_se
attr_accessor :ms_se
attr_reader :start_se
attr_accessor :mf_se
attr_reader :finish_se
attr_accessor :letter_frames
attr_accessor :face_letters
attr_accessor :sound_letters
attr_accessor :namebox_windowskin
attr_accessor :namebox_colour
attr_accessor :namebox_fontname
attr_accessor :namebox_fontsize
attr_accessor :namebox_offset_x
attr_accessor :namebox_offset_y
attr_accessor :namebox_x
attr_accessor :namebox_y
attr_accessor :namebox_opacity
attr_accessor :back_sprite
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize
reset
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Reset
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def reset
@message_x = MESSAGE_WINDOW_X
@message_y = MESSAGE_WINDOW_Y
@message_width = DEFAULT_WINDOW_WIDTH
@message_height = DEFAULT_WINDOW_HEIGHT
@message_opacity = MESSAGE_OPACITY
@message_fontname = FONT_NAME
@message_fontsize = FONT_SIZE
@message_colour = MESSAGE_COLOUR
@message_windowskin = WINDOWSKIN
@skip_disabled = SKIP_DISABLED
@wlh = WLH
@paragraph_format = PARAGRAPH_FORMAT
@justified_text = JUSTIFIED_TEXT
@appended_text = APPENDED_TEXT
@scrolling = SCROLLING
@shown_lines = SHOWN_LINES
@autopause = AUTO_PAUSE_ON_SCROLL
@faceside = FACE_SIDE
@face_x = FACE_X
@face_y = FACE_Y
@face_width = FACE_WIDTH
@face_height = FACE_HEIGHT
@face_offset_x = FACE_OFFSET_X
@face_offset_y = FACE_OFFSET_Y
@face_mirror = FACE_MIRROR
@face_opacity = FACE_OPACITY
@face_window = FACE_WINDOW
@face_windowskin = FACE_WINDOWSKIN
@face_window_opacity = FACE_WINDOW_OPACITY
@choicebox = CHOICEBOX
@choicebox_on_line = CHOICEBOX_ON_LINE
@choices_appended = CHOICES_APPENDED
@choicebox_fitted = CHOICEBOX_FITTED
@choicebox_width = CHOICEBOX_WIDTH
@choicebox_opacity = CHOICEBOX_OPACITY
@choicebox_windowskin = CHOICEBOX_WINDOWSKIN
@choicebox_fontname = CHOICEBOX_FONTNAME
@choicebox_colour = CHOICE_COLOUR
@choicebox_offset_x = CHOICEBOX_OFFSET_X
@choicebox_offset_y = CHOICEBOX_OFFSET_Y
@choicebox_x = CHOICEBOX_X
@choicebox_y = CHOICEBOX_Y
@row_max = MAX_ROWS
@column_max = MAX_COLUMNS
@lbl_se = LETTER_BY_LETTER_SOUND
self.message_se = MESSAGE_SE
@mt_se = MESSAGE_TERMINATION_SOUND
self.termination_se = TERMINATION_SE
@mp_se = MESSAGE_PAUSE_SOUND
self.pause_se = PAUSE_SE
@ms_se = MESSAGE_START_SOUND
self.start_se = START_SE
@mf_se = MESSAGE_FINISH_SOUND
self.finish_se = FINISH_SE
@letter_frames = LETTER_FRAMES
@face_letters = LETTERS_PER_FACE
@sound_letters = LETTERS_PER_SOUND
@namebox_windowskin = NAMEBOX_WINDOWSKIN
@namebox_colour = NAMEBOX_COLOUR
@namebox_fontname = NAMEBOX_FONTNAME
@namebox_fontsize = NAMEBOX_FONTSIZE
@namebox_offset_x = NAMEBOX_OFFSET_X
@namebox_offset_y = NAMEBOX_OFFSET_Y
@namebox_x = NAMEBOX_X
@namebox_y = NAMEBOX_Y
@namebox_opacity = NAMEBOX_OPACITY
@back_sprite = BACK_SPRITE
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Sound Effect
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_sound_effect (settings)
if settings.is_a? (Array)
name, volume, pitch = settings
volume = 100 if volume == nil
pitch = 100 if pitch == nil
else
name, volume, pitch = settings, 100, 100
end
return RPG::SE.new (name, volume, pitch)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Message SE =
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def message_se= (settings)
@message_se = set_sound_effect (settings)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Termination SE =
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def termination_se= (settings)
@termination_se = set_sound_effect (settings)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Pause SE =
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def pause_se= (settings)
@pause_se = set_sound_effect (settings)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start SE =
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def start_se= (settings)
@start_se = set_sound_effect (settings)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Finish SE =
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def finish_se= (settings)
@finish_se = set_sound_effect (settings)
end
end
#==============================================================================
# ** Game_Message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# Entire Class Overwritten
# new methods - convert_special_characters, perform_substitution, se_play,
# extract_special_codes, restore_special_codes
#==============================================================================
class Game_Message < Game_ATS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :texts # arrange text (by line)
attr_accessor :face_name # face graphic filename
attr_accessor :face_index # face graphic index
attr_accessor :background # background type
attr_accessor :position # display position
attr_accessor :main_proc # main callback (Proc)
attr_accessor :choice_proc # show choices: callback (Proc)
attr_accessor :choice_start # show choices: opening line
attr_accessor :choice_max # show choices: number of items
attr_accessor :choice_cancel_type # show choices: cancel
attr_accessor :num_input_variable_id # input number: variable ID
attr_accessor :num_input_digits_max # input number: digit count
attr_accessor :visible # displaying a message
# Not from $game_ats
attr_accessor :character
attr_accessor :char_ref
attr_accessor :highlight
attr_accessor :underline
attr_accessor :appending_text
attr_accessor :choice_texts
attr_accessor :old_backsprite
attr_accessor :battle_interpreter
attr_accessor :old_choice_cancel
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize
clear
@visible = false
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Clear
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def clear
# Original Game_Message
@texts = []
@face_name = ""
@face_index = 0
@background = 0
@position = 2
@main_proc = nil
@choice_start = 99
@choice_max = 0
@choice_cancel_type = 0
@choice_proc = nil
@num_input_variable_id = 0
@num_input_digits_max = 0
# Restore to default settings
@message_x = $game_ats.message_x
@message_y = $game_ats.message_y
@message_width = $game_ats.message_width
@message_height = $game_ats.message_height
@message_opacity = $game_ats.message_opacity
@message_windowskin = $game_ats.message_windowskin
@message_fontname = $game_ats.message_fontname
@message_fontsize = $game_ats.message_fontsize
@message_colour = $game_ats.message_colour
@skip_disabled = $game_ats.skip_disabled
@wlh = $game_ats.wlh
@paragraph_format = $game_ats.paragraph_format
@justified_text = $game_ats.justified_text
@appended_text = $game_ats.appended_text
@scrolling = $game_ats.scrolling
@shown_lines = $game_ats.shown_lines
@autopause = $game_ats.autopause
@faceside = $game_ats.faceside
@face_x = $game_ats.face_x
@face_y = $game_ats.face_y
@face_width = $game_ats.face_width
@face_height = $game_ats.face_height
@face_offset_x = $game_ats.face_offset_x
@face_offset_y = $game_ats.face_offset_y
@face_mirror = $game_ats.face_mirror
@face_opacity = $game_ats.face_opacity
@face_window = $game_ats.face_window
@face_windowskin = $game_ats.face_windowskin
@face_window_opacity = $game_ats.face_window_opacity
@choicebox = $game_ats.choicebox
@choices_appended = $game_ats.choices_appended
@choicebox_on_line = $game_ats.choicebox_on_line
@choicebox_fitted = $game_ats.choicebox_fitted
@choicebox_width = $game_ats.choicebox_width
@choicebox_opacity = $game_ats.choicebox_opacity
@choicebox_windowskin = $game_ats.choicebox_windowskin
@choicebox_fontname = $game_ats.choicebox_fontname
@choicebox_colour = $game_ats.choicebox_colour
@choicebox_offset_x = $game_ats.choicebox_offset_x
@choicebox_offset_y = $game_ats.choicebox_offset_y
@choicebox_x = $game_ats.choicebox_x
@choicebox_y = $game_ats.choicebox_y
@row_max = $game_ats.row_max
@column_max = $game_ats.column_max
@lbl_se = $game_ats.lbl_se
@message_se = $game_ats.message_se
@mt_se = $game_ats.mt_se
@termination_se = $game_ats.termination_se
@mp_se = $game_ats.mp_se
@pause_se = $game_ats.pause_se
@ms_se = $game_ats.ms_se
@start_se = $game_ats.start_se
@mf_se = $game_ats.mf_se
@finish_se = $game_ats.finish_se
@letter_frames = $game_ats.letter_frames
@face_letters = $game_ats.face_letters
@sound_letters = $game_ats.sound_letters
@namebox_windowskin = $game_ats.namebox_windowskin
@namebox_colour = $game_ats.namebox_colour
@namebox_fontname = $game_ats.namebox_fontname
@namebox_fontsize = $game_ats.namebox_fontsize
@namebox_offset_x = $game_ats.namebox_offset_x
@namebox_offset_y = $game_ats.namebox_offset_y
@namebox_x = $game_ats.namebox_x
@namebox_y = $game_ats.namebox_y
@namebox_opacity = $game_ats.namebox_opacity
@back_sprite = $game_ats.back_sprite
@character = -1
@char_ref = 0
@highlight = -1
@underline = false
@choice_texts = []
@appending_text = false
@battle_interpreter = false
@old_choice_cancel = 0 if @old_choice_cancel == nil
end
#--------------------------------------------------------------------------
# * New Page
#--------------------------------------------------------------------------
def new_page
while @texts.size % SHOWN_LINES > 0
@texts.push("")
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * SE play
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def se_play (se)
begin
se.play
rescue
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Convert Special Characters
# text : the text to convert
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def convert_special_characters (text)
return if text == nil
# Get substitutions
text = perform_substitution (text)
text.gsub!(/\\C\[(\d+)\]/i) { "\x01<#{$1.to_i}>" }
text.gsub!(/\\\./) { "\x02<15>" }
text.gsub!(/\\\|/) { "\x02<60>" }
text.gsub!(/\\W\[(\d+)\]/i) { "\x02<#{$1.to_i}>" }
text.gsub!(/\\G/i) { "\x03" }
text.gsub!(/\\!/) { "\x04" }
text.gsub!(/\\>/) { "\x05" }
text.gsub!(/\\</) { "\x06" }
text.gsub!(/\\\^/) { "\x07" }
text.gsub! (/\\NB\[(.+?)\]/i) { "\x99<#{$1.to_s}>" } # Name Window
text.gsub! (/\\NAME\[(.+?)\]/i) { "\x99<#{$1.to_s}>" } # Name Window
text.gsub! (/\\IICON\[(\d+)\]/i) { $1.to_i > 0 ? "\x98<#{$data_items[$1.to_i].icon_index}>" : ""} # Item Icon
text.gsub! (/\\WICON\[(\d+)\]/i) { $1.to_i > 0 ? "\x98<#{$data_weapons[$1.to_i].icon_index}>" : ""} # Weapon Icon
text.gsub! (/\\AICON\[(\d+)\]/i) { $1.to_i > 0 ? "\x98<#{$data_armors[$1.to_i].icon_index}>" : ""} # Armor Icon
text.gsub! (/\\ICON\[(\d+)\]/i) { "\x98<#{$1.to_s}>" } # Icon
text.gsub! (/\\ANI\[(\d+),\s*(\d+)\]/i) { "\x97<#{$1.to_s},#{$2.to_s}>" } # Animation
text.gsub! (/\\BLN\[(\d+),\s*(\d+)\]/i) { "\x96<#{$1.to_s},#{$2.to_s}>" } # Balloon
text.gsub! (/\\B/i) { "\x95" } # Bold
text.gsub! (/\\I/i) { "\x94" } # Italic
text.gsub! (/\\FN\[(.+?)\]/i) { "\x93<#{$1.to_s}>" } # Change font name
text.gsub! (/\\FS\[(\d+)\]/i) { "\x92<#{$1.to_s}>" }# Change font size
text.gsub! (/\\@@/) { "\x91" } # Show Fast
text.gsub! (/\\@/) { "\x90" } # Show Line Fast
text.gsub! (/\\%/) { "\x89" } # Disable Skipping
text.gsub! (/\\SE\[(.+?)\]/i) { "\x88<#{$1.to_s}>" } # Play Sound Effect
text.gsub! (/\\ME\[(.+?)\]/i) { "\x87<#{$1.to_s}>" } # Play Musical Effect
# Over/Under/Left/Right of Character
text.gsub! (/\\OC\[(\d+)\]/i) { "\x86<#{$1.to_s},0>" }
text.gsub! (/\\UC\[(\d+)\]/i) { "\x86<#{$1.to_s},1>" }
text.gsub! (/\\LC\[(\d+)\]/i) { "\x86<#{$1.to_s},2>" }
text.gsub! (/\\RC\[(\d+)\]/i) { "\x86<#{$1.to_s},3>" }
# Position Direct Setting
text.gsub! (/\\[PM]XY\[(-*\d+),\s*(-*\d+)\]/i) { "\x85<#{$1.to_s},#{$2.to_s}>" }
# Face Direct Setting
text.gsub! (/\\FXY\[(-*\d+),\s*(-*\d+)\]/i) { "\x84<#{$1.to_s},#{$2.to_s}>" }
# Name Direct Setting
text.gsub! (/\\NXY\[(-*\d+),\s*(-*\d+)\]/i) { "\x08<#{$1.to_s},#{$2.to_s}>" }
text.gsub! (/\\SOFF\[(\d+)\]/i) { "\x83<0,#{$1.to_s}>" }
text.gsub! (/\\SON\[(\d+)\]/i) { "\x83<1,#{$1.to_s}>" }
text.gsub! (/\\CENTRE/i) { "\x82<1>" } # Align Centre
text.gsub! (/\\CE?NTE?R/i) { "\x82<1>" } # Align Centre
text.gsub! (/\\C/i) { "\x82<1>" } # Align Centre
text.gsub! (/\\RI?GHT/i) { "\x82<2>" } # Align Right
text.gsub! (/\\R/i) { "\x82<2>" } # Align Right
text.gsub! (/\\AF\[(\d+)\]/i) { "\x81<#{$1.to_s}>" } # Use Actor FACE
text.gsub! (/\\HL\[(-*\d+)\]/i) { "\x80<#{$1.to_s}>" } # HighLight
text.gsub! (/\\HL/i) { "\x80<-1>" }
text.gsub! (/\\S/i) { "\x09" } # Shadow
text.gsub! (/\\U/i) { "\x10" } # Underline
return text
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Convert Substitution Codes
# text : the text to convert
#--------------------------------------------------------------------------
# Performs the substitutions required by the substitution codes
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def perform_substitution (text)
# FILTERS
text.gsub!(/\\F\[["'](.+?)["']\]/i) { Game_ATS::FILTERS[$1.to_s] }
text.gsub!(/\\F\[(.+?)\]/i) { Game_ATS::FILTERS[$1.to_i] }
# Party ID to Actor ID
text.gsub!(/\\PID\[(\d+)\]/i) { $game_party.members[$1.to_i].id }
# Old Codes
text.gsub!(/\\V\[([0-9]+)\]/i) { $game_variables[$1.to_i] } # Variable
text.gsub!(/\\N\[([0-9]+)\]/i) { $1.to_i > 0 ? $game_actors[$1.to_i].name : ""} # Actor Name
text.gsub!(/\\\\/) { "\\" }
# New Codes
begin
text.gsub! (/\\VOCAB\[(\w+)\]/i) { Vocab.send ($1.downcase) } # Vocab
rescue
end
text.gsub! (/\\AC\[(\d+)\]/i) { $game_actors[$1.to_i].class.name } # Actor Class
# Actor Stats
begin
text.gsub! (/\\A([^\[]+?)\[(\d+)\]/i) { $game_actors[$2.to_i].send ($1.to_s.downcase) }
rescue
end
text.gsub! (/\\NC\[(\d+)\]/i) { $1.to_i > 0 ? $data_classes[$1.to_i].name : "" } # Class Name
text.gsub! (/\\NE\[(\d+)\]/i) { $1.to_i > 0 ? $game_map.events[$1.to_i].name : "" } # Event Name
text.gsub! (/\\NM\[(\d+)\]/i) { $1.to_i > 0 ? $data_enemies[$1.to_i].name : "" } # Monster Name
text.gsub! (/\\NI\[(\d+)\]/i) { $1.to_i > 0 ? $data_items[$1.to_i].name : "" } # Item Name
text.gsub! (/\\NW\[(\d+)\]/i) { $1.to_i > 0 ? $data_weapons[$1.to_i].name : "" } # Weapon Name
text.gsub! (/\\NA\[(\d+)\]/i) { $1.to_i > 0 ? $data_armors[$1.to_i].name : "" } # Armor Name
text.gsub! (/\\PI\[(\d+)\]/i) { $1.to_i > 0 ? $data_items[$1.to_i].price.to_s : "" } # Item Price
text.gsub! (/\\PW\[(\d+)\]/i) { $1.to_i > 0 ? $data_weapons[$1.to_i].price.to_s : "" } # Weapon Price
text.gsub! (/\\PA\[(\d+)\]/i) { $1.to_i > 0 ? $data_armors[$1.to_i].price.to_s : "" } # Armor Price
return text
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Extract Special Codes
#--------------------------------------------------------------------------
# In order to format text properly, special codes should not exist
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def extract_special_codes (text)
codes = []
code_indices = []
# Codes without arguments
no_args_codes = ["\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x09",
"\x10", "\x95", "\x94", "\x91", "\x90", "\x89"]
# Codes with integer arguments
int_args_codes = ["\x01", "\x92", "\x84", "\x82", "\x81", "\x80"]
# Codes with non-integer arguments (array or string)
nonint_args_codes = ["\x99", "\x97", "\x96", "\x93", "\x88", "\x87",
"\x86", "\x85", "\x83", "\x08"]
i = 0
while i < text.size
# Work from the end of the string
c = text[i, 1]
if no_args_codes.include? (c)
text.sub!(c, "")
codes.unshift (c)
code_indices.unshift (i)
elsif int_args_codes.include? (c)
text.sub! (/(#{c}<-*\d*>)/, "")
codes.unshift ($1)
code_indices.unshift (i)
elsif nonint_args_codes.include? (c)
text.sub! (/(#{c}<.*?>)/, "")
codes.unshift ($1)
code_indices.unshift (i)
elsif c == "\x98" # Icon
# Replace with |'s to approximate size of Icon (24)
text.sub! (/(#{c}<\d*>)/, "")
codes.unshift ($1)
code_indices.unshift (i)
substring = ""
bmp = Bitmap.new (32, 32)
substring += "." while bmp.text_size(substring).width < 24
bmp.dispose
text.insert (i, substring)
codes.insert (1, substring)
else
i += 1
end
end
return text, codes, code_indices
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Restore Special Codes
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def restore_special_codes (text, codes, code_indices)
# Restore special codes
for i in 0...code_indices.size
text.insert (code_indices[i], codes[i])
if codes[i].include? ("\x98") # Icon
text.slice! (code_indices[i] + codes[i].size, codes[i + 1].size)
codes.delete_at (i + 1)
end
end
return text
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Busy?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def busy
return false if @appending_text
return @texts.size > 0
end
end
#==============================================================================
# ** Game_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# new method - name
#==============================================================================
class Game_Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Name
#--------------------------------------------------------------------------
# This method returns the name of the event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def name
return @event.name
end
end
#==============================================================================
# ** Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# aliased methods - command_101, setup_choices, command_403, command_end
# new method - search_choice_branch
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Show Message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_apnd_txt_show_94b command_101
def command_101
value = modalg_ats_apnd_txt_show_94b
if $game_message.appended_text && @list[@index].code == 101 && @list[@index].parameters == @params
$game_message.appending_text = true
command_101
$game_message.appending_text = false
end
$game_message.battle_interpreter = true if $game_temp.in_battle
return value
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * When Cancel
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_whn_cncl_chcebrnch_cmnd403_8jf5 command_403
def command_403
if $game_message.choicebox
# If canceling choice
if @branch[@indent] == $game_message.old_choice_cancel - 1
@branch.delete(@indent) # Erase branching data
return true # Continue
else # If doesn't match condition
return command_skip # Command skip
end
else
modalg_ats_whn_cncl_chcebrnch_cmnd403_8jf5
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Search Choice Branch
# index being searched
# old_size : the amount of choice branches before these ones
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def search_choice_branch (ind, old_size = 0)
# Find the end of current choice branch
branch_count = 0
loop do
command = @list[ind]
break if command.code == 404 && branch_count == 0
# Skip the 404 command if it belongs to another choice branch
if command.code == 102
branch_count += 1
elsif command.code == 404 # Only occurs if branch_count > 0
branch_count -= 1
# If a handler
elsif branch_count == 0 && command.code == 402
command.parameters[0] += old_size
end
ind += 1
end
return ind
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Setup Choices
# params : the code parameters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_chcbox_mods_stp_chces_84nr setup_choices
def setup_choices (params)
if $game_message.choicebox
if $game_message.choices_appended
# Collect all subsequent choice branches
command = @list[@index + 1]
# Find the end of the current choice branch
ind = search_choice_branch (@index + 1)
command = @list[ind + 1]
# If the command directly below this branch is a choice branch
if command.code == 102
# Append its contents to the current branch
old_size = params[0].size
params[0] += command.parameters[0]
params[1] = command.parameters[1]
# Unless Choices are disabled, determine which index is referred to
params[1] += old_size unless params[1] == 0
# Delete the command 404 and the command 102 from the list
@list.delete_at (ind)
@list.delete_at (ind)
# Find all of the handlers and change the indices appropriately
search_choice_branch (ind, old_size)
setup_choices (params)
return
end
end
# Once here, all choice branches have been appended
$game_message.choice_start = 0
$game_message.choice_max = params[0].size
for s in params[0]
$game_message.choice_texts.push (s.dup)
end
$game_message.choice_cancel_type = params[1]
$game_message.old_choice_cancel = $game_message.choice_cancel_type if params[1] > params[0].size
$game_message.choice_proc = Proc.new { |n| @branch[@indent] = n }
@index += 1
else
choices = params[0].dup
# Insert line breaks if paragraph format is active
choices.each_index { |i| choices[i] = "\\lb" + choices[i] } if $game_message.paragraph_format
# Remove the first line break if there is no text above the choices
choices[0].slice! (0, 3) if $game_message.texts.empty?
modalg_ats_chcbox_mods_stp_chces_84nr ([choices, params[1]])
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * End Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_end_int_bttl_reset_gm_msg_9dj4 command_end
def command_end
modalg_ats_end_int_bttl_reset_gm_msg_9dj4
$game_message.clear if $game_message.battle_interpreter
end
end
#==============================================================================
# ** Sprite Message Face
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# A sprite to reduce lag when using Animated Facesets
#==============================================================================
class Sprite_MessageFace < Sprite_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (face_file, face_index)
super ()
self.visible = false
self.z = 300
self.opacity = $game_message.face_opacity
wdth, hght = $game_message.face_width, $game_message.face_height
self.bitmap = Bitmap.new (wdth, hght)
face = Cache.face (face_file)
if face_file[/^\$/] != nil # SINGLE
rect = Rect.new((face.width-wdth) / 2, (face.height-hght) / 2, wdth, hght)
else
rect = Rect.new(0, 0, wdth, hght)
rect.x = (face_index % 4) * wdth + (96 - wdth) / 2
rect.y = (face_index / 4) * hght + (96 - hght) / 2
end
self.bitmap.blt(0, 0, face, rect)
self.mirror = $game_message.face_mirror
end
end
#==============================================================================
# ** Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# new method - draw_message_character (c)
#==============================================================================
class Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Message Character
# c : the character to be drawn
#``````````````````````````````````````````````````````````````````````````
# This method utilizes the codes shared between the MessageBox, NameBox,
# and ChoiceBox
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_message_character (c)
case c
when "\x03" # \G (gold display)
@gold_window.refresh
@gold_window.open
when "\x09"
contents.font.shadow = !contents.font.shadow
when "\x95" # Bold
contents.font.bold = !contents.font.bold
when "\x94" # Italic
contents.font.italic = !contents.font.italic
when "\x93" # Change Font Name
@text.sub!(/<(.*?)>/, "")
contents.font.name = $1.to_s if Font.exist? ($1.to_s)
when "\x92" # Change Font Size
@text.sub!(/<(\d*)>/, "")
contents.font.size = $1.to_i
else
return false
end
return true
end
end
#==============================================================================
# * Window_FaceBox
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This window handles face updates
#==============================================================================
class Window_FaceBox < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize
@face_sprites = []
wdth, hght = get_width_height
super (0, 0, wdth, hght)
self.windowskin = Cache.system ($game_message.face_windowskin)
self.back_opacity = $game_message.face_window_opacity
self.openness = 0
@opening = false # WIndow opening flag
@closing = false # Window closing flag
self.z = 250
@letter_count = 0
@active_face = 0
# Set default position
set_position
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Get Width/Height
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def get_width_height
# Get position and width/height
wdth, hght = $game_message.face_width, $game_message.face_height
# Sprite position offset
@sprpos_mod = $game_message.face_window ? 16 : 0
wdth += (@sprpos_mod*2)
hght += (@sprpos_mod*2)
return wdth, hght
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Check Window Size
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def check_window_size
if $game_message.face_width != self.width + (@sprpos_mod*2) ||
$game_message.face_height != self.height + (@sprpos_mod*2) ||
(self.openness == 0 && $game_message.face_window)
clear
contents.dispose
# Remake Window
self.width, self.height = get_width_height
create_contents
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Face
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_face (face_file, face_index = 0)
clear
check_window_size
name = face_file.dup
loop do
# Make face and store in @face_sprites unless invalied
face = Sprite_MessageFace.new (name, face_index) rescue break
@face_sprites.push (face)
# If face_file has a number appended, add all of it's animations
if name[/\_(\d+)$/i] != nil
name.sub! (/(\d+)$/) { ($1.to_i + 1).to_s }
elsif name[/^\!\[(\d+)\]./] != nil # If name has exclamation code
# Take all animations from the same face file
face_index += 1
break if face_index == $1.to_i
else
break
end
end
set_position
self.back_opacity = $game_message.face_window_opacity
open if $game_message.face_window
# First face sprite becomes visible
pause
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Clear
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def clear
@face_sprites.each { |face| face.dispose } # Dispose all faces
@face_sprites.clear
close if self.openness > 0
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Position Default
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_position (x = $game_message.face_x, y = $game_message.face_y)
# Set $game_message to a local variable for neatness
m = $game_message
# Set X position to message window if -1
if x == -1
x = m.faceside ? m.message_x + (@sprpos_mod - 16).abs : m.message_x + m.message_width - self.width - (@sprpos_mod - 16).abs
x = m.faceside ? x + m.face_offset_x : x - m.face_offset_x
end
# Set Y position to message window if -1
if y == -1
# If faceset is smaller than message window
if m.message_height > self.height
# Centre in box
y = m.message_y + ((m.message_height - self.height)) / 2
else
# If face too big and will go out of screen at top
if m.message_y + m.message_height < self.height
# Set to top of box
y = m.message_y
else # Set to bottom of box
y = m.message_y + m.message_height - self.height
end
end
y += m.face_offset_y
end
self.x = x
self.y = y
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Position
# x, y : direct position setting
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def x= (x)
super (x)
@face_sprites.each { |face| face.x = x + @sprpos_mod }
end
def y= (y)
super (y)
@face_sprites.each { |face| face.y = y + @sprpos_mod }
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Animate Face
#``````````````````````````````````````````````````````````````````````````
# This method controls face animation if animated facesets being used
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def animate_face
# Don't update if not using animated face sets
return if @face_sprites.size < 2
@letter_count = (@letter_count + 1) % $game_message.face_letters
if @letter_count == 0
@face_sprites[@active_face].visible = false
@active_face = (@active_face + 1) % @face_sprites.size
@face_sprites[@active_face].visible = true
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Pause
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def pause
return if @face_sprites.empty?
@face_sprites[@active_face].visible = false
@face_sprites[0].visible = true
@letter_count = 0
@active_face = 0
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dispose
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def dispose
clear
super
end
end
#==============================================================================
# ** Window Name Box
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This window displays the name of a speaker in Window_Message
#==============================================================================
class Window_NameBox < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
# string : the string to display
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (string = '')
# Convert String's special codes
string = $game_message.convert_special_characters (string)
# Set up a bitmap to test necessary width and size of the name
temp_bitmap = Bitmap.new (1, 1)
temp_bitmap.font.name = $game_message.namebox_fontname
temp_bitmap.font.size = $game_message.namebox_fontsize
rect = temp_bitmap.text_size (string)
rect.width, rect.height = 32, 32 if rect.width == 0
temp_bitmap.dispose
super (0, 0, rect.width + 32, rect.height + 32)
self.visible = string != ''
self.z = 300
# Use Namebox settings
self.back_opacity = $game_message.namebox_opacity
begin
self.windowskin = Cache.system ($game_message.namebox_windowskin)
rescue
end
contents.font.name = $game_message.namebox_fontname
contents.font.size = $game_message.namebox_fontsize
# Set to Colour
if $game_message.namebox_colour.is_a? (Color)
contents.font.color = $game_message.namebox_colour
else
contents.font.color = text_color ($game_message.namebox_colour)
end
# Draw Text
x = 0
loop do
c = string.slice! (/./m)
break if c.nil?
next if draw_message_character (c)
case c
when "\x98" # \icon (Icon)
string.sub!(/<(\d*)>/, "")
draw_icon ($1.to_i, x, 0)
x += 24
when "\x01" # Colour
string.sub!(/<([0-9]*)>/, "")
contents.font.color = text_color($1.to_i)
when "\x80" # Highlight
string.sub!(/<(\d*)>/, "")
$game_message.highlight = $1.to_i
else # Regular Character
ts = contents.text_size (c)
self.contents.draw_text (x, 0, ts.width, ts.height, c)
x += ts.width
end
end
set_position
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Position
# x, y : new position
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_position (x = $game_message.namebox_x, y = $game_message.namebox_y)
m = $game_message
# If namebox X set directly
if x == -1
x = m.message_x
# Adjust x for offset
x += m.faceside ? m.namebox_offset_x : m.message_width - m.namebox_offset_x
x -= self.width unless m.faceside
end
# If namebox y set directly
if y == -1
y = m.message_y
# Adjust y for offset
y += m.namebox_offset_y - self.height
y = m.message_y + m.message_height - m.namebox_offset_y if y < 0
end
self.x = x
self.y = y
end
end
#==============================================================================
# ** Window ChoiceBox
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This Window displays choices in a box separate from the message window
#==============================================================================
class Window_ChoiceBox < Window_Command
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize
commands, width = prepare_choices
index = 0
@true_command_indices = []
commands.dup.each { |i|
@true_command_indices.push (index)
while i.sub! (/\x83<(\d),(\d+)>/) { "" } != nil
if $1.to_i == 1 ? !$game_switches[$2.to_i] : $game_switches[$2.to_i]
commands.delete (i)
@true_command_indices.delete_at (index)
break
end
end
index += 1
}
# Height is same as window if on the same line, else it is no greater than window
if $game_message.choicebox_on_line
height = $game_message.message_height
else
wlh = $game_message.wlh
height = 32 + [(commands.size.to_f / $game_message.column_max.to_f).ceil.to_i*wlh, $game_message.row_max*wlh].min
end
# Compute window height from command quantity
super(width, commands, $game_message.column_max, 0, 24)
self.windowskin = Cache.system ($game_message.choicebox_windowskin)
self.height = height
self.z = 350
self.back_opacity = $game_message.choicebox_opacity
set_position
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Item
# index : the index of the command
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_item (index)
contents.font.name = $game_message.choicebox_fontname
# Set to Colour
if $game_message.choicebox_colour.is_a? (Color)
contents.font.color = $game_message.choicebox_colour
else
contents.font.color = text_color ($game_message.choicebox_colour)
end
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
# Retrieve colour command if it exists
string = @commands[index].dup
x = 0
string.gsub! (/\x82<(\d+)>/) { "" }
if $1 != nil
# Align Text
es = (rect.width - contents.text_size (string).width)
x += $1.to_i == 1 ? es / 2 : es
end
loop do
c = string.slice! (/./m)
break if c == nil
next if draw_message_character (c)
case c
when "\x01" # \C[n] (text character color change)
string.sub!(/<([0-9]*)>/, "")
contents.font.color = text_color($1.to_i)
when "\x98" # \icon (Icon)
string.sub!(/<(\d*)>/, "")
draw_icon ($1.to_i, rect.x + x, rect.y)
x += 24
when "\x80" # Highlight
string.sub!(/<(\d*)>/, "")
$game_message.highlight = $1.to_i
else
ts = contents.text_size (c)
self.contents.draw_text (rect.x + x, rect.y, ts.width, ts.height, c)
x += ts.width
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Command Index
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def command_index
return @true_command_indices[self.index]
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Position
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_position (x = $game_message.choicebox_x, y = $game_message.choicebox_y)
m = $game_message
# If position set for x
if x.between? (0, Graphics.width)
# Set X directly
self.x = x
elsif m.choicebox_on_line # ON line with message window
# Place adjacent to the message window
self.x = m.faceside ? m.message_x + m.message_width : m.message_x - self.width
else
# Place to right of the window
x1 = m.message_x + m.message_width - self.width - m.choicebox_offset_x
# Place to the Left of the window
x2 = m.message_x + m.choicebox_offset_x
self.x = m.faceside ? x1 : x2
end
# If position set directly for y
if y.between? (0, Graphics.height)
# Set X directly
self.y = y
elsif m.choicebox_on_line
# Place at same level as message window
self.y = m.message_y
else
# Place above message window
y1 = m.message_y - self.height + m.choicebox_offset_y
# Place below message window
y2 = m.message_y + m.message_height - m.choicebox_offset_y
self.y = y1 > 0 ? y1 : y2
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Prepare Choices
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def prepare_choices
# Initialize arrays
commands, codes, code_indices = [], [], []
# For neatness, assign $game_message to local variable m
m = $game_message
# Prepare text and get choicebox width
m.choice_texts.dup.each_index { |i|
string = m.convert_special_characters (m.choice_texts[i].dup)
commands[i], codes[i], code_indices[i] = m.extract_special_codes (string)
}
if m.choicebox_fitted
c_width = 0
bmp = Bitmap.new (1, 1)
bmp.font.name = $game_message.choicebox_fontname
# Get width of longest line
commands.each { |i| c_width = bmp.text_size(i).width if bmp.text_size(i).width > c_width }
bmp.dispose
# Add on the extra space
c_width = 32 + (24 + c_width)*m.column_max
else
c_width = m.choicebox_width
end
# Restore Special Codes
commands.each_index { |i| commands[i] = m.restore_special_codes (commands[i], codes[i], code_indices[i]) }
return commands, c_width
end
end
#==============================================================================
# ** Window_Message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# overwritten methods - convert_special_characters, update_message,
# create_back_sprite, start_message, new_page, input_pause
# new methods - draw_character, scroll_contents, create_namebox, format_text,
# remake_window, contents_width, determine_position, set_position,
# position_to_character, scroll_contents, set_alignment,
# play_event_graphic
# aliased methods - initialize, new_line, close, update_show_fast,
# start_choice, input_choice, update_cursor, finish_message,
# terminate_message
#==============================================================================
class Window_Message < Window_Selectable
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_win_msg_init initialize
def initialize
modalg_ats_win_msg_init
self.windowskin = Cache.system ($game_message.message_windowskin)
# Create Boxes
@face_window = Window_FaceBox.new
@sound_count = 0
@letter_drawn = false
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Name Box
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def create_namebox (string)
@name_window.dispose unless @name_window.nil? || @name_window.disposed?
@name_window = Window_NameBox.new (string)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Background Sprite
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def create_back_sprite
@back_sprite = Sprite.new
begin
@back_sprite.bitmap = Cache.system($game_message.back_sprite)
$game_message.old_backsprite = $game_message.back_sprite
rescue
end
@back_sprite.bitmap = Cache.system($game_message.old_backsprite) if @back_sprite.bitmap == nil
@back_sprite.visible = (@background == 1)
@back_sprite.z = 190
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Format Text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def format_text
return if $game_message.texts.empty?
@text = ""
# Only format if the option is selected
if $game_message.paragraph_format && (!$game_temp.in_battle || $game_message.battle_interpreter)
# Take all of the texts and combine into single text to be formatted
$game_message.texts.each { |i|
line = i.clone
# Remove white space at end and replace with single space
line.sub! (/\s*$/) {" "}
@text += line
}
@text = $game_message.convert_special_characters (@text)
# Break the text - remove all character codes for the purpose of formatting
@text, codes, code_indices = $game_message.extract_special_codes (@text)
# Find conscious paragraph divisions, noted by \lb (line break)
i = 0
@paragraphs = []
while @text[/\\LB/i] != nil
@paragraphs[i] = @text.slice! (/.*?\\LB/i)
# Remove the LB and replace with " " for easier code restoration
@paragraphs[i].sub! (/\\LB/i, " ")
i += 1
end
@paragraphs[i] = @text
@text = ""
# Use Zeriab's formatting algorithm if the font has set width
if contents.text_size('w').width == contents.text_size('i').width
formatter = Paragrapher::Formatter_2.new
else
formatter = Paragrapher::Formatter.new
end
formatted_text = Paragrapher::Formatted_Text.new
formatted_text.lines, formatted_text.blank_width = [], []
# Get total allowed message width
temp_bmp = Bitmap.new (contents_width, $game_message.wlh)
temp_bmp.font = contents.font.dup
# Format each paragraph and combine them
@paragraphs.each { |para|
f = formatter.format (para, temp_bmp.dup)
f.bitmap.dispose
formatted_text.lines += f.lines
formatted_text.blank_width += f.blank_width
}
temp_bmp.dispose
@paragraphs.clear
@text = ""
pos_array = [0]
# Convert formatted text to a string, rather than an array of characters
formatted_text.lines.each_index { |i|
formatted_text.lines[i].each{ |j| @text += j }
# If feature for pause at end of lines implemented
if $game_message.autopause
# If it will scroll next line and is not the last line
if (i + 1) % $game_message.shown_lines == 0 && (i + 1) != formatted_text.lines.size
# Insert command codes for pause and Play SE
@text += "\x04"
# Adjust code indices to match new code placements
code_indices.each_index { |j| code_indices[j] += 1 if @text.size < code_indices[j] }
end
end
@text += "\x00"
}
@text = $game_message.restore_special_codes (@text, codes, code_indices)
# Give back an array of widths only if the text ought to be justified
return formatted_text.blank_width
else
@text = ""
$game_message.texts.each_index { |i|
@text += $game_message.texts[i].clone + "\x00"
if ($game_message.scrolling && (!$game_temp.in_battle || $game_message.battle_interpreter)) && $game_message.autopause
# If it will scroll next line and is not the last line
if (i + 1) % $game_message.shown_lines == 0
# Insert command codes for pause
@text += "\x04"
end
end
}
convert_special_characters
@text.gsub! (/\\LB/i) { "" }
return nil
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Remake Window
# x, y, width, height : new size attributes
#-------------------------------------------------------------------------
# This remakes the message window to a different size, position, etc...
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def remake_window (x = self.x, y = self.y, width = self.width, height = self.height)
contents.clear
contents.dispose
set_position (x, y)
self.width, self.height = width, height
$game_message.message_width, $game_message.message_height = width, height
create_contents
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Contents Width
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def contents_width
@face_window.check_window_size
# Determine the message width allowed
message_width = contents.width
# If no overlap for face in Y direction
if @face_window.y + @face_window.height < self.y || self.y + self.height < @face_window.y ||
@face_window.x + @face_window.width < self.x || self.x + self.width < @face_window.x
face_ovrlp = 0
else
# Determine actual overlap of face window
if $game_message.faceside # On Left
face_ovrlp = @face_window.x + @face_window.width - self.x
else # On Right
face_ovrlp = self.x + self.width - @face_window.x - 16
end
end
message_width -= face_ovrlp unless $game_message.face_name.empty?
@contents_width = message_width
return message_width
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Determine Position
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def determine_position
m = $game_message
# Set custom position if custom position desired
# Centre by default
x = m.message_x == -1 ? (Graphics.width - m.message_width) / 2 : m.message_x
if m.message_y == -1
y = (Graphics.height - m.message_height)
y = @position == 0 ? 0 : @position == 1 ? y / 2 : y
else
y = m.message_y
end
width = m.message_width
height = m.message_height
# Adjust Window Size according to choicebox position
if $game_message.choicebox && $game_message.choicebox_on_line && !$game_message.choice_texts.empty?
dummy = Window_ChoiceBox.new
commands, c_w = dummy.prepare_choices
dummy.dispose
width -= c_w
x += $game_message.choicebox_width unless $game_message.faceside
end
# Remake the window if the new proportions do not match the old ones.
if [x, y, width, height] != [self.x, self.y, self.width, self.height]
remake_window (x, y, width, height)
else
set_position (x, y)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Position
# x, y : new coordinates
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_position (x = $game_message.message_x, y = $game_message.message_y)
# Set message window position
self.x, self.y, $game_message.message_x, $game_message.message_y = x, y, x, y
@back_sprite.x, @back_sprite.y = x, y
@name_window.set_position unless @name_window.nil?
@face_window.set_position
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Position To Character
# character_id : the character around which the message window is to go
# type : Over, Below, Left or Right of character
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def position_to_character (character_id, type)
character = character_id == 0 ? $game_player : $game_map.events[character_id]
# Do not change position if character does not exist
return if character == nil
# Do not change position if the character is not on screen.
return unless character.screen_x.between? (0, Graphics.width) && character.screen_y.between? (0, Graphics.height)
# Get the size of the character
bmp = Cache.character (character.character_name).clone
if character.character_name[/^\$/] == nil
c_wdth, c_hght = bmp.width / 12, bmp.height / 8
else
c_wdth, c_hght = bmp.width / 3, bmp.height / 4
end
bmp.dispose
# Centre X or Y depending on position
if type / 2 == 0
# Centre X
x = [character.screen_x - (self.width/ 2) , 0].max
x = x + self.width <= Graphics.width ? x : Graphics.width - self.width
else
# Centre Y
y = [character.screen_y - ((self.height + c_hght) / 2), 0].max
y = y + self.height <= Graphics.height ? y : Graphics.height - self.height
end
case type
when 0 # Over
y = [character.screen_y - c_hght - self.height, 0].max
when 1 # Below
y = [character.screen_y, Graphics.height - self.height].min
when 2 # Left
x = [character.screen_x - (c_wdth / 2) - self.width, 0].max
when 3 # Right
x = [character.screen_x + (c_wdth / 2), Graphics.width - self.width].min
end
set_position (x, y)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start Message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def start_message
contents.font.name = $game_message.message_fontname
contents.font.size = $game_message.message_fontsize
# Set to Colour
if $game_message.message_colour.is_a? (Color)
contents.font.color = $game_message.message_colour
else
contents.font.color = text_color ($game_message.message_colour)
end
self.back_opacity = $game_message.message_opacity
reset_window
determine_position
# Set it around character if it is set
unless $game_message.character <= -1
position_to_character ($game_message.character, $game_message.char_ref % 4)
end
@face_window.set_position
# Change the text into paragraph format
@line_spacing = format_text
# In case choice box is off
@item_max = $game_message.choice_max
# Play Start SE
$game_message.se_play ($game_message.start_se) if $game_message.ms_se
new_page
# If no text and just choices...
if $game_message.texts.empty?
finish_message
return
end
# Check Back Sprite
unless $game_message.back_sprite == $game_message.old_backsprite
@back_sprite.bitmap.dispose
create_back_sprite
end
@back_sprite.x, @back_sprite.y = self.x, self.y
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * New Page
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def new_page
contents.clear
@face_window.clear
# Make Face
@contents_x = $game_message.faceside ? contents.width - contents_width : 0
# Make face unless there is none
if $game_message.face_name.empty?
@contents_x = 0
else
@face_window.set_face ($game_message.face_name, $game_message.face_index)
end
# When not scrolling
if $game_message.justified_text && !($game_message.scrolling && (!$game_temp.in_battle || $game_message.battle_interpreter))
# Adjust line spacing to reflect page currently on.
@line_spacing.slice! (0, @line_count)
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * New Line
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_atsv2_nl_scroll new_line
def new_line
modalg_atsv2_nl_scroll
@contents_x = $game_message.faceside ? contents.width - @contents_width : 0
@contents_x = 0 if $game_message.face_name.empty?
@contents_y -= WLH
# If Reached end of page
if @line_count >= $game_message.shown_lines
@show_fast = false
# If scrolling
$game_message.scrolling && (!$game_temp.in_battle || $game_message.battle_interpreter) ? scroll_contents : self.pause = true
else
@contents_y += $game_message.wlh
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Scroll Contents
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def scroll_contents
# Don't scroll if at end of page
return if @text.size <= 2
@old_bitmap = contents.dup
contents.clear
wlh = $game_message.wlh
contents.blt (0, 0, @old_bitmap, Rect.new (0, wlh, contents.width, ($game_message.shown_lines - 1)*wlh))
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Alignment
# align : The alignment ( 1 => Centre, 2 => Right )
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def set_alignment (align = 1)
# Get rest of line
length = 1
length += 1 while @text[length - 1, 1] != "\x00"
if @line_spacing.nil? || @line_spacing[@line_count].nil? || @line_spacing[@line_count].floor == 0
# Calculate Empty Space
es = $game_message.faceside ? contents.width : @contents_width
string = $game_message.extract_special_codes (@text[0, length])
es -= (contents.text_size (string).width + @contents_x)
else
es = @line_spacing[@line_count] * length
end
@contents_x += (align == 1 ? es / 2 : es).to_i
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Convert Special Characters
# text : the text to convert
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def convert_special_characters
@text = $game_message.convert_special_characters (@text)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Close
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_strt_chce_if_able_94n5 close
def close
# Create Choice Window if Choicebox setting is true
start_choice if $game_message.choicebox && !$game_message.choice_texts.empty?
modalg_ats_strt_chce_if_able_94n5
if !(@choice_window.nil? && (self.visible || !@closing))
@choice_window.x = (Graphics.width - @choice_window.width) / 2
@choice_window.y = (Graphics.height - @choice_window.height) / 2
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Fast Forward Flag
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_inpt_shw_fst_dsble_84b5 update_show_fast
def update_show_fast
modalg_ats_inpt_shw_fst_dsble_84b5
# Update Face Window
@face_window.update
# Disallow that type of show fast if skip disabled
@show_fast = false if $game_message.skip_disabled
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update_message
loop do
c = @text.slice!(/./m) # Get next text character
# If no text left
if c.nil?
finish_message # Finish update
break
end
draw_character (c)
break unless @show_fast || @line_show_fast
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Character
# c : the character to be drawn
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_character (c)
return if draw_message_character (c)
case c
when "\x00" # New line
new_line
when "\x01" # \C[n] (text character color change)
@text.sub!(/<([0-9]*)>/, "")
contents.font.color = text_color($1.to_i)
when "\x02" # \p[x] (Wait x frames)
@text.sub!(/<(\d+)>/, "")
@wait_count = $1.to_i
@face_window.pause
when "\x04" # \! (Wait for input)
self.pause = true
@face_window.pause
when "\x05" # \> (Text Faster)
$game_message.letter_frames = [$game_message.letter_frames - 1, 0].max
when "\x06" # \< (Text slower)
$game_message.letter_frames += 1
when "\x07" # \^ (No wait for input)
@pause_skip = true
when "\x08" # \NXY[x,y] (Name XY)
@text.sub! (/<(-*\d*),(-*\d*)>/, "")
@name_window.set_position ($1.to_i, $2.to_i) unless @name_window.nil?
when "\x10"
$game_message.underline = !$game_message.underline
when "\x99" # \nb (Namebox)
@text.sub!(/<(.*?)>/, "")
create_namebox ($1.to_s)
when "\x98" # \icon (Icon)
@text.sub!(/<(\d*)>/, "")
draw_icon ($1.to_i, @contents_x, @contents_y)
@contents_x += 24
when "\x97" # \ani[x,y] (Show Animation)
play_event_graphic (true)
when "\x96" # \bln[x,y] (Show Balloon)
play_event_graphic (false)
when "\x91" # \@@ (Toggle Show Fast)
# Toggle Show Fast
@show_fast = !@show_fast
when "\x90" # \@ (Toggle Show Line Fast)
# Toggle Show Line Fast
@line_show_fast = !@line_show_fast
when "\x89" # \% (Toggle Skipping)
# Toggle Skip Disable
$game_message.skip_disabled = !$game_message.skip_disabled
@show_fast = false
@line_show_fast = false
when "\x88" # \SE[x] (Play Sound effect)
# Play sound effect
@text.sub!(/<(.*?)>/, "")
$game_message.se_play (RPG::SE.new($1))
when "\x87" # \ME[x] (Play Music effect)
# Play music effect
@text.sub!(/<(.*?)>/, "")
$game_message.se_play (RPG::ME.new($1))
when "\x86" # Around Character
@text.sub! (/<(\d*),(\d*)>/, "")
position_to_character ($1.to_i, $2.to_i) if $1.to_i > -1
when "\x85" # \MXY[x,y] (Message XY)
@text.sub! (/<(-*\d*),(-*\d*)>/, "")
set_position ($1.to_i, $2.to_i)
when "\x84" # \FXY[x,y] (Face XY)
@text.sub! (/<(-*\d*),(-*\d*)>/, "")
@face_window.set_position ($1.to_i, $2.to_i)
when "\x82"
@text.sub! (/<(\d*)>/, "")
# Alignment
set_alignment ($1.to_i)
when "\x81"
@text.sub! (/<(\d*)>/, "")
@face_window.set_face ($game_actors[$1.to_i].face_name, $game_actors[$1.to_i].face_index)
when "\x80" # Highlight
@text.sub!(/<(-*\d*)>/, "")
$game_message.highlight = $1.to_i
else # Normal text character
c_width = contents.text_size(c).width
ls = (@line_spacing == nil || !$game_message.justified_text) ? 0 : @line_spacing[@line_count]
hl_rect = Rect.new (@contents_x, @contents_y, 0, $game_message.wlh)
hl_rect.width = (c_width + ls).round
# Highlight
if $game_message.highlight.between? (0, 31)
colour = text_color ($game_message.highlight)
colour.alpha = 120
contents.fill_rect (hl_rect, colour)
end
if $game_message.underline
y = @contents_y + contents.font.size + ($game_message.wlh - contents.font.size) / 2
contents.fill_rect (@contents_x, y, hl_rect.width, 2, contents.font.color)
end
contents.draw_text(@contents_x, @contents_y, 40, $game_message.wlh, c)
@contents_x += c_width + ls
# Unless it is a blank or is being sped through
unless c == " " || @show_fast || @line_show_fast
# Animate Face
@face_window.animate_face
@wait_count += $game_message.letter_frames
return unless $game_message.lbl_se
# Update Sound
@sound_count = (@sound_count + 1) % $game_message.sound_letters
$game_message.se_play ($game_message.message_se) if @sound_count == 0
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Play Event Graphic
# type : true => Animation, false => Balloon
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def play_event_graphic (type)
# Extract Target and Graphic ID
@text.sub! (/<(\d*),(\d*)>/, "")
# If target is player
if $1.to_i == 0
type ? $game_player.animation_id = $2.to_i : $game_player.balloon_id = $2.to_i
else
event = $game_map.events[$1.to_i]
# Discard command if Event does not exist
return if event == nil
type ? event.animation_id = $2.to_i : event.balloon_id = $2.to_i
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start Choices
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_old_choice_start start_choice
def start_choice
if $game_message.choicebox
@choice_window.dispose unless @choice_window.nil? || @choice_window.disposed?
@choice_window = Window_ChoiceBox.new
self.active = @choice_window.active = true
self.index = @choice_window.index = 0
@choice_window.visible = true
else
# Save self.active state
modalg_ats_old_choice_start
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Choice Input
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_inpt_chce_choicebox_mod_84b5 input_choice
def input_choice
# Update Choice Box if it exists
if $game_message.choicebox && @choice_window != nil
@choice_window.update
self.index = @choice_window.command_index
end
modalg_ats_inpt_chce_choicebox_mod_84b5
self.index = @choice_window.index if $game_message.choicebox && @choice_window != nil
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Text Advancement Input
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def input_pause
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
self.pause = false
if @text != nil and not @text.empty?
new_page if @line_count >= $game_message.shown_lines && !($game_message.scrolling && (!$game_temp.in_battle || $game_message.battle_interpreter))
$game_message.se_play ($game_message.pause_se) if $game_message.mp_se
else
terminate_message
end
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Cursor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_update_crsr_dspr_choicebox_9fh5 update_cursor
def update_cursor
# Overwrite default so that cursor does not exist when choicebox
modalg_ats_update_crsr_dspr_choicebox_9fh5 unless $game_message.choicebox
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * End Message Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_msg_fin finish_message
def finish_message
@face_window.pause
# Play Finish SE
$game_message.se_play ($game_message.finish_se) if $game_message.mf_se
modalg_ats_msg_fin
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * End Message
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_win_msg_term terminate_message
def terminate_message
$game_message.se_play ($game_message.termination_se) if $game_message.mt_se
modalg_ats_win_msg_term
# Dispose of faces
@face_window.clear
# Dispose of name window
@name_window.dispose unless @name_window == nil
@name_window = nil
# Dispose of choice window
@choice_window.dispose unless @choice_window.nil? || @choice_window.disposed?
@choice_window = nil
@line_count = 0
determine_position if $game_temp.in_battle
$game_message.mt_se = $game_ats.mt_se
end
end
#========================================================================
# ** Scene_Title
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# aliased method - create_game_objects
#========================================================================
class Scene_Title
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Game Objects
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_gm_obj_create create_game_objects
def create_game_objects
# Create the object which holds default values for message
$game_ats = $ats_default = Game_ATS.new
# Run original method
modalg_ats_gm_obj_create
end
end
#========================================================================
# ** Scene_File
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# aliased methods - write_save_data, read_save_data
#========================================================================
class Scene_File
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Write Save Data
# file : the file being written to
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_write_save write_save_data
def write_save_data (file)
# Run Original Method
modalg_ats_write_save (file)
Marshal.dump($game_ats, file)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Read Save Data
# file : the file being read from
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_ats_read_save_data read_save_data
def read_save_data (file)
# Run Original Method
modalg_ats_read_save_data (file)
$game_ats = $ats_default = Marshal.load (file)
end
end
Código:
#========================================================================
# Paragraph Formatter (VX)
# Version: 1.1
# Author: modern algebra (rmrk.net)
# Date: March 4, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Apology:
# The idea behind this script is to easily separate a long string into a paragraph that fits in to
# the dimensions you specify.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
# For ease of use of people who are not neccesarily interested in writing their own algorithm,
# I have included a facade which you can use simply by this code:
#
# bitmap.draw_paragraph (x, y, width, height, string)
#
# where x & y are the x & y coordinates on the specified bitmap, and width and height are the
# maximum dimensions of the paragraph and string is the text you want to display in
# paragraph formatter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# How it works:
# The paragrapher expects two objects when initialized, a Formatter and an Artist. The idea
# behind the formatter is that it is expected to take the initial specifications and convert it to a
# Formatted Text object. Then, the Artist class is expected to interpret the Formatted Text
# object and draw the paragraph. For details on how each specific algorithm works, visit the
# comments above and inside them. It is not necessary to use the default Formatter, Artist, or
# Formatted Text objects.
#========================================================================
#======================================================================
# ** Bitmap
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Facade for easy application of the Paragraph Formatter
#======================================================================
class Bitmap
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Get Formatter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def paragraph_formatter
@p_formatter = $game_system.default_formatter.new if @p_formatter.nil?
return @p_formatter
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Formatter
# formatter : The uninitialized formatter class you would like to use
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def paragraph_formatter= (formatter)
@p_formatter = formatter.new
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Get Artist
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def paragraph_artist
@p_artist = $game_system.default_artist.new if @p_artist.nil?
return @p_artist
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Artist
# artist : The uninitialized artist class you would like to use
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def paragraph_artist= (artist)
@p_artist = artist.new
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * The Facade, which uses default Formatter and Artist to draw the formatted text directly
# to a bitmap, such as self.contents
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_paragraph (x, y, max_width, max_height, string)
bitmap = Bitmap.new (max_width, max_height)
bitmap.font = self.font
pg = Paragrapher.new(paragraph_formatter, paragraph_artist)
bitmap = pg.paragraph (string, bitmap)
blt (x, y, bitmap, bitmap.rect)
# Dispose of the proxy bitmap
bitmap.dispose
end
end
#========================================================================
# ** Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of changes:
# new instance variables - default_formatter, default_artist
# aliased methods - initialize
#========================================================================
class Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :default_formatter
attr_accessor :default_artist
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_paragraph_formatter_init initialize
def initialize
# Run original method
ma_paragraph_formatter_init
# Initialize original default format and artist classes
@default_formatter = Paragrapher::Formatter_2
@default_artist = Paragrapher::Artist
end
end
#======================================================================
# ** Paragrapher
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Module containing the objects for the Paragrapher
#======================================================================
module Paragrapher
#===================================================================
# Allows the 'Paragrapher.new' command outside of the module to be used
# rather than having to use 'Paragrapher::Paragrapher.new'
#===================================================================
class << self
def new(*args, &block)
return Paragrapher.new(*args, &block)
end
end
#===================================================================
# * The Paragrapher class
#===================================================================
class Paragrapher
def initialize(formatter, artist)
@formatter = formatter
@artist = artist
end
def paragraph(string, *specifications)
f = @formatter.format(string, *specifications)
return @artist.draw(f)
end
end
#===================================================================
# * The Formatter class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This class converts a string into a formatted text object, which is then
# passed on to the Artist class
#===================================================================
class Formatter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Format
# string : the string to be formatted
# specifications : the desired width of the paragraph, or the bitmap
#-------------------------------------------------------------------------------------------------------------------
# This works on a very simple algorithm. Basically, it just formats the
# text by going through each word in the string. If a word
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def format(string, specifications)
# Initializes Formatted_Text object
f = Formatted_Text.new
# Checks whether specifications is a bitmap or a number. It then sets
# max_width and f.bitmap accordingly
if specifications.is_a? (Bitmap)
f.bitmap = specifications
max_width = specifications.width
elsif specifications.is_a? (Fixnum) || specifications.is_a? (Float)
max_width = specifications
f.bitmap = Bitmap.new (max_width, 32)
else
# Error Catching: Bad Specifications
bitmap = Bitmap.new (200, 64)
f = format ('Specifications Error', bitmap)
p 'Specifications Error: Please Pass Fixnum, Float or Bitmap'
return f
end
# Breaks the given string into an array of all it's characters
temp_word_array = string.scan (/./)
position = 0
line_break = 0
# Initializes f.lines
f.lines = []
f.blank_width = []
for i in 0...temp_word_array.size
character = temp_word_array[i]
# Error catching
if character == "\n"
p 'This formatter does not recognize line breaks'
character = " "
end
# If at a new word
if character == " " || i == temp_word_array.size - 1
# Take into account the last character of the string
if i == temp_word_array.size - 1
i += 1
end
# If this word fits on the current line
if f.bitmap.text_size (string[line_break, i-line_break]).width <= max_width
position = i
else
line = temp_word_array[line_break, position-line_break]
# Adds the first lines to f.lines
f.lines.push (line)
# Calculates the blank space left to cover in the line
line_blank = max_width - f.bitmap.text_size(string[line_break,position-line_break]).width
# Calculates the necessary distance between letters to make up for
# line_blank and adds that value to the f.blank_width array
f.blank_width.push (line_blank.to_f / (line.size.to_f-1.0))
# Keeps track of the position in the array of each line
line_break = position + 1
position = i
end
end
end
# Adds the last line to f.lines
f.lines.push (temp_word_array[line_break, temp_word_array.size - line_break])
# Since the last line is drawn normally, blank_width should be 0
f.blank_width.push (0)
if specifications.class == Fixnum
# Sets up the bitmap if it was unspecified.
f.bitmap = Bitmap.new(max_width, f.lines.size*32)
end
# Returns the Formatted_Text object
return f
end
end
#===================================================================
# * Formatter 2 (Using Zeriab's Algorithm)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This algorithm was written by Zeriab for fonts which have characters of the same width.
# This is like Courier New, UMEGothic and fonts of that sort. This algorithm attaches a
# cost to each line based on the amount of white space at the end of that line. It will
# display the way of writing the text with the lowest total cost. In prcatice, this will mean
# that it will, as much as possible, reduce the spacing between letters in a line and make
# the spacing more consistent for each line of the paragraph
#===================================================================
class Formatter_2
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Format
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def format (string, specifications)
f = Formatted_Text.new
f.lines, f.blank_width, word_lengths, words = [], [], [], []
tracker = 0
for i in 0...string.size
if string[i,1] == " " || i == string.size - 1
if i == string.size - 1
i += 1
end
word_lengths.push (i - tracker)
words.push (string[tracker, i - tracker])
tracker = i + 1
end
end
if specifications.class == Bitmap
max_width = specifications.width
f.bitmap = specifications
elsif specifications.class == Fixnum || specifications.class == Float
max_width = specifications
f.bitmap = Bitmap.new (1,1)
else
# Error Catching: Bad specification
bitmap = Bitmap.new (200, 64)
f = format ('Specifications Error', bitmap)
p 'Specifications Error: Please Pass Fixnum, Float or Bitmap'
return f
end
tw = f.bitmap.text_size('a').width
max_width = [max_width / tw, 180].min
# Error Catching: Word too long
if word_lengths.max > max_width
f = format ('Too long' , specifications)
p 'One or more words is too long for specified width'
return f
end
position = line_break (word_lengths, max_width)
lines = give_lines (position, position.size - 1, words)
max_width *= tw
for i in 0...lines.size
line = lines[i]
f.lines.push (line.scan (/./))
if i == lines.size - 1
f.blank_width.push (0)
else
text_width = line.size * tw
extra_space = max_width - text_width
f.blank_width.push (extra_space.to_f / (line.size.to_f - 1.0))
end
end
if f.bitmap != specifications
f.bitmap = Bitmap.new (max_width, f.lines.size*32)
end
return f
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Line Break (written by Zeriab)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def line_break(word_lengths, max_length)
return false if max_length > 180
word_lengths.unshift(nil)
extra_spaces = Table.new(word_lengths.size,word_lengths.size)
line_prices = Table.new(word_lengths.size,word_lengths.size)
word_price = []
position = []
inf = max_length*max_length + 1
for i in 1...word_lengths.size
extra_spaces[i,i] = max_length - word_lengths[i]
for j in (i+1)..[word_lengths.size-1, max_length/2+i+1].min
extra_spaces[i,j] = extra_spaces[i,j-1] - word_lengths[j]-1
end
end
for i in 1...word_lengths.size
for j in i..[word_lengths.size-1, max_length/2+i+1].min
if extra_spaces[i,j] < 0
line_prices[i,j] = inf
elsif j == word_lengths.size-1 and extra_spaces[i,j] >= 0
line_prices[i,j] = 0
else
line_prices[i,j] = extra_spaces[i,j]*extra_spaces[i,j]
end
end
end
word_price[0] = 0
for j in 1...word_lengths.size
word_price[j] = inf
for ik in 1..j
i = j - ik + 1
break if line_prices[i,j] == inf
if word_price[i-1] + line_prices[i,j] < word_price[j]
word_price[j] = word_price[i-1] + line_prices[i,j]
position[j] = i
end
end
end
return position
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Give_Lines (written by Zeriab)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def give_lines(position,last_index,words)
first_index = position[last_index]
word_array = []
if first_index != 1
word_array = give_lines(position, first_index - 1,words)
end
str = ""
for x in first_index..last_index
str += ' ' if x != first_index
str += words[x-1]
end
word_array << str
return word_array
end
end
#===================================================================
# * The Artist class
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Interprets a Formatted Text object and draws the paragraph encoded
#===================================================================
class Artist
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw
# f : Formatted Text Object
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw (f)
# Calculates the necessary distance between lines
line_distance = f.bitmap.height.to_f / f.lines.size.to_f
line_distance = [f.bitmap.font.size + 10, line_distance].min
# For all lines in the lines array
for i in 0...f.lines.size
blank_space = f.blank_width[i]
position = 0
# For all indices of the line array
for j in 0...f.lines[i].size
word = f.lines[i][j]
ws = f.bitmap.text_size (word)
position += blank_space if j != 0
# Adds blank_space and position, and draws the string located at each index
f.bitmap.draw_text (position, line_distance*i,ws.width+1,ws.height+1,word)
# Keeps track of the position we are in in pixels
position += ws.width
end
end
return f.bitmap
end
end
#===================================================================
# * The Formatted_Text class containing the results of the formatter
#===================================================================
class Formatted_Text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :lines # An array of strings, each a line of the paragraph
attr_accessor :blank_width # The amount of white space between each letter
attr_accessor :bitmap # The bitmap drawn to
end
end
Los scripts no me dan problema con ningún otro texto ademas de que no me salta error, simplemente se queda la pantalla congelada... es mas, ni siquiera se pone blanca con el clásico "not responding", simplemente... se detiene. Lo que queria hacer con el evento es que al pasar a la pagina 2 se cambiara el sprite a un destello y en el 3 el sprite de una persona.... No se que hago mal. EDIT: Oops, olvidé decir que uso el VX. Última edición por Anrativa fecha: 28-oct-2011 a las 04:49. |
|
#2
|
||||
|
||||
|
Si el proble es "Mi personaje no se mueve"
la solucion es cambiar el detonante de inicio por Proceso Paralelo (y al final de este Borrar evento.)→esto no es obligatorio solo si quieres que el evento desaparesca,y si quieres que este alli unos isntantes usa esperar X frames Editt Última edición por ppablo_oz fecha: 12-dic-2011 a las 17:30. |
![]() |
|
|
Temas Similares para: Problema con evento
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| [Evento Pokemon] Manaphy Se Presenta en un Evento Wi-Fi | Charizard4200 | Nintendo DS | 7 | 24-ago-2010 03:29 |
| problema con un evento de Rmk2 | link RPG | RPG Maker | 0 | 15-ene-2010 20:38 |
| Problema con Evento | jesus1993 | RPG Maker | 4 | 01-abr-2009 04:33 |