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.
Ingame System SE Definition

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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Ingame System Audio Definition
Version: 2.0
Author: modern algebra
Date: June 5, 2010


Description


This script allows you to change what audio files are associated with the system at any time during the game. That's a bit abstract, so an easier way to explain it would be that if, for whatever reason, you want to be able to change the sound effect that is played when you press enter on something, then this script allows you to change that in-game. In other words, you don't have to have only one decision SE for the entire game. The same goes for all of the BGMs, MEs, and SEs that are set in the System tab of the Database, except for the title ones.

Features

  • Allows you to change the system audio at any point in game
  • Can set pitch and volume along with the new SE
  • Could easily be adapted into an options menu that allows the user to select his own system audio
  • Very easy to use interface

Instructions

Place this script in its own slot in the Script Editor (F11), above Main but below Materials.

You can change any of the system audio files in-game using the following code in a call script:
Code: [Select]
change_audio (:type, "filename", volume, pitch)
         type - this is how you set which sound effect to change. The possible values are (they correspond to their name in System):
             :cursor, :decision, :cancel, :buzzer, :equip, :save, :load, :battle_start, :escape, :enemy_attack, :enemy_damage, :enemy_collapse, :actor_damage, :actor_collapse, :recovery, :miss, :evasion, :shop, :item_use, :skill_use, :boat, :ship, :airship, :battle, :battle_end, :gameover
         filename - the name of the audio file to change to it must be within quotation marks. If excluded, it erases the sound altogether.
         volume - the volume you want the audiofile to play at. If excluded, this defaults to 100
         pitch - the pitch you want the audiofile to play at. If excluded, this defaults to 100

EXAMPLES:
    change_audio (:cursor, "Cursor2", 60)
    change_audio (:gameover,"Victory1",120,80)

  You will want to avoid having it go over more than one line in the script call, so if it doesn't fit, set the name or other attributes to a new variable, like this:
    n = "Decision2"
    change_audio (:decision, n, 65, 100)

Script


