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

Status
Not open for further replies.

DRG

Orange juice lover, Sunny D Hater.
Veteran
Joined
Apr 23, 2018
Messages
97
Reaction score
42
First Language
english
Primarily Uses
RMMV
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.)
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.
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
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.
 

DRG

Orange juice lover, Sunny D Hater.
Veteran
Joined
Apr 23, 2018
Messages
97
Reaction score
42
First Language
english
Primarily Uses
RMMV
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.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
What's the ID of your melee element?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
Okay, instead of this.isPhysical(), put

this.getItemElements().contains(1)
 

DRG

Orange juice lover, Sunny D Hater.
Veteran
Joined
Apr 23, 2018
Messages
97
Reaction score
42
First Language
english
Primarily Uses
RMMV
Okay, instead of this.isPhysical(), put

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

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,399
Reaction score
5,042
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Part of me is really missin' the good 'ol days of RM '95... goodness just seems like such simpler times
Just got two Switch E-Shop 20$ gift cards... Is 3D All-Stars worth it? Or should I get something like Celeste? I'd love to know your opinion!
I’m looking at the MZ full body images and I think Priscilla is taller than Reid...
Ami
--- Music Selection ---

M.Archer: It's Music Station,You can Change the Music as you like.
F.Healer: i want to hear the Romantic Music.
M.Fighter: Then,i want the Hard-Rock one!
(the Troll Song has played)
M.Archer: Hey,i hear this Music.
F.Healer: It's popular from Internet Music,i wonder who change it?
Hero: I change it.
Entire Party: YOU????

Forum statistics

Threads
103,045
Messages
996,926
Members
134,517
Latest member
galm
Top