How to make a proper purge + damage dealing skill

I'm attempting to create a skill in which the target receives damage and then has all of their buffs and debuffs removed, much like a purging ability in most RPGs.


This is the current formula I created: c = (b.mhp/3) - b.mdf * 1.44; removeAllBuffs(); c


When I test this ability the skill deals zero damage when instead it should deal 1/3 of the targets total health, it also doesnt interact with buffs/debuffs in any form


Simply using the line: (b.mhp/3) - b.mdf * 1.44 results in the damage being dealt and working fine, yet the removeAllBuffs() syntax does not work at all even when used alone.


What am I missing here? I would be surprised if the only way to do this is to add "effects" that removed every individual debuff and buff from the system.
Haven't tested it, but it looks like you are missing the object you want to remove the buffs from:


b.removeAllBuffs()


The rest looks fine to me.
Haven't tested it, but it looks like you are missing the object you want to remove the buffs from:


b.removeAllBuffs()


The rest looks fine to me.



You're right about forgetting the b. I added this in and the skill still deals no damage though. If I remove all of the code except the b.removeAllBuffs() it also just crashes.


Here is the skill screen for reference The full code is in the note section with only the b.removeAllBuffs() left in the formula box for now.

halp.jpg
That's strange,


c = (b.mhp/3) - b.mdf * 1.44; b.removeAllBuffs(); c


works fine for me; also no crash with just b.removeAllBuffs() in the formula.


Do you have any plugins that change the way damage formulas work? Can you show a screenshot of your console (F8) when the game crashes?
I've got it to where it does damage for me now as well. (I must have just misspelled something when I was messing around with the formula).


My plugin manager is blank as I wanted to see what I could do without plugins before I started adding anything.


Also when it deals the damage it doesn't remove the buff I'm testing (just a generic hp regen ability) and of course just the b.removeAllBuffs() still crashes it for me.

crash.jpg
Is your HP regen "buff" really a buff or a state? Those are handled differently, and removeAllBuffs() only removes buffs and debuffs, not states. If you want to remove all the states, add something like this to your formula:


for (i = 0; i < b.states().length; i++) {b.removeState(i)}


This goes through all of b's states and removes them.


For the error message, it seems to have to do something with the fact that just "b.removeAllBuffs()" returns no value for the damage. If you ever want to make a skill that needs the damage formula, but does no damage, you can add  ; 0 at the end of the formula, that should prevent the crash.


Apart from that, there is a fix in this thread:




It might also be fixed in the default engine by now; I'm running 1.3.3 and I don't get an error... If your RMMV or your project is on a lower version, you might consider updating.
Yeh I should have clarified better on wanting it to remove all states and buffs, thats my bad I wasn't explaining it very well. So what exactly would the updated formula look like if it is also removing states?


Do you just add the extra to the end like c = (b.mhp/3) - b.mdf * 1.44; b.removeAllBuffs(); c for (i = 0; i < b.states().length; i++) {b.removeState(i)} ?


I had to leave the pc at home so I can't check it myself at the moment. 
No, you use it the same way as b.removeAllBuffs(), so if you want to remove states and buffs, you would write it like this:


c = (b.mhp/3) - b.mdf * 1.44; b.removeAllBuffs(); for (i = 0; i < b.states().length; i++) {b.removeState(i)}; c


or the other way around, that shouldn't make any difference:


c = (b.mhp/3) - b.mdf * 1.44; for (i = 0; i < b.states().length; i++) {b.removeState(i)}; b.removeAllBuffs(); c


But the value for the damage (c in this case) always needs to be the last statement.
Oh okay, I just got home and tested it and the state still isnt removing, do I need to plug in the numbers of my states somewhere? Like 1-50 so it knows which to remove?
Try this:


c = (b.mhp/3) - b.mdf * 1.44; b.removeAllBuffs(); for (i = 1; i <= 20; i++) {b.removeState(i)}; c


and replace the 20 with the number of states your project has.
Sorry for the late reply but that worked! It deals the damage and removes the state all in one go. 


Thank you so much for the help I don't think I would have been capable of creating that on my own. Best wishes for being so patient with me and willing to help out!
No problem  🙂

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-proper-purge-damage-dealing-skill.71026/