Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
120
Reaction score
31
First Language
English
Primarily Uses
RMMV
Hi all, I have a skill idea that would make a second enemy attack only if that second enemy is a specific enemy id. Basically what I would need to know is how to write an if statement that would go something like:

If (enemy troop member "x" is equal to enemy_id "x")
{
do stuff
};

For the most part i know how to get this to work but the only thing i need is the Enemy troop member and enemy_id scripts. If anyone can help it would be greatly appreciated.

Additionally, If anyone know how to check the casters enemy_id, that would also be helpful.
Example based on above:

If (enemy troop member "x"'s enemy_id is equal to casters enemy_id )
{
do stuff
};

I was thinking that if I could do it that way, the same skill could be used by other enemies without having to make a second skill.
 
Last edited:

eomereolsson

Veteran
Veteran
Joined
Sep 29, 2021
Messages
447
Reaction score
367
First Language
German
Primarily Uses
RMMV
To get a specific enemy troop member you can simply access the array $gameTroop.members().
Note that arrays begin their numbering at 0 and that there is no guarantee that a given array element even exists when you just directly access it via its index. To access the second troop member's enemy id and compare it to x and ensure that it exists you will need to do the following:
$gameTroop.members()[1] && $gameTroop.members()[1].enemyId() == x

The second question could be a bit more involved, depending on where exactly you put that code. Yanfly notetags often are able to access caster and target as a and b like in the damage formula. However if this code goes into a common event that will be executed by the skill you will need to save the caster id first (for example in the damage formula or a yanfly notetag) to a variable and then access this variable in the common event.
 

Random Panda

Veteran
Veteran
Joined
May 3, 2016
Messages
120
Reaction score
31
First Language
English
Primarily Uses
RMMV
Thank you so much. That gave me what I needed to get the skill completed.
 

Latest Threads

Latest Profile Posts

M42S7Us.gif

It's the little things. Lengthened the time the bar fades in and out to be a bit more comfortable.
3 days until release!
Well, with one problem (the hurricane) over with, we now have another problem. My dad and stepmom both tested positive for COVID-19 and I'm unable to visit them anytime soon. Meanwhile, I've just posted a new video on my YouTube.
I am back...from the land of the dead!

Forum statistics

Threads
125,730
Messages
1,173,084
Members
164,872
Latest member
chorustrilogy
Top