#=============================================================================== # # Yanfly Engine RD - Custom Message System # Last Date Updated: 2009.06.14 # Level: Easy, Lunatic # # This is by no means a complex message system like Modern Algebra's ATS or # Woratana's Neo Message System. If you want a message system with a lot of # features, I highly recommend that you take a look at those. This message # system here will supply the most basic functions and needs without adding # too many extra features. # # What this script has to offer is basic functionality for new tags, a namebox # window, and drawn items, weapons, and armours along with their icons. There # also exists a Lunatic Mode to create quick and easy custom shortcuts. For # the most part, this script is plug and play. # #=============================================================================== # Updates: # ---------------------------------------------------------------------------- # o 2009.06.14 - Started script and finished. #=============================================================================== # Instructions #=============================================================================== # # Scroll down and bind ROW_VARIABLE to the desired variable. This variable will # let you adjust how many rows can be viewed at once. If the rows are set to 0, # it will display the default row amount of 4 rows. # # The following are codes you may use when typing out your messages. Replace # x, y with numbers unless specified otherwise. # # Code: Effect: # \v[x] Writes variable x's value. # \n[x] Writes actor x's name. # \c[x] Changes the colour of the text to x. # \g Displays the gold window. # \. Waits 15 frames (quarter second). # \| Waits 60 frames (a full second). # \! Waits until key is pressed. # \> Following text is instant. # \< Following text is no longer instant. # \^ Skips to the next message. # \\ Writes a "\" in the window. # # \w[x] Waits x frames (60 frames = 1 second). # # \nb[x] Creates a name window with x. Left side. # \nbl[x] Creates a name window with x. Locks the namebox. Left side. # \nbu[x] Creates a name window with x. Unlocks the namebox. Left side. # \rnb[x] Creates a name window with x. Right side. # \rnbl[x] Creates a name window with x. Locks the namebox. Right side. # \rnbu[x] Creates a name window with x. Unlocks the namebox. Right side. # \nbu Closes name window. Unlocks the namebox. # # \fn[x] Changes the font name to x. Set to 0 to reset font name. # \fs[x] Changes the font size to x. Set to 0 to reset font size. # \fb Changes the font to bold and back. # \fi Changes the font to italic # \fh Changes the font to shadowed and back. # # \ac[x] Writes actor x's class name. # \as[x] Writes actor x's subclass name. Requires Subclass System. # \ax[x] Writes actor x's combination class name. Requires Subclass System. # \af[x] Replaces face with actor x's face. # \af[x:y] Replaces face with actor x's face name but uses expression y. # # \pn[x] Writes ally's name in party slot x. # \pc[x] Writes ally's class name in party slot x. # \ps[x] Writes ally's subclass name in party slot x. # \px[x] Writes ally's combination class name in party slot x. # \pf[x] Replaces face with ally's face in party slot x. # \pf[x:y] Replaces face with ally's face name but uses expression y. # # \nc[x] Writes class ID x's name. # \ni[x] Writes item ID x's name. # \nw[x] Writes weapon ID x's name. # \na[x] Writes armour ID x's name. # \ns[x] Writes skill ID x's name. # \nt[x] Writes state ID x's name. # # \i[x] Draws icon ID x into the message window. # \ii[x] Writes item ID x's name with icon included. # \iw[x] Writes weapon ID x's name with icon included. # \ia[x] Writes armour ID x's name with icon included. # \is[x] Writes skill ID x's name with icon included. # \it[x] Writes state ID x's name with icon included. # #=============================================================================== # # Compatibility # - Incompatible: Any other message systems obviously. # - Alias: Window_Message: initialize, update, dispose, new_page # - Overwrites: Game_Interpreter: command_101, setup_choices # - Overwrites: Window_Message: convert_special_characters, update_message # #=============================================================================== # Credits: # Woratana for reference on stringing multiple message text. # Modern Algebra for reference on a few misc methods. #=============================================================================== $imported = {} if $imported == nil $imported["CustomMessageSystem"] = true module YE module MESSAGE # This adjusts how many rows are shown. On screen. If it's 0 or under, a # maximum of 4 rows will be shown. If it's above, it will show that many # rows and texts following it immediately after will also display that many # extra rows. ROW_VARIABLE = 90 # This adjusts the icon width. Used mostly for monospaced fonts so that # icons will not break the alignment. ICON_WIDTH = 24 # This determines where you would like the namebox window to appear relative # to the message window. Adjust the following accordingly. NAME_WINDOW_X = 0 # Adjusts X position offset from Message Window. NAME_WINDOW_Y = 40 # Adjusts Y position offset from Message Window. NAME_WINDOW_W = 20 # Adjusts extra width added to the Name Window. NAME_WINDOW_H = 40 # Adjusts the height of the Name Window. NAME_COLOUR = 6 # Default colour used for name box. # The following lets you adjust whether or not you would like to see the # back of the name window. NAME_WINDOW_SHOW_BACK = true # The following allows you to adjust the font defaults for ALL text in the # game. This includes the text outside of the message window and includes # the text within the menu windows. FONT_NAME = ["Verdana", "Arial", "Courier New"] FONT_SIZE = 20 FONT_BOLD = false FONT_ITALIC = false FONT_SHADOW = true end # MESSAGE end # YE #=============================================================================== # How to Use: Lunatic Mode #=============================================================================== # # This portion is for those who know how to script. # # \X[x] or \X[x:y] or \X[x:y:z] # These let you create your own custom tags. If you use the first tag, there is # one case for the "custom_convert" definition to return. If you use the second # tag, there will be two cases for you to select from. And likewise, if there's # three tags, then the z case will also be taken into account of. # #=============================================================================== class Window_Message < Window_Selectable def custom_convert(x_case, y_case = 0, z_case = 0) text = "" case x_case #--------------------------------------------------------------------------- # ////////////////////////////////////////////////////////////////////////// # This is where you begin adding in your own custom converted tags. #--------------------------------------------------------------------------- when 1 # Show the full name of the actor. case y_case # This is the extra case for the actor. when 1 text = "\\n[1] von Xiguel" when 2 text = "Michelle \\n[2]" when 3 text = "\\n[3] Manfred" when 4 text = "\\n[4] Fernaeus" end when 2 # Show how much gold the party has. text = $game_party.gold when 3 # Show party's max level text = $game_party.max_level #--------------------------------------------------------------------------- # This is the part you guys shouldn't touch afterwards. # ////////////////////////////////////////////////////////////////////////// #---------------------------------------------------------------------------"" end return text end end # Window_Message #=============================================================================== # Editting anything past this point may potentially result in causing computer # damage, incontinence, explosion of user's head, coma, death, and/or halitosis. # Therefore, edit at your own risk. #=============================================================================== Font.default_size = YE::MESSAGE::FONT_SIZE Font.default_name = YE::MESSAGE::FONT_NAME Font.default_bold = YE::MESSAGE::FONT_BOLD Font.default_italic = YE::MESSAGE::FONT_ITALIC Font.default_shadow = YE::MESSAGE::FONT_SHADOW #=============================================================================== # Window_Message #=============================================================================== class Window_Message < Window_Selectable #-------------------------------------------------------------------------- # alias initialize #-------------------------------------------------------------------------- alias initialize_cms initialize unless $@ def initialize initialize_cms var = $game_variables[YE::MESSAGE::ROW_VARIABLE] @max_rows = (var <= 0) ? 4 : var nheight = YE::MESSAGE::NAME_WINDOW_H @name_window = Window_Base.new(YE::MESSAGE::NAME_WINDOW_X, 0, 100, nheight) @name_text = Window_Base.new(YE::MESSAGE::NAME_WINDOW_X, 0, 100, 56) @name_window.openness = 0 @name_text.openness = 0 @name_text.opacity = 0 @name_window.z = self.z + 1 @name_text.z = @name_window.z + 1 @name_window_lock = false end #-------------------------------------------------------------------------- # alias dispose #-------------------------------------------------------------------------- alias dispose_cms dispose unless $@ def dispose dispose_cms @name_window.dispose if @name_window != nil @name_text.dispose if @name_text != nil end #-------------------------------------------------------------------------- # close #-------------------------------------------------------------------------- def close super @name_window.close @name_text.close @name_window_lock = false end #-------------------------------------------------------------------------- # alias update #-------------------------------------------------------------------------- alias update_cms update unless $@ def update @name_window.update @name_text.update refresh_size update_cms end #-------------------------------------------------------------------------- # refresh_size #-------------------------------------------------------------------------- def refresh_size var = $game_variables[YE::MESSAGE::ROW_VARIABLE] @max_rows = (var <= 0) ? 4 : var calc_height = @max_rows * 24 + 32 if self.height != calc_height self.height = calc_height create_contents end end #-------------------------------------------------------------------------- # overwrite reset_window #-------------------------------------------------------------------------- def reset_window var = $game_variables[YE::MESSAGE::ROW_VARIABLE] wheight = var <= 0 ? 4 * 24 + 32 : var * 24 + 32 @background = $game_message.background @position = $game_message.position self.opacity = (@background == 0) ? 255 : 0 case @position when 0 # Top self.y = 0 @gold_window.y = 360 when 1 # Middle self.y = (Graphics.height - wheight) / 2 @gold_window.y = 0 when 2 # Bottom self.y = (Graphics.height - wheight) @gold_window.y = 0 end end #-------------------------------------------------------------------------- # overwrite convert_special_characters #-------------------------------------------------------------------------- def convert_special_characters @name_window_open = false #------------------------------------------------------------- # Lunatic REGEXP Conversions #------------------------------------------------------------- @text.gsub!(/\\X\[(\d+)\]/i) { custom_convert($1.to_i) } @text.gsub!(/\\X\[(\d+):(\d+)\]/i) { custom_convert($1.to_i, $2.to_i) } @text.gsub!(/\\X\[(\d+):(\d+):(\d+)\]/i) { custom_convert($1.to_i, $2.to_i, $3.to_i) } #------------------------------------------------------------- # Default REGEXP Conversions #------------------------------------------------------------- @text.gsub!(/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] } @text.gsub!(/\\V\[(\d+)\]/i) { $game_variables[$1.to_i] } @text.gsub!(/\\N\[(\d+)\]/i) { $game_actors[$1.to_i].name } @text.gsub!(/\\C\[(\d+)\]/i) { "\x01{#{$1}}" } @text.gsub!(/\\G/i) { "\x02" } @text.gsub!(/\\\./) { "\x03" } @text.gsub!(/\\\|/) { "\x04" } @text.gsub!(/\\!/) { "\x05" } @text.gsub!(/\\>/) { "\x06" } @text.gsub!(/\\= @max_rows # If line count is maximum unless @text.empty? # If there is more self.pause = true # Insert number input break end end when "\x01" # \C[n] (text character color change) @text.sub!(/\{(\d+)\}/, "") contents.font.color = text_color($1.to_i) next when "\x02" # \G (gold display) @gold_window.refresh @gold_window.open when "\x03" # \. (wait 1/4 second) @wait_count = 15 break when "\x04" # \| (wait 1 second) @wait_count = 60 break when "\x05" # \! (Wait for input) self.pause = true break when "\x06" # \> (Fast display ON) @line_show_fast = true when "\x07" # \< (Fast display OFF) @line_show_fast = false when "\x08" # \^ (No wait for input) @pause_skip = true #---------------------------------------------------------------------- # New Cases #---------------------------------------------------------------------- when "\x09" # \| Wait x frames @text.sub!(/\{(\d+)\}/, "") @wait_count = $1.to_i break when "\x10" # \i Draws icon ID x @text.sub!(/\{(\d+)\}/, "") icon = $1.to_i icon_width = (24 - YE::MESSAGE::ICON_WIDTH) / 2 draw_icon(icon, @contents_x - icon_width, @contents_y) @contents_x += YE::MESSAGE::ICON_WIDTH when "\x11" # \fs Font Size Change @text.sub!(/\{(\d+)\}/, "") size = $1.to_i if size <= 0 # If 0, revert back to the default font size. size = Font.default_size end contents.font.size = size text_height = [size + (size / 5), WLH].max when "\x12" # \fs Font Name Change @text.sub!(/\{(.*?)\}/, "") name = $1.to_s if name == "0" # If 0, revert back to the default font. name = Font.default_name end contents.font.name = name when "\x13" # \fb Font bold contents.font.bold = contents.font.bold ? false : true when "\x14" # \fi Font italic contents.font.italic = contents.font.italic ? false : true when "\x15" # \fi Font shadowed contents.font.shadow = contents.font.shadow ? false : true #---------------------------------------------------------------------- # Finish Up #---------------------------------------------------------------------- else # Normal text character contents.draw_text(@contents_x, @contents_y, 40, text_height, c) c_width = contents.text_size(c).width @contents_x += c_width end break unless @show_fast or @line_show_fast end end #-------------------------------------------------------------------------- # alias new_page #-------------------------------------------------------------------------- alias new_page_cms new_page unless $@ def new_page new_page_cms contents.font.name = Font.default_name contents.font.size = Font.default_size contents.font.bold = Font.default_bold contents.font.italic = Font.default_italic contents.font.shadow = Font.default_shadow end #-------------------------------------------------------------------------- # combination_class #-------------------------------------------------------------------------- def combination_class(actor) return "" if actor == nil class1 = actor.class.name return class1 unless $imported["SubclassSelectionSystem"] return class1 if actor.subclass == nil class2 = actor.subclass.name text = sprintf(YE::SUBCLASS::DISPLAY_FORMAT, class1, class2) return text unless YE::SUBCLASS::USE_COMPLEX_CLASS_NAMES if YE::SUBCLASS::COMPLEX_CLASS_NAMES_FULL.include?(text) text = YE::SUBCLASS::COMPLEX_CLASS_NAMES_FULL[text] end return text end #-------------------------------------------------------------------------- # refresh_name_box #-------------------------------------------------------------------------- def refresh_name_box(name, side = 0) return if $game_temp.in_battle font_colour = YE::MESSAGE::NAME_COLOUR font_name = Font.default_name font_size = Font.default_size font_bold = Font.default_bold font_italic = Font.default_italic font_shadow = Font.default_shadow icon = 0 name_width = 0 #---Convert Special Characters name = name.gsub(/\x01\{(\d+)\}/i) { font_colour = $1.to_i ""} name = name.gsub(/\x09\{(\d+)\}/i) {""} name = name.gsub(/\x10\{(\d+)\}/i) { icon = $1.to_i name_width += YE::MESSAGE::ICON_WIDTH ""} name = name.gsub(/\x11\{(\d+)\}/i) { font_size = $1.to_i ""} name = name.gsub(/\x12\{(.*?)\}/i) { font_name = $1.to_s ""} name = name.gsub(/\x13/i) { font_bold = true ""} name = name.gsub(/\x14/i) { font_italic = true ""} name = name.gsub(/\x15/i) { font_shadow = true ""} #---Convert Special Characters @name_text.contents.font.name = font_name @name_text.contents.font.size = font_size @name_text.contents.font.bold = font_bold @name_text.contents.font.italic = font_italic @name_text.contents.font.shadow = font_shadow name_width += @name_text.contents.text_size(name).width name_width += YE::MESSAGE::NAME_WINDOW_W @name_window.width = name_width + 40 @name_text.width = @name_window.width var = $game_variables[YE::MESSAGE::ROW_VARIABLE] wheight = var <= 0 ? 4 * 24 + 32 : var * 24 + 32 position = $game_message.position case position when 0 @name_window.y = self.height - YE::MESSAGE::NAME_WINDOW_H @name_window.y += YE::MESSAGE::NAME_WINDOW_Y when 1 @name_window.y = (Graphics.height - wheight) / 2 @name_window.y -= YE::MESSAGE::NAME_WINDOW_Y when 2 @name_window.y = (Graphics.height - wheight) @name_window.y -= YE::MESSAGE::NAME_WINDOW_Y end offset = (@name_text.height - @name_window.height) / 2 @name_text.y = @name_window.y - offset if YE::MESSAGE::NAME_WINDOW_SHOW_BACK and $game_message.background == 0 @name_window.opacity = 255 else @name_window.opacity = 0 end if side == 0 @name_window.x = YE::MESSAGE::NAME_WINDOW_X else @name_window.x = Graphics.width - YE::MESSAGE::NAME_WINDOW_X @name_window.x -= @name_window.width end @name_text.x = @name_window.x @name_window.create_contents @name_text.create_contents txh = [font_size + (font_size / 5), WLH].max @name_text.contents.font.color = text_color(font_colour) @name_text.contents.font.name = font_name @name_text.contents.font.size = font_size @name_text.contents.font.bold = font_bold @name_text.contents.font.italic = font_italic @name_text.contents.font.shadow = font_shadow if icon > 0 iw = YE::MESSAGE::ICON_WIDTH @name_text.draw_icon(icon, YE::MESSAGE::NAME_WINDOW_W / 2, 0) @name_text.contents.draw_text(iw, 0, name_width + 8 - iw, txh, name, 1) else @name_text.contents.draw_text(0, 0, name_width + 8, txh, name, 1) end @name_window.open @name_text.open @name_window_open = true end end # Window_Message #=============================================================================== # Game_Interpreter #=============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # overwrite Show Text #-------------------------------------------------------------------------- def command_101 unless $game_message.busy $game_message.face_name = @params[0] $game_message.face_index = @params[1] $game_message.background = @params[2] $game_message.position = @params[3] flow = true loop { if @list[@index].code == 101 and meet_stringing_conditions and flow @index += 1 else break end flow = @row_check while @list[@index].code == 401 and meet_stringing_conditions $game_message.texts.push(@list[@index].parameters[0]) @index += 1 end } if @list[@index].code == 102 # Show choices setup_choices(@list[@index].parameters) elsif @list[@index].code == 103 # Number input processing setup_num_input(@list[@index].parameters) end set_message_waiting # Set to message wait state end return false end #-------------------------------------------------------------------------- # overwrite setup_choices #-------------------------------------------------------------------------- def setup_choices(params) var = $game_variables[YE::MESSAGE::ROW_VARIABLE] rows = (var <= 0) ? 4 : var if $game_message.texts.size <= rows - params[0].size $game_message.choice_start = $game_message.texts.size $game_message.choice_max = params[0].size for s in params[0] $game_message.texts.push(s) end $game_message.choice_cancel_type = params[1] $game_message.choice_proc = Proc.new { |n| @branch[@indent] = n } @index += 1 end end #-------------------------------------------------------------------------- # meet_stringing_conditions #-------------------------------------------------------------------------- def meet_stringing_conditions var = $game_variables[YE::MESSAGE::ROW_VARIABLE] rows = (var <= 0) ? 4 : var @row_check = (rows > 4) ? true : false return true if rows > $game_message.texts.size return false end end # Game_Interpreter #=============================================================================== # # END OF FILE # #===============================================================================