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.
Individual Collapse Sounds

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
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


Code: [Select]
#==============================================================================
#    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


  • modern algebra

Thanks

  • Genjis, for the request

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.

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
a.w.e.s.o.m.e.

***
Rep:
Level 82
aka DigiDeity
Wow nice work!
I should learn more about "*args" you use it it often. :P

Deity
Greetings
DigiDeity

├Work┤
├Contact┤


*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
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:

Code: [Select]
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:

Code: [Select]
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:

Code: [Select]
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:

Code: [Select]
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.

**
Rep: +0/-0Level 72
Black Onslaught
Could be great if somebody send some Dying SE to use.
By the way, great script!

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Or you could check the last post date and create your own topic for it. There is a warning on when you post over topics 60 days old, yeah?
it's like a metaphor or something i don't know

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
For scripts and resources, it is perfectly OK to post on them even when they're old, as it avoids clutter and other problems.

Necroposting is only prohibited where it makes sense to prohibit it: for instance when it's responding to a conversation when none of the participants are still here or still care. For scripts, resources, forum games, it's almost always OK.

***
Rep:
Level 73
Prepare for trouble!
I was actually making some SFX for my game, and had looking for a script like this on my to-do list.  Necroposting saved the effort :3  In return for a fabulous script, I can submit some unused sfx sometime in the future.  x3  I'd love to contribute to this site, but I'm more on the creative side, not so much the scripting or technical. 

THAT SAID.

Thanks so much for the script. <3

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Sorry MA.
I'll try to do better next time.
I thought it was prohibited everywhere. Sorry ;9
it's like a metaphor or something i don't know