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
#==============================================================================
# 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
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.