Advertisement
blackmorning

Blackmorning - Ace Message

Nov 4th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 33.83 KB | None | 0 0
  1. #==============================================================================
  2. # ** Blackmorning -> Message Codes (modded from ATS)
  3. #------------------------------------------------------------------------------
  4. #  Blackmorning
  5. #  Version 1.05
  6. #  released 01/29/2014
  7. #  updated 03/21/2014
  8. #==============================================================================
  9. # ¨‹ Introduction
  10. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  11. # - write out different terms using codes in messages
  12. # - write text based on switches
  13. # - shows busts instead of specified faceset (switch on/off)
  14. #     - busts found in Graphics/Portraits
  15. #     - filename format: face_name-face_index
  16. # - add text sounds and animations during messages
  17. # - add animations over characters during messages
  18. # - add balloons over characters during messages
  19. #==============================================================================
  20. # ¨‹ Instructions
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # To install this script, open up your script editor and copy/paste this script
  23. # to an open slot below BM - Base and other message scripts but above ¨‹ Main.
  24. # Remember to save.
  25. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  26. # Message Window codes - These go inside of your message window.
  27. # -----------------------------------------------------------------------------
  28. #  Names:      Effect:
  29. # \nmp       - Write name of the map the player is currently on.
  30. # \nmp[n]    - Write name of the map with ID n.
  31. # \nev[n]    - Write name of the event with ID n on the current map.
  32. # \nem[n]    - Write name of the enemy with ID n.
  33. # \ntr[n]    - Write name of the troop with ID n.
  34. # \nvr[n]    - Write name of the variable with ID n.
  35. # \nsw[n]    - Write name of the switch with ID n.
  36. # \nel[n]    - Write name of the element with ID n.
  37. # \nwt[n]    - Write name of the weapon type with ID n.
  38. # \nat[n]    - Write name of the armor type with ID n.
  39. # \nst[n]    - Write name of the skill type with ID n.
  40. # \npr[n]    - Write name of the parameter with ID n.
  41. #              or :hp, :mp, :atk, :def, :mat, :mdf, :agi, :luk
  42. # \nxp[n]    - Write name of the extra parameter with ID n.
  43. #              or :hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg
  44. # \nsp[n]    - Write name of the special parameter with ID n.
  45. #              or :tgr, ::grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr
  46. # \npg       - Write amount of money the party has.
  47. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  48. # \apr[n, x] - Write value of the parameter with ID n for actor x.
  49. # \axp[n, x] - Write value of the extra parameter with ID n for actor x.
  50. # \asp[n, x] - Write value of the special parameter with ID n for actor x.
  51. #              *Note: If x is 0 or negative, it will show the respective
  52. #               party member's instead.
  53. #                   0 - Party Leader
  54. #                  -1 - 1st non-leader member.
  55. #                  -2 - 2nd non-leader member. So on.
  56. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  57. # \vocab[method] - Write whatever Vocab.method returns, if it is a valid
  58. #                  method call.
  59. # \vocab[param, n] - Will draw the label for parameter with ID n. 0 => Max HP;
  60. #                    1 => Max MP; 2 => Attack; 3 => Defence; 4 => Magic;
  61. #                    5 => Magic Defence; 6 => Agility; 7 => Luck
  62. # \vocab[etype, n] - Will draw the label for equipment type with ID n.
  63. #                    0 => Weapon; 1 => Shield; 2 => Head; 3 => Body;
  64. #                    4 => Accessory
  65. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  66. # Icon Names: Effect:
  67. # (need BM - Icon module to draw icons, otherwise just the word appears)
  68. # \icl[n] - Writes out class n's name including icon.
  69. # \iel[n] - Writes out element n's name including icon.
  70. # \ip[n]  - Writes out parameter n's name including icon.
  71. # \iwt[n] - Writes out weapon type n's name including icon.
  72. # \iat[n] - Writes out armor type n's name including icon.
  73. # \ist[n] - Writes out skill type n's name including icon.
  74. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  75. # \#{code}    - This will evaluate code.
  76. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  77. # \s{n,text}  - Write text if the switch with ID n is ON.
  78. # \s!{n,text} - Write text if the switch with ID n is OFF.
  79. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  80. #  Sound Effects:
  81. # \lse - Turns the letter by letter SE on.
  82. # /lse - Turns the letter by letter SE off.
  83. # \pse - Turns the pause SE on.
  84. # /pse - Turns the pause SE off.
  85. # \fse - Turns the finish SE on.
  86. # /fse - Turns the finish SE off.
  87. # \tse - Turns the terminate SE on.
  88. # /tse - Turns the terminate SE off.
  89. # \pSE[file,x,y] - Play the "file" SE at volume x and pitch y
  90. # \pME[file,x,y] - Play the "file" ME at volume x and pitch y
  91. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  92. #  Other Effects:
  93. # \pANIM[x,n] - Play the animation with ID n over character x
  94. # \pBLN[x,n]  - Play the balloon with ID n over character x
  95. #==============================================================================
  96. module BM
  97.   module MESSAGE
  98.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  99.     # Text Sound
  100.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  101.     SOUND_ON     = true        # the sound will be played as letters are drawn
  102.     # SE = [name, vol, pitch]
  103.     LETTER_SE    = ["Cursor2"]   # sound as letters are drawn
  104.     START_SE     = ["Chime2"]    # sound whenever a message first opens
  105.     PAUSE_SE     = ["Decision2"] # sound whenever a message pauses & waits for player input
  106.     FINISH_SE    = ["Chime1"]    # sound whenever a message finishes.
  107.     TERMINATE_SE = ["Cancel2"]   # sound whenever a message finishes
  108.    
  109.     LETTERS_PER_SEC = 4        # amount of letters that are drawn between each sound effect
  110.     PITCH_RANGE     = 80...100 # (x...y) pitch randomly selected between the x and y
  111.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  112.     # Bust Options
  113.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  114.     BUST ={
  115.       :disable_sw => 4,   # Turn swith ON to disable busts and show normal face
  116.       :z          => -1,
  117.       # adds to z value of busts if needed. A negative number will make the bust
  118.       # appear below the message window.
  119.       :y => false,  
  120.       # true = busts sit at the bottom of the screen
  121.       # false = busts sit on top of the message window
  122.       :x => 0,
  123.       # Offset text when displaying busts above the message window. The script
  124.       # automatically offsets the text x by the bust image width IF the BUST_Z
  125.       # is 0 or more.
  126.       :slide => true,# Slide portrait onto the screen instead of fading in.      
  127.     } # DO NOT REMOVE
  128.   end
  129. end
  130. #==============================================================================
  131. # ¨‹ Editting anything past this point may potentially result in causing
  132. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  133. # halitosis so edit at your own risk.
  134. #==============================================================================
  135. module BM
  136.   def self.required(name, req, version, type = nil)
  137.     if !$imported[:bm_base]
  138.       msg = "The script '%s' requires the script\n"
  139.       msg += "'BM - Base' v%s or higher above it to work properly\n"
  140.       msg += "Go to bmscripts.weebly.com to download this script."
  141.       msgbox(sprintf(msg, self.script_name(name), version))
  142.       exit
  143.     else
  144.       self.required_script(name, req, version, type)
  145.     end
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # * script_name
  149.   #   Get the script name base on the imported value
  150.   #--------------------------------------------------------------------------
  151.   def self.script_name(name, ext = "BM")
  152.     name = name.to_s.gsub("_", " ").upcase.split
  153.     name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  154.     name.join(" ")
  155.   end
  156. end
  157. $imported ||= {}
  158. $imported[:bm_message] = 1.05
  159. BM.required(:bm_message, :bm_base, 1.00, :above)
  160. #============================================================================
  161. # ** BM_MESSAGE
  162. #============================================================================
  163. class BM_MESSAGE
  164.     CONFIG ||= {}
  165.     CONFIG[:bm_message] = {
  166.     bm_message: true,
  167.     letter_sound_on:     BM::MESSAGE::SOUND_ON,
  168.     letter_se:           BM::MESSAGE::LETTER_SE,
  169.     occurence:           BM::MESSAGE::LETTERS_PER_SEC,
  170.     random_pitch:        BM::MESSAGE::PITCH_RANGE,
  171.     #  :start_sound_on - when this is true, the sound specified at :start_se
  172.     # will play whenever a message first opens.
  173.     start_sound_on:        false,
  174.     start_se:            BM::MESSAGE::START_SE,
  175.     #  :pause_sound_on - when this is true, the sound specified at :pause_se is
  176.     # played whenever a message pauses and waits for player input.
  177.     pause_sound_on:        false,
  178.     pause_se:            BM::MESSAGE::PAUSE_SE,
  179.     #  :finish_sound_on - when this is true, the sound specified at :finish_se
  180.     # is played whenever a message finishes.
  181.     finish_sound_on:       false,
  182.     finish_se:           BM::MESSAGE::FINISH_SE,
  183.     #  :terminate_sound_on - when this is true, the sound specified at
  184.     # :terminate_se is played whenever a message finishes.
  185.     terminate_sound_on:    false,
  186.     terminate_se:        BM::MESSAGE::TERMINATE_SE,
  187.   }
  188.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  189.   # * Public Instance Variables
  190.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  191.   CONFIG[:bm_message].keys.each { |key| attr_accessor key }
  192.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  193.   # * SE methods
  194.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  195.   [:letter_se, :start_se, :pause_se, :finish_se, :terminate_se].each { |method_name|
  196.     define_method(:"#{method_name}=") do |*args|
  197.       instance_variable_set(:"@#{method_name}", BM_MESSAGE.set_sound_effect(*args))
  198.     end
  199.   }
  200.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  201.   # * Set Sound Effect
  202.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  203.   def self.set_sound_effect(settings)
  204.     return settings if settings.is_a?(RPG::SE)
  205.     settings = [settings] if settings.is_a?(String)
  206.     settings[1] = 80 if !settings[1]
  207.     RPG::SE.new(*settings)
  208.   end
  209.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  210.   # * Set Random Pitch
  211.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  212.   def random_pitch=(val)
  213.     @random_pitch = val.is_a?(Integer) ? letter_se.pitch..(letter_se.pitch + val) : val
  214.   end
  215.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  216.   # * Initialize
  217.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  218.   def initialize; reset; end
  219.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  220.   # * Reset any or all installed ATS scripts
  221.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  222.   def reset(script_name = nil)
  223.     if script_name.is_a? (Symbol) # If script to reset specified
  224.       CONFIG[script_name].each_pair { |key, value|
  225.         self.send("#{key}=".to_sym, value)
  226.         $game_message.send("#{key}=".to_sym, value)
  227.       }
  228.     else                          # Reset all ATS scripts
  229.       CONFIG.keys.each { |script| reset(script) }
  230.     end
  231.   end
  232.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  233.   # * Initialize any newly installed ATS scripts
  234.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  235.   def init_new_installs
  236.     CONFIG.keys.each { |script| reset(script) unless self.send(script) }
  237.   end
  238. end
  239. #============================================================================
  240. # ** DataManager
  241. #============================================================================
  242. module DataManager
  243.   class << self
  244.     alias :bm_message_cgo :create_game_objects
  245.     alias :bm_message_msc :make_save_contents
  246.     alias :bm_message_esc :extract_save_contents
  247.   end
  248.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  249.   # * Alias: Create Game Objects
  250.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  251.   def self.create_game_objects(*args, &block)
  252.     bm_message_cgo(*args, &block)
  253.     $bm_message = BM_MESSAGE.new
  254.     $bm_message.init_new_installs
  255.   end
  256.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  257.   # * Alias: Make Save Contents
  258.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  259.   def self.make_save_contents(*args, &block)
  260.     contents = bm_message_msc(*args, &block)
  261.     contents[:bm] = $bm_message
  262.     contents
  263.   end
  264.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  265.   # * Alias: Extract Save Contents
  266.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  267.   def self.extract_save_contents(contents, *args, &block)
  268.     bm_message_esc(contents, *args, &block)
  269.     $bm_message = contents[:bm] ? contents[:bm] : BM_MESSAGE.new
  270.     $bm_message.init_new_installs
  271.   end
  272. end
  273. #==============================================================================
  274. # ** Game_Interpreter
  275. #==============================================================================
  276. class Game_Interpreter
  277.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  278.   # * New method: bust_mirror
  279.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  280.   def bust_mirror(state)
  281.     $game_message.mirror = state
  282.   end
  283.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  284.   # * Alias: command_101
  285.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  286.   alias :bm_message_101 :command_101
  287.   def command_101
  288.     $game_message.bust_name = @params[0]
  289.     $game_message.bust_index = @params[1]
  290.     bm_message_101
  291.   end
  292. end
  293. #==============================================================================
  294. # ** Game_Message
  295. #==============================================================================
  296. class Game_Message  
  297.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  298.   # * Public Instance Variables
  299.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  300.   attr_accessor :bust_name
  301.   attr_accessor :bust_index
  302.   attr_accessor :mirror
  303.   BM_MESSAGE::CONFIG[:bm_message].keys.each { |key| attr_accessor key }
  304.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  305.   # * Alias: Initialize
  306.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  307.   alias :bm_message_init :initialize
  308.   def initialize
  309.     bm_message_init
  310.     @mirror = false
  311.   end
  312.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  313.   # * Alias: Clear
  314.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  315.   alias :bm_message_clear :clear
  316.   def clear(*args, &block)
  317.     @bust_name = ""
  318.     @bust_index = 0
  319.     tso = @terminate_sound_on # Don't reset terminate sound
  320.     bm_message_clear(*args, &block) # Call Original Method
  321.     return if !$bm_message
  322.     BM_MESSAGE::CONFIG.values.each { |installed|
  323.       installed.keys.each { |key| self.send("#{key}=".to_sym, $bm_message.send(key)) }
  324.     }
  325.     @terminate_sound_on = tso unless tso.nil?
  326.   end
  327.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  328.   # * New method: SE Definitions
  329.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  330.   [:letter, :start, :pause, :finish, :terminate].each { |method_name|
  331.     define_method(:"#{method_name}_se=") do |*args|
  332.       instance_variable_set(:"@#{method_name}_se", BM_MESSAGE.set_sound_effect(*args))
  333.     end
  334.   }
  335.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  336.   # * New method: Play Sound?
  337.   #    type : :letter, :start, :pause, :finish, or :terminate
  338.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  339.   def play_sound?(type)
  340.     return instance_variable_get(:"@#{type}_sound_on") &&
  341.       !instance_variable_get(:"@#{type}_se").nil?
  342.   end
  343.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  344.   # * New method: Set Random Pitch
  345.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  346.   def random_pitch=(val)
  347.     @random_pitch = val.is_a?(Integer) ? letter_se.pitch..(letter_se.pitch + val) : val
  348.   end
  349. end  
  350. #==============================================================================
  351. # ** Window_Message
  352. #==============================================================================
  353. class Window_Message < Window_Base
  354.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  355.   # * Alias: Object Initialization
  356.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  357.   alias :bm_message_init :initialize
  358.   def initialize(*args, &block)
  359.     @char_count = 0
  360.     bm_message_init(*args, &block) # Call Original Method
  361.   end
  362.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  363.   # * Alias: Process All Text
  364.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  365.   alias :bm_message_pat :process_all_text
  366.   def process_all_text(*args, &block)
  367.     # Play Start SE
  368.     $game_message.start_se.play if $game_message.play_sound?(:start)
  369.     bm_message_pat(*args, &block) # Call Original Method
  370.     # Play Finish SE
  371.     $game_message.finish_se.play if $game_message.play_sound?(:finish)
  372.   end
  373.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  374.   # * Alias: Input Processing
  375.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  376.   alias :bm_message_pi :process_input
  377.   def process_input(*args, &block)
  378.     # Don't play Pause Sound if Finish Sound played
  379.     $game_message.pause_sound_on = false if $game_message.play_sound?(:finish)
  380.     bm_message_pi(*args, &block)
  381.   end
  382.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  383.   # * Alias: Close Window and Wait for It to Fully Close
  384.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  385.   alias :bm_message_caw :close_and_wait
  386.   def close_and_wait(*args, &block)
  387.     # Play Terminate SE
  388.     $game_message.terminate_se.play if $game_message.play_sound?(:terminate)
  389.     $game_message.terminate_sound_on = $bm_message.terminate_sound_on
  390.     bm_message_caw(*args, &block) # Call Original Method
  391.   end
  392.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393.   # * Alias: Process Escape Character
  394.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  395.   alias :bm_message_pec :process_escape_character
  396.   def process_escape_character(code, text, *args, &block) # (code, text, pos)
  397.     case code.upcase
  398.     when 'ATSMOSE'
  399.       param = obtain_escape_param(text)
  400.       case param / 2
  401.         when 0 then $game_message.letter_sound_on = (param == 0)    # Letter Sound
  402.         when 1 then $game_message.pause_sound_on = (param == 2)     # Pause Sound
  403.         when 2 then $game_message.finish_sound_on = (param == 4)    # Finish Sound
  404.         when 3 then $game_message.terminate_sound_on = (param == 6) # Terminate Sound
  405.       end
  406.     when 'PLAYSOUND'
  407.       return unless text.slice!(/^\[([MS]E),\"(.+?)\",?(\d*),?(\d*)\]/i)
  408.      RPG.const_get($1.to_sym).new($2, $3.empty? ? 80 : $3.to_i, $4.empty? ? 100 : $4.to_i).play
  409.    when 'ANIMATION'
  410.      return unless text.slice!(/^\[(\d+),(\d+),(\d+)\]/)
  411.      character = atsmo_get_character($2.to_i)
  412.      if character
  413.        case $1.to_i
  414.          when 0 then character.animation_id = $3.to_i
  415.          when 1 then character.balloon_id = $3.to_i
  416.        end
  417.      end
  418.    else
  419.      bm_message_pec(code, text, *args, &block) # Run Original Method
  420.    end
  421.  end
  422.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  423.  # * Get Character
  424.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  425.  def atsmo_get_character(id)
  426.    id == 0 ? $game_player : $game_map.events[id]
  427.  end
  428.  #--------------------------------------------------------------------------
  429.  # * alias: create_back_bitmap
  430.  #--------------------------------------------------------------------------
  431.  alias :bm_message_cbb :create_back_bitmap
  432.  def create_back_bitmap
  433.    @bust = Sprite.new if @bust.nil?
  434.    @bust.visible = true
  435.    @bust.opacity = 0
  436.    @bust.z = z + BM::MESSAGE::BUST[:z]
  437.    bm_message_cbb
  438.  end
  439.  #--------------------------------------------------------------------------
  440.  # * alias: dispose
  441.  #--------------------------------------------------------------------------  
  442.  alias :bm_message_dispose :dispose
  443.  def dispose
  444.    bm_message_dispose
  445.    dispose_bust
  446.  end
  447.  #--------------------------------------------------------------------------
  448.  # * new method: dispose_bust
  449.  #--------------------------------------------------------------------------  
  450.  def dispose_bust
  451.    @bust.dispose if !@bust.nil?
  452.    @bust.bitmap.dispose if !@bust.bitmap.nil?
  453.  end
  454.  #--------------------------------------------------------------------------
  455.  # * alias: update_back_sprite
  456.  #--------------------------------------------------------------------------
  457.  alias :bm_message_ubs :update_back_sprite
  458.  def update_back_sprite
  459.    bm_message_ubs
  460.    update_bust if openness > 0
  461.  end
  462.  #--------------------------------------------------------------------------
  463.  # * new method: update_bust
  464.  #--------------------------------------------------------------------------
  465.  def update_bust
  466.    allow_bust = !$game_switches[BM::MESSAGE::BUST[:disable_sw]]
  467.    if allow_bust
  468.      portrait_name = $game_message.bust_name + "-" + ($game_message.bust_index).to_s
  469.      allow_bust = portrait_exist?(portrait_name)
  470.    end
  471.    if allow_bust
  472.      @bust.mirror = $game_message.mirror
  473.      @bust.bitmap = Cache.portrait(portrait_name)
  474.      if !$game_message.mirror
  475.        if BM::MESSAGE::BUST[:slide]
  476.          @bust.x = ((openness.to_f / 255) * @bust.width) - @bust.width
  477.        else
  478.          @bust.x = 0
  479.        end
  480.      else
  481.        if BM::MESSAGE::BUST[:slide]
  482.          @bust.x = Graphics.width - ((openness.to_f / 255) * @bust.width)
  483.        else
  484.          @bust.x = Graphics.width - @bust.bitmap.width
  485.        end
  486.      end
  487.      
  488.      if $game_message.position == 2 && !BM::MESSAGE::BUST[:y]
  489.        @bust.y = Graphics.height - @bust.bitmap.height - self.height
  490.      else
  491.        @bust.y = Graphics.height - @bust.bitmap.height
  492.      end
  493.      @bust.opacity = openness
  494.    else
  495.      @bust.bitmap = nil
  496.      @bust.opacity = 0
  497.    end        
  498.    @bust.update
  499.  end
  500.  #--------------------------------------------------------------------------
  501.  # * alias: new_line_x
  502.  #--------------------------------------------------------------------------
  503.  alias bm_message_nlx new_line_x
  504.  def new_line_x
  505.    allow_bust = !$game_switches[BM::MESSAGE::BUST[:disable_sw]]
  506.    if allow_bust
  507.      portrait_name = $game_message.face_name + "-" + ($game_message.face_index).to_s
  508.      allow_bust = portrait_exist?(portrait_name)
  509.    end
  510.    if !allow_bust
  511.      return bm_message_nlx
  512.    else
  513.      if @bust.z >= self.z && !$game_message.mirror && $game_message.position == 2
  514.        $game_message.face_name.empty? ? 0 : @bust.bitmap.width + BM::MESSAGE::BUST[:x]
  515.      else
  516.        return 0
  517.      end
  518.    end
  519.  end
  520.  #--------------------------------------------------------------------------
  521.  # * alias: draw_face
  522.  #--------------------------------------------------------------------------
  523.  alias :bm_message_df :draw_face
  524.  def draw_face(face_name, face_index, x, y, enabled = true)
  525.    allow_bust = !$game_switches[BM::MESSAGE::BUST[:disable_sw]]
  526.    if allow_bust
  527.      portrait_name = $game_message.face_name + "-" + ($game_message.face_index).to_s
  528.      allow_bust = portrait_exist?(portrait_name)
  529.    end
  530.    return if allow_bust
  531.    bm_message_df(face_name, face_index, x, y, enabled)
  532.  end
  533.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  534.  # * Alias: Process Normal Character
  535.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  536.  alias :bm_message_pnc :process_normal_character
  537.  def process_normal_character(c, pos, *args, &block)
  538.    bm_message_pnc(c, pos, *args, &block) # Call Original Method
  539.    # Play SE if not showing fast and the letter sound is on
  540.    play_letter_by_letter_se if $game_message.play_sound?(:letter) &&
  541.      !@show_fast && !@line_show_fast
  542.  end
  543.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  544.  # * Alias: Input Pause
  545.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  546.  alias :bm_message_ip :input_pause
  547.  def input_pause(*args, &block)
  548.    # Play Pause SE
  549.    $game_message.pause_se.play if $game_message.play_sound?(:pause) # Play
  550.    bm_message_ip(*args, &block) # Call Original Method
  551.  end
  552.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  553.  # * Alias: Play Letter By Letter SE
  554.  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  555.  def play_letter_by_letter_se
  556.    # If drawn enough letters to play the SE
  557.    if @char_count >= $game_message.occurence
  558.      @char_count = 0
  559.      unless $game_message.random_pitch.first == $game_message.random_pitch.last
  560.        # Randomize pitch
  561.        $game_message.letter_se.pitch = $game_message.random_pitch.first +
  562.          rand($game_message.random_pitch.last - $game_message.random_pitch.first)
  563.      end
  564.      $game_message.letter_se.play # Play Letter by Letter SE
  565.    else
  566.      @char_count += 1 # Advance character count
  567.    end
  568.  end
  569. end
  570. #==============================================================================
  571. # ** Window_Base
  572. #==============================================================================
  573. class Window_Base < Window  
  574.  #--------------------------------------------------------------------------
  575.  # * Alias: convert_escape_characters
  576.  #--------------------------------------------------------------------------
  577.  alias :bm_message_cec :convert_escape_characters
  578.  def convert_escape_characters(text)
  579.    result = bm_message_cec(text)
  580.    result = convert_bm_escape_characters(result)
  581.    return result
  582.  end  
  583.  #--------------------------------------------------------------------------
  584.  # * New method: convert_bm_escape_characters
  585.  #--------------------------------------------------------------------------
  586.  def convert_bm_escape_characters(result)
  587.    # Names
  588.    result.gsub!(/\eNPG/i)           { $game_party.gold rescue ""}
  589.    result.gsub!(/\eNMP\[(\d+)\]/i)  { load_data(sprintf("Data/Map%03d.rvdata2", $1.to_i)).display_name rescue "" }
  590.    result.gsub!(/\eNMP/i)           { $game_map.display_name rescue "" }
  591.    result.gsub!(/\eNEV\[(\d+)\]/i)  { $game_map.events[$1.to_i].name rescue "" }
  592.    result.gsub!(/\eNEM\[(\d+)\]/i)  { Vocab.enemies($1.to_i) rescue "" }
  593.    result.gsub!(/\eNPR\[(\d+)\]/i)  { Vocab.param_a($1.to_i) rescue "" }
  594.    result.gsub!(/\eNXP\[(\d+)\]/i)  { Vocab.xparam_a($1.to_i) rescue "" }
  595.    result.gsub!(/\eNSP\[(\d+)\]/i)  { Vocab.sparam_a($1.to_i) rescue "" }
  596.    result.gsub!(/\eNTR\[(\d+)\]/i)  { $data_troops[$1.to_i].name rescue "" }
  597.    result.gsub!(/\eNVR\[(\d+)\]/i)  { Vocab.variables($1.to_i) rescue "" }
  598.    result.gsub!(/\eNSW\[(\d+)\]/i)  { Vocab.switches($1.to_i) rescue "" }
  599.    result.gsub!(/\eNWT\[(\d+)\]/i)  { Vocab.weapon_types($1.to_i) rescue "" }
  600.    result.gsub!(/\eNAT\[(\d+)\]/i)  { Vocab.armor_types($1.to_i) rescue "" }
  601.    result.gsub!(/\eNST\[(\d+)\]/i)  { Vocab.skill_types($1.to_i) rescue "" }
  602.    result.gsub!(/\eNEL\[(\d+)\]/i)  { Vocab.element($1.to_i) rescue "" }
  603.    # Parameters
  604.    result.gsub!(/\eAPR\[([-+]?\d+)\,(\d+)\]/i)  { actor_param($2.to_i, $1.to_i) }
  605.    result.gsub!(/\eAXP\[([-+]?\d+)\,(\d+)\]/i)  { actor_xparam($2.to_i, $1.to_i) }
  606.    result.gsub!(/\eASP\[([-+]?\d+)\,(\d+)\]/i)  { actor_sparam($2.to_i, $1.to_i) }
  607.    # Vocab
  608.    result.gsub!(/\eVOCAB\[(\w+),\s*(\d+)\s*\]/i) { Vocab.send($1.downcase, $2.to_i) rescue "" }
  609.    result.gsub!(/\eVOCAB\[(\w+)\]/i) { Vocab.send($1.downcase) rescue "" }
  610.    # Names and Icons
  611.    result.gsub!(/\eICL\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :classes) }
  612.    result.gsub!(/\eIPR\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :param) }
  613.    result.gsub!(/\eISP\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :sparam) }
  614.    result.gsub!(/\eIXP\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :xparam) }
  615.    result.gsub!(/\eIWT\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :weapon_types) }
  616.    result.gsub!(/\eIAT\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :armor_types)}
  617.    result.gsub!(/\eIST\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :skill_types)  }
  618.    result.gsub!(/\eIEL\[(\d+)\]/i) { escape_icon_and_text($1.to_i, :element) }
  619.    # Conditional Text
  620.    result.gsub!(/\eS\[(\d+)[,;:](.+?)\]/mi)  { $game_switches[$1.to_i] ? $2 : "" }
  621.    result.gsub!(/\eS!\[(\d+)[,;:](.+?)\]/mi) { $game_switches[$1.to_i] ? "" : $2 }
  622.    result.gsub!(/\eS\{(\d+)[,;:](.+?)\}/mi)  { $game_switches[$1.to_i] ? $2 : "" }
  623.    result.gsub!(/\eS!\{(\d+)[,;:](.+?)\}/mi) { $game_switches[$1.to_i] ? "" : $2 }
  624.    # Evaluation
  625.    result.gsub!(/\e#\{(.+?)\}/im)  { (eval($1)).to_s rescue "" }
  626.    # Sound Effects
  627.    result.gsub!(/\eP_?([MS]E)\[\s*\"?([^\",\]]+)\"?(.*?)\]/i)   { "\ePLAYSOUND\[#{$1.upcase},\"#{$2}\"#{$3.gsub(/ /, "")}\]" }
  628.     result.gsub!(/\eP_?(ANIM|BLN)\[\s*(\d+)[\s,:;]*(\d+)\s*\]/i) { "\eANIMATION\[#{$1.upcase == "ANIM" ? 0 : 1},#{$2},#{$3}\]" }
  629.     letter_ary = ["L", "P", "F", "T"]
  630.     # Turn Sound Effects on or off
  631.     result.gsub!(/([\e\/])([LPFT])SE/i) {
  632.       num = ($1 == "\e" ? 0 : 1) + (2*letter_ary.index($2.upcase))
  633.       "\eATSMOSE\[#{num}\]" }
  634.     # Do resubstitutions if requested
  635.     if result.sub!(/\eRESUB/i, "") != nil
  636.       result = convert_escape_characters(result, *args, &block)
  637.     end
  638.     return result    
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # new method: actor_param
  642.   #--------------------------------------------------------------------------
  643.   def actor_param(actor_id, param_id)
  644.     return "" unless param_id <= 7 && param_id >= 0
  645.     actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  646.     actor = $game_actors[actor_id]
  647.     return "" if actor.nil?
  648.     case param_id
  649.     when 0,:hp,:maxhp; value = actor.mhp
  650.     when 1,:mp,:maxmp; value = actor.mmp
  651.     when 2,:atk; value = actor.atk
  652.     when 3,:def; value = actor.def
  653.     when 4,:mat; value = actor.mat
  654.     when 5,:mdf; value = actor.mdf
  655.     when 6,:agi; value = actor.agi
  656.     when 7,:luk; value = actor.luk
  657.     end
  658.     return value.group
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # new method: actor_xparam
  662.   #--------------------------------------------------------------------------
  663.   def actor_xparam(actor_id, param_id)
  664.     return "" unless param_id <= 9 && param_id >= 0
  665.     actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  666.     actor = $game_actors[actor_id]
  667.     return "" if actor.nil?
  668.     case param_id
  669.     when 0,:hit;      value = actor.hit
  670.     when 1,:eva;      value = actor.eva
  671.     when 2,:cri;      value = actor.cri
  672.     when 3,:cev;      value = actor.cev
  673.     when 4,:mev;      value = actor.mev
  674.     when 5,:mrf;      value = actor.mrf
  675.     when 6,:cnt;      value = actor.cnt
  676.     when 7,:hrg;      value = actor.hrg
  677.     when 8,:mrg;      value = actor.mrg
  678.     when 9,:trg;      value = actor.trg
  679.     end
  680.     return sprintf("%d%%", value * 100)
  681.   end
  682.   #--------------------------------------------------------------------------
  683.   # new method: actor_sparam
  684.   #--------------------------------------------------------------------------
  685.   def actor_sparam(actor_id, param_id)
  686.     return "" unless param_id <= 9 && param_id >= 0
  687.     actor_id = $game_party.members[actor_id.abs].id if actor_id <= 0
  688.     actor = $game_actors[actor_id]
  689.     return "" if actor.nil?
  690.     case param_id
  691.     when 0,:tgr;      value = actor.tgr
  692.     when 1,:grd;      value = actor.grd
  693.     when 2,:rec;      value = actor.rec
  694.     when 3,:pha;      value = actor.pha
  695.     when 4,:mcr;      value = actor.mcr
  696.     when 5,:tcr;      value = actor.tcr
  697.     when 6,:pdr;      value = actor.pdr
  698.     when 7,:mdr;      value = actor.mdr
  699.     when 8,:fdr;      value = actor.fdr
  700.     when 9,:exr;      value = actor.exr      
  701.     end
  702.     return sprintf("%d%%", value * 100)
  703.   end
  704.   #--------------------------------------------------------------------------
  705.   # * New Method: escape_icon_and_text
  706.   #--------------------------------------------------------------------------
  707.   def escape_icon_and_text(data_id, type)
  708.     icon = 0
  709.     case type    
  710.     when :sparam, :xparam
  711.       name = eval("Vocab.#{type}_a(#{data_id})")
  712.       icon = eval("Icon.#{type}(#{data_id})") if $imported[:bm_icon]
  713.     when :param, :weapon_types, :armor_types, :skill_types, :element
  714.       name = eval("Vocab.#{type}(#{data_id})")
  715.       icon = eval("Icon.#{type}(#{data_id})") if $imported[:bm_icon]
  716.     when :classes
  717.       name = eval("Vocab.#{type}(#{data_id})")
  718.       icon = Icon.class(data_id) if $imported[:bm_icon]
  719.     else; return ""
  720.     end
  721.     if icon != 0
  722.       text = "\eI[#{icon}]" + name
  723.     else
  724.       text = name
  725.     end
  726.     return text
  727.   end
  728. end
  729. #===============================================================================
  730. #
  731. # END OF FILE
  732. #
  733. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement