Check an enemy's weakness

Hi, is there a way to check (via events) if an enemy is weak to a certain element?
Maybe through a conditional branch, it would be perfect.
Do you mean check a specific enemy or just whether at least one enemy in the battle is weak against the element in question?
Yanfly have a libra skill (you can adjust it in the way you want too) found here.
remember, you need the required plugins to make this work.
I'm creating an ability that varies based on the elemental weakness of the enemies. Any suggestions on how to program it?
What exactly do you want it to do?
The skill is physical but can acquire an element between fire, ice or lightning if the enemy has one of these 3 weaknesses.
My problem is that I don't know how to check which element the enemy is weak at.
Are you using Yanfly's Element Core plugin? This'll be really easy if you are.
Yes, I have the plugin but I can't find anything that allows me to check to which element an enemy is weak.
You use the enemy's elementRate function for that. I just about have something working but I have to go out, I'll sort it when I'm home.
Ok thanks, meanwhile I try to see if I can do something myself.
If I can, I'll post the solution!
Code:
<Before Eval>
let target = $gameTroop.members()[this._targetIndex];
$gameTemp._forcedElements = [];
if (target.elementRate(2) > 1) {
  $gameTemp._forcedElements.push(2);
}
if (target.elementRate(3) > 1) {
  $gameTemp._forcedElements.push(3);
}
if (target.elementRate(4) > 1) {
  $gameTemp._forcedElements.push(4);
}
</Before Eval>
<After Eval>
delete $gameTemp._forcedElements;
</After Eval>
OK thanks! It's exactly what I needed! The topic can be closed.
Moderator note: Closing Topic at OP's request, and also Moving it to the correct board (Plugin Support).@Super015 In the future, you can Report your own post and say it's been solved - that will ensure a mod sees it and close the topic or help you with whatever else you need.

Original thread: https://forums.rpgmakerweb.com/threads/check-an-enemys-weakness.124581/