Hey everyone, I've been looking for a method to have music change during an attack in a battle, the BGM will play until finish, then revert back to the original BGM prior to being changed. I've tried using a common event that changes the music, but it only plays the music AFTER the attack is completely finished and launched. I've looked everywhere for this and only found something very similar for RPGMaker MZ, and I'm looking for one for VX Ace. I don't think this is possible without a script, which is why I'm here. If you know anything about a possible method to this with or without a script, please let me know as soon as possible. Thank you so much.
Change Music during Skill Use
RGSS3 Script RequestsBump
Do you have multiple battle BGMs? I can think of a way to do this with common events, but if there's multiple battle themes that complicates things somewhat as you'd need to get what music is playing. I guess you could do that with variables, or troop IDs...
Proper head scratcher!
Proper head scratcher!
Sorry for the late response, I didn't get an email for some reason. But yes, I do have a lot of battle BGMs. That's why I don't think it would be possible with common events.
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Skill BGM ║ Version: 1.00 ║
# ║ Author: Roninator2 ║ ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function: ║ Date Created ║
# ║ ╠════════════════════╣
# ║ Allow skills to use their own BGM ║ 01 Dec 2021 ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ For each skill set the note tag for the BGM to play ║
# ║ Will do nothing if there is no tag ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions: ║
# ║ Place <skill bgm: theme1> in the skill notebox ║
# ║ The BGM is played when the skill is used ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use: ║
# ║ Free for all uses in RPG Maker ║
# ╚═════════════════════════════════════╝
module R2_BGM_Skill_Play
Regex = /<skill[-_ ]bgm(?::\s*(\w+))?>/i
end
module RPG
class Skill
def bgm_skill_play
load_skill_bgm unless @bgm_skill != nil
return @bgm_skill
end
def load_skill_bgm
@bgm_skill = nil
res = self.note.scan(R2_BGM_Skill_Play::Regex)
res.each do
@bgm_skill = $1.to_s
end
return @bgm_skill
end
end
end
class Game_Battler < Game_BattlerBase
def change_skill_bgm(item)
return unless item.is_a?(RPG::Skill)
return item.bgm_skill_play
end
end
class Scene_Battle < Scene_Base
alias r2_use_item_bgm_skill use_item
def use_item
item = @subject.current_action.item
song = @subject.change_skill_bgm(item)
curr_bgm = RPG::BGM.last
pos = curr_bgm.pos
if song != nil
RPG::BGM.stop
new_bgm = RPG::BGM.new("#{song}", 100, 100)
new_bgm.play
end
r2_use_item_bgm_skill
if song != nil
RPG::BGM.stop
curr_bgm.play(pos)
end
end
end
Original thread: https://forums.rpgmakerweb.com/threads/change-music-during-skill-use.141804/