Can someone check a line of javascript for me? I feel like it should work.

dicepool14

Villager
Member
Joined
Sep 27, 2017
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMMV
So, brief summary. I have a character with some aggressive abilities that, in addition to other effects, buff their own attack and debuff their own defense, making them more dangerous and more fragile as the battle goes on.

I was hoping to give them an ability with low base damage that, if it kills an enemy, heals them a small amount and removes all of their currently ongoing defense debuffs.

I have Yanfly's Skill Core plugin in order to insert javascript into skills. My notebox currently reads:

<Post-Damage Eval>
if (target.hp <= 0) {
user.gainHp(50);
user.removeDebuff(3);
}
</Post-Damage Eval>

So, in theory, this should deal the skill's damage, then evaluate if the target's HP is 0 or less. If it is, the user of the skill gains 50hp and removes their defense debuffs. When I use the skill and it doesn't kill an enemy, everything is fine. When I use the skill and it kills an enemy, the game gets an error and the javascript effects do not trigger. If I remove the "user.removeDebuff(3)" part, it works fine. If it switch it to "user.removeBuff(3)", that works fine.

So, I assume I'm somehow writing "user.removeDebuff(3)" incorrectly? It's driving me a little insane.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Forgive my ignorance as I haven't used this particular plugin, but I'll give it a try anyways. I looked through the YEP Skill Core, YEP Buffs & States plugin, and the core RMMV code, and I didn't see a "removeDebuff" or "removeBuff" function defined anywhere.

1.) Where did you learn that these functions are defined to use? If it's another plugin, please provide the link and I can read the code for you to try to find out what is happening.

2.) When the game errors, please press F8 and post a screenshot of the full error message.

Edit: As caethyril points out below, "removeBuff" is indeed defined in the core RMMV code.
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,117
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
In the base code: removeDebuff does not exist, but removeBuff does (it's defined in rpg_objects.js). Basically, removeBuff just sets the magnitude and duration of the specified parameter's buff to 0. A debuff is simply a negative buff magnitude; you can't be buffed and debuffed at the same time. (If you want that sort of effect, consider using states as "fake" debuffs instead.)

You could try something like this:
Code:
<Post-Damage Eval>
if (target.hp <= 0) {
  user.gainHp(50);
  if (user.isDebuffAffected(3)) {
    user.removeBuff(3);
  }
}
</Post-Damage Eval>
isDebuffAffected is a function defined in rpg_objects.js, and does what you'd expect. =)
 

dicepool14

Villager
Member
Joined
Sep 27, 2017
Messages
22
Reaction score
2
First Language
English
Primarily Uses
RMMV
Thank you both! I tried your solution, caethyril, and it worked perfectly. I just assumed that since 'Debuff' is used in other contexts, it would be used in all contexts, and obviously that was wrong. I appreciate the help and also pointing me at rpg_objects.js, which I'm sure will solve several future headaches preemptively. =)
 

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,470
Members
137,821
Latest member
Capterson
Top