Combining DoT Stacking and Stockpile Split Up/Conditional Animations

Hi,
I've been messing around experimenting with stacking DoT using Yanfly's plugins in my game recently and I've been wondering whether it's possible to have an animation change once, say, the maximum amount of stacks is reached. Does anyone know if this is this possible, and if so, how?

As a follow up I was also wondering if it was possible to program in attacks that require the target to have full stacks of the DoT state

Read below for more details
Moved to: Javascript/Plugin Support
Please edit your post to include a link to the web page(s) where you got the plugin(s) that you want to amend. That way if people need to check something before offering a suggestion they won't have to go hunting.
Okay so, I'm not too confident on the coding at the moment. I'm trying to learn as I go along
Essentially this is what I'm struggling with:

-First I wanted a damage over time effect which I got from this video:

it makes use of these plugins:
http://yanfly.moe/2015/10/10/yep-3-battle-engine-core/ Battle Engine Core
http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/ Buffs and States Core
Here's the code Yanfly wrote for it:
http://yanfly.moe/2016/04/30/tips-tricks-damage-over-time-stacking-rpg-maker-mv/

Then I thought it would be cool to try and make an attack which is only unlocked when you reach a certain number of stacks of the DoT effect, deals damage based off the number of stacks and then proceeds to reset the number of stacks to 0

-I found these videos on Stockpile and Stockpile Split Up effect from Pokemon:
http://yanfly.moe/2017/02/15/tips-tricks-stockpile-pokemon-rpg-maker-mv/
http://yanfly.moe/2017/02/17/tips-tricks-stockpile-spit-up-pokemon-rpg-maker-mv/

Both the effects work perfectly on their own....

However, this is only similar to what I wanted to achieve, however, Stockpile doesn't do DoT and it stacks on the user. So the first thing I tried doing was changing the code of the stockpile effects, replacing 'user' and 'a' with 'target' and/or 'b'

For instance:
Stockpile:

<Custom Apply Effect>
target._stockpile = target._stockpile || 0;
target._stockpile += 1;
target._stockpile = Math.min(target._stockpile, 3);
target.setStateCounter(stateId, target._stockpile);
</Custom Apply Effect>

<Custom Remove Effect>
target._stockpile = 0;
target.setStateCounter(stateId, target._stockpile);
</Custom Remove Effect>

Stockpile Split Up:

<Damage Formula>
if (!this._stockpileDmg) {
b._stockpile = b._stockpile || 1;
if (b._stockpile === 1) {
this._stockpileDmg = a.mat * 10;
} else if (b._stockpile === 2) {
this._stockpileDmg = a.mat * 20;
} else {
this._stockpileDmg = a.mat * 40;
}
}
value = this._stockpileDmg;
</Damage Formula>

<Custom Requirement>
target._stockpile = target._stockpile || 0;
if (target._stockpile <= 0) {
value = false;
}
</Custom Requirement>

<After Eval>
target.removeState(17);
</After Eval>

After I did this, the stockpile effect was successfully being applied to the target, however the stockpile split up ability was either never disabled despite the custom requirement saying the ability is only to be disabled at 0 stacks. This doesn't even account for the damage over time formula:

<Custom Apply Effect>
target._stackingPoison = target._stackingPoison || 0;
target._stackingPoison += 1;
</Custom Apply Effect>


<Custom Remove Effect>
target._stackingPoison = 0;
</Custom Remove Effect>

<Custom Regenerate Effect>
target._stackingPoison = target._stackingPoison || 1;
var stacks = Math.min(5, target._stackingPoison);
var damage = stacks * a.mat;
target.startAnimation(67);
target.gainHp(-damage);
target.startDamagePopup();
target.clearResult();
if (target.isDead()) {
target.performCollapse();
}
</Custom Regenerate Effect>

Now, I assume you would take the Apply and Remove effects and replace them with the one above making sure to refer to the effect as one thing (i.e. all 'StackingPoison' or all 'stockpile') but like I said, the stockpile split up doesn't work by itself and I feel like just jamming more code in there without really knowing what I'm doing here is not going to help.

My other idea was about changing the animation to signify to the player that they had max stacks of DoT. I assume this would be an if/else statement looking a bit like this:

if (b._stockpile === 3) {
target.startAnimation (67)
} else {
target.startAnimation (66)

It's most likely wrong and I'm not sure where it would go in the code but it would be a nice mechanic if I could implement it somehow

Like I said, I'm not really too confident on coding at the moment and any advice or assistance would be much appreciated
Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/combining-dot-stacking-and-stockpile-split-up-conditional-animations.103855/