siengried Posted September 26, 2013 Share Posted September 26, 2013 (edited) Scusate io ho un problema con 2 script:Il primo è lo script di moghunter della battaglia mentre il secondo è quello di yafly dei messaggi...funzionano bene solo che in battaglia quando parlano esce il emssa sotto e poi esce sopra...non c'e un modo di creare compatiblità ecco i 2 link #============================================================================== # # ? Yanfly Engine Ace - Ace Message System v1.05 # -- Last Updated: 2012.01.13 # -- Level: Normal # -- Requires: n/a # #============================================================================== $imported = {} if $imported.nil? $imported["YEA-MessageSystem"] = true #============================================================================== # ? Updates # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # 2012.07.21 - Fixed REGEXP error at line 824 # 2012.01.13 - Bug Fixed: Negative tags didn't display other party members. # 2012.01.12 - Compatibility Update: Message Actor Codes # 2012.01.10 - Added Feature: \pic[x] text code. # 2012.01.04 - Bug Fixed: \ic tag was \ii. No longer the case. # - Added: Scroll Text window now uses message window font. # 2011.12.31 - Started Script and Finished. # #============================================================================== # ? Introduction # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # While RPG Maker VX Ace certainly improved the message system a whole lot, it # wouldn't hurt to add in a few more features, such as name windows, converting # textcodes to write out the icons and/or names of items, weapons, armours, and # more in quicker fashion. This script also gives the developer the ability to # adjust the size of the message window during the game, give it a separate # font, and to give the player a text fast-forward feature. # #============================================================================== # ? Instructions # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # To install this script, open up your script editor and copy/paste this script # to an open slot below ? Materials/?? but above ? Main. Remember to save. # # ----------------------------------------------------------------------------- # Message Window text Codes - These go inside of your message window. # ----------------------------------------------------------------------------- # Default: Effect: # \v[x] - Writes variable x's value. # \n[x] - Writes actor x's name. # \p[x] - Writes party member x's name. # \g - Writes gold currency name. # \c[x] - Changes the colour of the text to x. # \i[x] - Draws icon x at position of the text. # \{ - Makes text bigger by 8 points. # \} - Makes text smaller by 8 points. # \$ - Opens 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. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Wait: Effect: # \w[x] - Waits x frames (60 frames = 1 second). Message window only. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # NameWindow: Effect: # \n<x> - Creates a name box with x string. Left side. *Note # \nc<x> - Creates a name box with x string. Centered. *Note # \nr<x> - Creates a name box with x string. Right side. *Note # # *Note: Works for message window only. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Position: Effect: # \px[x] - Sets x position of text to x. # \py[x] - Sets y position of text to y. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Picture: Effect: # \pic[x] - Draws picture x from the Graphics\Pictures folder. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Outline: Effect: # \oc[x] - Sets outline colour to x. # \oo[x] - Sets outline opacity to x. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Font: Effect: # \fr - Resets all font changes. # \fz[x] - Changes font size to x. # \fn[x] - Changes font name to x. # \fb - Toggles font boldness. # \fi - Toggles font italic. # \fo - Toggles font outline. # \fs - Toggles font shadow. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Actor: Effect: # \af[x] - Shows face of actor x. *Note # \ac[x] - Writes out actor's class name. *Note # \as[x] - Writes out actor's subclass name. Req: Class System. *Note # \an[x] - Writes out actor's nickname. *Note # # *Note: If x is 0 or negative, it will show the respective # party member's face instead. # 0 - Party Leader # -1 - 1st non-leader member. # -2 - 2nd non-leader member. So on. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Names: Effect: # \nc[x] - Writes out class x's name. # \ni[x] - Writes out item x's name. # \nw[x] - Writes out weapon x's name. # \na[x] - Writes out armour x's name. # \ns[x] - Writes out skill x's name. # \nt[x] - Writes out state x's name. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Icon Names: Effect: # \ic[x] - Writes out class x's name including icon. * # \ii[x] - Writes out item x's name including icon. # \iw[x] - Writes out weapon x's name including icon. # \ia[x] - Writes out armour x's name including icon. # \is[x] - Writes out skill x's name including icon. # \it[x] - Writes out state x's name including icon. # # *Note: Requires YEA - Class System # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # And those are the text codes added with this script. Keep in mind that some # of these text codes only work for the Message Window. Otherwise, they'll work # for help descriptions, actor biographies, and others. # #============================================================================== # ? Compatibility # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that # it will run with RPG Maker VX without adjusting. # #============================================================================== module YEA module MESSAGE #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - General Message Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # The following below will adjust the basic settings and that will affect # the majority of the script. Adjust them as you see fit. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # This button is the button used to make message windows instantly skip # forward. Hold down for the effect. Note that when held down, this will # speed up the messages, but still wait for the pauses. However, it will # automatically go to the next page when prompted. TEXT_SKIP = :A # Input::A is the shift button on keyboard. # This variable adjusts the number of visible rows shown in the message # window. If you do not wish to use this feature, set this constant to 0. # If the row value is 0 or below, it will automatically default to 4 rows. VARIABLE_ROWS = 21 # This variable adjusts the width of the message window shown. If you do # not wish to use this feature, set this constant to 0. If the width value # is 0 or below, it will automatically default to the screen width. VARIABLE_WIDTH = 22 # This is the amount of space that the message window will indent whenever # a face is used. Default: 112 FACE_INDENT_X = 112 #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Name Window Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # The name window is a window that appears outside of the main message # window box to display whatever text is placed inside of it like a name. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- NAME_WINDOW_X_BUFFER = -20 # Buffer x position of the name window. NAME_WINDOW_Y_BUFFER = 0 # Buffer y position of the name window. NAME_WINDOW_PADDING = 20 # Padding added to the horizontal position. NAME_WINDOW_OPACITY = 255 # Opacity of the name window. NAME_WINDOW_COLOUR = 0 # Text colour used by default for names. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # - Message Font Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # Ace Message System separates the in-game system font form the message # font. Adjust the settings here for your fonts. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # This array constant determines the fonts used. If the first font does not # exist on the player's computer, the next font in question will be used # in place instead and so on. MESSAGE_WINDOW_FONT_NAME = ["Verdana", "Arial", "Courier New"] # These adjust the other settings regarding the way the game font appears # including the font size, whether or not the font is bolded by default, # italic by default, etc. MESSAGE_WINDOW_FONT_SIZE = 24 # Font size. MESSAGE_WINDOW_FONT_BOLD = false # Default bold? MESSAGE_WINDOW_FONT_ITALIC = false # Default italic? MESSAGE_WINDOW_FONT_OUTLINE = true # Default outline? MESSAGE_WINDOW_FONT_SHADOW = false # Default shadow? end # MESSAGE end # YEA #============================================================================== # ? Editting anything past this point may potentially result in causing # computer damage, incontinence, explosion of user's head, coma, death, and/or # halitosis so edit at your own risk. #============================================================================== #============================================================================== # ? Variable #============================================================================== module Variable #-------------------------------------------------------------------------- # self.message_rows #-------------------------------------------------------------------------- def self.message_rows return 4 if YEA::MESSAGE::VARIABLE_ROWS <= 0 return 4 if $game_variables[YEA::MESSAGE::VARIABLE_ROWS] <= 0 return $game_variables[YEA::MESSAGE::VARIABLE_ROWS] end #-------------------------------------------------------------------------- # self.message_width #-------------------------------------------------------------------------- def self.message_width return Graphics.width if YEA::MESSAGE::VARIABLE_WIDTH <= 0 return Graphics.width if $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] <= 0 return $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] end end # Variable #============================================================================== # ? Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # overwrite method: command_101 #-------------------------------------------------------------------------- def command_101 wait_for_message $game_message.face_name = @params[0] $game_message.face_index = @params[1] $game_message.background = @params[2] $game_message.position = @params[3] while continue_message_string? @index += 1 if @list[@index].code == 401 $game_message.add(@list[@index].parameters[0]) end break if $game_message.texts.size >= Variable.message_rows end case next_event_code when 102 @index += 1 setup_choices(@list[@index].parameters) when 103 @index += 1 setup_num_input(@list[@index].parameters) when 104 @index += 1 setup_item_choice(@list[@index].parameters) end wait_for_message end #-------------------------------------------------------------------------- # new method: continue_message_string? #-------------------------------------------------------------------------- def continue_message_string? return true if next_event_code == 101 && Variable.message_rows > 4 return next_event_code == 401 end end # Game_Interpreter #============================================================================== # ? Window_Base #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # new method: setup_message_font #-------------------------------------------------------------------------- def setup_message_font @message_font = true change_color(normal_color) contents.font.out_color = Font.default_out_color contents.font.name = YEA::MESSAGE::MESSAGE_WINDOW_FONT_NAME contents.font.size = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SIZE contents.font.bold = YEA::MESSAGE::MESSAGE_WINDOW_FONT_BOLD contents.font.italic = YEA::MESSAGE::MESSAGE_WINDOW_FONT_ITALIC contents.font.outline = YEA::MESSAGE::MESSAGE_WINDOW_FONT_OUTLINE contents.font.shadow = YEA::MESSAGE::MESSAGE_WINDOW_FONT_SHADOW end #-------------------------------------------------------------------------- # alias method: reset_font_settings #-------------------------------------------------------------------------- alias window_base_reset_font_settings_ams reset_font_settings def reset_font_settings if @message_font setup_message_font else window_base_reset_font_settings_ams contents.font.out_color = Font.default_out_color contents.font.outline = Font.default_outline contents.font.shadow = Font.default_shadow end end #-------------------------------------------------------------------------- # alias method: convert_escape_characters #-------------------------------------------------------------------------- alias window_base_convert_escape_characters_ams convert_escape_characters def convert_escape_characters(text) result = window_base_convert_escape_characters_ams(text) result = convert_ace_message_system_new_escape_characters(result) return result end #-------------------------------------------------------------------------- # new method: convert_ace_message_system_new_escape_characters #-------------------------------------------------------------------------- def convert_ace_message_system_new_escape_characters(result) #--- result.gsub!(/\eFR/i) { "\eAMSF[0]" } result.gsub!(/\eFB/i) { "\eAMSF[1]" } result.gsub!(/\eFI/i) { "\eAMSF[2]" } result.gsub!(/\eFO/i) { "\eAMSF[3]" } result.gsub!(/\eFS/i) { "\eAMSF[4]" } #--- result.gsub!(/\eAC\[([-+]?\d+)\]/i) { escape_actor_class_name($1.to_i) } result.gsub!(/\eAS\[([-+]?\d+)\]/i) { escape_actor_subclass_name($1.to_i) } result.gsub!(/\eAN\[([-+]?\d+)\]/i) { escape_actor_nickname($1.to_i) } #--- result.gsub!(/\eNC\[(\d+)\]/i) { $data_classes[$1.to_i].name } result.gsub!(/\eNI\[(\d+)\]/i) { $data_items[$1.to_i].name } result.gsub!(/\eNW\[(\d+)\]/i) { $data_weapons[$1.to_i].name } result.gsub!(/\eNA\[(\d+)\]/i) { $data_armors[$1.to_i].name } result.gsub!(/\eNS\[(\d+)\]/i) { $data_skills[$1.to_i].name } result.gsub!(/\eNT\[(\d+)\]/i) { $data_states[$1.to_i].name } #--- result.gsub!(/\eIC\[(\d+)\]/i) { escape_icon_item($1.to_i, :class) } result.gsub!(/\eII\[(\d+)\]/i) { escape_icon_item($1.to_i, :item) } result.gsub!(/\eIW\[(\d+)\]/i) { escape_icon_item($1.to_i, :weapon) } result.gsub!(/\eIA\[(\d+)\]/i) { escape_icon_item($1.to_i, :armour) } result.gsub!(/\eIS\[(\d+)\]/i) { escape_icon_item($1.to_i, :skill) } result.gsub!(/\eIT\[(\d+)\]/i) { escape_icon_item($1.to_i, :state) } #--- return result end #-------------------------------------------------------------------------- # new method: escape_actor_class_name #-------------------------------------------------------------------------- def escape_actor_class_name(actor_id) actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0 actor = $game_actors[actor_id] return "" if actor.nil? return actor.class.name end #-------------------------------------------------------------------------- # new method: actor_subclass_name #-------------------------------------------------------------------------- def escape_actor_subclass_name(actor_id) return "" unless $imported["YEA-ClassSystem"] actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0 actor = $game_actors[actor_id] return "" if actor.nil? return "" if actor.subclass.nil? return actor.subclass.name end #-------------------------------------------------------------------------- # new method: escape_actor_nickname #-------------------------------------------------------------------------- def escape_actor_nickname(actor_id) actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0 actor = $game_actors[actor_id] return "" if actor.nil? return actor.nickname end #-------------------------------------------------------------------------- # new method: escape_icon_item #-------------------------------------------------------------------------- def escape_icon_item(data_id, type) case type when :class return "" unless $imported["YEA-ClassSystem"] icon = $data_classes[data_id].icon_index name = $data_items[data_id].name when :item icon = $data_items[data_id].icon_index name = $data_items[data_id].name when :weapon icon = $data_weapons[data_id].icon_index name = $data_weapons[data_id].name when :armour icon = $data_armors[data_id].icon_index name = $data_armors[data_id].name when :skill icon = $data_skills[data_id].icon_index name = $data_skills[data_id].name when :state icon = $data_states[data_id].icon_index name = $data_states[data_id].name else; return "" end text = "\eI[#{icon}]" + name return text end #-------------------------------------------------------------------------- # alias method: process_escape_character #-------------------------------------------------------------------------- alias window_base_process_escape_character_ams process_escape_character def process_escape_character(code, text, pos) case code.upcase #--- when 'FZ' contents.font.size = obtain_escape_param(text) when 'FN' text.sub!(/\[(.*?)\]/, "") font_name = $1.to_s font_name = Font.default_name if font_name.nil? contents.font.name = font_name.to_s #--- when 'OC' colour = text_color(obtain_escape_param(text)) contents.font.out_color = colour when 'OO' contents.font.out_color.alpha = obtain_escape_param(text) #--- when 'AMSF' case obtain_escape_param(text) when 0; reset_font_settings when 1; contents.font.bold = !contents.font.bold when 2; contents.font.italic = !contents.font.italic when 3; contents.font.outline = !contents.font.outline when 4; contents.font.shadow = !contents.font.shadow end #--- when 'PX' pos[:x] = obtain_escape_param(text) when 'PY' pos[:y] = obtain_escape_param(text) #--- when 'PIC' text.sub!(/\[(.*?)\]/, "") bmp = Cache.picture($1.to_s) rect = Rect.new(0, 0, bmp.width, bmp.height) contents.blt(pos[:x], pos[:y], bmp, rect) #--- else window_base_process_escape_character_ams(code, text, pos) end end end # Window_Base #============================================================================== # ? Window_ChoiceList #============================================================================== class Window_ChoiceList < Window_Command #-------------------------------------------------------------------------- # alias method: initialize #-------------------------------------------------------------------------- alias window_choicelist_initialize_ams initialize def initialize(message_window) window_choicelist_initialize_ams(message_window) setup_message_font end end # Window_ChoiceList #============================================================================== # ? Window_ScrollText #============================================================================== class Window_ScrollText < Window_Base #-------------------------------------------------------------------------- # alias method: initialize #-------------------------------------------------------------------------- alias window_scrolltext_initialize_ams initialize def initialize window_scrolltext_initialize_ams setup_message_font end end # Window_ScrollText #============================================================================== # ? Window_NameMessage #============================================================================== class Window_NameMessage < Window_Base #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize(message_window) @message_window = message_window super(0, 0, Graphics.width, fitting_height(1)) self.opacity = YEA::MESSAGE::NAME_WINDOW_OPACITY self.z = @message_window.z + 1 self.openness = 0 setup_message_font @close_counter = 0 deactivate end #-------------------------------------------------------------------------- # update #-------------------------------------------------------------------------- def update super return if self.active return if self.openness == 0 return if @closing @close_counter -= 1 return if @close_counter > 0 close end #-------------------------------------------------------------------------- # start_close #-------------------------------------------------------------------------- def start_close @close_counter = 4 deactivate end #-------------------------------------------------------------------------- # force_close #-------------------------------------------------------------------------- def force_close @close_counter = 0 deactivate close end #-------------------------------------------------------------------------- # start #-------------------------------------------------------------------------- def start(text, x_position) @text = text.clone set_width create_contents set_x_position(x_position) set_y_position refresh activate open end #-------------------------------------------------------------------------- # set_width #-------------------------------------------------------------------------- def set_width text = @text.clone dw = standard_padding * 2 + text_size(text).width dw += YEA::MESSAGE::NAME_WINDOW_PADDING * 2 dw += calculate_size(text.slice!(0, 1), text) until text.empty? self.width = dw end #-------------------------------------------------------------------------- # calculate_size #-------------------------------------------------------------------------- def calculate_size(code, text) case code when "\e" return calculate_escape_code_width(obtain_escape_code(text), text) else return 0 end end #-------------------------------------------------------------------------- # calculate_escape_code_width #-------------------------------------------------------------------------- def calculate_escape_code_width(code, text) dw = -text_size("\e").width - text_size(code).width case code.upcase when 'C', 'OC', 'OO' dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width return dw when 'I' dw += -text_size("[" + obtain_escape_param(text).to_s + "]").width dw += 24 return dw when '{' make_font_bigger when '}' make_font_smaller when 'FZ' contents.font.size = obtain_escape_param(text) when 'FN' text.sub!(/\[(.*?)\]/, "") font_name = $1.to_s font_name = Font.default_name if font_name.nil? contents.font.name = font_name.to_s when 'AMSF' case obtain_escape_param(text) when 0; reset_font_settings when 1; contents.font.bold = !contents.font.bold when 2; contents.font.italic = !contents.font.italic when 3; contents.font.outline = !contents.font.outline when 4; contents.font.shadow = !contents.font.shadow end else return dw end end #-------------------------------------------------------------------------- # set_y_position #-------------------------------------------------------------------------- def set_x_position(x_position) case x_position when 1 # Left self.x = @message_window.x self.x += YEA::MESSAGE::NAME_WINDOW_X_BUFFER when 2 # 3/10 self.x = @message_window.x self.x += @message_window.width * 3 / 10 self.x -= self.width / 2 when 3 # Center self.x = @message_window.x self.x += @message_window.width / 2 self.x -= self.width / 2 when 4 # 7/10 self.x = @message_window.x self.x += @message_window.width * 7 / 10 self.x -= self.width / 2 when 5 # Right self.x = @message_window.x + @message_window.width self.x -= self.width self.x -= YEA::MESSAGE::NAME_WINDOW_X_BUFFER end self.x = [[self.x, Graphics.width - self.width].min, 0].max end #-------------------------------------------------------------------------- # set_y_position #-------------------------------------------------------------------------- def set_y_position case $game_message.position when 0 self.y = @message_window.height self.y -= YEA::MESSAGE::NAME_WINDOW_Y_BUFFER else self.y = @message_window.y - self.height self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER end end #-------------------------------------------------------------------------- # refresh #-------------------------------------------------------------------------- def refresh contents.clear reset_font_settings @text = sprintf("\eC[%d]%s", YEA::MESSAGE::NAME_WINDOW_COLOUR, @text) draw_text_ex(YEA::MESSAGE::NAME_WINDOW_PADDING, 0, @text) end end # Window_NameMessage #============================================================================== # ? Window_Message #============================================================================== class Window_Message < Window_Base #-------------------------------------------------------------------------- # alias method: initialize #-------------------------------------------------------------------------- alias window_message_initialize_ams initialize def initialize window_message_initialize_ams setup_message_font end #-------------------------------------------------------------------------- # overwrite method: window_width #-------------------------------------------------------------------------- def window_width return Variable.message_width end #-------------------------------------------------------------------------- # overwrite method: window_height #-------------------------------------------------------------------------- def window_height return fitting_height(Variable.message_rows) end #-------------------------------------------------------------------------- # alias method: create_all_windows #-------------------------------------------------------------------------- alias window_message_create_all_windows_ams create_all_windows def create_all_windows window_message_create_all_windows_ams @name_window = Window_NameMessage.new(self) end #-------------------------------------------------------------------------- # overwrite method: create_back_bitmap #-------------------------------------------------------------------------- def create_back_bitmap @back_bitmap = Bitmap.new(width, height) rect1 = Rect.new(0, 0, Graphics.width, 12) rect2 = Rect.new(0, 12, Graphics.width, fitting_height(4) - 24) rect3 = Rect.new(0, fitting_height(4) - 12, Graphics.width, 12) @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true) @back_bitmap.fill_rect(rect2, back_color1) @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true) end #-------------------------------------------------------------------------- # alias method: dispose_all_windows #-------------------------------------------------------------------------- alias window_message_dispose_all_windows_ams dispose_all_windows def dispose_all_windows window_message_dispose_all_windows_ams @name_window.dispose end #-------------------------------------------------------------------------- # alias method: update_all_windows #-------------------------------------------------------------------------- alias window_message_update_all_windows_ams update_all_windows def update_all_windows window_message_update_all_windows_ams @name_window.update @name_window.back_opacity = self.back_opacity @name_window.opacity = self.opacity end #-------------------------------------------------------------------------- # alias method: update_show_fast #-------------------------------------------------------------------------- alias window_message_update_show_fast_ams update_show_fast def update_show_fast @show_fast = true if Input.press?(YEA::MESSAGE::TEXT_SKIP) window_message_update_show_fast_ams end #-------------------------------------------------------------------------- # overwrite method: input_pause #-------------------------------------------------------------------------- def input_pause self.pause = true wait(10) Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || Input.press?(YEA::MESSAGE::TEXT_SKIP) Input.update self.pause = false end #-------------------------------------------------------------------------- # overwrite method: convert_escape_characters #-------------------------------------------------------------------------- def convert_escape_characters(text) result = super(text.to_s.clone) result = namebox_escape_characters(result) result = message_escape_characters(result) return result end #-------------------------------------------------------------------------- # new method: namebox_escape_characters #-------------------------------------------------------------------------- def namebox_escape_characters(result) result.gsub!(/\eN\<(.+?)\>/i) { namewindow($1, 1) } result.gsub!(/\eN1\<(.+?)\>/i) { namewindow($1, 1) } result.gsub!(/\eN2\<(.+?)\>/i) { namewindow($1, 2) } result.gsub!(/\eNC\<(.+?)\>/i) { namewindow($1, 3) } result.gsub!(/\eN3\<(.+?)\>/i) { namewindow($1, 3) } result.gsub!(/\eN4\<(.+?)\>/i) { namewindow($1, 4) } result.gsub!(/\eN5\<(.+?)\>/i) { namewindow($1, 5) } result.gsub!(/\eNR\<(.+?)\>/i) { namewindow($1, 5) } return result end #-------------------------------------------------------------------------- # new method: namebox #-------------------------------------------------------------------------- def namewindow(text, position) @name_text = text @name_position = position return "" end #-------------------------------------------------------------------------- # new method: message_escape_characters #-------------------------------------------------------------------------- def message_escape_characters(result) result.gsub!(/\eAF\[(-?\d+)]/i) { change_face($1.to_i) } return result end #-------------------------------------------------------------------------- # new method: change_face #-------------------------------------------------------------------------- def change_face(actor_id) actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0 actor = $game_actors[actor_id] return "" if actor.nil? $game_message.face_name = actor.face_name $game_message.face_index = actor.face_index return "" end #-------------------------------------------------------------------------- # alias method: new_page #-------------------------------------------------------------------------- alias window_message_new_page_ams new_page def new_page(text, pos) adjust_message_window_size window_message_new_page_ams(text, pos) end #-------------------------------------------------------------------------- # overwrite method: new_line_x #-------------------------------------------------------------------------- def new_line_x return $game_message.face_name.empty? ? 0 : YEA::MESSAGE::FACE_INDENT_X end #-------------------------------------------------------------------------- # new method: adjust_message_window_size #-------------------------------------------------------------------------- def adjust_message_window_size self.height = window_height self.width = window_width create_contents update_placement self.x = (Graphics.width - self.width) / 2 start_name_window end #-------------------------------------------------------------------------- # new method: clear_name_window #-------------------------------------------------------------------------- def clear_name_window @name_text = "" @name_position = 0 end #-------------------------------------------------------------------------- # new method: start_name_window #-------------------------------------------------------------------------- def start_name_window return if @name_text == "" @name_window.start(@name_text, @name_position) end #-------------------------------------------------------------------------- # overwrite method: fiber_main #-------------------------------------------------------------------------- def fiber_main $game_message.visible = true update_background update_placement loop do process_all_text if $game_message.has_text? process_input $game_message.clear @gold_window.close @name_window.start_close Fiber.yield break unless text_continue? end close_and_wait $game_message.visible = false @fiber = nil end #-------------------------------------------------------------------------- # alias method: open_and_wait #-------------------------------------------------------------------------- alias window_message_open_and_wait_ams open_and_wait def open_and_wait clear_name_window adjust_message_window_size window_message_open_and_wait_ams end #-------------------------------------------------------------------------- # alias method: close_and_wait #-------------------------------------------------------------------------- alias window_message_close_and_wait_ams close_and_wait def close_and_wait @name_window.force_close window_message_close_and_wait_ams end #-------------------------------------------------------------------------- # alias method: all_close? #-------------------------------------------------------------------------- alias window_message_all_close_ams all_close? def all_close? return window_message_all_close_ams && @name_window.close? end #-------------------------------------------------------------------------- # alias method: process_escape_character #-------------------------------------------------------------------------- alias window_message_process_escape_character_ams process_escape_character def process_escape_character(code, text, pos) case code.upcase when 'W' # Wait wait(obtain_escape_param(text)) else window_message_process_escape_character_ams(code, text, pos) end end end # Window_Message #============================================================================== # # ? End of File # #============================================================================== e questo è quello della battaglia #============================================================================== # +++ MOG - Advanced Battle Hud (v2.6) +++ #============================================================================== # By Moghunter # [url=http://www.atelier-rgss.com/]http://www.atelier-rgss.com/[/url] #============================================================================== # Sistema de hud avançado de batalha. #============================================================================== #============================================================================== # ? Histórico (Version History) #============================================================================== # v 2.6 - Melhor codificação # v 2.5 - Melhoria na performance # - Correção de bugs. #============================================================================== # # Battle_AT_Layout.png # Battle_AT_Meter.png # #============================================================================== # ? - FACE ANIMADAS DOS PERSONAGENS - (Opcional) #============================================================================== # 1 - Grave as imagens das faces dos personagens na pasta. # # GRAPHICS/BATTLERS/ # # 2 - Nomeie a imagem com o mesmo nome do personagem. (EG - Hertor.png) # 3 - A largura da imagem deverá ser dividido por 5. (A escolha do tamanho # da face é livre desde que a lagura dividido pela altura seja igual a 5 ) # #============================================================================== #============================================================================== # ? BATTLE HUD SETTING #============================================================================== module MOG_BATTLE_HUD # Ativar Battlers dos personagens em faces, deixe desativado em caso de haver # outros scripts que usam battlers dos personagens em seu projeto. BATTLER_FACE_ENABLE = true #Definição geral da posição da HUD. HUD_POSITION = [5,315] #Definição da posição da face FACE_POSITION = [60,30] #Definição da posição do numero de HP. HP_NUMBER_POSITION = [85,28] #Definição da posição do medidor de HP. HP_METER_POSITION = [27,37] #Definição da posição do numero de MP. MP_NUMBER_POSITION = [101,46] #Definição da posição do medidor de MP. MP_METER_POSITION = [43,55] #Definição da posição do numero de TP. TP_NUMBER_POSITION = [85,64] #Definição da posição do medidor de TP. TP_METER_POSITION = [27,73] #Definição da posição das condições STATES_POSITION = [5,1] #Definição da posição do comando de batalha. COMMAND_POSITION = [0,-145] #Definição da posição do espaço da HUD entre os membros do grupo. MEMBERS_SPACE = [136,0] #Definição da prioridade da HUD. BATTLE_HUD_Z = 0 #Definição da velocidade de animação dos medidores. METER_FLOW_SPEED = 2 #Ativa o layout mais limpo nas janelas de item e skill. ITEM_SKILL_WINDOWS_CLEAN_STYLE = true #Definição da opacidade das janelas. ITEM_SKILL_WINDOW_OPACITY = 0 end #============================================================================== # ? Game Temp #============================================================================== class Game_Temp attr_accessor :cache_battle_hud #-------------------------------------------------------------------------- # ? Initialize #-------------------------------------------------------------------------- alias mog_battle_hud_initialize initialize def initialize mog_battle_hud_initialize pre_cache_battle_hud end #-------------------------------------------------------------------------- # ? Pre Cache Battle Hud #-------------------------------------------------------------------------- def pre_cache_battle_hud @cache_battle_hud = [] @cache_battle_hud.push(Cache.system("Battle_Hud_Number")) @cache_battle_hud.push(Cache.system("Battle_Hud_Meter")) @cache_battle_hud.push(Cache.system("Iconset")) @cache_battle_hud.push(Cache.system("Battle_Hud_Layout")) end end #============================================================================== # ? Battle_Hud #============================================================================== class Battle_Hud include MOG_BATTLE_HUD #-------------------------------------------------------------------------- # ? Initialize #-------------------------------------------------------------------------- def initialize(actor) @actor = actor @x = HUD_POSITION[0] + (MEMBERS_SPACE[0] * @actor.index) @y = HUD_POSITION[1] + (MEMBERS_SPACE[1] * @actor.index) @flow_speed = 0 pre_cache create_layout create_hp_number create_hp_meter create_mp_number create_mp_meter create_tp_number create_tp_meter create_states end #-------------------------------------------------------------------------- # ? Pre Cache #-------------------------------------------------------------------------- def pre_cache $game_temp.pre_cache_battle_hud @number = $game_temp.cache_battle_hud[0] @number_cw = @number.width / 10 @number_ch = @number.height / 4 @meter = $game_temp.cache_battle_hud[1] @meter_cw = @meter.width / 3 @meter_ch = @meter.height / 3 @icon = $game_temp.cache_battle_hud[2] end #-------------------------------------------------------------------------- # ? Create Layout #-------------------------------------------------------------------------- def create_layout @layout = Sprite.new @layout.bitmap = $game_temp.cache_battle_hud[3] @layout.z = BATTLE_HUD_Z @layout.x = @x @layout.y = @y end #-------------------------------------------------------------------------- # ? Create HP Number #-------------------------------------------------------------------------- def create_hp_number @hp = @actor.hp @hp_old = @actor.hp @hp_ref = @hp_old @hp_refresh = false @hp_number = Sprite.new @hp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch) @hp_number.z = BATTLE_HUD_Z + 2 @hp_number.x = @x + HP_NUMBER_POSITION[0] @hp_number.y = @y + HP_NUMBER_POSITION[1] refresh_hp_number end #-------------------------------------------------------------------------- # ? Create HP Meter #-------------------------------------------------------------------------- def create_hp_meter @hp_meter = Sprite.new @hp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch) @hp_meter.z = BATTLE_HUD_Z + 1 @hp_meter.x = @x + HP_METER_POSITION[0] @hp_meter.y = @y + HP_METER_POSITION[1] @hp_flow = rand(@meter_cw * 2) @hp_width_old = @meter_cw * @actor.hp / @actor.mhp hp_flow_update end #-------------------------------------------------------------------------- # ? Hp Flow Update #-------------------------------------------------------------------------- def hp_flow_update @hp_meter.bitmap.clear hp_width = @meter_cw * @actor.hp / @actor.mhp hp_src_rect = Rect.new(@hp_flow, 0,hp_width, @meter_ch) @hp_meter.bitmap.blt(0,0, @meter, hp_src_rect) @hp_flow += METER_FLOW_SPEED @hp_flow = 0 if @hp_flow >= @meter_cw * 2 end #-------------------------------------------------------------------------- # ? Execute Damage Flow #-------------------------------------------------------------------------- def execute_damage_flow(hp_width) n = (@hp_width_old - hp_width).abs * 3 / 100 damage_flow = [[n, 2].min,0.5].max @hp_width_old -= damage_flow @hp_width_old = hp_width if @hp_width_old < hp_width src_rect_old = Rect.new(@hp_flow, @meter_ch * 3,@hp_width_old, @meter_ch) @hp_meter.bitmap.blt(0,0, @meter, src_rect_old) end #-------------------------------------------------------------------------- # ? Update HP Number #-------------------------------------------------------------------------- def update_hp_number @hp_refresh = true n = 2 * (@actor.hp - @hp_old).abs / 100 hp_ref = [[n, 100].min,1].max if @hp_old < @actor.hp @hp += hp_ref if @hp >= @actor.hp @hp_old = @actor.hp @hp = @actor.hp @hp_ref = 0 end elsif @hp_old > @actor.hp @hp -= hp_ref if @hp <= @actor.hp @hp_old = @actor.hp @hp = @actor.hp @hp_ref = 0 end end end #-------------------------------------------------------------------------- # ? Refresh HP Number #-------------------------------------------------------------------------- def refresh_hp_number @flow_speed = METER_FLOW_SPEED @hp_number.bitmap.clear number_value = @hp.abs.to_s.split(//) hp_color = @hp < @actor.mhp * 30 / 100 ? @number_ch : 0 center_x = 0 for r in 0..number_value.size - 1 number_value_abs = number_value[r].to_i src_rect = Rect.new(@number_cw * number_value_abs, hp_color, @number_cw, @number_ch) @hp_number.bitmap.blt((@number_cw + 1) * r, 0, @number, src_rect) center_x += 1 end @hp_number.x = @x + HP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1)) @hp_refresh = false if @hp == @actor.hp end #-------------------------------------------------------------------------- # ? Create MP Number #-------------------------------------------------------------------------- def create_mp_number @mp = @actor.mp @mp_old = @actor.mp @mp_ref = @mp_old @mp_refresh = false @mp_number = Sprite.new @mp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch) @mp_number.z = BATTLE_HUD_Z + 2 @mp_number.x = @x + MP_NUMBER_POSITION[0] @mp_number.y = @y + MP_NUMBER_POSITION[1] refresh_mp_number end #-------------------------------------------------------------------------- # ? Create MP Meter #-------------------------------------------------------------------------- def create_mp_meter @mp_meter = Sprite.new @mp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch) @mp_meter.z = BATTLE_HUD_Z + 1 @mp_meter.x = @x + MP_METER_POSITION[0] @mp_meter.y = @y + MP_METER_POSITION[1] @mp_flow = rand(@meter_cw * 2) @mp_width_old = @meter_cw * @actor.mp / @actor.mmp rescue 0 mp_flow_update end #-------------------------------------------------------------------------- # ? Mp Flow Update #-------------------------------------------------------------------------- def mp_flow_update return if @actor.mmp == 0 @mp_meter.bitmap.clear mp_width = @meter_cw * @actor.mp / @actor.mmp rescue 0 src_rect = Rect.new(@mp_flow, @meter_ch,mp_width, @meter_ch) @mp_meter.bitmap.blt(0,0, @meter, src_rect) @mp_flow += METER_FLOW_SPEED @mp_flow = 0 if @mp_flow >= @meter_cw * 2 end #-------------------------------------------------------------------------- # ? Update MP Number #-------------------------------------------------------------------------- def update_mp_number @mp_refresh = true n = 2 * (@actor.mp - @mp_old).abs / 100 mp_ref = [[n, 100].min,1].max if @mp_old < @actor.mp @mp += mp_ref if @mp >= @actor.mp @mp_old = @actor.mp @mp = @actor.mp @mp_ref = 0 end elsif @mp_old > @actor.mp @mp -= mp_ref if @mp <= @actor.mp @mp_old = @actor.mp @mp = @actor.mp @mp_ref = 0 end end end #-------------------------------------------------------------------------- # ? Refresh MP Number #-------------------------------------------------------------------------- def refresh_mp_number @flow_speed = METER_FLOW_SPEED @mp_number.bitmap.clear number_value = @mp.abs.to_s.split(//) center_x = 0 for r in 0..number_value.size - 1 number_value_abs = number_value[r].to_i src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 2, @number_cw, @number_ch) @mp_number.bitmap.blt((@number_cw + 1) * r, 0, @number, src_rect) center_x += 1 end @mp_number.x = @x + MP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1)) @mp_refresh = false if @mp == @actor.mp end #-------------------------------------------------------------------------- # ? Create TP Number #-------------------------------------------------------------------------- def create_tp_number @tp = @actor.tp @tp_old = @actor.tp @tp_ref = @tp_old @tp_refresh = false @tp_number = Sprite.new @tp_number.bitmap = Bitmap.new((@number_cw * 6),@number_ch) @tp_number.z = BATTLE_HUD_Z + 2 @tp_number.x = @x + TP_NUMBER_POSITION[0] @tp_number.y = @y + TP_NUMBER_POSITION[1] refresh_tp_number end #-------------------------------------------------------------------------- # ? Create TP Meter #-------------------------------------------------------------------------- def create_tp_meter @tp_meter = Sprite.new @tp_meter.bitmap = Bitmap.new(@meter_cw,@meter_ch) @tp_meter.z = BATTLE_HUD_Z + 1 @tp_meter.x = @x + TP_METER_POSITION[0] @tp_meter.y = @y + TP_METER_POSITION[1] @tp_flow = rand(@meter_cw * 2) @tp_width_old = @meter_cw * @actor.tp / @actor.max_tp rescue 0 tp_flow_update end #-------------------------------------------------------------------------- # ? TP Flow Update #-------------------------------------------------------------------------- def tp_flow_update return if @actor.max_tp == 0 @tp_meter.bitmap.clear tp_width = @meter_cw * @actor.tp / @actor.max_tp rescue 0 src_rect = Rect.new(@tp_flow, @meter_ch * 2,tp_width, @meter_ch) @tp_meter.bitmap.blt(0,0, @meter, src_rect) @tp_flow += METER_FLOW_SPEED @tp_flow = 0 if @tp_flow >= @meter_cw * 2 end #-------------------------------------------------------------------------- # ? Update TP Number #-------------------------------------------------------------------------- def update_tp_number @tp_refresh = true n = 2 * (@actor.tp - @tp_old).abs / 100 tp_ref = [[n, 100].min,1].max if @tp_old < @actor.tp @tp += tp_ref if @tp >= @actor.tp @tp_old = @actor.tp @tp = @actor.tp @tp_ref = 0 end elsif @tp_old > @actor.tp @tp -= tp_ref if @tp <= @actor.tp @tp_old = @actor.tp @tp = @actor.tp @tp_ref = 0 end end end #-------------------------------------------------------------------------- # ? Refresh TP Number #-------------------------------------------------------------------------- def refresh_tp_number @flow_speed = METER_FLOW_SPEED @tp_number.bitmap.clear number_value = @tp.truncate.to_s.split(//) center_x = 0 for r in 0..number_value.size - 1 number_value_abs = number_value[r].to_i src_rect = Rect.new(@number_cw * number_value_abs, @number_ch * 3, @number_cw, @number_ch) @tp_number.bitmap.blt((@number_cw + 1) * r, 0, @number, src_rect) center_x += 1 end @tp_number.x = @x + TP_NUMBER_POSITION[0] - (center_x * (@number_cw + 1)) @tp_refresh = false if @tp == @actor.tp end #-------------------------------------------------------------------------- # ? Create_States #-------------------------------------------------------------------------- def create_states refresh_states @status = Sprite.new @status.bitmap = Bitmap.new(24,24) @status.x = @x + STATES_POSITION[0] @status.y = @y + STATES_POSITION[1] @status_flow = -24 @states_speed = 50 @status.z = BATTLE_HUD_Z + 2 @old_states = @actor.states flow_states end #-------------------------------------------------------------------------- # ? Flow_Status #-------------------------------------------------------------------------- def flow_states return if @actor.states.size == 0 and !@status.visible @states_speed = 0 @status.bitmap.clear src_rect = Rect.new(@status_flow,0, 24,24) @status.bitmap.blt(0,0, @actor_status, src_rect) @status.visible = @actor.states.size == 0 ? false : true @status_flow += 1 @status_flow = -24 if @status_flow >= @states_size - 24 end #-------------------------------------------------------------------------- # ? Refresh States #-------------------------------------------------------------------------- def refresh_states @old_states = @actor.states @actor_status.dispose if @actor_status != nil @states_size = @actor.states.size > 0 ? (48 * @actor.states.size) : 24 @actor_status = Bitmap.new(@states_size,24) index = 0 for i in @actor.states rect = Rect.new(i.icon_index % 16 * 24, i.icon_index / 16 * 24, 24, 24) @actor_status.blt(48 * index , 0, @icon, rect) index += 1 end end #-------------------------------------------------------------------------- # ? Dispose #-------------------------------------------------------------------------- def dispose return if @layout == nil @layout.dispose @hp_number.bitmap.dispose @hp_number.dispose @hp_meter.bitmap.dispose @hp_meter.dispose @mp_number.bitmap.dispose @mp_number.dispose @mp_meter.bitmap.dispose @mp_meter.dispose @tp_number.bitmap.dispose @tp_number.dispose @tp_meter.bitmap.dispose @tp_meter.dispose @status.bitmap.dispose @status.dispose @actor_status.dispose if @actor_status != nil @layout = nil end #-------------------------------------------------------------------------- # ? Update #-------------------------------------------------------------------------- def update return if @meter == nil update_hp_number if @hp_old != @actor.hp refresh_hp_number if @hp_refresh update_mp_number if @mp_old != @actor.mp refresh_mp_number if @mp_refresh update_tp_number if @tp_old != @actor.tp refresh_tp_number if @tp_refresh refresh_states if @old_states != @actor.states @flow_speed += 1 if @flow_speed >= METER_FLOW_SPEED @flow_speed = 0 hp_flow_update tp_flow_update mp_flow_update end flow_states end end #============================================================================== # ? Game_System #============================================================================== class Game_System attr_accessor :battler_hud #-------------------------------------------------------------------------- # ? Initialize #-------------------------------------------------------------------------- alias mog_adv_battle_hud_initialize initialize def initialize @battler_hud = false mog_adv_battle_hud_initialize end end #============================================================================== # ? Spriteset Battle #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ? Initialize #-------------------------------------------------------------------------- alias mog_battle_hud_initialize initialize def initialize mog_battle_hud_initialize create_battle_hud end #-------------------------------------------------------------------------- # ? Create Battle Hud #-------------------------------------------------------------------------- def create_battle_hud @battle_hud = [] for i in $game_party.battle_members @battle_hud.push(Battle_Hud.new(i)) end end #-------------------------------------------------------------------------- # ? Dispose #-------------------------------------------------------------------------- alias mog_battle_hud_dispose dispose def dispose mog_battle_hud_dispose dispose_battle_hud end #-------------------------------------------------------------------------- # ? Dispose Battle Hud #-------------------------------------------------------------------------- def dispose_battle_hud return if @battle_hud == nil @battle_hud.each {|sprite| sprite.dispose } @battle_hud = nil end #-------------------------------------------------------------------------- # ? Update #-------------------------------------------------------------------------- alias mog_battle_hud_update update def update mog_battle_hud_update update_battle_hud end #-------------------------------------------------------------------------- # ? Update Battle Hud #-------------------------------------------------------------------------- def update_battle_hud return if @battle_hud == nil @battle_hud.each {|sprite| sprite.update } end end #============================================================================== # ? Game_Actor #============================================================================== class Game_Actor < Game_Battler include MOG_BATTLE_HUD attr_accessor :hud_x attr_accessor :hud_y #-------------------------------------------------------------------------- # ? HUD X #-------------------------------------------------------------------------- def hud_x return HUD_POSITION[0] + (MEMBERS_SPACE[0] * index) end #-------------------------------------------------------------------------- # ? HUD Y #-------------------------------------------------------------------------- def hud_y return HUD_POSITION[1] + (MEMBERS_SPACE[1] * index) end end #============================================================================== # ? Scene Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ? Create Party Command Window #-------------------------------------------------------------------------- alias mog_battle_hud_create_party_command_window create_party_command_window def create_party_command_window mog_battle_hud_create_party_command_window set_party_window_position end #-------------------------------------------------------------------------- # ? Set Party Window Position #-------------------------------------------------------------------------- def set_party_window_position @party_command_window.viewport = nil return if $mog_rgss3_at_system != nil a_index = [] for actor in $game_party.alive_members a_index = [actor.hud_x, actor.hud_y] break end return if a_index.empty? @party_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + a_index[0] @party_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + a_index[1] end #-------------------------------------------------------------------------- # ? Set Party Window Position #-------------------------------------------------------------------------- alias mog_battle_hud_start_party_command_selection start_party_command_selection def start_party_command_selection set_party_window_position mog_battle_hud_start_party_command_selection end #-------------------------------------------------------------------------- # ? Update #-------------------------------------------------------------------------- alias mog_battle_hud_update_basic update_basic def update_basic mog_battle_hud_update_basic update_command_window_visible end #-------------------------------------------------------------------------- # ? Update Command Window Visible #-------------------------------------------------------------------------- def update_command_window_visible @status_window.visible = @status_window.active ? true : false @actor_command_window.visible = @actor_command_window.active ? true : false @skill_window.visible = @skill_window.active ? true : false @item_window.visible = @item_window.active ? true : false end #-------------------------------------------------------------------------- # ? Start Actor Command Selection #-------------------------------------------------------------------------- alias mog_battle_hud_start_actor_command_selection start_actor_command_selection def start_actor_command_selection mog_battle_hud_start_actor_command_selection @actor_command_window.viewport = nil @actor_command_window.x = MOG_BATTLE_HUD::COMMAND_POSITION[0] + $game_party.members[BattleManager.actor.index].hud_x @actor_command_window.y = MOG_BATTLE_HUD::COMMAND_POSITION[1] + $game_party.members[BattleManager.actor.index].hud_y @party_command_window.x = @actor_command_window.x @party_command_window.y = @actor_command_window.y end end #============================================================================== # ? Game_Actor #============================================================================== class Game_Actor < Game_Battler include MOG_BATTLE_HUD attr_accessor :battler_face attr_accessor :battler_face_name attr_accessor :screen_x attr_accessor :screen_y attr_accessor :screen_z #-------------------------------------------------------------------------- # ? Initialize #-------------------------------------------------------------------------- alias mog_battle_hud_initialize setup def setup(actor_id) mog_battle_hud_initialize(actor_id) battler_sprite_setup end #-------------------------------------------------------------------------- # ? Battler Sprite Setup #-------------------------------------------------------------------------- def battler_sprite_setup @battler_face = [0,0,0] @battler_face_name = @name + "_Face" end if BATTLER_FACE_ENABLE #-------------------------------------------------------------------------- # ? Use Sprite? #-------------------------------------------------------------------------- def use_sprite? return true end end end #============================================================================== # ? Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base include MOG_BATTLE_HUD #-------------------------------------------------------------------------- # ? Dispose #-------------------------------------------------------------------------- alias mog_battler_face_dispose dispose def dispose mog_battler_face_dispose dispose_battler_face end #-------------------------------------------------------------------------- # ? Update #-------------------------------------------------------------------------- alias mog_battler_face_update update def update refresh_face_battler mog_battler_face_update update_battler_face end #-------------------------------------------------------------------------- # ? Refresh Face Battler #-------------------------------------------------------------------------- def refresh_face_battler return if @face_sprite != nil return if @battler == nil return if @battler.is_a?(Game_Enemy) setup_battler_screen if @battler.screen_x == nil or $game_system.battler_hud @face_sprite = Battler_Face_Sprite.new(self.viewport, @battler) end #-------------------------------------------------------------------------- # ? Setup Battler Screen #-------------------------------------------------------------------------- def setup_battler_screen $game_system.battler_hud = true @battler.screen_x = FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * @battler.index) @battler.screen_y = FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * @battler.index) @battler.screen_z = 103 if @battler.screen_z == nil end #-------------------------------------------------------------------------- # ? Dispose Battler Face #-------------------------------------------------------------------------- def dispose_battler_face return if @face_sprite == nil @face_sprite.dispose end #-------------------------------------------------------------------------- # ? Update Battler Face #-------------------------------------------------------------------------- def update_battler_face return if @face_sprite == nil @face_sprite.update_actor_battler end #-------------------------------------------------------------------------- # ? Update Posiion #-------------------------------------------------------------------------- alias mog_battler_face_update_position update_position def update_position mog_battler_face_update_position update_face_z end #-------------------------------------------------------------------------- # ? Update Face Z #-------------------------------------------------------------------------- def update_face_z return if @face_sprite == nil @face_sprite.update_face_z(self.z) end #-------------------------------------------------------------------------- # ? Update Collapse #-------------------------------------------------------------------------- alias mog_battle_hud_update_collapse update_collapse def update_collapse if face_can_cancel_method? self.opacity = 255 self.visible = true return end mog_battle_hud_update_collapse end #-------------------------------------------------------------------------- # ? Update Instant Collapse #-------------------------------------------------------------------------- alias mog_battle_hud_update_instant_collapse update_instant_collapse def update_instant_collapse if face_can_cancel_method? self.opacity = 255 self.visible = true return end mog_battle_hud_update_instant_collapse end #-------------------------------------------------------------------------- # ? Init Visibility #-------------------------------------------------------------------------- alias mog_battle_face_init_visibility init_visibility def init_visibility if face_can_cancel_method? self.opacity = 255 self.visible = true return end mog_battle_face_init_visibility end #-------------------------------------------------------------------------- # ? Face Can Cancel Method #-------------------------------------------------------------------------- def face_can_cancel_method? return false if !BATTLER_FACE_ENABLE return false if @battler.is_a?(Game_Enemy) return false if !$game_system.battler_hud return true end end #============================================================================== # ? Battler Face Sprite #============================================================================== class Battler_Face_Sprite < Sprite include MOG_BATTLE_HUD #-------------------------------------------------------------------------- # ? Initialize #-------------------------------------------------------------------------- def initialize(viewport = nil,battler) super(viewport) @battler = battler @f_im = Cache.battler(@battler.battler_face_name, 0) @f_cw = @f_im.width / 5 @f_ch = @f_im.height self.bitmap = Bitmap.new(@f_cw,@f_ch) x = -(@f_cw / 2) + FACE_POSITION[0] + HUD_POSITION[0] + (MEMBERS_SPACE[0] * @battler.index) y = -@f_ch + FACE_POSITION[1] + HUD_POSITION[1] + (MEMBERS_SPACE[1] * @battler.index) @org_pos = [x,y] @battler.battler_face = [0,0,0] @battler_visible = true @low_hp = @battler.mhp * 30 / 100 @old_face_index = 0 self.z = @battler.screen_z make_face(true) end #-------------------------------------------------------------------------- # ? Dispose #-------------------------------------------------------------------------- def dispose super dispose_battler_face_sprite end #-------------------------------------------------------------------------- # ? Dispose Battler Face Sprite #-------------------------------------------------------------------------- def dispose_battler_face_sprite self.bitmap.dispose @f_im.dispose end #-------------------------------------------------------------------------- # ? Update #-------------------------------------------------------------------------- def update_face_sprite(battler) @battler = battler update_face_reset_time update_face_effect end #-------------------------------------------------------------------------- # ? Face Base Setting #-------------------------------------------------------------------------- def face_base_setting self.x = @org_pos[0] self.y = @org_pos[1] self.zoom_x = 1 self.zoom_y = 1 self.mirror = false end #-------------------------------------------------------------------------- # ? Check Base Face #-------------------------------------------------------------------------- def check_base_face(reset) face_base_setting return if @battler.battler_face[2] > 0 @battler.battler_face = [0,0,0] if reset and @battler.battler_face[1] != 2 @battler.battler_face[0] = 3 if @battler.hp < @low_hp @battler.battler_face[0] = 4 if @battler.hp == 0 end #-------------------------------------------------------------------------- # ? Make Face #-------------------------------------------------------------------------- def make_face(reset = false) self.bitmap.clear check_base_face(reset) src_rect_back = Rect.new(@f_cw * @battler.battler_face[0], 0, @f_cw, @f_ch) self.bitmap.blt(0,0, @f_im, src_rect_back) @old_face_index = @battler.battler_face[0] end #-------------------------------------------------------------------------- # ? Update Actor Battler #-------------------------------------------------------------------------- def update_actor_battler return if self.bitmap == nil update_face_effect update_face_reset_time make_face if @old_face_index != @battler.battler_face[0] end #-------------------------------------------------------------------------- # ? Update Face Z #-------------------------------------------------------------------------- def update_face_z(value) self.z = value + 2 end #-------------------------------------------------------------------------- # ? Update Face Reset Time #-------------------------------------------------------------------------- def update_face_reset_time return if @battler.battler_face[2] == 0 @battler.battler_face[2] -= 1 if @battler.battler_face[2] == 0 or (@battler.hp < @low_hp and @battler.battler_face[0] == 0) make_face(true) end end #-------------------------------------------------------------------------- # ? Update Face Effect #-------------------------------------------------------------------------- def update_face_effect return if @battler.battler_face[2] == 0 case @battler.battler_face[1] when 0 face_damage when 1..2 face_heal when 3 face_action end end #-------------------------------------------------------------------------- # ? Face Damage #-------------------------------------------------------------------------- def face_damage self.x = (@org_pos[0] - (@battler.battler_face[2] /2)) + rand(@battler.battler_face[2]) end #-------------------------------------------------------------------------- # ? Face Heal #-------------------------------------------------------------------------- def face_heal case @battler.battler_face[2] when 20..40 self.zoom_x += 0.01 self.zoom_y = self.zoom_x when 0..20 self.zoom_x -= 0.01 self.zoom_y = self.zoom_x end end #-------------------------------------------------------------------------- # ? Face Action #-------------------------------------------------------------------------- def face_action case @battler.battler_face[2] when 25..50 self.zoom_x += 0.01 self.zoom_y = self.zoom_x self.mirror = true when 0..25 self.zoom_x -= 0.01 self.zoom_y = self.zoom_x self.mirror = false end self.zoom_x = self.zoom_x > 1.5 ? self.zoom_x = 1.5 : self.zoom_x < 1 ? 1 : self.zoom_x self.zoom_y = self.zoom_y > 1.5 ? self.zoom_y = 1.5 : self.zoom_y < 1 ? 1 : self.zoom_y end end #============================================================================== # ? Battle Manager #============================================================================== class << BattleManager #-------------------------------------------------------------------------- # ? Battle End #-------------------------------------------------------------------------- alias mog_battle_hud_battle_process_victory process_victory def process_victory execute_face_effect mog_battle_hud_battle_process_victory end #-------------------------------------------------------------------------- # ? Prepare #-------------------------------------------------------------------------- def execute_face_effect for i in $game_party.members i.battler_face = [1,2,40] if i.hp > 0 end end end #============================================================================== # ? Game Action #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ? Show Animations #-------------------------------------------------------------------------- alias mog_battle_hud_show_animation show_animation def show_animation(targets, animation_id) make_face_action_battle mog_battle_hud_show_animation(targets, animation_id) end #-------------------------------------------------------------------------- # ? Make Face Action #-------------------------------------------------------------------------- def make_face_action_battle return if !@subject.is_a?(Game_Actor) @subject.battler_face = [2,3,50] end end #============================================================================== # ? Game Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ? Item Apply #-------------------------------------------------------------------------- alias mog_battle_hud_item_apply item_apply def item_apply(user, item) old_hp = self.hp old_mp = self.mp mog_battle_hud_item_apply(user, item) check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp) end #-------------------------------------------------------------------------- # ? Check Face Effect #-------------------------------------------------------------------------- def check_face_effect(old_hp,old_mp) if self.hp > old_hp or self.mp > old_mp self.battler_face = [1,1,40] elsif self.hp < old_hp self.battler_face = [3,0,40] end end #-------------------------------------------------------------------------- # ? Added New State #-------------------------------------------------------------------------- alias mog_battle_hud_add_new_state add_new_state def add_new_state(state_id) mog_battle_hud_add_new_state(state_id) if self.is_a?(Game_Actor) self.battler_face = [1,1,40] if $data_states[state_id].note =~ /<Good State>/ self.battler_face = [3,0,40] if $data_states[state_id].note =~ /<Bad State>/ end end #-------------------------------------------------------------------------- # ? Regenerate HP #-------------------------------------------------------------------------- alias mog_battle_hud_regenerate_hp regenerate_hp def regenerate_hp old_hp = self.hp old_mp = self.mp mog_battle_hud_regenerate_hp check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp) end #-------------------------------------------------------------------------- # ? Regenerate MP #-------------------------------------------------------------------------- alias mog_battle_hud_regenerate_mp regenerate_mp def regenerate_mp old_hp = self.hp old_mp = self.mp mog_battle_hud_regenerate_mp check_face_effect(old_hp,old_mp) if can_check_face_effect?(old_hp,old_mp) end #-------------------------------------------------------------------------- # ? Can Check Face Effect #-------------------------------------------------------------------------- def can_check_face_effect?(old_hp,old_mp) return false if self.is_a?(Game_Enemy) return true if old_hp != self.hp return true if old_mp != self.mp return false end end #============================================================================== # ? Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ? Invoke Counter Attack #-------------------------------------------------------------------------- alias mog_battle_hud_invoke_counter_attack invoke_counter_attack def invoke_counter_attack(target, item) mog_battle_hud_invoke_counter_attack(target, item) if target.is_a?(Game_Actor) and target.battler_face[0] != 2 target.battler_face = [2,3,50] end end #-------------------------------------------------------------------------- # ? Invoke Magic Reflection #-------------------------------------------------------------------------- alias mog_battle_hud_invoke_magic_reflection invoke_magic_reflection def invoke_magic_reflection(target, item) mog_battle_hud_invoke_magic_reflection(target, item) if target.is_a?(Game_Actor) and target.battler_face[0] != 2 target.battler_face = [2,3,50] end end end #============================================================================== # ? Scene Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ? select_enemy_selection #-------------------------------------------------------------------------- alias mog_battle_cursor_select_enemy_selection select_enemy_selection def select_enemy_selection mog_battle_cursor_select_enemy_selection if $mog_rgss3_battle_cursor != nil @enemy_window.visible = false @info_viewport.rect.width = 0 end end #-------------------------------------------------------------------------- # ? select_enemy_selection #-------------------------------------------------------------------------- alias mog_battle_cursor_select_actor_selection select_actor_selection def select_actor_selection mog_battle_cursor_select_actor_selection if $mog_rgss3_battle_cursor != nil @actor_window.visible = false @info_viewport.rect.width = 0 end end end $mog_rgss3_battle_hud = true Vi prego aiutatemi ç_ç Edited September 27, 2013 by Holy87 Ricorda i tag Code! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now