[Solved] Help with bear trap state (YEP Buffs & States Core)

So in my game, there is a skill that applies a state to the target called "bear trap" when the trapped enemy/party member is attacked with a physical skill, the attacker is given a special state, and they also take damage. However, in my game, there are 2 elements that are considered physical attacks "melee" and "ranged".

I only want the trap status effect to react to melee attacks, However, due to my zero knowledge of javascript, I don't know how to do that. If anyone could help me modify this code to make it work how I want, that would be amazing!
(The code is taken from two different Yanfly Tips & Tricks videos. One is thorn mail, and the other I forgot.)
Spoiler: Custom React Effect code
JavaScript:
if (value > 0 && this.isPhysical()) {
  var rate = 0.25;
  var recoil = value * rate;
  var rate = 0.25;
  var bonus = target.def * rate;
  var dmg = Math.ceil(bonus + recoil);
  user.gainHp(-1 * dmg);
  if (user.isDead()) {
    user.performCollapse();
  }
}
if (value > 0 && this.isPhysical()) {
  if (this.isHpEffect() && value > 0) {
    user.addState(36);
    target.removeState(35);
    if (user.isDead()) {
      user.performCollapse();
    }
  }
}
I did try to change "this.isPhysical" to "this.isMelee" which didn't work unsurprisingly.

P.S. I'm typing this at 12am and I'm gonna go to bed immediately after posting this thread so sorry if it takes a while to respond.
Are you using Element Core? You don't need it for this, but if you have it installed the method for doing this will change slightly.
Are you using Element Core? You don't need it for this, but if you have it installed the method for doing this will change slightly.
I do have YEP element core.
What's the ID of your melee element?
What's the ID of your melee element?
Melee is 01
Okay, instead of this.isPhysical(), put

this.getItemElements().contains(1)
Okay, instead of this.isPhysical(), put

this.getItemElements().contains(1)
Nice! It works! Thanks for all the help!

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/solved-help-with-bear-trap-state-yep-buffs-states-core.124858/