Help Needed Setting Region ID Specific Battle Backgrounds

Hello Everyone Im fresh back into RPG Maker ( last used in 2007 RPG XP trial version ) now using MV I Have a Multitude of Questions most that have been answered in others threads and some like this one with detailed but somewhat confusing fixes.
I Apologise in advances if this has been re asked but after sifting through 40 pages of forums my eyes are at their limits.

My Question is as Below...
I've tried seting up a region ID batleback Common Event but i guess I'm missing something I'm using control variable X of Player,Y of Player,MapID and RegionID on a random 1~10 (as i have 10 regions on my world map) followed by location info Region ID=Region ID ({x},{y}) and the assorted if regionID = 1 set batle back to for e.i grassland,grassland yet its still loading the base background for all regions.
any clue's where I've gone wrong?

if someone could take time out of their day to type up the basics of this it would be much appreciated.

Edit: apon reading this i also think i should have placed a conditional branch rather than a controled variable
Please post a Screenshot of the event with the complete Windows, not only the content.

Your description misses half of the needed info to understand what might have gone wrong.
I think I've Figured where i went wrong but here's what ive got so far the first image is what seemed to work the 3rd is the common event ive got running on my "world map" the 2nd is how i had it previously.
I don't know why it was designed this way, but RPG Maker MV has hard-coded the Battle Background based on the autotile used on the World Map.

Spoiler: RPG Maker MV Code
Code:
Spriteset_Battle.prototype.terrainBattleback1Name = function(type) {
    switch (type) {
    case 24: case 25:
        return 'Wasteland';
    case 26: case 27:
        return 'DirtField';
    case 32: case 33:
        return 'Desert';
    case 34:
        return 'Lava1';
    case 35:
        return 'Lava2';
    case 40: case 41:
        return 'Snowfield';
    case 42:
        return 'Clouds';
    case 4: case 5:
        return 'PoisonSwamp';
    default:
        return null;
    }
};

Spriteset_Battle.prototype.terrainBattleback2Name = function(type) {
    switch (type) {
    case 20: case 21:
        return 'Forest';
    case 22: case 30: case 38:
        return 'Cliff';
    case 24: case 25: case 26: case 27:
        return 'Wasteland';
    case 32: case 33:
        return 'Desert';
    case 34: case 35:
        return 'Lava';
    case 40: case 41:
        return 'Snowfield';
    case 42:
        return 'Clouds';
    case 4: case 5:
        return 'PoisonSwamp';
    }
};

It's really strange because it's not visible to the developer how these Battlebacks are determined.
You may want to check out Yanfly Region Battlebacks , it was written for exactly this purpose.
Thanks for the Info I'll give it a squiz I've seen alot of yanfly mensioned in the posts I've viewed,It seems like it might be a way to go after im done with this second* first game build...originally 4 chars 8 towns 6 dungeons with a set of 40/40/40 items/armor/weapons(now 4 chars* with 2nd classes,300 mobs,30 bosses,21 towns 14 dungeons and 80/80 wep/armors 60 items) I think ill use some of his premade scripts to help tweek my idea past a base noob game.

pardon the flux of text in relation to my post and your comment i did find it weird that i had to disable the batle background selected on my world map before image 1 activated the options at first it was auto loading option 10 til i realised i didn't put in a random but a constant.
RPG Maker MV has hard-coded the Battle Background based on the autotile used on the World Map.

Nope.

That code only gets run if you don't have a battleback set some other way. It is the default 'fallback', and is based on the current map, not on the world map. If you set a battleback in the map properties, that will be used, unless you have used the Change Battle Back command, which overrides it.

@Krakaz you do not need a plugin. You can do this with events, but, sorry to say, your events are a bit of a mess. The use of variables and conditions is all wrong, as is your understanding of how common events, parallel processes and switches run.

Here's what's going to happen with your common event ...

The variable will be set to a completely random number, and then it will be set to the region id based on <some other variables that do not get set here and may not get set anywhere>.
Then it checks if the region is 1 and sets the battleback to grassland.
If the region is not 1, the battleback will be set to grassland, then grassland & forest, then meadow & forest, then desert, then swamp & wasteland, then snow, then lava, then sand, then space, then sky.

So my guess is that you will always get either grassland or sky as your battleback.

