Enemy Levels on the World Map

I'm currently trying to organize enemy levels by region on the world map. Ideally, I'd like this game to be sort of like Pokemon, in that you could theoretically see any monster at any point in the game because each has a level, and so you could see a level 1 rat at the beginning, or a level 80 rat near the end (though by that point, there will be more interesting enemies).

The problem is that I'm working with the Visustella RPG maker plugins, and I'm also working with a pretty limited knowledge of coding. It seems that I can either set enemy levels for a map (not a problem in dungeons), or for each enemy (which overrides any general map settings), based on notetags on the map or enemy. The problem is the world map. I'd love to determine enemy level by map region, but I think that will require some javascript in the map notetag, which is beyond me now.

So some options:

1. Go full Pokemon and make route maps between cities and dungeons. This effectively breaks the world map into smaller chunks, and each chunk can have its own assigned level range. It would just take a LOT of time.

2. Remove enemies from the world map entirely. More boring, and would create a need to adjust exp curves, since the player would encounter fewer monsters, but it avoids the issue completely.

3. Make multiple copies of the world map. Each would be identical, but would have different level settings. Events like travel to different regions or story progression could cause a switch to a higher or lower difficulty map. This seems like it would take a lot of extra steps to think about when eventing travel, etc.

4. Make the overall world map level vary with the party's level. This is the easiest option, but I find it less natural, since you could return to the very first region of the map near the endgame and find common goblins and things that are absolutely juiced.

Anyways, wondering if anyone has an approach that's worked for them, with or without plugins. I may have made myself a problem by introducing flexible enemy levels with an inflexible world map.
At the moment, I can't test the code, but in terms of logic, I've been considering checking which region the player is in and determining the enemy levels based on that. In the example below, if the player is in region 1, the enemy level will be 5; if they're in region 2, the level will be 10, and so on.

You could also link the regions directly to the levels, allowing for a clear correspondence between regions and levels during the editor phase (for example, region 1 = level 1).

<JS Enemy Level: $gamePlayer.regionId() === 1 ? 5 : $gamePlayer.regionId() === 2 ? 15 : $gamePlayer.regionId() === 3 ? 30 : 1>



Edit: Upon closer reading, I realized that by 'regions' you didn’t mean those in RPG Maker, but geographical regions. So, I’ll include the Visustella tags related to enemy levels on specific maps. The tag for inserting code still applies if you want to expand on this mechanic



1727770755754.png
If I had a way without Javascript to assign enemy levels using the Visustella plugin based on assigned map regions within a specific map, then that would be ideal. But yeah, that would require more programming than I can pull off. I guess to sum up the issue in another way, I don't have the programming skills to make one world map that has enemies at different levels in different parts of that same map without making duplicate versions of specific enemies or maps or something else. Just brainstorming ways around that limitation.
What's wrong with the code that @ISC provided?

Granted, he proceeded to second-guess and misread your request and crossed it out, but did you try it?

I don't see why it would circle back to you having to know JavaScript.
I appreciate his post, and they work for most situations. The problem is that those notetags set one static enemy level (or range of levels) for each map. This works well for dungeons or other locations, but not for a world map, since the party will have encounters on the world map many times throughout the game at different levels. If you set a static map level of 5-7 for a world map (which from what I understand is what these plugins do), then even in the endgame locations of the world map, the party will face only level 5-7 monsters, same as they would in the starter areas of the world map. It's one static range, whereas a world map specifically usually calls for more granular control, since it's such a large map containing many types of encounters based on region. Does that make sense?
I appreciate his post, and they work for most situations. The problem is that those notetags set one static enemy level (or range of levels) for each map.
No, they don't. The code ISC posted is giving a different level for the enemy based on the region ID you triggered the battle from.

<JS Enemy Level: $gamePlayer.regionId() === 1 ? 5 : $gamePlayer.regionId() === 2 ? 15 : $gamePlayer.regionId() === 3 ? 30 : 1>
Ok. Let’s try to minimize the use of scripts.
Let me see if I understood correctly. The world map is divided into regions, and each region has map encounters with enemies of different levels. So, in the south, you might encounter level 1 enemies, while in the north, you could encounter the same type of enemies, but at level 10. Is that right?

