O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

Combine two scripts - Advanced Messages & Composite Faces

Iniciado por siemic, 08/06/2023 às 01:40

08/06/2023 às 01:40 Última edição: 08/06/2023 às 01:41 por siemic
Hello, eu tenho esses dois scripts. Um é para mensagens avançadas. O outro é para faces compostas.

No entanto, se eu usar faces compostas, não conseguirei utilizá-las em Mensagens avançadas, devido a um método diferente de definir e desenhar as faces.

Existe alguma maneira de combinar esses dois scripts, de forma que eu possa usar o método \AF[actor_id] para mostrar uma face composta (que é desenhada de draw_actor_face em Comp Faces)

Advanced Messages:
https://pastebin.com/7jr7wtG5

Composite Faces:
Spoiler
#==============================================================================
#  Composite Faces/Layer Face Graphics
#  Version 1.0
#  By Mangomight
#  Date: October 27, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script below Materials, and below Composite Character
#   if it's in use.

#    The script assumes that the images to look for is located in the
#   Graphics/Faces/ folder.
#
#============================================================================#
# * Setting up (Actors)
#============================================================================#
#
#    To begin with, you can set up the default Face-set for your actors
#   at line 223.
#   
#   Then, to have an actor equip new graphics via armors or weapons, all
#   you need to do is putting this comment in its notefield; 
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#   \FG[<Name of Face Set>, <index in face set>, <hue>, <z>]
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#  EXAMPLES:
#    \fg[Actor1, 2]        # Face Set = Actor1 : index = 2 : hue = 0 : z = 0
#    \FG[Evil]             # Face Set = Evil   : index = 0 : hue = 0 : z = 0
#    \fG[Actor2, 3, 50, 2] # Face Set = Actor2 : index = 3 : hue = 50 : z = 2
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#
#  If you leave out index, it defaults to 0 and if you leave out hue, it also
#  defaults to 0. You can put more than one graphic to an armor or weapon and
#  they will stack by priority (z). Things with lower priority are drawn first.
#
#============================================================================#
# * Setting up (Events)
#============================================================================#
#
#    Setting up an Event is similar - all you need to do is place a comment at
#  the very beginning of the event and put in the same code to generate a
#  composite face graphic for the event. How to display the Event's Face
#  Graphic in a message is explained below.
#
#============================================================================#
# * Displaying the Faces in messages
#============================================================================#
#
#  To display an event's face graphic, you'd just have to use this
# code in a Script Call;
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#  show_event_face_graphic (event_id)
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#  ..event_id "0" means 'this' event, and 1, 2..etc is the id
#  of 'an' event. If not set, defaults to 0.
#
# To display an Actor's face graphic in messages is very similar;
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#  show_actor_face_graphic (actor_id)
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# 
#  Where actor_id is the id of an actor. Defaults to the first
#  actor if not set.
#
#  * Note that the face-graphic you specify will only appear if
#  the Message's Face Graphic is empty. It'll then be continuesly
#  displayed until it's interrupted by another Face Graphic or
#  when the message is closed.
#
#   You can also you use this code to stop showing the current
#  graphic;
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#  stop_showing
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#============================================================================#
# * Adding & Removing Face-sets via Script Call
#============================================================================#
#
#  To remove graphics from an actor;
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#   remove_face_graphic (actor_id, index)
#   remove_face_graphic (actor_id, graphic_name, graphic_index)
#   remove_face_graphic (actor_id, graphic_name, graphic_index, graphic_hue) 
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#
#  Adding graphics to an actor;
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# add_face_graphic (actor_id, graph_name, graph_index, graph_hue, index)
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#  where:
#    actor_id      : the ID of the actor whose graphic you are changing
#    index         : the index of the graphic in the actor's composite_face set
#    graphic_name  : the name of the character set
#    graphic_index : the index of the character file in the set
#    graphic_hue   : the hue of the graphic
#
#    Same as for Composite Character, the Change Graphic event command
#   adds Graphics to the current set, you can clean the set with the code:
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#    clear_character_graphic (actor_id)
#~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#   Note that this cleans both the Composite Face and Composite
#  Character arrays at the same time.
#
#<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~<>~~#
# * If you'd find any bugs or compability issues with this script, please
#  report them at rmrk.net and I'll try my best to help you.
#
#<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~<>~~#
#==============================================================================


