Stop playing map music after a battle is completed?

Peva

Don't overwhelm yourself. Set small goals.
Veteran
Joined
Dec 5, 2012
Messages
199
Reaction score
18
First Language
Russian
Primarily Uses
RMMV
Here's the original topic I made.

https://forums.rpgmakerweb.com/index.php?threads/boss-battle-music-start-in-the-cutscene.109536/

Basically, I would like a way to stop music from playing after a specific battle is completed.

The reason I need a plugin for this is because I want the boss music to start playing during the cutscene before the battle and seamlessly transition into the same music during the battle. I can do this, but the problem is after the battle is completed, the results screen (that shows the XP, money, and items you get) continues to play the music because that's what was set before entering the battle. Of course I can get it to end instantly after the results screen, but it'll still play during the results screen.

If you know of a way to get that fixed with events, please let me know, but in my above topic I was told that it needs a plugin.

Thanks in advance! I hope this request is easy.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Give this a try. Either create a new file called "StopMapBgm.js" and save everything in the code block as the contents of the file, or download it from here.

Make sure you name it exactly "StopMapBgm.js" if you create it yourself. The Plugin Parameters won't be properly read if you name it something else. The order you import it should not matter.

There's one Plugin Parameter to setup, which is just to specify which game switch you would like to use to indicate that the current Map's BGM should not play after battle. By default, it's Switch 20, so if Switch 20 is on, then when a battle ends, the music that was playing on the Map will not continue to play.

Code:
/*:
* @plugindesc Allows a user to specify a switch to use to indicate whether a Map's BGM should
* continue to play after battle end. If the switch is ON, it will not play.
* @author Zevia
*
* @help Specify a switch in the setup, then whenever that switch is ON, the BGM on the
* Map will stop after the battle is over. If a victory ME is enabled, it will stop the Map
* music from playing after the victory ME. If a victory ME is not enabled, it will stop
* the Map music from playing as soon as the battle processes its end.
*
* @param switchNumber
* @text Stop Map BGM Switch
* @type switch
* @default 20
*/

(function(module) {
    'use strict';

    module.Zevia = module.Zevia || {};
    var StopMapBgm = module.Zevia.stopMapBgm = {};

    var stopSwitch = parseInt(PluginManager.parameters('StopMapBgm').switchNumber);
    if (isNaN(stopSwitch)) {
        throw new Error('The switch specified needs to be an Integer, please check the Plugin settings for StopMapBgm');
    }

    StopMapBgm.replayBattleBgsAndBgm = BattleManager.replayBgmAndBgs;
    BattleManager.replayBgmAndBgs = function() {
        if ($gameSwitches._data[stopSwitch]) {
            BattleManager._mapBgm = null;
        }
        StopMapBgm.replayBattleBgsAndBgm.call(BattleManager);
    };
})(window);
Let me know if it works for your needs.
 

Peva

Don't overwhelm yourself. Set small goals.
Veteran
Joined
Dec 5, 2012
Messages
199
Reaction score
18
First Language
Russian
Primarily Uses
RMMV
Thanks for making this for me! I tested it out and it works great!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top