If I understood this correctly, I have two solutions in mind:

1) Two plugins working together + a level management variable.
Thanks to the Visustella Events and Movement Core plugin, we can set it up so that a region tile remotely triggers an event that sets a variable to the desired level.
We would use Visustella’s Enemy Level plugin to give each enemy the note tag:
`<Level Variable: x>`
How it works:
When the player moves into a specific region, it activates an event that sets the level management variable to the desired level. Thanks to the tag on enemies, they’ll have levels based on the region the player is currently standing in.
Pros: You wouldn’t need any scripts for this mechanic. The event activated by regions would simply be a common event that sets the variable to "X".
Cons: Without scripts, you’ll need to create an event to link to every region tile.
Also, the Events and Movement plugin tends to work heavily in parallel (so to speak) and might slow down your game. I would only recommend using it if you need it for more than just this one purpose.

2) A small control script.
An alternative to the Event and Movement Core plugin would be to create a parallel event that checks the region tile the player is on and adjusts a variable based on that, which would be used to determine the enemy’s level, as described earlier.
Pros: We avoid using a second plugin, keeping the game lighter.
We would have just one map event that sets the level variable as needed.
Cons: We’d still need to create several conditions that check which region tile the player is on and adjust the level variable accordingly.

Using these two concepts, we could even have enemy variety that changes from zone to zone by utilizing more than one variable. For example:
In the south, level 1 bats and level 2 goblins. In the north, level 3 bats and level 5 goblins.

Keep in mind that these are just theoretical concepts at the moment. To find the most suitable solution, I need to fully understand the details of the mechanic you’re aiming for. In cases like this, I need to brainstorm with the requester to fully grasp what they want and avoid issues like bugs, lag, slowdowns, and other unpleasant things. I apologize for this – it’s one of my limitations.
Do either of these solutions sound like what you’re looking for? If so, I can run some targeted tests and give you the correct procedure to follow
Thanks for the replies, and for the well-thought through solutions. To back up a step, ATT_Turan is correct. I'm sorry I didn't read more carefully through your first reply, ISC. I guess I get a little intimidated by Javascript, but I'm not opposed to learning a little. It seems like that might be the most efficient way to solve the issue, since it avoids having multiple parallel events. I took some time to learn about the code you first posted, and I think I figured it out.

From what I understand, in the script <JS Enemy Level: $gamePlayer.regionId() === 1 ? 5 : $gamePlayer.regionId() === 2 ? 15 : $gamePlayer.regionId() === 3 ? 30 : 1>, "$gamePlayer.regionID()" marks the regionID the player is on as a variable, and that in the statement "=== x ? y " , x defines the value of that regionID variable and y is the level you are setting the enemies to, which makes ":" a marker for a new statement, and the final "1" a default level to set if there are problems with the other statements. If so, then I have just two more questions.

Firstly, I have tried a couple of different ways to give enemy levels some variance. The easiest has been to use the enemy notetag <Level Variance: x>, but I also found that the function "Math. random() * (max - min) + min" can be incorporated as well, but I think it's easier to introduce typos by adding more functions, because I've had inconsistent results there in quick testing. Would one of these approaches be better inherently from a performance perspective, or does it just come down to a game design choice (granular control v map tags or universal control through enemy tags)? At this time, my test map is using the script:

<JS Enemy Level: $gamePlayer.regionId() === 1 ? 5 : $gamePlayer.regionId() === 2 ? 15 : $gamePlayer.regionId() === 3 ? 30 : $gamePlayer.regionId() === 4 ? 40 :1>

Individual enemies then use the notetag

<Level Variance: 2>


Secondly, and as a general question, how many additional regions could I define before starting to induce lag? I assume that 10-15 wouldn't be a concern, but as a purely educational question, is this even an issue?