#==============================================================================
# *** module Cache
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - composite_face
#==============================================================================
module Cache
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Composite Face
  #    face_array : An array holding the names of all parts of a graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def self.composite_face (face_array)
    @cache = {} if @cache == nil
    @type = [] if @type == nil
    # Blank bitmap if there is nothing in the array.
    @cache[face_array] = Bitmap.new (128, 128) if face_array.empty?
    # Create a template bitmap
    bitmap = Bitmap.new (128, 128)
    # If not in the cache
    if !@type.include? (face_array) || @cache[face_array].disposed?
      # Add in all the graphics
      face_array.each { |i|
        name, index, hue = i[0], i[1], i[2]
        bmp = load_bitmap ("Graphics/Faces/", name, hue)
        wdth = bmp.width / 4
        hgth = bmp.height / 2
        rect = Rect.new((index%4)*wdth, (index/4)*hgth, wdth, hgth)
        bitmap.blt(0, 0, bmp, rect)
      }
      @cache[face_array] = bitmap
      # Type ensures it is a Face Graphic
      @type.push (face_array.flatten)
    end
    @cache[face_array]
  end
end

#==============================================================================
# ** RPG::BaseItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - face_graphics
#==============================================================================
class RPG::BaseItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Face Graphics
  #``````````````````````````````````````````````````````````````````````````
  #  Retrieves Face Graphics from Note Field
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def face_graphics
  graphics = []
  # Retrieve Graphics from Note Field
  text = self.note.dup
  while text.sub!(/\\fg\[([^,\]]+),*\s*(\d*),*\s*(\d*),*\s*(\d*)\]/i, '') != nil
    graphics.push([$1.to_s, $2.to_i, $3.to_i, $4.to_i])
  end
  graphics
