Creating a Map-Based Battle Effect that can be shut off using a switch

Okay so let me explain. In the game I'm making, I have enemies who are basically robot goblins and they are on-map patrolling encounters. Some of them would be positioned near a Clockwork Factory. If you fight the goblins while near them, they are given a Passive regeneration effect which I assigned to the region around these factories using Map Linked Battle Effects by Yanfly. But now I want it so you can interact with the Clockwork Factory first (a scene plays of your character breaking the device), which completely disables this passive for goblins who are inside that region.

It's quite a complicated idea, I know, and I've been thinking of ways to make it work. My main question would be how can I make it so that you can you can stop the Battle Effect from occuring if I trigger a switch from interacting with the factory? Though I must also ask if there's a more streamlined method to execute my idea of an out-of-combat device granting in-combat buffs to enemies if you fought them within its area/region.
Sounds to me like you just turn on a switch if the player interacts with the factory and make the effect check whether or not said switch is on?

Not sure how that could possibly be any more streamlined.
Sounds to me like you just turn on a switch if the player interacts with the factory and make the effect check whether or not said switch is on?

Not sure how that could possibly be any more streamlined.
The problem is that I need to turn off a Passive State that is applied every time a battle occurs on that region. Said passive state was implemented using Yanfly's Map Linked Battle Effects Tips and Tricks which checks if your combat encounter happens in the designated region and map. I don't know how exactly I could make the State's note tag to check if my Switch is on or off.
Should be

Code:
if ($gameSwitches.value(x)) {
  Stuff
}
or simply don't give that passive state the effect, but have a troop event check and implement everything.

you make one troop event that checks for both the switch for the factory and the region effect (there are multiple ways to go about this) and apply the regenerative state if all conditions are met.
have that troop event run on turn 0, and use yanfly base troop plugin to have it run for every troop.
or simply don't give that passive state the effect, but have a troop event check and implement everything.

you make one troop event that checks for both the switch for the factory and the region effect (there are multiple ways to go about this) and apply the regenerative state if all conditions are met.
have that troop event run on turn 0, and use yanfly base troop plugin to have it run for every troop.
Another thing I forgot to mention is that there are more than 1 factory in the map, so I want to make sure that shutting down one factory only affects the passive state given to the goblins in that region area.

Also how do I make it check for the Region Effect? I got the part for the Factory Switch tho, but considering I use overworld encounters and that the same troops are affected by this regeneration effect I want to also make sure it doesn't turn off for the others in the different region.
If you have different regions for each factory, you could tweak the Yanfly code to only add the particular region to the region ID list if the switch is off. So, instead of the bit which goes

Code:
 // Insert the region ID's you want this state to be active on.
  regionIds.push(10, 11, 12, 13);
  regionIds.push(14, 15, 16, 17);

you'd do

Code:
 // Insert the region ID's you want this state to be active on.
  if (!$gameSwitches.value(1)) {
    regionIds.push(10, 11, 12, 13);
  };
  regionIds.push(14, 15, 16, 17);

(If switch 1 being on turns off the passive for enemies standing in regions 10, 11, 12 and 13). And so on.
Code:
 // Insert the region ID's you want this state to be active on.
  if (!$gameSwitches.value(1)) {
    regionIds.push(10, 11, 12, 13);
  };
  regionIds.push(14, 15, 16, 17);

(If switch 1 being on turns off the passive for enemies standing in regions 10, 11, 12 and 13). And so on.
Do I repeat this in the notes for every switch per region? Because right now the notes look like this:
<Custom Passive Condition>

var condition = true;

if (BattleManager.isBattleTest()) {

condition = false;

} else if ($gameMap && $gameParty.inBattle()) {

var activeMaps = [];

activeMaps.push(34, 35);

activeMaps.push(34, 35);

var terrainTags = [];

terrainTags.push(0, 1, 2, 3);

var regionIds = [];

if (!$gameSwitches.value(141)) {

regionIds.push(7, 8);

};

regionIds.push(9, 10);

if (activeMaps.length > 0) {

if (!activeMaps.contains($gameMap.mapId())) {

condition = false;

}

}

if (terrainTags.length > 0) {

if (!terrainTags.contains($gamePlayer.terrainTag())) {

condition = false;

}

}

if (regionIds.length > 0) {

if (!regionIds.contains($gamePlayer.regionId())) {

condition = false;

}

}

} else {

condition = false;

}

</Custom Passive Condition>
141 was the switch for the first factory, and I reserved Switches 142, 143, and 144 for other factories.
Also how do I make it check for the Region Effect?
basically checking the player position with the get location info event command
basically checking the player position with the get location info event command
I'm a bit confused on how to execute it. I tested it with a goblin outside the zone but the passive still exists.
Below is the battle event and its content being set to Turn 0
1765272377259.png

And below is the map where I'm testing this on. Region 7 is the area of the first factory. I also had a goblin outside the area to test if the passive isn't present when fighting them outside the zone.
1765272647493.png

Please help me understand what to do here
instead of using fixed coordinates that only work for position 29,34 you need to get the player location with two variables for player_X and player_Y, then use those variables for the targeting of get location
instead of using fixed coordinates that only work for position 29,34 you need to get the player location with two variables for player_X and player_Y, then use those variables for the targeting of get location
Sorry I still don't get it. Can you please show me an example on how to do it?

EDIT: So after doing a bit of research, I figured out what to do about getting the location for the Region ID. But the state won't show up on the encounters who are within Region 7. What else am I doing wrong here?
1765366760825.png

EDIT #2: Okay I figured it out! All I need to do is put the Region ID calling on the overworld goblin events and it worked. Buff was properly given to the goblins in the Region, and those outside the region don't get it anymore. And the regen effect also doesn't take effect when the switch on the factory is turned off.

Original thread: https://forums.rpgmakerweb.com/threads/creating-a-map-based-battle-effect-that-can-be-shut-off-using-a-switch.181346/