Changing the Title Screen's Music Based on Game Progression

● ARCHIVED · READ-ONLY
Started by Marche100 9 posts View original ↗
  1. Hi, everyone. 

    I'd like to request a script that allows you to dynamically change the music that plays on the title screen. I'm going to use another script that I'm currently using to explain my idea:

    This is Rachael's Dynamic Title Script. It allows you to change the title screen's background based on the value of a variable. To find the value of that variable it can either check your most recent save or it can check every one of your saves and take the one that has the highest value for the variable.

    I would like a similar script that performs the same basic function, but with the title screen's music. I only need to change it once for the game that I'm currently working on (I want to change it when the player unlocks the epilogue, as the title screen's background changes drastically when that happens), but it may be useful to be able to change it as many times as you can, similar to how Rachael's script allows you to change the title screen's background an unlimited number of times (which was good for me in that case, because I need to change the background a bunch of times. Not the music). But I'm not really that picky. I'd simply be more than happy if anyone would take me up on my request. 

    And if I had to choose between a script that checks your most recent save or all of your saves, I would use the one that only checks your most recent save. Just in case anyone wants to make the script but doesn't want to accommodate both.

    Edit: As an addendum, this script should be compatible with the script I referenced above.

    Thanks for any help. Cheers,

    Marche100
  2. I just want to add that, of course, this script should be compatible with Rachael's title image script, so both can be used at the same time.


    This seems like a given, but someone could easily overlook it.
  3. Can't you use an event to swap it out?
  4. TygerBurnz said:
    Can't you use an event to swap it out?
    I don't see how...
  5. Solo said:
    I just want to add that, of course, this script should be compatible with Rachael's title image script, so both can be used at the same time.

    This seems like a given, but someone could easily overlook it.
    Yeah, I figured that was a given. But I'll add it to my original post.

    TygerBurnz said:
    Can't you use an event to swap it out?
    If you can, I'd sure like to know how!
  6. I pretty much just duplicated my previous script and changed it to work with music instead. Pretty lazy on my part, but appears to work as intended. I assumed you weren't changing the music as often as the image, so I tied it to a different variable.

    Spoiler
    Spoiler




    Code:
    #==============================================================================
    # Dynamic Title Screen Music
    # by: Racheal
    # Version 1.0
    # Created: 22/11/2014
    #==============================================================================
    # Changes the title screen music based on a variable set in-game.
    #==============================================================================
    # Instructions:
    # * Insert in the Materials section
    # * Configure to your liking below
    #==============================================================================
    # Compatibility:
    # This script is for RPG Maker VX Ace
    # * Overwrites: Scene_Title: play_title_music
    #==============================================================================
    
    #==============================================================================
    # Customization
    #==============================================================================
    module Racheal_Title_Music
      #Set which variable controls the change in the title screen
      TITLE_MUSIC_VARIABLE = 6
      
      #Set whether to check the highest variable in all the save files or
      #just use the most recent save
      CHECK_ALL_SAVES = false
      
      #Set music file info here
      MUSIC_SETTINGS = [#[name, volume, pitch],
                         ["Theme1", 100, 100],
                         ["Theme2", 100, 100]
                       ]
    end
    #==============================================================================
    # End Customization
    #==============================================================================
    
    #==============================================================================
    # ** DataManager
    #==============================================================================
    
    module DataManager
      #--------------------------------------------------------------------------
      # * Create Save Header
      #--------------------------------------------------------------------------
      class << self; alias dynamic_title_music_make_save_header make_save_header; end
      def self.make_save_header
          header = dynamic_title_music_make_save_header
          header[:music] = $game_variables[Racheal_Title_Music::TITLE_MUSIC_VARIABLE]
          header
      end 
    end
    
    #==============================================================================
    # ** Scene_Title
    #==============================================================================
    
    class Scene_Title < Scene_Base
      #--------------------------------------------------------------------------
      # * Play Title Screen Music
      #--------------------------------------------------------------------------
      def play_title_music
        music = get_music
        Audio.bgm_play('Audio/BGM/' + music[0], music[1], music[2])
        RPG::BGS.stop
        RPG::ME.stop
      end
      #--------------------------------------------------------------------------
      # * Get Music Title
      #--------------------------------------------------------------------------
      def get_music
        music = 0
        if Racheal_Title_Music::CHECK_ALL_SAVES
          #Check all saves
          for i in 0...DataManager.savefile_max
            header = DataManager.load_header(i)
            next unless header and header[:music]
            music = [music, header[:music]].max
          end
        else
          #Check latest save
          header = DataManager.load_header(DataManager.latest_savefile_index)
          if header and header[:music]
            music = [music, header[:music]].max
          end
        end
        #---
        return Racheal_Title_Music::MUSIC_SETTINGS[music]
      end
    end
  7. Wow, it doesn't get much better than getting the script from the one who inspired your request, does it? :)
  8. Yato said:
    I pretty much just duplicated my previous script and changed it to work with music instead. Pretty lazy on my part, but appears to work as intended. I assumed you weren't changing the music as often as the image, so I tied it to a different variable.

    Spoiler
    #==============================================================================# Dynamic Title Screen Music# by: Racheal# Version 1.0# Created: 22/11/2014#==============================================================================# Changes the title screen music based on a variable set in-game.#==============================================================================# Instructions:# * Insert in the Materials section# * Configure to your liking below#==============================================================================# Compatibility:# This script is for RPG Maker VX Ace# * Overwrites: Scene_Title: play_title_music#==============================================================================#==============================================================================# Customization#==============================================================================module Racheal_Title_Music #Set which variable controls the change in the title screen TITLE_MUSIC_VARIABLE = 6 #Set whether to check the highest variable in all the save files or #just use the most recent save CHECK_ALL_SAVES = false #Set music file info here MUSIC_SETTINGS = [#[name, volume, pitch], ["Theme1", 100, 100], ["Theme2", 100, 100] ]end#==============================================================================# End Customization#==============================================================================#==============================================================================# ** DataManager#==============================================================================module DataManager #-------------------------------------------------------------------------- # * Create Save Header #-------------------------------------------------------------------------- class << self; alias dynamic_title_music_make_save_header make_save_header; end def self.make_save_header header = dynamic_title_music_make_save_header header[:music] = $game_variables[Racheal_Title_Music::TITLE_MUSIC_VARIABLE] header end end#==============================================================================# ** Scene_Title#==============================================================================class Scene_Title < Scene_Base #-------------------------------------------------------------------------- # * Play Title Screen Music #-------------------------------------------------------------------------- def play_title_music music = get_music Audio.bgm_play('Audio/BGM/' + music[0], music[1], music[2]) RPG::BGS.stop RPG::ME.stop end #-------------------------------------------------------------------------- # * Get Music Title #-------------------------------------------------------------------------- def get_music music = 0 if Racheal_Title_Music::CHECK_ALL_SAVES #Check all saves for i in 0...DataManager.savefile_max header = DataManager.load_header(i) next unless header and header[:music] music = [music, header[:music]].max end else #Check latest save header = DataManager.load_header(DataManager.latest_savefile_index) if header and header[:music] music = [music, header[:music]].max end end #--- return Racheal_Title_Music::MUSIC_SETTINGS[music] endend
    Wow, thank you very much!
  9. Im glad i google this first and i hope its ok if i use this, end credits will include the you in script authors (as should be expected (personal opinion))