end
end


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  Summary of Changes:
#    aliased_method - initialize
#==============================================================================
class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variable
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :hair_sprites
  attr_accessor :mango_comp_face
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mangmght_vsual_equip_face_init initialize
  def initialize (id)
    # Run Original Method
    mangmght_vsual_equip_face_init (id)
    @mango_comp_face = []
    @hair_sprites = []
    case @actor_id
    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    # EDITABLE REGION
    #|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
    #  An actor will automatically have whatever you set in the database
    #  as a bottom layer for him, but if you need to have other character
    #  sets piled on top, then put them in this format:
    #
    #  when <actor_id>
    #    @mango_comp_face.push (['graphic_name', index, hue, z])
    #      *for as many graphics as you want - first ones drawn first. If you
    #       want to know what each is, see the Instructions in the header.
    #       The z value allows you to set priority. So, something with -1
    #       z will be drawn below anything with a greater z value
    #/////////////////////////////////////////////////////////////////////
    when 1 # 1st Actor
      # Create Hair Sprite; put "x = hair_sprite" as comment in order
      # to remove the hair-graphic when helmet is equipped.
      @mango_comp_face.push (['![2]Player-Male-Skin01', 1, 0, 1])
      #<Insert Here>
    when 3 # 3rd Actor
      # Create Hair Sprite
      @mango_comp_face.push (['LayerFaceGraphics = hair_sprite', 2, 65])
      # Create Shirt Sprite
      @mango_comp_face.push (['LayerFaceGraphics', 6, 175])
      #<Insert Here>
    #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    # END EDITABLE REGION
    #/////////////////////////////////////////////////////////////////////
    end
    @mango_comp_face.each { |i|
      i.push 0 while i.size < 4
      while i[0].sub!(/(\s*=\s*hair_sprite)/i) { '' } != nil
        @hair_sprites.push (i)
      end
    }
    if @ma_composite_character != nil
      @ma_composite_character.each { |i|
        while i[0].sub!(/(\s*=\s*hair_sprite)/i) { '' } != nil
          @hair_sprites.push (i)
        end
      }
    end
    @mango_comp_face.unshift ([@face_name, @face_index, 0, -1]) if @face_name != ''
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Composite Face
  #``````````````````````````````````````````````````````````````````````````
  #  Returns Graphic Array for the actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def composite_face
    armor_graphics = []
    weapon_graphics = []
    # Body Armor, then Helmet, then Shield, then all others
    dup_armors = armors.dup
    for i in 0...2
      j = 2 - i
      armor_graphics += dup_armors[j].face_graphics if dup_armors[j]
      dup_armors.delete_at (j)
    end
    # If there is some multi-equip script, will get accessories and rest in order
    dup_armors.each { |armr| armor_graphics += armr.face_graphics if armr }
    weapons.each { |wpn| weapon_graphics += wpn.face_graphics if wpn }
    fg = @mango_comp_face + armor_graphics + weapon_graphics
    # If a helmet is equipped, temporarily removes the hair-sprite.
    fg.delete_if { |i| @hair_sprites.include?(i) && armors[1] }
    fg.sort! { |a, b| a[3] <=> b[3] }
    fg
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Composite Character
  #     aliased to fix the Hair Sprite-'bug'
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined?(:composite_character)
    alias_method (:old_comp_char, :composite_character)
    def composite_character
      cg = old_comp_char
      cg.delete_if { |i| @hair_sprites.include?(i) && armors[1] }
      cg
    end
  end 
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Change Graphics
  #     character_name  : new character graphic filename
  #     character_index : new character graphic index
  #     face_name       : new face graphic filename
  #     face_index      : new face graphic index
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias man125_go_set_graphic set_graphic
  def set_graphic (*args)
    old_face_name, old_face_index = @face_name, @face_index
    # Run Original Method
    man125_go_set_graphic (*args)
    # Find old character name
    count = 0
    @mango_comp_face.each { |i|
      count += 1
      break if i[0] == old_face_name && i[1] == old_face_index
    }
    @mango_comp_face.insert (count, [@face_name, @face_index, 0, -1])
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Clear Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def clear_graphic
    # Clears the composite character array
    if @ma_composite_character
      @ma_composite_character.clear
      @ma_composite_character.push ([@character_name, @character_index, 0, -1])
    end
    # Clears the composite face array
    @mango_comp_face.clear
    @hair_sprites.clear
    @mango_comp_face.push ([@face_name, @face_index, 0, -1])
  end
end 
 
#==============================================================================
# ** Game_Character
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - composite_face
#==============================================================================

class Game_Character
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader :composite_face
end

#==============================================================================
# ** Game_Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - setup
#==============================================================================

