Status
Not open for further replies.

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
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?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,686
Reaction score
9,863
First Language
German
Primarily Uses
RMMV
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.
 

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
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.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,992
Reaction score
2,345
First Language
Dutch
Primarily Uses
RMMV
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.
 

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
Thank you, I appreciate your help but it doesn't seem to work
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,992
Reaction score
2,345
First Language
Dutch
Primarily Uses
RMMV
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.
 

Jay19

Veteran
Veteran
Joined
Dec 27, 2018
Messages
72
Reaction score
26
First Language
Français
Primarily Uses
N/A
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 ^^
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,992
Reaction score
2,345
First Language
Dutch
Primarily Uses
RMMV
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.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,841
Reaction score
6,255
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Anyone know of any good guides for editing the UI in RMMV?
eris2.png
just 1 more then I'm done with these sheets *tears of joy*
Im free today . finally have some time to continue coding . yes!
Regret that I wasn't able to actually finish my igmc entry in time for the actual igmc. Will probably just offload it as a standalone thing.

Forum statistics

Threads
124,426
Messages
1,163,501
Members
163,230
Latest member
Reqz
Top