07-06-2020, 03:55 AM
KMapAudio XP
by Kyonides Arkanthes
Introduction
Did you ever wanted not to keep the current map's BGM or BGS because the in game atmosphere had changed?
Let's say you wanted to let the player know that a previously visited town has changed. Perhaps it's now decadent or somber.

OK, you could just change the playing BGM but let's be honest, that's a tremendous job to keep track of all of the changes that implies!

Well, not anymore! With my scriptlet you can change it once in a single place that will be executed just once!

The best part is it lets you save and load this change automatically!

Script
Code:
# * KMapAudio XP
# Scripter : Kyonides Arkanthes
# v0.1.0
# * Script Calls * #
# To set a new Map BGM or BGS
# # You can also add Volume and Pitch as optional parameters!
# KMap.new_bgm(MapID, BGMname)
# KMap.new_bgs(MapID, BGSname)
module KMap
def self.setup_audio_file(name, args)
volume = args[0] || 80
pitch = args[1] || 100
RPG::AudioFile.new(name, volume, pitch)
end
def self.new_bgm(map_id, name, *args)
file = setup_audio_file(name, args)
$game_system.set_alt_bgm(map_id, file)
end
def self.new_bgs(map_id, name, *args)
file = setup_audio_file(name, args)
$game_system.set_alt_bgs(map_id, file)
end
end
class Game_System
alias :kyon_md_gm_sys_init :initialize
def initialize
kyon_md_gm_sys_init
@alternate_bgm = {}
@alternate_bgs = {}
end
def set_alt_bgm(map_id, file)
@alternate_bgm[map_id] = file
bgm_play(file)
end
def set_alt_bgs(map_id, file)
@alternate_bgs[map_id] = file
bgs_play(file)
end
attr_reader :alternate_bgm, :alternate_bgs
end
class Game_Map
alias :kyon_md_gm_map_setup :setup
def setup(map_id)
kyon_md_gm_map_setup(map_id)
alt_bgm = $game_system.alternate_bgm[map_id]
alt_bgs = $game_system.alternate_bgs[map_id]
@map.bgm = alt_bgm if alt_bgm
@map.bgs = alt_bgs if alt_bgs
end
end
Terms & Conditions

By the way, I only support the latest version of my scripts.

Give me a free copy of your completed game if you include at least 2 of my scripts!
