MZ battle funds

Hello, good afternoon, morning, or evening. I have a question: how can I have different backgrounds for battles, or how can I change them without changing the background of all the troops? I'm using regional encounters, not events.
The simplest way is to make a parallel event that checks the player's region and changes the battle back. It could look something like this:

Spoiler
Code:
◆Control Variables:#0030 BattlebackX = Map X of Player
◆Control Variables:#0031 BattlebackY = Map Y of Player
◆Get Location Info:BattlebackRegion, Region ID, ({BattlebackX},{BattlebackY})
◆If:BattlebackRegion = 1
  ◆Change Battle Back:DirtField & Grassland
  ◆
:Else
  ◆If:BattlebackRegion = 2
    ◆Change Battle Back:Grassland & Clouds
    ◆
  :Else
    ◆If:BattlebackRegion = 3
      ◆Change Battle Back:PoisonSwamp & PoisonSwamp
      ◆
    :Else
      ◆Change Battle Back:Snowfield & Snowfield
      ◆
    :End
    ◆
  :End
  ◆
:End

Or, if you use my SwitchCommands plugin, you could do it like this:

Spoiler
Code:
◆Control Variables:#0030 BattlebackX = Map X of Player
◆Control Variables:#0031 BattlebackY = Map Y of Player
◆Get Location Info:BattlebackRegion, Region ID, ({BattlebackX},{BattlebackY})
◆Plugin Command:switch @29
◆Show Choices:1, 2, 3, 4, 5, 6 (Window, Right, #1, -)
:When 1
  ◆Change Battle Back:DirtField & Grassland
  ◆
:When 2 
  ◆Change Battle Back:Grassland & Clouds
  ◆
:When 3
  ◆Change Battle Back:PoisonSwamp & PoisonSwamp
  ◆
:When 4
  ◆Change Battle Back:Snowfield & Snowfield
  ◆
:When 5
  ◆Change Battle Back:Meadow & Forest
  ◆
:When 6
  ◆Change Battle Back:Wood2 & Ship
  ◆
:End
The above example was copied from MV, but it works more or less the same in MZ too.

This approach can vary the battleback on any number of conditions, not just region. However, if you want it to be based on the troop ID, a different approach would probably be needed.
It would be great if I could change the battle background to troop ID, since I sometimes have several troops under the same ID, and I also use many regions on different maps for battle encounters.
how can I change them without changing the background of all the troops?
First, changing the battleback in the editor has no effect on the game.
In the editor you can select any battleback to help with positioning the enemies in the troop by drag'n drop, but that has nothing to do with the battleback selection in game.

in the game/engine the battleback depends on the map settings, nothing else.
and the change battleback command only works for the map setting, which is not automatically updated inside combat - so it is easy to change it for evented encounters, but not for random encounters.

if you want it changed on troop ID, then it is possible to change it in a troop event on turn 0 IF you use a script command to force the engine to update the battleback after changing it.

unfortunately I can't tell you what the script command to force the update is, someone else would have to provide that for MZ
As Andar says, the easiest way to do it based on troop ID is to put the Change Battleback command directly in the troop on turn 0. Hime's Change Battleback plugin allows battlebacks to change in the middle of battle in MV, but I don't know if it works in MZ or if there's an equivalent plugin for MZ.

Whether that's the best way to do it, I'm not really sure.
I think you can also put conditionals here where it gets the names for battleback 1 and battleback 2.
If you want to read troop tags, there's no note field for troops though, so you'd have to check them for comments, like $dataTroops[id].pages[0].list check that for the comment codes and if there's some kind of tag.

EDIT: Oh yeah, you get the troop id with like $gameTroop._troopId

Sprite_Battleback.prototype.battleback1Name = function() {
if (BattleManager.isBattleTest()) {
return $dataSystem.battleback1Name;
} else if ($gameMap.battleback1Name() !== null) {
return $gameMap.battleback1Name();
} else if ($gameMap.isOverworld()) {
return this.overworldBattleback1Name();
} else {
return "";
}
};

Sprite_Battleback.prototype.battleback2Name = function() {
if (BattleManager.isBattleTest()) {
return $dataSystem.battleback2Name;
} else if ($gameMap.battleback2Name() !== null) {
return $gameMap.battleback2Name();
} else if ($gameMap.isOverworld()) {
return this.overworldBattleback2Name();
} else {
return "";
}
};
Thanks to everyone for your help, I've achieved what I set out to do, I appreciate your support.

Original thread: https://forums.rpgmakerweb.com/threads/battle-funds.181927/