Region IDs and the troops that can appear therein…

I’m trying to find a way to modify what troops can appear in a certain region given a certain switch being on or off. I’ve seen a few plugins that allow for just changing the region IDs outright, but they’re a bad option for this specific case — I’d need a persistent mass non-contiguous region ID change for that to be viable. Also, approaches involving changing the enemies using an “appear halfway” trick aren’t helpful because there aren’t any encounters for that region ID when the switch is off.

I realize I could just make a copy of the map, but this needs done on the overworld map, and that’s a lot of towns and dungeons with multiple exits that I would need to sort out which version of the map to transfer to. x.x
if your issue is simply not wanting any encounters on a specific regionId until a time comes when you do actually want encounters on that specific regionId... can't you just modify one of those scripts which change regionIds to search all tiles on the map for that regionId (loop through the map) and then if it finds one just turn it to negative. this way when you do want to use them again just flip it back positive?

loop through all tiles on the map to find regionId 20
change all regionId 20's to -20
no more encounters

loop through all tiles on the map to find regionId -20
change all regionId -20 to 20
encounters once again

while it may not be the most optimal way to handle it, depending on how often its used, when its used and the size of your map it might be viable.

just the first possible solution that came to mind which should be rather easy to try out.

granted this won't really work if its only in specific areas of your map that you want regionId 20 encounters disabled but in other parts keep it disabled.


Another possible solution could be to alias this function:

JavaScript:
Game_Player.prototype.canEncounter = function() {
    return (!$gameParty.hasEncounterNone() && $gameSystem.isEncounterEnabled() &&
            !this.isInAirship() && !this.isMoveRouteForcing() && !this.isDebugThrough());
};

and have it to check for your specific conditions such as switches and what tile the player is on and what map the player is on before allowing the regular code to run this could be easy or it could be a lot of conditions you have to check depending on how many regionIds and switches you are using.

without more information its hard to say exactly how you'd need to work inside this function
I would suggest to deactivate the Random Encounter in the Map Properties.
But you can still add all the Troops there which are not determined by the Region and the Switch.
Than create a Parallel Event:
Code:
◆Control Variables:#0005 Var5_Player_Steps = Steps
◆If:Var5_Player_Steps ≠ Var7_Player_Old_Steps
  ◆Control Variables:#0007 Var7_Player_Old_Steps = Var5_Player_Steps
  ◆Control Variables:#0008 Var8_StepCount += 1
  ◆Control Variables:#0006 Var6_StepsUntilFight = Random 25..35
  ◆If:Var8_StepCount ≥ Var6_StepsUntilFight
    ◆Control Variables:#0008 Var8_StepCount = 0
    ◆Common Event:EnemySelectionWorldmap
    ◆
  :End
  ◆
:End

And the common Event, with no trigger (never running), only getting called, could look like this:
In MZ Get Location Info can get the Region the Player is standing on directly, in MV you need to use Set Variables)
Code:
◆Get Location Info:Var9_Region Id, Region ID, Player
◆If:Var9_Region Id = 5
  ◆If:The_Special_Switch is OFF
    ◆Battle Processing:#0001
    :If Win
      ◆
    :If Escape
      ◆
    :End
    ◆Exit Event Processing
    ◆
  :End
  ◆If:The_Special_Switch is ON
    ◆Battle Processing:#0002
    :If Win
      ◆
    :If Escape
      ◆
    :End
    ◆Exit Event Processing
    ◆
  :End
  ◆
:End
◆Battle Processing:Same as Random Encounters
:If Win
  ◆
:If Escape
  ◆
:End
◆Exit Event Processing

If needed, I could try and explain the copy pasted Eventcode above.

Edit: It is not the best workaround, but maybe useable. But after finishing this, it occurs to me that there maybe is another Workaround.
I would use Shaz's Tile Change plugin to change the region ID on the tiles.

Then the map encounter settings will function without any extra work.
I'll leave this here as another option:
Caethyril to the rescue! I could have sworn I’d thoroughly gone through Galv’s plugins, but I missed this one entirely. I haven’t actually tested it as yet, but that looks to be the most promising solution of the lot. Thanks muchly. ^.^

Original thread: https://forums.rpgmakerweb.com/threads/region-ids-and-the-troops-that-can-appear-therein.153817/