How to delay Battle BGM for a couple of seconds

Hi all,

I'm using VS Battle Core FYI.

Is there a means of delaying the BGM kicking in at the start of a battle? The reason I ask is that I have a custom encounter sound that overlaps with the BGM starting.

I saw a similar thread but it wasn't for MZ. Can anyone assist? I've tried injecting a setTimeout() in rmmz_scenes.js:
JavaScript:
Scene_Battle.prototype.start
= function() {
    Scene_Message.prototype.start.call(this);
    setTimeout(() =>  BattleManager.playBattleBgm(), 4000);
    BattleManager.startBattle();
    this._statusWindow.refresh();
    this.startFadeIn(this.fadeSpeed(), false);
};

This didn't do anything unfortunately (and truth be told, I'd rather do this with a simple script call or plugin somewhere).


Any advice?

Thanks for reading 🙂

Mike
Hi all,

I'm using VS Battle Core FYI.

Is there a means of delaying the BGM kicking in at the start of a battle? The reason I ask is that I have a custom encounter sound that overlaps with the BGM starting.

I saw a similar thread but it wasn't for MZ. Can anyone assist? I've tried injecting a setTimeout() in rmmz_scenes.js:
JavaScript:
Scene_Battle.prototype.start
= function() {
    Scene_Message.prototype.start.call(this);
    setTimeout(() =>  BattleManager.playBattleBgm(), 4000);
    BattleManager.startBattle();
    this._statusWindow.refresh();
    this.startFadeIn(this.fadeSpeed(), false);
};

This didn't do anything unfortunately (and truth be told, I'd rather do this with a simple script call or plugin somewhere).


Any advice?

Thanks for reading 🙂

Mike
When you say the setTimeout didn't do anything, do you mean the BGM started exactly when it did before?

I would be very surprised if there isn't a plugin or several that overwrites or changes parts of Scene_Battle's start function. My first port of call would be to open the console in test play and type

JavaScript:
Scene_Battle.prototype.start

(no brackets) and press enter. See if what comes up is the one from rmmz_scenes.js.

And just as a general piece of advice, I wouldn't recommend injecting anything into the core scripts; you'll lose your changes when the engine gets updated.
When you say the setTimeout didn't do anything, do you mean the BGM started exactly when it did before?

I would be very surprised if there isn't a plugin or several that overwrites or changes parts of Scene_Battle's start function. My first port of call would be to open the console in test play and type

JavaScript:
Scene_Battle.prototype.start

(no brackets) and press enter. See if what comes up is the one from rmmz_scenes.js.

And just as a general piece of advice, I wouldn't recommend injecting anything into the core scripts; you'll lose your changes when the engine gets updated.
Thanks, you were bang on the money, it was due to a plugin for encounter effects so it had overwritten the point when BattleManager.playBattleBgm(); was called.

Fortunately it was easy to edit from within the plugin and use the setTimeout function.

Thank you for your help and I will certainly bear in mind your advise on the core scripts 🙂
If you set up a silent audio file as the starting default music, and have it change to a non-silent music, that would also effectively work like a delayed music fade in.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-delay-battle-bgm-for-a-couple-of-seconds.154893/