Script references for last element id used on enemy

As I said in title, I need references for scripting with last element id used on enemy, in addition I must insert into a variable the last element id used on a specified enemy and compare with latest(more recent) element id used.

example:
enemy hit by ice by a member, then another member hit same enemy by fire, how to call references for that?Which is the best way to use in enemy or skills category?
would be useful a common event in battle(through yanfly script)?
Hello, you can't reference that cause once an action is done, it's done; the engine don't keep track of the last element used.
I think the easier way to do this would be to use states. When an enemy is hit by a fire skill, it receive a "fire state" lasting a couples of turns. When hit by ice while the "fire state" is still active, it alter the effect of ice (amplifying damage I guess...), than remove "fire state" and add "ice state", and so on.
You can set a state for each elements or have a single state that react differently dependending of the element, using scripting notetags of YEP_BuffsStatesCore.
You can grab the last action through a common event run as an Effect for the skill.

Code:
BattleManager._action.item().damage.elementId

But yeah, better off using a state.
As I wrote in private Ossra, there's the problem of natural defence.

If a monster have 300% def to fire and the state vulnerability set 200% bonus, this does not count as a vulnerability.

even setting a vulnerability higher would be unbalanced cause some monsters will get huge damage and others instead the normal bonus(example 1000% on a 100% resistance monster is 900% and 1000% on a 500% resistance only 500%).
In addition, not every monster must get the combo skill damage, only some:

for the rocky monsters:

ice fire combo

for normal monsters not.
So I cannot set this state on skill effect cause will be applied to all targeted monsters.
So I cannot set this state on skill effect cause will be applied to all targeted monsters.
You can have the state to be conditionally applied depending on enemy id?
Code:
<Before Eval>
  if (target._enemyId === X) {
    target.addState(Y)
  }
</Before Eval>
yeah through yanfly battle scripts, I will use that, in case I will pm you and Ossra in future for a better solution, thanks

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/script-references-for-last-element-id-used-on-enemy.117618/