RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Menu Use SEs

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Menu Use SEs
Version: 1.0
Author: modern algebra
Date: June 2, 2011

Version History


  • <Version 1.0> 06.02.2011 - Original Release

Description


This script restores the lost RMXP ability to set individual sound effects when using items and skills in the menu.

Features

  • Allows you to set individualized sound effects for each item and skill when using them in the menu

Instructions

Place this script in your Script Editor (F11), above Main but below Materials. If you are using any scripts that alter Scene_Item or Scene_Skill, then put this script under those too. If it still doesn't work then it might be an incompatibility.

For further instructions on how to implement this script in your game, please see the header of the script.

Script


Code: [Select]
#==============================================================================
#    Menu Use SEs
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: June 2, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script restores the lost RMXP ability to set individual sound effects
#   when using items and skills in the menu.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script in your Script Editor (F11), above Main but below
#   Materials. If you are using any scripts that alter Scene_Item or
#   Scene_Skill, then put this script under those too. If it still doesn't work
#   then it might be an incompatibility. Contact me at RMRK.
#
#    This script is otherwise easy to use. All you need to do is place the
#   following code in the notebox of an Item or Skill:
#
#        \menu_se[filename, volume, pitch]
#          filename : the name of the SE file you are using from Audio/SE
#          volume   : how loud you want it to be. Can be from 0 - 100. If you
#            exclude it, it defaults to 80.
#          pitch    : the pitch to play the sound at. Can be from 50 - 150. If
#            you exclude it, it defaults to 100
#
#    EXAMPLES:
#
#      \menu_se[Heal2, 70]
#         This plays the Heal2 SE at 70 volume and 100 pitch when the item or
#        skill is used
#      \menu_se[Fire1]
#         This plays the Fire1 SE at 80 volume and 100 pitch when the item or
#        skill is used
#      \menu_se[Thunder2, 90, 120]
#         This plays the Thunder2 SE at 90 volume and 120 pitch when the item 
#        or skill is used
#==============================================================================

$imported = {} unless $imported
$imported["MAMenuUseSE"] = true

#==============================================================================
# *** RPG::UsableItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - menu_use_se
#==============================================================================

class RPG::UsableItem
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Menu Use SE
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def menu_use_se
    if !@menu_use_se && self.note[/\\MENU_SE\[(.+?)\]/i] != nil
      params = $1.to_s
      @menu_use_se = []
      params.gsub (/\s*?(.+?)\s*?($|[,;])/) { @menu_use_se.push ($1.to_s) if @menu_use_se.size < 3; "" }
      @menu_use_se[1] = @menu_use_se[1].to_i if @menu_use_se[1]
      @menu_use_se[2] = @menu_use_se[2].to_i if @menu_use_se[2]
    end
    return @menu_use_se
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Compatibility with Note Editor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined? (:ma_reset_note_values)
    alias mlg_meuse_reset_note_5ed1 ma_reset_note_values
    def ma_reset_note_values (*args)
      @menu_use_se = nil
      mlg_meuse_reset_note_5ed1 (*args) # Run Original Method
    end
  end
end

#==============================================================================
# *** Sound
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - play_use_item
#==============================================================================

module Sound
  class << self
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Override SEs for play_use_item and play_use_skill
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [:play_use_item, :play_use_skill].each { |method|
      alias_method ("ma_mnuse_#{method}_3ws4".to_sym, method)
      define_method (method) { |*args|
        if $game_temp.menu_use_se
          RPG::SE.new (*$game_temp.menu_use_se).play
          $game_temp.menu_use_se = nil
        else
          self.send ("ma_mnuse_#{method}_3ws4".to_sym, *args)
        end
      }
    }
  end
end

#==============================================================================
# ** Game_Temp
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - menu_use_se
#==============================================================================

class Game_Temp
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :menu_use_se
end

#==============================================================================
# ** Scene_Item
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - use_item_nontarget
#==============================================================================

class Scene_Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Use Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdrna_menuse_useitem_5th6 use_item_nontarget
  def use_item_nontarget (*args)
    # Set the menu item SE
    $game_temp.menu_use_se = @item.menu_use_se if @item
    mdrna_menuse_useitem_5th6 (*args) # Run Original Method
  end
end

#==============================================================================
# ** Scene_Item
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - use_skill_nontarget
#==============================================================================

class Scene_Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Use Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias moda_mense_skill_use_4di9 use_skill_nontarget
  def use_skill_nontarget (*args)
    # Set the menu item SE
    $game_temp.menu_use_se = @skill.menu_use_se if @skill
    moda_mense_skill_use_4di9 (*args)
  end
end

Credit


  • modern algebra

Thanks


Support


Please post in this topic at RMRK if you have any bugs to report, suggestions for improvement, or requests for compatibility patches with other scripts.

Known Compatibility Issues

This may not work with some foreign Item or Skill scenes. It also won't work with any foreign scene that uses an item or skill.