Individual Collapse Sounds
Version: 1.0
Author: modern algebra
Date: April 10, 2010
Version History
- <Version 1.0> 04.10.2010 - Original Release
Description
This script allows you to set individual collapse sounds for your enemies and actors. Want humans to scream when they die but robots to break down? This is what this script does.
Features
- Allows you to specify different sounds for each and every actor and monster
- Allows you to change pitch and volume on those sounds
- Intuitive configuration
Instructions
Paste the script into the Script Editor (F11) above Main but below the rest of the default scripts.
Script
#==============================================================================
# Individual Collapse Sounds
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: April 10, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to set individual collapse sounds for your enemies
# and actors. Want humans to scream when they die but robots to break down?
# This is what this script does.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into the Script Editor in its own slot above Main and
# below Materials. To configure an enemy collapse sound, simply type into its
# notebox this code:
# \CS[se_name, volume, pitch]
# se_name : the filename of the SE you want to play upon death
# volume : the volume you want it to play at. 100 is default if you
# exclude it.
# pitch : the pitch you want it to play at. 100 is default if you
# exclude it.
#
# If you don't put anything at all, then the enemy collapse sound will be
# the default one you set in the database. Note that you don't need to
# specify volume or pitch, so \CS[se_name] would be fine, as would be
# \CS[se_name, volume].
# EXAMPLE: \CS[Collapse1, 95, 85]
#
# To set up the actor's collapse sounds. See the EDITABLE REGION at line 47.
#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - perform_collapse
# new method - maic_collapse_sound
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Collapse Sound
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maic_collapse_sound
name, volume, pitch = $data_system.sounds[13].name, 100, 100
case @actor_id
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# EDITABLE REGION
#````````````````````````````````````````````````````````````````````````
# To set up an actor, use this format:
# when actor_id
# name = "filename" (defaults to database collapse file)
# volume = integer (defaults to 100)
# pitch = integer (dfaults to 100)
#
# If you do not set one up for an actor at all, then it will play the
# database actor collapse sound when that actor dies. If you set one up
# for an actor but exclude any of the values, it will default the value
# specified above.
#
# EXAMPLE:
# when 1 # Ralph
# name = "Collapse1"
# volume = 80
# pitch = 65
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
when 1 # Ralph
name = "Collapse1"
volume = 80
when 2 # Ulrika
name = "Collapse2"
pitch = 150
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END EDITABLE REGION
#////////////////////////////////////////////////////////////////////////
else
return $data_system.sounds[13]
end
return RPG::SE.new (name, volume, pitch)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Perform Collapse
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mornal_indcol_perform_9tv1 perform_collapse
def perform_collapse (*args)
system_sound = $data_system.sounds[13]
$data_system.sounds[13] = maic_collapse_sound
mornal_indcol_perform_9tv1 (*args) # Run Original Method
$data_system.sounds[13] = system_sound
end
end
#==============================================================================
# ** RPG::Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - maiec_collapse_sound
#==============================================================================
class RPG::Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Collapse Sound
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maiec_collapse_sound
if self.note[/\\CS\[(.+?),?\s*?(\d*?),?\s*?(\d*?)\]/i] != nil
pitch = $3 ? $3.to_i : 100
volume = $2 ? $2.to_i : 100
return RPG::SE.new ($1.to_s, volume, pitch)
else
return $data_system.sounds[11]
end
end
end
#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - perform_collapse
#==============================================================================
class Game_Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Perform Collapse
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malgbr_indenmyclapse_8ik1 perform_collapse
def perform_collapse (*args)
system_sound = $data_system.sounds[11]
$data_system.sounds[11] = self.enemy.maiec_collapse_sound
malgbr_indenmyclapse_8ik1 (*args) # Run Original Method
$data_system.sounds[11] = system_sound
end
end
Credit
Thanks
Support
Please post in this topic for support, no matter how old the topic is. Do not PM me.
Known Compatibility Issues
No known compatibility issues. If you find one, please post and I will do my best to resolve it.
I use it for compatibility purposes the args part is just the name of the variable; what matters is the * operator. You can think of it as collapsing an array, so if you have an array like:
coords = [x, y, z]
a, b, c = *coords # a = x; b = y; c = z
It also works in reverse, so *coords = x, y, z # coords = [x, y, z]
I use it in both ways where I am aliasing. It first takes all of the arguments passed to a method and puts them in an array (called args, but again you could name it anything). I then collapse that array and pass those arguments through the original method call.
So:
alias new_method old_method
def old_method (*args)
new_method (*args)
end
I think it helps for compatibility, because you don't need to know what arguments that method is expecting if you don't need to use them. Because consider this situation:
Original method:
def old_method (x, y)
# Stuff
end
And then another scripter comes along and decides he wants to add another argument he/she can pass to this method for his/her own purposes, so he/she writes this:
alias new_method old_method
def old_method (x, y, z = 0)
new_method (x, y)
# Stuff
end
So far everything is dandy. It will work everywhere. But then another scripter comes along and writes this:
alias new_method2 old_method
def old_method (x, y)
new_method2 (x, y)
# Stuff
end
Now, wherever in the first scripter's code that he passes the extra argument to old_method there will be an argument error because he's passing three arguments to old_method when it only takes two. Now that would be a very easy error to correct since all anyone would need to do is put the second script above the first script in the Editor, but it's not hard to imagine more serious incarnations of this and in any case, most RM users aren't overly adept at solving errors in their scripts. So, as long as you're not using the arguments passed to the method you alias, then you might as well use *args in order to avoid potential argument errors.