[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
98
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
98
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
98
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,418
Reaction score
5,057
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 Posts

Latest Profile Posts

I started to paint again after it didn't fit my female character. (I really intend to draw women)

I was more focused on female characters than men.

Score Rundown for the demo I'm trying to get done before Halloween, Or around it. Ending is based on your score currently.
Oh goooood, why am putting so many skills into my game AAAAAAAAAAAA!
Stream will be live shortly with some pixel art! Feel free to drop by!

Forum statistics

Threads
103,157
Messages
997,706
Members
134,633
Latest member
NeoLightningProductions
Top