Thanks again for putting some real thought into the posts above, and being patient with me. I appreciate it!
"$gamePlayer.regionID()" marks the regionID the player is on as a variable, and that in the statement "=== x ? y " , x defines the value of that regionID variable and y is the level you are setting the enemies to, which makes ":" a marker for a new statement, and the final "1" a default level to set if there are problems with the other statements. If so, then I have just two more questions.
almost. its called a ternary operation. the first part is a comparison of sorts. in this case, of
Code:
$gamePlayer.regionID() === x ? y : z
it checks if the value of $gamePlayer.regionID() is equal to x. if it is, the value the statement returns is y. if they are not equal, then it returns z, which youve already figured out can also be chained into another one to make a different case

I have tried a couple of different ways to give enemy levels some variance. The easiest has been to use the enemy notetag <Level Variance: x>, but I also found that the function "Math. random() * (max - min) + min" can be incorporated as well, but I think it's easier to introduce typos by adding more functions
if you dont mind learning a bit more on your own time, you can make your plugin that contains your own own functions to replace code you see yourself repeating a lot. in my project, i ended up adding a Math.variance function that i just feed a value and a decimal to create a random number within range. less likely to make a typo, and it saves me from having to write out "value + Math.random() * (value*variance*2) - value*variance" everywhere i use it

Would one of these approaches be better inherently from a performance perspective
just talking about performance, most likely not. youd be surprised just how many lines of code gets ran every second when your game is running. adding a couple extra basic operations where that static number would be wont be the straw that breaks the camel's back.

At this time, my test map is using the script:

<JS Enemy Level: $gamePlayer.regionId() === 1 ? 5 : $gamePlayer.regionId() === 2 ? 15 : $gamePlayer.regionId() === 3 ? 30 : $gamePlayer.regionId() === 4 ? 40 :1>
you could also use the value of the region id in a calculation to determine the level and simplify the whole process. like, if you tried <JS Enemy Level: $gamePlayer.regionID()*5> the level would be 5x the region id. or even simpler, <JS Enemy Level: $gamePlayer.regionID()> and you then just use the region ids as youre mapping to be the levels of the encounters.

also you could try setting up a variable at that point. no idea if it works, but theoretically
<JS Enemy Level: $gamePlayer.regionId() === 1 ? 5 : $gamePlayer.regionId() === 2 ? 15 : $gamePlayer.regionId() === 3 ? 30 : $gamePlayer.regionId() === 4 ? 40 :1>
is equivalent to
Code:
<JS Enemy Level: var r = $gamePlayer.regionId(); r === 1 ? 5 : r === 2 ? 15 : r === 3 ? 30 : r === 4 ? 40 :1>
but is easier to type

Secondly, and as a general question, how many additional regions could I define before starting to induce lag?
all i can tell you is that the number probably isnt low
It might get easier for you to organize this (and it would be less typing) if you outsource it to a plugin function.

Copy the below into a text editor, save as a *.js file, include as a plugin.
Code:
MarthEnemyLevel = function()
{
let lev = 1;
switch ($gamePlayer.regionId())
{
    case 1:
        lev = 5;
        break;
    case 2:
        lev = 15;
        break;
    case 3:
        lev = 30;
        break;
    case 4:
        lev = 40;
        break;
}
return lev;
};

Then your notetags just have
Code:
<JS Enemy Level: MarthEnemyLevel()>

The above should be pretty easy to extrapolate - the number after case is the region ID, and lev = beneath is the level the enemies will be there. Copy and paste additional entries as you like.

Heck, if you decide you want a different level progression on another map, make another copy of the function with a different name and different levels for each region ID.

Secondly, and as a general question, how many additional regions could I define before starting to induce lag?
As @Robro33 said, there's no reason this should even be a thought. Your CPU performs billions of operations per second.
Thanks, everyone. I'll play around with these. Great suggestions, and some good learning goals moving forwards.
I would like to add something. I think the system you're trying to create is very interesting, but I also believe it needs a clear design. By using the function proposed by ATT_Turan, you'd have a code summary of your mechanic. Following Robro33's suggestion of linking enemy levels to regions, you'd get a direct overview in the editor. By playing around with the code, you could also set limits based on the characters' average level. This is because I believe that if a level 1 player encounters level 100 enemies, their experience could be frustrating. There are really so many possibilities by using the plugin tags and JavaScript.

Original thread: https://forums.rpgmakerweb.com/threads/enemy-levels-on-the-world-map.172252/