Sixth's Map Object and Victor's Map Turn Battle compatibility.

I'm trying to make Sixth's Map Object script, found here...

https://forums.rpgmakerweb.com/index.php?threads/map-objects-v1-0-06-06-2018.96175/

... to be compatible with Victor's Map Turn Battles, found here...

https://forums.rpgmakerweb.com/index.php?threads/ve-map-turn-battle.2676/

As of right now, in my project, when you enter a Map battle, all the map objects just vanish. Running through the code, this is because Victor's Map Battles get their sprites from a new class called Spriteset_MapBattle, which inherits from Spriteset_Battle. Sixth's Map Objects, though, run from Spriteset_Map, which is unrelated from Spriteset_Battle, so it makes sense that they would just vanish when the battle starts. The way how the game's rendering you're not "On the Map" anymore, you're "On the Map Battle", which just looks the same as a map. Unless you try to add to the map, it seems.

I feel like this is an issue which is either ludicrously complicated to fix, or very simple. I feel like there should be a way to get Victor's new Spriteset_MapBattle access to Spriteset_Map stuff... But the coding on this is beyond me. Of course, maybe I'm just an optimist, and the way these 2 scripts are programmed are just impossible to ever work together! That would be disappointing, but not altogether shocking, seeing as they were made years apart by different scripters.

Super early in my project, luckily, so it wouldn't be the end of the world to pick one of these two scripts over the other. But I'm hoping there's a way to get both working together.
Can't promise that I will make them work together, but if you make a demo project with both scripts installed and setup, and with a ready to test event that takes me to a map battle (however that is made, never used that script before) I can take a look at it.
Busy with commissions though, so it may take a while.
Hey, thanks! Here is a Demo.

https://www.dropbox.com/s/13g02tqbvyo6qy5/Map Battles.zip?dl=0

Just talk to the guy, and you'll be taken to a Map Battle. The flowers are all Map Objects. The water shows how the map still animates even when in battle.

Victor's VX Ace scripts were pretty well known to have compatibility issues with other users. If you look at this, and your gut says that it's a doomed effort to try and make them work together, that's fine! I'm not married to using Map Battles, it wouldn't be the end of the world for these scripts to not ever work together.

I don't think I've changed anything else in the scripts beyond installing the needed scripts for this demo. If I did, it's only, like, a minor window change, or a change to background music. Victor's scripts need a bit of work to install, so I just copied this demo from my main project. That's why it's possible there is a minor change or two in the core scripts, if I changed something to them in my main project. Though I think it'd only be, like I said, a minor change to windows or music. Nothing effecting Spritesets, or anything like that.
Thanks for the demo!
It was easier than expected, so here is the addon/patch:
Spoiler
Code:
class Spriteset_MapBattle < Spriteset_Battle
 
  attr_accessor :mobjs
 
  def create_viewports
    @mobjs = {}
    super
  end
 
  alias add_mobj_stuffs1111 dispose_characters
  def dispose_characters
    dispose_mobjs
    add_mobj_stuffs1111
  end
 
  alias add_mobj_stuffs2222 create_characters
  def create_characters
    load_mobjs
    add_mobj_stuffs2222
  end
 
  def load_mobjs
    $game_map.map_objs.each do |mobj|
      add_mobj(mobj)
    end
  end
 
  def add_mobj(dt,save=false)
    same = @mobjs.keys.select {|mky| mky.include?(dt['name']) }
    if same.empty?
      id = 0
    else
      sel = same.max_by {|mky|
        if mky =~ /#{dt['name']}_(\d+)/
          val = $1.to_i
        end
      }
      if sel =~ /#{dt['name']}_(\d+)/
        max_id = $1.to_i + 1
      end
      id = max_id
      max_id.times do |i|
        cky = dt['name'] + "_#{i}"
        next if @mobjs[cky]
        id = i
        break
      end
    end
    ky = dt['name'] + "_#{id}"
    dt['key'] = ky
    @mobjs[ky] = MapO::MapObj.new(dt,@viewport1)
    if save
      $game_map.map_objs << dt
      save_mobj_data
    end
  end
 
  def save_mobj_data
    file = sprintf(MapO::Data[:folder]+MapO::Data[:mdata],$game_map.map_id)
    save_data($game_map.map_objs,file)
  end
 
  alias add_mobj_stuffs1357 update_characters
  def update_characters
    add_mobj_stuffs1357
    update_mobjs
  end
 
  def update_mobjs
    @mobjs.each do |ky,sp|
      sp.update
      sp.upd_pos
    end
  end
 
  def dispose_mobjs
    @mobjs.each do |ky,sp|
      sp.bitmap.dispose
      sp.dispose
    end
    @mobjs = {}
  end

end
Just put it below the Map Battle and Map Objects scripts. I didn't test this much, but it seems to work.
Seems to work! Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/sixths-map-object-and-victors-map-turn-battle-compatibility.102747/