Code: [Select]
#==============================================================================
#  Ingame System Audio Definition
#  Author: modern algebra (rmrk.net)
#  Version: 2.0
#  Date Released: June 5, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to change what audio files are associated with the
#   system at any time during the game. That's a bit abstract, so an easier way
#   to explain it would be that if, for whatever reason, you want to be able to
#   change the sound effect that is played when you press enter on something,
#   then this script allows you to change that in-game. In other words, you
#   don't have to have only one decision SE for the entire game. The same goes
#   for all of the BGMs, MEs, and SEs that are set in the System tab of the
#   Database, except for the title ones.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script in its own slot in the Script Editor (F11), above Main
#   but below Materials.
#
#    You can change any of the system audio files in-game using the following
#   code in a call script:
#
#        change_audio (:type, "filename", volume, pitch)
#          type - this is how you set which sound effect to change. The
#            possible values are (they correspond to their name in System):
#              :cursor, :decision, :cancel, :buzzer, :equip, :save, :load,
#              :battle_start, :escape, :enemy_attack, :enemy_damage,
#              :enemy_collapse, :actor_damage, :actor_collapse, :recovery,
#              :miss, :evasion, :shop, :item_use, :skill_use, :boat, :ship,
#              :airship, :battle, :battle_end, :gameover
#          filename - the name of the audio file to change to it must be within
#            quotation marks. If excluded, it erases the sound altogether.
#          volume - the volume you want the audiofile to play at. If excluded,
#            this defaults to 100
#          pitch - the pitch you want the audiofile to play at. If excluded,
#            this defaults to 100
#
#  EXAMPLES:
#    change_audio (:cursor, "Cursor2", 60)
#    change_audio (:gameover,"Victory1",120,80)
#
#  You will want to avoid having it go over more than one line in the script
# call, so if it doesn't fit, set the name or other attributes to a new
# variable, like this:
#    n = "Decision2"
#    change_audio (:decision, n, 65, 100)
#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new attr_reader - ma_sounds; ma_music
#    aliased method - initialize
#    new method - set_audiofile
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader :ma_sounds
  attr_reader :ma_music
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malrab_igsd2_inze_4xc9 initialize
  def initialize (*args)
    malrab_igsd2_inze_4xc9 (*args) # Run Original Method
    initialize_system_audio
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize System Audio
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize_system_audio
    @ma_sounds = Marshal.load (Marshal.dump($data_system.sounds))
    @ma_music = [$data_system.boat.bgm.dup, $data_system.ship.bgm.dup,
      $data_system.airship.bgm.dup, $data_system.battle_bgm.dup,
      $data_system.battle_end_me.dup, $data_system.gameover_me.dup]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set AudioFile
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def set_audiofile (id, name = "", *args)
    if id >= @ma_sounds.size
      id -= @ma_sounds.size
      @ma_music[id] = id < 4 ? RPG::BGM.new (name, *args) : RPG::ME.new (name, *args)
      case id
      when 0 then $data_system.boat.bgm = $game_system.ma_music[0]
      when 1 then $data_system.ship.bgm = $game_system.ma_music[1]
      when 2 then $data_system.airship.bgm = $game_system.ma_music[2]
      when 3 then $data_system.battle_bgm = $game_system.ma_music[3]
      when 4 then $data_system.battle_end_me = $game_system.ma_music[4]
      when 5 then $data_system.gameover_me = $game_system.ma_music[5]
      end
    else
      @ma_sounds[id] = RPG::SE.new (name, *args)
      $data_system.sounds[id] = @ma_sounds[id]
    end
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - change_audio
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Change Audio
  #     type : symbol or integer representing type
  #     args : the attributes of the new file
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def change_audio (type = nil, *args)
    if type.is_a? (Symbol)
      id = [:cursor, :decision, :cancel, :buzzer, :equip, :save, :load,
        :battle_start, :escape, :enemy_attack, :enemy_damage, :enemy_collapse,
        :actor_damage, :actor_collapse, :recovery, :miss, :evasion, :shop,
        :item_use, :skill_use, :boat, :ship, :airship, :battle, :battle_end,
        :gameover].index (type)
    else
      id = type
    end
    return if !id.is_a? (Integer)
    $game_system.set_audiofile (id, *args)
  end
end

#==============================================================================
# ** Scene File
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - read_save_data
#==============================================================================

class Scene_File
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Read Save Data
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modrabra_isad_rdsvda_5uj8 read_save_data
  def read_save_data (*args)
    modrabra_isad_rdsvda_5uj8 (*args) # Run Original Method
    if $game_system.ma_sounds.nil?
      $game_system.initialize_system_audio
    else
      $data_system.sounds = $game_system.ma_sounds
      $data_system.boat.bgm = $game_system.ma_music[0]
      $data_system.ship.bgm = $game_system.ma_music[1]
      $data_system.airship.bgm = $game_system.ma_music[2]
      $data_system.battle_bgm = $game_system.ma_music[3]
      $data_system.battle_end_me = $game_system.ma_music[4]
      $data_system.gameover_me = $game_system.ma_music[5]
    end
  end
end

Credit


  • modern algebra

Thanks

  • Zylos, for pointing out the problem

Support


Just post in this topic.

Known Compatibility Issues

I don't forsee any compatibility problems that can't be fixed by putting this script below any of your other custom scripts, but still above Main.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: June 05, 2010, 11:05:47 PM by modern algebra »

********
Furry Philosopher
Rep:
Level 94
Rawr?
2013 Best RPG Maker User (Creativity)Gold - GIAW 11 (Hard)Randomizer - GIAW 11Secret Santa 2013 ParticipantFor frequently finding and reporting spam and spam bots2012 Best RPG Maker User (Mapping)2012 Best RPG Maker User (Programming)Secret Santa 2012 ParticipantGold - GIAW 9Project of the Month winner for September 2008For taking a crack at the RMRK Wiki2011 Best RPG Maker User (Programming)2011 Best Veteran2011 Kindest Member2010 Best RPG Maker User (Story)2010 Best RPG Maker User (Technical)
Modern, I love you.




*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I'm not into bestiality, sorry  :P

