How to check if the enemy has a buff?

someone know what code to check if enemy has a buff in javascript?
All battlers have a isBuffAffected(paramId) method.

If you're not checking for a specific buff and you want to see if they have any buff, you could do:
Code:
target._buffs.some(element => element>0);
replacing target with whatever your reference is to the enemy, of course.
All battlers have a isBuffAffected(paramId) method.

If you're not checking for a specific buff and you want to see if they have any buff, you could do:
Code:
target._buffs.some(element => element>0);
replacing target with whatever your reference is to the enemy, of course.
thank you so much
One more question, how to use it on script command? I want to use it via conditional branch script command. Already tested it and not work
One more question, how to use it on script command? I want to use it via conditional branch script command. Already tested it and not work
You need to provide more information to get help on this. Where's a screenshot/copy of the exact code that you tried? Where is this conditional branch?

If you're doing this in, say, a common event called by a skill, the event has no idea what enemy you used the skill on. So where I said:
replacing target with whatever your reference is to the enemy, of course.
you have no reference to the enemy.

You would first have to set a variable to the index of the last target enemy:
Control Variable -> Game Data -> Last Target Enemy Index

(we'll say you put that in game variable 17)

Then you could do in your Conditional Branch -> Script:
Code:
$gameTroop.members()[$gameVariables.value(17)]._buffs.some(element => element>0);

which returns true if the enemy you just targeted had any buffs on it.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-if-the-enemy-has-a-buff.152516/