Get enemy id (Resolved)

Hello,
I have a new question regarding a formula in javascript.
I need to retrieve the id of the 8 enemies during my fights.
I will explain the context to you.

In my game, my characters can learn group abilities. One of them is being able to see the HP of non-boss enemies.
For this, I use the Yanfly VisualHpGauge plugin.
My problem is that this plugin offers to display enemies' HP "all the time" or "after defeating them at least once". It is not possible to do this according to a switch.
I managed to modify the plugin so that the display is "never" and therefore I have to use a formula to display the HP gauge.
The formula is:

Code:
$gameSystem.addHpGaugeEnemy(id);

My problem is that I have to replace "id" with the id of ALL enemies in my game.
I can do something that looks like this:

Code:
$gameSystem.addHpGaugeEnemy(1);
$gameSystem.addHpGaugeEnemy(2);
$gameSystem.addHpGaugeEnemy(3);
...........
$gameSystem.addHpGaugeEnemy(500);

Or I can try to find a solution for the formula to repeat for 1 to 500 (for example, and I will place my bosses after 500 to hide their HP).
Or, so that the calculation is done on the 8 enemies at the start of each fight.
Is it possible to do this?
I think the first step would be to clarify if you're talking about enemy ID or enemy index.

in a troop, the troop members are identified by the index. the index can be 1 to 8, never higher unless you really rewrite the battlecode.

each troop index contains an ID to determine which enemy of the database will be used as a template to get that troop members data.

the enemy ID of different troop members can be identical if the same enemy is used multiple time - that is another reason why the battlecode focuses on troop index and uses the enemy id only for templates.

and it also means that no matter how many different enemies are in your game, each battle has a maximum of eight of those ids, often less.

so you will never need to go through all the hundreds of enemy IDs in any given battle.
Unfortunately the formula I showed you is based on the identifier. I will have to apply it for all my database and read it when acquiring the skill that allows you to gauge HP.
I mentioned enemies 1 to 8 in combat because I assumed that there was a way to recover their index at the start of combat, but it may not be the right solution.
I think I will have to repeat the formula 500 times. Isn't there a function to repeat it automatically by adding +1?
Or to replace the id of my formula by a variable? I can create a loop and add the +1 to the variable. Unfortunately, I do not master javascript, even if I am starting to familiarize myself with certain terms.
to get the numbers, why not doing:

maxNum = 8;
for (i = 0; i < maxNum; i++) {
$gameSystem.addHpGaugeEnemy(maxNum);
};

or around this part?

I dont say this code works, but a sample how to loop through it.
Thank you, I appreciate your help but it doesn't seem to work
that because you probably need more code around or inside
it to make it work 🙂

I know YEP_VisualHpGauges only by name, so I dont know
how it functions or how you want to use it effectively.

there is the "how", "when", and "where" you want to use it.
because that make teh difference how to code correctly.
It works. There was just two small errors in your formula. Here's what works:

maxNum = 500;
for (i = 0; i < maxNum; i++) {
$gameSystem.addHpGaugeEnemy(i);
} ;

Thank you very much for your help ^^
I probably knew I forgot something as I learn JS still,
but was an example more than plain copy paste =)

but I'm gladd you go it to work =)

good luck with your project further.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/get-enemy-id-resolved.149066/