First line ... why are you setting the region id to a random variable? The region id is NOT a random number.
Second line ... you've got this right, but where are you setting the Region X and Region Y variables? You should set them right before the Get Location Info command, so you know that they are up to date.
If tests ... you've put each test within the previous one. If the region is 1, the first test will be true, but the next one will be false (the region can be 1 OR 2, not both). If the region is 2, the "if region = 1" test will be false so it won't even get to check. And so on through the rest of the tests.
The Else section. You are setting the region to be each number, which does nothing, and then changing the background accordingly. So if the region is not 1 and you drop through to the Else, it's going to run every single one of those commands.
Now, about how you're calling it ... you have the common event set to parallel process, and conditioned by a switch. So as soon as that switch is turned on, it's going to start running. Then you have a map event that's conditioned by the same switch, set to parallel process, that's calling the common event again. So you're going to have the common event running twice, at the same time, which is crazy.

Here's what you need to do ...

Common event:
Code:
Control Variables {Region X} = Game Data > Player's X
Control Variables {Region Y} = Game Data > Player's Y
Get Location Info {Region ID} = Region ID {Region X} {Region Y}
If {Region ID} = 1
  Change Battleback Grassland, Grassland
Else
  If {Region ID} = 2
    Change Battleback Grassland & Forest
  Else
    If {Region ID} = 3
      Change Battleback Meadow & Forest
    Else
      If {Region ID} = 4
        Change Battleback Dirt2 & Forest
      Else
        ... and so on
      End
    End
  End
End

WAIT 10 FRAMES!!!

So you are setting up the X and Y position you want to look at, then getting the region id from that location.
Then you are testing the region id's value - if you find a match, you are changing the battleback; if you don't find a match you are moving on to the next test
Finally you are going to add a WAIT in there. The player is not going to move 60 tiles in a second, so you do not need this whole thing running 60 times a second. And with two of them going, like you had, it won't be long before you have major lag on your map!

I notice you have a Player X and Player Y common event, which I assume is going to put the player's X and Y position into variables - probably 60 times a second. I'd just get rid of those common events and the one for map id as well, and only execute those commands when you need to.

And ditch the map event that calls the common event. If you have a common event that's set to autorun or parallel, then it will run when the switch is on. You don't call it via a map event.

Hope this gives you better success.
@Shaz thanks mate that clears it up for me.after reading and trialing alot of diferent things i think its time for me to do a bit of spring cleaning on the mess that is my game back to the original small trial i was banging up.
Thanks to everyones help on that note.
That code only gets run if you don't have a battleback set some other way. It is the default 'fallback', and is based on the current map, not on the world map. If you set a battleback in the map properties, that will be used, unless you have used the Change Battle Back command, which overrides it.

My apologies, you are totally correct [as usual 🙂]. After reading it more, I realize that on Tilesets classified as "World Type" it uses the autotile type as the 'fallback' (if the battleback isn't defined otherwise from Map Settings or Event Command) and on Tilesets classified as "Area Type" it takes a snapshot of the map as the 'fallback'.

@Krakaz I do still think that plugin is worth looking at *later* because it checks for the region only when the battle starts instead of every X frames (multiple times per second), which could save on performance/lag. However, for now it can be a great opportunity to read Shaz's advice closely to help improve your eventing/variables skills.
@Aloe Guvner and @Shaz thank you both for your input.I'll go with Shaz's process for now until im more accustomed to MV and how all the basic of basics work maybe sometime next year ill try building a advance beginner version "sequel" to what im making now using scripts or with a beter understanding of how controled variables,switches and events pan out. I was going to upload the image but it's not loading for me at this point i have deleted the (f6) event turned off the parallel and switch i believe it will work.

thanks again for taking the time to answer this guys.
sweet i thought i did it wrong again but working fine *thumbs* thanks guys
Tilesets classified as "Area Type" it takes a snapshot of the map as the 'fallback'.

Really? That's very interesting ... might have to play with that a bit.
this is what i've done hopefully i did it correctly but seems to work. as a note i have no battle background set on the maps im using at this point.
it will work, but the event would be better readable and a tiny bit easier if you disabled the else branches and have all conditional branches on the main level.
that can be done in this case because all branches check for equal.
I wondered the same thing when I wrote it. But that way, it's doing every test, even if the first one is true, while with the nested branches it only tests until it finds a match.
so far its worked without issue,that being said my build isn't overly eventful so there's alot of room for processing the few things I've evented. 56hrs later im at the last part of the first tutorial ( even tho its for VXace ) it's been insightful in how to do basic eventing.
downloading the RTP at the moment to grasp where I've gone wrong with the complex event.
as always thanks for the help much appreciated.
Ace and MV are very similar as far as tiles and events go, so the VX Ace tutorial should work just as well for MV in most areas.

Original thread: https://forums.rpgmakerweb.com/threads/help-needed-setting-region-id-specific-battle-backgrounds.90108/