class Game_Event
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Event page setup
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mngo13_stp12 setup
  def setup(new_page)
    mngo13_stp12 (new_page)
    @composite_face = []
    return unless @page
    # Retrieve  first line comments
    comments = []
    @page.list.each { |i|
      i.code == 108 || i.code == 408 ? comments.push (i) : break
    }
    # Evaluate comments for \FG codes
    comments.each { |i|
      text = i.parameters[0].dup
      while text.sub! (/\\fg\[([^,\]]+),*\s*(\d*),*\s*(\d*)\]/i) { '' } != nil
        @composite_face.push [$1.to_s, $2.to_i, $3.to_i, $4.to_i]
      end
    }
    # Sort Composite Faces by z value.
    @composite_face.sort! { |a, b| a[3] <=> b[3] }
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new methods - clear_character_graphic
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader :events_id, :actors_id, :display_actor_face_msg,
              :display_event_face_msg
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Clear Character Graphic
  #    actor_id : the ID of the actor to be cleared
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def clear_character_graphic (actor_id)
    $game_actors[actor_id].clear_graphic
    $game_player.refresh
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Remove Face Graphic From Character
  #    actor_id : the ID of the actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def remove_face_graphic (actor_id, *args)
    actor = $game_actors[actor_id]
    if args[0].is_a? (Integer)
      index = args[0]
    else
      index = 0
      # Find index of the specified face set
      for composite in actor.mango_comp_face
        break if args == composite.first(args.size)
        index += 1
      end
    end
    # Delete graphic from the arrays
    a = actor.mango_comp_face.delete_at (index)
    actor.hair_sprites.delete(a)
    index
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Add Graphic To actor
  #    actor_id                           : the ID of the actor
  #    graph_name, graph_index, graph_hue : graphic specifications
  #    index                              : where to insert the new graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def add_face_graphic (actor_id, graph_name, graph_index = 0, graph_hue = 0, z = 0, index = nil)
    actor = $game_actors[actor_id]
    index = actor.mango_comp_face.size unless index
    while graph_name.sub!(/(\s*=\s*hair_sprite)/i) { '' } != nil
      actor.hair_sprites.push [graph_name, graph_index, graph_hue, z]
    end
    actor.mango_comp_face.insert (index, [graph_name, graph_index, graph_hue, z])
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Add Graphic To Character
  #    aliased method (for composite character fix)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined?(:add_graphic_to_actor)
    alias_method (:old_add_graph_to_actr, :add_graphic_to_actor)
    def add_graphic_to_actor (*args)
      while args[1].sub!(/(\s*=\s*hair_sprite)/i) { '' } != nil
        $game_actors[args[0]].hair_sprites.push (args[1..4])
      end
      # Run Original Method
      old_add_graph_to_actr (*args)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Display Actor's Face Graphic in Message
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def show_actor_face_graphic (actor_id = 1)
    @display_actor_face_msg = true
    @display_event_face_msg = false
    @actors_id = $game_actors[actor_id]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Display Event's Face Graphic in Message
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def show_event_face_graphic (event_id = 0)
    @display_event_face_msg = true
    @display_actor_face_msg = false
    @events_id = get_character(event_id)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Stop showing the face graphic in Message
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def stop_showing
    @display_actor_face_msg = false
    @display_event_face_msg = false
  end 
end

#==============================================================================
# ** Window_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    overwritten method - draw_actor_face
#    new method - draw_event_face
#==============================================================================
class Window_Base < Window
 
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Actor Face Graphic
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     size  : Display size
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def draw_actor_face(actor, x, y, size = 128)
    bitmap = Cache.composite_face (actor.composite_face)
    rect = Rect.new(0, 0, size, size)
    self.contents.blt(x, y, bitmap, rect)
    bitmap.dispose
  end

  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Event Face Graphic
  #     event : event
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     size  : Display size
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def draw_event_face(event, x, y, size = 96)
    bitmap = Cache.composite_face (event.composite_face)
    rect = Rect.new(0, 0, size, size)
    self.contents.blt(x, y, bitmap, rect)
    bitmap.dispose
  end
end   

#==============================================================================
# ** Window_Message
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - new_page, dispose
#==============================================================================

class Window_Message < Window_Selectable
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * New Page
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mngo124_mt_nw_pge512 new_page
  def new_page
    mngo124_mt_nw_pge512
    if $game_message.face_name.empty?
      if $game_map.interpreter.display_actor_face_msg
        actor = $game_map.interpreter.actors_id
        if actor != nil
          draw_actor_face(actor, -10, -20, 128)
          @contents_x = 112
        else
          $game_map.interpreter.stop_showing
        end 
      elsif $game_map.interpreter.display_event_face_msg
        event = $game_map.interpreter.events_id
        if event != nil
          draw_event_face(event, 0, 0)
          @contents_x = 112
        else
          $game_map.interpreter.stop_showing
        end 
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * New Line
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma64_go_nw_line642 new_line
  def new_line
    ma64_go_nw_line642
    event_face = $game_map.interpreter.display_event_face_msg
    actor_face = $game_map.interpreter.display_actor_face_msg
    if $game_message.face_name.empty?
      @contents_x = event_face || actor_face ? 112 : 0
    end
  end 
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Dispose
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  alias mn_go_mt42_dspose14 dispose
  def dispose
    mn_go_mt42_dspose14
    # Makes sure the graphic won't re-appear after closing message.
    $game_map.interpreter.stop_showing
  end 
end
[close]