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.
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?
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!