MV Is there a way to edit the Arisen Phoenix ability in Yanfly's plug-ins to affect buffs and debuffs rather than States?

Link to the Arisen Phoenix Ability!

Hey everybody, new here and I need some help 🙂

I'm trying to create two abilities: one that cleanses buffs and debuffs, healing the target for every buff and debuff cleansed, the other is a similar ability that damages the target instead.

The link I posted does what I want but affects States and I was wondering if there was a way to change it to get it to work the way I want? Thanks for any help :LZSexcite:
Not really, kind of.

The engine doesn't track buffs and debuffs separately the way it does states. If a given battler has received two ATK buffs and one ATK debuff, the only thing the game knows is they have an ATK buff rating of 1.

So changing the skill to go off of buffs would treat that battler as having 1 buff, not 3 things getting removed.

If that's what you want, the actual code change is pretty simple.

Code:
<Custom Select Condition>
// Make targets only selectable if the target's total states exceed 1.
condition = target._buffs.some(buff => buff != 0);
</Custom Select Condition>

<Damage Formula>
// Get the number of (de)buffs the target has.
var states = b._buffs.filter(buff => buff != 0).length;
// Calculate the amount of healing done based on the state count
value = (a.mdf * 2) * states;
</Damage Formula>

<Pre-Damage Eval>
// Remove buffs
target.clearBuffs();
</Pre-Damage Eval>

That will count the number as the number of parameters that have a buff or debuff. If you want it to function differently than that, e.g. off the net rating of the buff or debuff, that's doable.
in addition to what Turan said, if you did want each level of buffs/debuffs to be counted, youd want to use this in your damage formula instead
Code:
var states = b._buffs.reduce((a,b) => a + Math.abs(b), 0)

this totally wasnt a ninja recovery attempt
this totally wasnt a ninja recovery attempt
Ninjas are like cats - they always land on their feet!

Wait, I guess I'm the ninja in this scenario.

Well, you can be a ninja, too, if you like. Or a cat.
Ah this is so incredibly useful, thank you so much both of you! So glad I joined the forums :LZSsmile:

I did try editing and figuring it out by myself but it just didn't do anything. Thank you again!

So to be clear, based off the responses the code should be the following:

Code:
<Custom Select Condition>
// Make targets only selectable if the target's total states exceed 1.
condition = target._buffs.some(buff => buff != 0);
</Custom Select Condition>

<Damage Formula>
// Get the number of (de)buffs the target has.
var states = b._buffs.reduce((a,b) => a + Math.abs(b), 0)
// Calculate the amount of healing done based on the state count
value = (a.mdf * 2) * states;
</Damage Formula>

<Pre-Damage Eval>
// Remove buffs
target.clearBuffs();
</Pre-Damage Eval>
yes. did you try it and encounter a problem?
Yes it seems to work! Thank you everyone!

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-edit-the-arisen-phoenix-ability-in-yanflys-plug-ins-to-affect-buffs-and-debuffs-rather-than-states.173859/