Grouped BGM Problem. Help in developing plugin.

Warilized

Random Encounter
Veteran
Joined
Mar 19, 2018
Messages
38
Reaction score
9
First Language
Indonesia
Primarily Uses
RMMV
Regarding this request post of mine. I actually developed my own plugin with this idea, yay~ lol.
A bunch of thanks for Caethyril for helping me.

It works alright :kaopride:
It will play BGM of the referenced map, even if the current has no BGM. If the current map has BGM it will get played instead.

A bit of problem though, this plugin invalidates BGM change through auto run event (unless if "wait: ~10 frames" are added before changing). It can still do it with other trigger though.
It only invalidates the auto run event at the same time it detect a change in <bgm_reference: [MapID]>.
If the <bgm_reference: [MapID]> is the same as the map before, it will let you change BGM through auto run event like normal.

Do you guys have any idea how to solve it? I have tried what I know. :kaocry:

JavaScript:
(function($) {

  var currentGroup;
  
  const BGM_Group_Autoplay = Game_Map.prototype.autoplay;
  Game_Map.prototype.autoplay = function() {
  BGM_Group_Autoplay.call(this);
    var BGMGroup = parseInt($dataMap.meta.bgm_reference);
    var mapRef = 'Map%1.json'.format(BGMGroup.padZero(3));
    loadReference = function(src) {
      var xhr = new XMLHttpRequest();
      var url = 'data/' + src;
      xhr.open('GET', url);
      xhr.overrideMimeType('application/json');
      xhr.onload = function() {
        if (xhr.status < 400) {
          dataMapRef = JSON.parse(xhr.responseText);
          DataManager.extractMetadata(dataMapRef);
          if (BGMGroup != currentGroup) {
            currentGroup = BGMGroup;
            AudioManager.playBgm(dataMapRef.bgm);  
          }
        }
      };
      xhr.onerror = ResourceHandler.createLoader(url, loadReference.bind($, src));
      dataMapRef = null;
      xhr.send();
    };
    if (BGMGroup > 0 && !$dataMap.autoplayBgm)  {
      if ($gamePlayer.isInVehicle()) {
          $gameSystem.saveWalkingBgm2();
      } else {
          loadReference(mapRef);
      }    
    }
  };

})(eqD.groupedBGM);
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top