Enemy discovery and scaling

Hi!

I'm stuck trying to make a plugin. I'm new to MV but not to coding.

I want to:
- When a new enemy is fought, store the party level along with the enemy ID.
- Every time the party fights this enemy, use the stored value to scale the monster stats.
Just to clarify: it tracks when we encounter Enemies, not Tropes.
Also, scaling is flat: when discovered, the enemy stats are scaled and stay like that for the rest of the game.

I think I can work the logic of this mechanic
- Create a 2d array like enemies[id][lvl], initialized to 0.
- When combat starts, hit the array value for this enemy, and use it to multiply its stats.
- If the value is zero, set it to partyLevel first.

The problem is that I don't know the engine yet - can I get some help me implement this?
Or at least point me in the right direction 🙂

Thank you!

Bonus question: do I have to save this array data manually, or does the engine take care of that?
Moved to: Learning Javascript
Just to understand what you're saying

You want new enemies to always be at an appropriate level for the party the first time you fight them, then remain static for the rest of the game (so if you fight your first slime at level 5, it'll be a level 5 slime forever, but if you avoid all encounters in the starting area, and come back and fight it at level 50, it'll be a level 50 slime forever)?



Well, in general, you can get most of the heavy lifting done by just using a yanfly plugin

http://www.yanfly.moe/wiki/Enemy_Levels_(YEP) will handles the level scaling. It also has built-in gain level functions / plugin commands, and an easy way to check the party level.

First, set up an event at the beginning of every battle, running on turns 0 * 0 (so before anyone acts).

Cycle through $gameTroop.members().[whatever] to list all the ones that are there. For each member, read from an array which you crammed into one of the default game variable slots.
MyMonster=$gameVariables.value(WhateverYourMonsterVariableIs)[thisMonster]

(note: This is considered slightly poor form because it'll cause weird stuff if you accidentally do anything with that variable in the editor, but if you're careful it's fine). If needed, change the value to the current party strength using

$gameVariables.value(WhateverYourMonsterVariableIs)[thisMonster]=$gameParty.averageLevelBattleMembers();

Then, run the yanfly plugin command to amp up the monster by using
enemy.gainLevel(MyMonster=$gameVariables.value(WhateverYourMonsterVariableIs)[thisMonster])


Should be enough to give you something to work from.

Here's a good index of useful scriptcalls as well:
@Restart: Thank you, that put me in the right track.
@Kes: Actually I intended this to be a plugin request -- I can muster up some code but I wanted to see it properly implemented by someone who knows what they are doing. But since we're in this board...

I managed to implement the mechanic, but I'm sure it can be improved. My enemy-discovery code and parameter-scaling calculations happen inside Game_Enemy.prototype.paramBase where I return the scaled value instead of the default parameter. While it works, the code it's run once per parameter per action per enemy -- that makes lots of times for each round of combat!
Is there a better place to do this, for example somewhere that runs once and only once per battle?

Original thread: https://forums.rpgmakerweb.com/threads/enemy-discovery-and-scaling.111536/