********
Furry Philosopher
Rep:
Level 94
Rawr?
2013 Best RPG Maker User (Creativity)Gold - GIAW 11 (Hard)Randomizer - GIAW 11Secret Santa 2013 ParticipantFor frequently finding and reporting spam and spam bots2012 Best RPG Maker User (Mapping)2012 Best RPG Maker User (Programming)Secret Santa 2012 ParticipantGold - GIAW 9Project of the Month winner for September 2008For taking a crack at the RMRK Wiki2011 Best RPG Maker User (Programming)2011 Best Veteran2011 Kindest Member2010 Best RPG Maker User (Story)2010 Best RPG Maker User (Technical)
 :o Not that kind of love!

Anyway, the only complaint I have about the script is that you cannot change volume or pitch. (Or can you?)




*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I was thinking of adding that actually, I'll fix it up in a second.

EDIT::

Bear in mind, you can easily change any single part of the SE with the codes:

$game_system.whatever_se.name = "filename"
$game_system.whatever_se.volume = value
$game_system.whatever_se.pitch = value

But I will make it possible that you can set everything in one line, for the sake of ease.

EDIT 2:: It's done now. Read the instructions to see how.
« Last Edit: March 05, 2008, 01:50:10 AM by modern algebra »

**
Rep:
Level 86
Ya I tried this. It didn't work. Even with a brand new project with no added scripts.

*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I'm going to have to disagree with you there - I just tried it and it works fine. What does your code to change the sound look like (the call script part)?

**
Rep:
Level 86
script: $game_system.cursor_se = "beep5",80,50

that is what I have in my call script. probably missing something though.

*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Does an error message come up or does it simply not change the SE, or does no SE play at all?
« Last Edit: July 30, 2008, 10:18:59 PM by modern algebra »

**
Rep:
Level 86
line 198 in the script
undefined methods "sound"

I have place the code for the script above main...can't see why that is the problem unless it needs to be somewhere in game_system.



*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Well, above Main and below Materials, but that wouldn't be the error caused if you had it in the wrong position in the editor.

Anyway, so does this error happen as soon as you go into the game - I imagine it would. And is it undefined method 'sound' or 'sounds'?

**
Rep:
Level 86
Yes as soon as I start the game it appears. Even if I have don't have the call script event.

Okay what I did was have an event running with the call script with my desired sound change(which was the cursor).
That is it.

By the way, thanks for the quite replies. I really appreciate it. The same sound over and over again bores my game that I am creating.

*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Can you upload that test project you made for me? Just zip it or rar it and attach it to your post through the additional options.

And it's no problem - I'm happy to help.

**
Rep:
Level 86
Here it is.

Oh, and I meant quick replies, not "quite".

*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I figured as much.

And the #1 problem that is occuring is that you are using RMVX scripts in an RMXP project :P

**
Rep:
Level 86
Ahhhhhhhhhhhhhhhhhhhhhh, your kidding me!

Damn it ahahahaha. No wonder it wasn't working.

There is a script to do the same thing for XP I hope.


I feel like a damn idiot.

*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Ah, don't feel badly :P

I don't know if there is a script to do the same thing for XP - it might be a little inconvenient.

**
Rep:
Level 86
Okay, it is no big deal anyway. Like I said, I just didn't like the same sound over and over. I guess I can just march on with the project anyways.
Thanks again for your help.

*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
I rewrote this script, so it is updated to Version 2.0. It can now modify all System Audio (except for Title BGM) and has a much nicer way to change them.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
This is nice. I like how you didn't forget the pitch function, which almost everyone I know ignores. Also, would the save_data method work the same as the Marshal.dump method?

*
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 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Not really. save_data would do roughly the same thing in that it would use Marshal.dump but it would save it to a file. I didn't want to save it to a file ~ the only thing I wanted to do was clone all the elements of $data_system.sounds in addition to the array. In actuality, I didn't need to; I wrote it that way before I had decided not to leave any backup work for the original $data_system objects to do. But a simple $game_system.ma_sounds = $data_system.sounds would have been sufficient and probably a better design choice.

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
After reading over the help file again, it makes sense, I guess.

Thanks for the tip.